extract JSONToken gem
fixes: CNVS-11785 Test Plan: Automated tests will check most of it. Make sure Canvas is not broken. Change-Id: I797a71b492a043fc7d14b88457842bbde4295bb2 Reviewed-on: https://gerrit.instructure.com/31719 Reviewed-by: Jacob Fugal <jacob@instructure.com> Product-Review: Simon Williams <simon@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> QA-Review: August Thornton <august@instructure.com>
This commit is contained in:
parent
1845b45b2f
commit
24680d9925
|
@ -124,6 +124,7 @@ gem 'canvas_statsd', :path => 'gems/canvas_statsd'
|
|||
gem 'canvas_stringex', :path => 'gems/canvas_stringex'
|
||||
gem 'canvas_uuid', :path => 'gems/canvas_uuid'
|
||||
gem 'html_text_helper', :path => 'gems/html_text_helper'
|
||||
gem 'json_token', :path => 'gems/json_token'
|
||||
gem 'lti_outbound', :path => 'gems/lti_outbound'
|
||||
gem 'multipart', :path => 'gems/multipart'
|
||||
gem 'utf8_cleaner', :path => 'gems/utf8_cleaner'
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
gemspec
|
|
@ -0,0 +1 @@
|
|||
require "bundler/gem_tasks"
|
|
@ -0,0 +1,23 @@
|
|||
# coding: utf-8
|
||||
|
||||
lib = File.expand_path('../lib', __FILE__)
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
|
||||
Gem::Specification.new do |spec|
|
||||
spec.name = "json_token"
|
||||
spec.version = "0.0.1"
|
||||
spec.authors = ["Nick Cloward", "Joseph Rodriguez"]
|
||||
spec.email = ["nickc@instructure.com", "jrodriguez@pivotallabs.com"]
|
||||
spec.summary = %q{Convenience methods for encoding and decoding a slug of data into base64 encoded JSON}
|
||||
|
||||
spec.files = Dir.glob("{lib}/**/*") + %w(Rakefile)
|
||||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
||||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
||||
spec.require_paths = ["lib"]
|
||||
|
||||
spec.add_dependency 'json', '1.8.1'
|
||||
|
||||
spec.add_development_dependency "bundler", "~> 1.5"
|
||||
spec.add_development_dependency "rake"
|
||||
spec.add_development_dependency "rspec"
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (C) 2011 Instructure, Inc.
|
||||
# Copyright (C) 2014 Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
|
@ -16,6 +16,9 @@
|
|||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
require 'json'
|
||||
require 'base64'
|
||||
|
||||
# Convenience methods for encoding and decoding a slug of data into base64
|
||||
# encoded JSON, e.g. to use in a URL
|
||||
module JSONToken
|
|
@ -0,0 +1,29 @@
|
|||
#
|
||||
# Copyright (C) 2014 Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe JSONToken do
|
||||
it 'should encode' do
|
||||
expect(JSONToken.encode({a: 123, b: [1, 2, '13']})).to eq "eyJhIjoxMjMsImIiOlsxLDIsIjEzIl19"
|
||||
end
|
||||
|
||||
it 'should decode' do
|
||||
expect(JSONToken.decode("eyJhIjoxMjMsImIiOlsxLDIsIjEzIl19")).to eq({"a" => 123, "b" => [1, 2, "13"]})
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
require 'json_token'
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.treat_symbols_as_metadata_keys_with_true_values = true
|
||||
config.run_all_when_everything_filtered = true
|
||||
config.filter_run :focus
|
||||
config.color_enabled = true
|
||||
config.order = 'random'
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash
|
||||
result=0
|
||||
|
||||
bundle install
|
||||
bundle exec rspec spec
|
||||
let result=$result+$?
|
||||
|
||||
if [ $result -eq 0 ]; then
|
||||
echo "SUCCESS"
|
||||
else
|
||||
echo "FAILURE"
|
||||
fi
|
||||
|
||||
exit $result
|
Loading…
Reference in New Issue