fog-json-1.2.0/0000755000004100000410000000000013363671252013274 5ustar www-datawww-datafog-json-1.2.0/.travis.yml0000644000004100000410000000017513363671252015410 0ustar www-datawww-datalanguage: ruby matrix: include: - rvm: 2.0 - rvm: 2.1 - rvm: 2.2 - rvm: 2.3 - rvm: 2.4 - rvm: 2.5 fog-json-1.2.0/test/0000755000004100000410000000000013363671252014253 5ustar www-datawww-datafog-json-1.2.0/test/json_decode_test.rb0000644000004100000410000000076413363671252020122 0ustar www-datawww-datarequire "minitest/autorun" require "fog/json" class TestJSONDecoding < Minitest::Test def test_decode_array @json = %q{["one", "two", "three"]} @expected = %w(one two three) assert_equal @expected, Fog::JSON.decode(@json) end def test_decode_hash @json = %q{{"key":"value"}} @expected = { "key" => "value" } assert_equal @expected, Fog::JSON.decode(@json) end def test_decode_with_nil assert_raises(Fog::JSON::DecodeError) { Fog::JSON.decode(nil) } end end fog-json-1.2.0/test/json_encode_test.rb0000644000004100000410000000110213363671252020117 0ustar www-datawww-datarequire "minitest/autorun" require "fog/json" class TestJSONEncoding < Minitest::Test def test_encode_array @array = %W(one two three) @expected = %q{["one","two","three"]} assert_equal @expected, Fog::JSON.encode(@array) end def test_encode_hash @hash = { "key" => "value" } @expected = %q{{"key":"value"}} assert_equal @expected, Fog::JSON.encode(@hash) end def test_encode_with_bad_input skip if %w(1.8.7 2.0.0).include?(RUBY_VERSION) assert_raises(Fog::JSON::EncodeError) { Fog::JSON.encode("\x82\xAC\xEF") } end end fog-json-1.2.0/test/json_sanitize_test.rb0000644000004100000410000000141513363671252020517 0ustar www-datawww-datarequire "minitest/autorun" require "fog/json" class TestJSONSanitizing < Minitest::Test def setup @time = Time.utc(2014, 02, 14, 12, 34, 56) end def test_sanitize_with_array @data = [@time] @expected = ["2014-02-14T12:34:56+00:00"] assert_equal @expected, Fog::JSON.sanitize(@data) end def test_sanitize_with_hash @data = { "key" => @time } @expected = { "key" => "2014-02-14T12:34:56+00:00" } assert_equal @expected, Fog::JSON.sanitize(@data) end def test_sanitize_with_time @data = @time @expected = "2014-02-14T12:34:56+00:00" assert_equal @expected, Fog::JSON.sanitize(@data) end def test_sanitize_with_string @data = "fog" @expected = "fog" assert_equal @expected, Fog::JSON.sanitize(@data) end end fog-json-1.2.0/README.md0000644000004100000410000000273313363671252014560 0ustar www-datawww-data# Fog::Json Extraction of the JSON parsing tools shared between a number of providers in the 'fog' gem. ## Installation Add this line to your application's Gemfile: gem "fog-json" And then execute: $ bundle Or install it yourself as: $ gem install fog-json ## Usage This gem extracts shared code from the `fog` gem (http://github.com/fog/fog) that allows a standard interface to JSON encoding and decoding on top of MultiJson but with errors support. ## Contributing 1. Fork it ( http://github.com/fog/fog-json/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am "Add some feature"`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request ## Versioning This library aims to adhere to [Semantic Versioning 2.0.0][semver]. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, that version should be immediately yanked and/or a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions. As a result of this policy, you can (and should) specify a dependency on this gem using the [Pessimistic Version Constraint][pvc] with two digits of precision. For example: ```ruby spec.add_dependency "fog-json", "~> 1.0" ``` [semver]: http://semver.org/ [pvc]: http://docs.rubygems.org/read/chapter/16#page74 fog-json-1.2.0/LICENSE.md0000644000004100000410000000216413363671252014703 0ustar www-datawww-dataThe MIT License (MIT) Copyright (c) 2014 [CONTRIBUTORS.md](https://github.com/fog/fog/blob/master/CONTRIBUTORS.md) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. fog-json-1.2.0/CHANGELOG.md0000644000004100000410000000041413363671252015104 0ustar www-datawww-datav1.2.0 * Fix time parsing issue * Remove duplicated software licence * Remove `fog-core` version dependency v1.1.0 * bump fog-core dependency v1.0.2 Changes: * bump multi-json dependency v1.0.1 Changes: * Use a relative require path v1.0.0 Initial release. fog-json-1.2.0/CONTRIBUTORS.md0000644000004100000410000000032713363671252015555 0ustar www-datawww-data* Jonathan Soeder * Paul Thornthwaite * Paul Thornthwaite * Paulo Henrique Lopes Ribeiro * geemus fog-json-1.2.0/.gitignore0000644000004100000410000000025213363671252015263 0ustar www-datawww-data*.gem *.rbc .bundle .config .yardoc Gemfile.lock gemfiles/*.lock InstalledFiles _yardoc coverage doc/ lib/bundler/man pkg rdoc spec/reports test/tmp test/version_tmp tmp fog-json-1.2.0/Rakefile0000644000004100000410000000021713363671252014741 0ustar www-datawww-datarequire "bundler/gem_tasks" require "rake/testtask" task :default => [:test] Rake::TestTask.new do |t| t.pattern = "test/**/*_test.rb" end fog-json-1.2.0/lib/0000755000004100000410000000000013363671252014042 5ustar www-datawww-datafog-json-1.2.0/lib/fog/0000755000004100000410000000000013363671252014615 5ustar www-datawww-datafog-json-1.2.0/lib/fog/json/0000755000004100000410000000000013363671252015566 5ustar www-datawww-datafog-json-1.2.0/lib/fog/json/version.rb0000644000004100000410000000007113363671252017576 0ustar www-datawww-datamodule Fog module Json VERSION = "1.2.0" end end fog-json-1.2.0/lib/fog/json.rb0000644000004100000410000000227413363671252016120 0ustar www-datawww-datarequire "fog/core" require "multi_json" require File.expand_path("../json/version", __FILE__) module Fog # The {JSON} module includes functionality that is common between APIs using JSON to send and # receive data. # # The intent is to provide common code for provider APIs using JSON but not require it for those # using XML. # module JSON class EncodeError < Fog::Errors::Error; end class DecodeError < Fog::Errors::Error; end # This cleans up Time objects to be ISO8601 format # def self.sanitize(data) case data when Array data.map { |datum| sanitize(datum) } when Hash data.each { |key, value| data[key] = sanitize(value) } when ::Time data.strftime("%Y-%m-%dT%H:%M:%S%:z") else data end end # Do the MultiJson introspection at this level so we can define our encode/decode methods and # perform the introspection only once rather than once per call. def self.encode(obj) MultiJson.encode(obj) rescue => err raise EncodeError.slurp(err) end def self.decode(obj) MultiJson.decode(obj) rescue => err raise DecodeError.slurp(err) end end end fog-json-1.2.0/fog-json.gemspec0000644000004100000410000000220013363671252016355 0ustar www-datawww-data# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'fog/json/version' Gem::Specification.new do |spec| spec.name = "fog-json" spec.version = Fog::Json::VERSION spec.authors = ["Wesley Beary (geemus)", "Paul Thornthwaite (tokengeek)", "The fog team"] spec.email = ["geemus@gmail.com", "tokengeek@gmail.com"] spec.summary = %q{JSON parsing for fog providers} spec.description = %q{Extraction of the JSON parsing tools shared between a number of providers in the 'fog' gem.} spec.homepage = "http://github.com/fog/fog-json" spec.license = "MIT" spec.files = `git ls-files`.split($/) 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 "fog-core" spec.add_dependency "multi_json", "~> 1.10" spec.add_development_dependency "bundler", "~> 1.5" spec.add_development_dependency "rake" spec.add_development_dependency "minitest" end fog-json-1.2.0/CONTRIBUTING.md0000644000004100000410000000152713363671252015532 0ustar www-datawww-data## Getting Involved New contributors are always welcome, when it doubt please ask questions. We strive to be an open and welcoming community. Please be nice to one another. ### Coding * Pick a task: * Offer feedback on open [pull requests](https://github.com/fog/fog-json/pulls). * Review open [issues](https://github.com/fog/fog-json/issues) for things to help on. * [Create an issue](https://github.com/fog/fog-json/issues/new) to start a discussion on additions or features. * Fork the project, add your changes and tests to cover them in a topic branch. * Commit your changes and rebase against `fog/fog-json` to ensure everything is up to date. * [Submit a pull request](https://github.com/fog/fog-json/compare/). ### Non-Coding * Offer feedback on open [issues](https://github.com/fog/fog-json/issues). * Organize or volunteer at events. fog-json-1.2.0/.ruby-gemset0000644000004100000410000000001113363671252015530 0ustar www-datawww-datafog-json fog-json-1.2.0/Gemfile0000644000004100000410000000013513363671252014566 0ustar www-datawww-datasource 'https://rubygems.org' # Specify your gem's dependencies in fog-json.gemspec gemspec fog-json-1.2.0/.ruby-version0000644000004100000410000000000613363671252015735 0ustar www-datawww-data2.4.3