legion-json 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7fc66ec01a80c1d2f22776515bd09207a5a99141
4
+ data.tar.gz: 5dc901b48f5a20303d102367d7d6bb6ba0042355
5
+ SHA512:
6
+ metadata.gz: 2da309a5d787f236506b51fd122163453d838f5d6a7345faf68840248946b30344e7c7ba12fa12f7de93770eb05637e4623378adb2de5f8cb9d2c2871f537013
7
+ data.tar.gz: f2bfaff8d1efafdcdf4fd5845701d96a5b562e49ca6315f33f5bba80aaca32a339efd166884568b1133a92a5fbae50ade0d5b07c0143ba6c9422fb8854626a1a
@@ -0,0 +1,167 @@
1
+ version: 2 # use CircleCI 2.0
2
+ jobs:
3
+ "rubocop":
4
+ docker:
5
+ - image: circleci/ruby:2.4-node
6
+ steps:
7
+ - checkout
8
+ - run: gem install rubocop
9
+ - run:
10
+ name: Run Rubocop
11
+ command: rubocop
12
+ - store_test_results:
13
+ path: test_results
14
+ "ruby-2.0":
15
+ docker:
16
+ - image: circleci/ruby:2.0
17
+ steps:
18
+ - checkout
19
+ - run:
20
+ name: Bundle Install
21
+ command: bundle install
22
+ - run:
23
+ name: Run RSpec
24
+ command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
25
+ when: always
26
+ - store_test_results:
27
+ path: test-results
28
+ "ruby-2.1":
29
+ docker:
30
+ - image: circleci/ruby:2.1
31
+ steps:
32
+ - checkout
33
+ - run:
34
+ name: Bundle Install
35
+ command: bundle install
36
+ - run:
37
+ name: Run RSpec
38
+ command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
39
+ when: always
40
+ - store_test_results:
41
+ path: test-results
42
+ "ruby-2.2":
43
+ docker:
44
+ - image: circleci/ruby:2.2
45
+ steps:
46
+ - checkout
47
+ - run:
48
+ name: Bundle Install
49
+ command: bundle install
50
+ - run:
51
+ name: Run RSpec
52
+ command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
53
+ when: always
54
+ - store_test_results:
55
+ path: test-results
56
+
57
+ "ruby-2.3":
58
+ docker:
59
+ - image: circleci/ruby:2.3
60
+ steps:
61
+ - checkout
62
+ - run:
63
+ name: Bundle Install
64
+ command: bundle install
65
+ - run:
66
+ name: Run RSpec
67
+ command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
68
+ when: always
69
+ - store_test_results:
70
+ path: test-results
71
+
72
+ "ruby-2.4":
73
+ docker:
74
+ - image: circleci/ruby:2.4-node
75
+ steps:
76
+ - checkout
77
+ - run:
78
+ name: Bundle Install
79
+ command: bundle install
80
+ - run:
81
+ name: Run RSpec
82
+ command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
83
+ when: always
84
+ - store_test_results:
85
+ path: test-results
86
+ "ruby-2.5":
87
+ docker:
88
+ - image: circleci/ruby:2.5-node
89
+ steps:
90
+ - checkout
91
+ - run:
92
+ name: Bundle Install
93
+ command: bundle install
94
+ - run:
95
+ name: Run RSpec
96
+ command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
97
+ when: always
98
+ - store_test_results:
99
+ path: test-results
100
+ "ruby-2.6":
101
+ docker:
102
+ - image: circleci/ruby:2.6-node
103
+ steps:
104
+ - checkout
105
+ - run:
106
+ name: Bundle Install
107
+ command: bundle install
108
+ - run:
109
+ name: Run RSpec
110
+ command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
111
+ when: always
112
+ - store_test_results:
113
+ path: test-results
114
+ "jruby-9.2":
115
+ docker:
116
+ - image: circleci/jruby:9.2
117
+ steps:
118
+ - checkout
119
+ - run:
120
+ name: Bundle Install
121
+ command: bundle install
122
+ - run:
123
+ name: Run RSpec
124
+ command: bundle exec rspec --format progress --format RspecJunitFormatter -o test-results/rspec/results.xml
125
+ when: always
126
+ - store_test_results:
127
+ path: test-results
128
+
129
+ workflows:
130
+ version: 2
131
+ cop_rake_deploy:
132
+ jobs:
133
+ - rubocop
134
+ - ruby-2.2:
135
+ requires:
136
+ - ruby-2.4
137
+ filters:
138
+ branches:
139
+ only: /\bdevelop\b|\bmaster\b/
140
+ - ruby-2.3:
141
+ requires:
142
+ - ruby-2.4
143
+ filters:
144
+ branches:
145
+ only: /\bdevelop\b|\bmaster\b/
146
+ - ruby-2.4:
147
+ requires:
148
+ - rubocop
149
+ - ruby-2.5:
150
+ requires:
151
+ - ruby-2.4
152
+ filters:
153
+ branches:
154
+ only: /\bdevelop\b|\bmaster\b/
155
+ - ruby-2.6:
156
+ requires:
157
+ - ruby-2.4
158
+ filters:
159
+ branches:
160
+ only: /\bdevelop\b|\bmaster\b/
161
+ - jruby-9.2:
162
+ requires:
163
+ - ruby-2.2
164
+ - ruby-2.3
165
+ - ruby-2.4
166
+ - ruby-2.5
167
+ - ruby-2.6
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /rspec/
11
+ /test-results/
12
+
13
+ # rspec failure tracking
14
+ .rspec_status
15
+
data/.rubocop ADDED
@@ -0,0 +1,25 @@
1
+ Metrics/LineLength:
2
+ Max: 120
3
+ Metrics/MethodLength:
4
+ Max: 30
5
+ Metrics/ClassLength:
6
+ Max: 1500
7
+ Metrics/BlockLength:
8
+ Max: 50
9
+ Layout/SpaceAroundEqualsInParameterDefault:
10
+ EnforcedStyle: space
11
+ Style/SymbolArray:
12
+ Enabled: true
13
+ Layout/AlignHash:
14
+ EnforcedHashRocketStyle: table
15
+ EnforcedColonStyle: table
16
+ Style/HashSyntax:
17
+ EnforcedStyle: ruby19_no_mixed_keys
18
+ Style/Documentation:
19
+ Enabled: false
20
+ AllCops:
21
+ TargetRubyVersion: 2.2
22
+ Style/FrozenStringLiteralComment:
23
+ Enabled: false
24
+ Naming/FileName:
25
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in legion-json.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Miverson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Legion::Json
2
+
3
+ Legion::Json is part of the Legion Framework
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'legion-json'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install legion-json
21
+
22
+ ## Usage
23
+
24
+ This library provides the Legion JSON parser abstraction, enabling the use of platform specific JSON parsers.
25
+
26
+ ## Development
27
+
28
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
+
30
+ To install this gem onto your local machine, run `bundle exec install`.
31
+
32
+ ## Contributing
33
+
34
+ Bug reports and pull requests are welcome on GitHub at https://bitbucket.org/legion-io/legion-json/issues This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
39
+
40
+ ## Credit
41
+
42
+ This gem was based on the Sensu JSON gem. You can find the original gem [here](https://github.com/sensu/sensu-json)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'legion/json'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,16 @@
1
+ image: ruby:2.4.0
2
+
3
+ pipelines:
4
+ branches:
5
+ master:
6
+ - step:
7
+ caches:
8
+ - bundler
9
+ script:
10
+ - gem install bundle rubocop
11
+ - bundle install
12
+ - rubocop
13
+ - rake
14
+ definitions:
15
+ caches:
16
+ bundler: vendor/bundle
@@ -0,0 +1,36 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'legion/json/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'legion-json'
7
+ spec.version = Legion::Json::VERSION
8
+ spec.authors = ['Esity']
9
+ spec.email = ['matthewdiverson@gmail.com']
10
+
11
+ spec.summary = 'Legion JSON'
12
+ spec.description = 'A gem used to load and use JSON objects inside the Legion framework'
13
+ spec.homepage = 'https://bitbucket.org/legion-io/legion-json'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = '~> 2.2'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = 'exe'
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1'
25
+ spec.add_development_dependency 'codecov', '~> 0'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rspec', '~> 3.0'
28
+ spec.add_development_dependency 'rspec_junit_formatter', '~> 0'
29
+ spec.add_development_dependency 'rubocop', '~> 0'
30
+ spec.add_dependency 'json', '~> 2.1'
31
+ if RUBY_ENGINE == 'jruby'
32
+ spec.add_dependency('jrjackson', '~> 0.4')
33
+ else
34
+ spec.add_dependency('oj', '~> 2.18')
35
+ end
36
+ end
@@ -0,0 +1,45 @@
1
+ require 'legion/json/version'
2
+ require 'legion/json/parse_error'
3
+
4
+ module Legion
5
+ # Used to create JSON objects
6
+ module JSON
7
+ class << self
8
+ # Set up the JSON parser. This method must be called before any
9
+ # attempt to use the parser. This method is currently called at
10
+ # the bottom of this file. The appropriate JSON parser will be
11
+ # loaded for the current platform.
12
+ #
13
+ # @return [Object] parser.
14
+ def setup!
15
+ if RUBY_ENGINE == 'jruby'
16
+ require 'legion/json/jrjackson'
17
+ @parser = Legion::JSON::JrJackson.new
18
+ else
19
+ require 'legion/json/oj'
20
+ @parser = Legion::JSON::Oj.new
21
+ end
22
+ end
23
+
24
+ # Load (and parse) a JSON string.
25
+ #
26
+ # @param string [String]
27
+ # @return [Object]
28
+ def load(string)
29
+ @parser.load(string)
30
+ rescue StandardError => error
31
+ raise Legion::JSON::ParseError.build(error, string)
32
+ end
33
+
34
+ # Dump (generate) a JSON string from a Ruby object.
35
+ #
36
+ # @param object [Object]
37
+ # @param options [Hash]
38
+ def dump(object, options = {})
39
+ @parser.dump(object, options)
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ Legion::JSON.setup!
@@ -0,0 +1,16 @@
1
+ require 'jrjackson'
2
+
3
+ module Legion
4
+ module JSON
5
+ # The Legion JSON parser when running on JRuby.
6
+ class JrJackson
7
+ def load(string)
8
+ ::JrJackson::Json.load(string, symbolize_keys: true, raw: true)
9
+ end
10
+
11
+ def dump(object, options = {})
12
+ ::JrJackson::Json.dump(object, options)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ require 'oj'
2
+ Oj.default_options = { mode: :compat }
3
+
4
+ module Legion
5
+ module JSON
6
+ # The Legion JSON parser when running on MRI.
7
+ class Oj
8
+ def load(string)
9
+ ::Oj.load(string, symbol_keys: true)
10
+ end
11
+
12
+ def dump(object, options = {})
13
+ options[:indent] = 2 if options[:pretty]
14
+ ::Oj.dump(object, options)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module Legion
2
+ module JSON
3
+ # The Legion JSON parser error abstraction.
4
+ class ParseError < StandardError
5
+ attr_reader :data, :cause
6
+
7
+ def self.build(original_error, data)
8
+ new(original_error.message).tap do |error|
9
+ error.instance_eval do
10
+ @cause = original_error
11
+ set_backtrace original_error.backtrace
12
+ @data = data
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ module Legion
2
+ module Json
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: legion-json
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Esity
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-12-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: codecov
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec_junit_formatter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: json
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.1'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: oj
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.18'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.18'
125
+ description: A gem used to load and use JSON objects inside the Legion framework
126
+ email:
127
+ - matthewdiverson@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".circleci/config.yml"
133
+ - ".gitignore"
134
+ - ".rubocop"
135
+ - Gemfile
136
+ - LICENSE.txt
137
+ - README.md
138
+ - Rakefile
139
+ - bin/console
140
+ - bin/setup
141
+ - bitbucket-pipelines.yml
142
+ - legion-json.gemspec
143
+ - lib/legion/json.rb
144
+ - lib/legion/json/jrjackson.rb
145
+ - lib/legion/json/oj.rb
146
+ - lib/legion/json/parse_error.rb
147
+ - lib/legion/json/version.rb
148
+ homepage: https://bitbucket.org/legion-io/legion-json
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - "~>"
159
+ - !ruby/object:Gem::Version
160
+ version: '2.2'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.6.14
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: Legion JSON
172
+ test_files: []