sensu-json 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 605a98cc6ae77de3609a10fc69a586df9ed6538e
4
+ data.tar.gz: 0a7372801934d75dabe29e9bf3d76b7133838858
5
+ SHA512:
6
+ metadata.gz: 50518f61efe074a066bc1a7fd3fbdba8c349d962a301773ff797d02308ef56b9872be49e616ef33430e2cc844be950646bcd117286498017651e8b634230451d
7
+ data.tar.gz: 4be401bb0594582ac01af703987769cb2fb713f091b5f82cac6229c82b540e5bcfe42e2d81f1082c5e111acfa9254ebb9e7aed2ca741ec659a0ef215df57c2dc
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sensu-json.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2016 Heavy Water Operations, LLC.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Sensu::JSON
2
+
3
+ [![Build Status](https://travis-ci.org/sensu/sensu-json.svg?branch=master)](https://travis-ci.org/sensu/sensu-json)
4
+
5
+ [![Code Climate](https://codeclimate.com/github/sensu/sensu-json.png)](https://codeclimate.com/github/sensu/sensu-json)
6
+ [![Code Climate Coverage](https://codeclimate.com/github/sensu/sensu-json/coverage.png)](https://codeclimate.com/github/sensu/sensu-json)
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'sensu-json'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ ## Usage
19
+
20
+ This library provides the Sensu JSON parser abstraction, enabling
21
+ the use of platform specific JSON parsers. Its documentation can be
22
+ found [here](http://rubydoc.info/github/sensu/sensu-json/Sensu/JSON).
23
+
24
+ ## Contributing
25
+
26
+ Please do not submit a pull request to add features that Sensu does
27
+ not nor will not require.
28
+
29
+ 1. [Fork it](https://github.com/sensu/sensu-json/fork)
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create a new Pull Request
34
+
35
+ ## License
36
+
37
+ Sensu JSON is released under the [MIT license](https://raw.github.com/sensu/sensu-json/master/LICENSE.txt).
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sensu/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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,19 @@
1
+ require "json"
2
+
3
+ module Sensu
4
+ module JSON
5
+ class Java
6
+ def load(string)
7
+ ::JSON.parse(string, :symbolize_names => true)
8
+ end
9
+
10
+ def dump(object, options={})
11
+ if options[:pretty]
12
+ ::JSON.pretty_generate(object)
13
+ else
14
+ ::JSON.fast_generate(object)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ gem "oj", "2.14.6"
2
+
3
+ require "oj"
4
+
5
+ module Sensu
6
+ module JSON
7
+ class Oj
8
+ def load(string)
9
+ ::Oj.load(string, :symbol_keys => true)
10
+ end
11
+
12
+ def dump(object, options={})
13
+ options.merge!(:indent => 2) if options[:pretty]
14
+ ::Oj.dump(object, options)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ module Sensu
2
+ module JSON
3
+ class ParseError < StandardError
4
+ attr_reader :data, :cause
5
+
6
+ def self.build(original_error, data)
7
+ new(original_error.message).tap do |error|
8
+ error.instance_eval do
9
+ @cause = original_error
10
+ set_backtrace original_error.backtrace
11
+ @data = data
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
data/lib/sensu/json.rb ADDED
@@ -0,0 +1,30 @@
1
+ require "sensu/json/parse_error"
2
+
3
+ module Sensu
4
+ module JSON
5
+ class << self
6
+ def setup
7
+ @@parser = case
8
+ when RUBY_PLATFORM =~ /java/
9
+ require "sensu/json/java"
10
+ Sensu::JSON::Java.new
11
+ else
12
+ require "sensu/json/oj"
13
+ Sensu::JSON::Oj.new
14
+ end
15
+ end
16
+
17
+ def load(string)
18
+ begin
19
+ @@parser.load(string)
20
+ rescue => error
21
+ raise Sensu::JSON::ParseError.build(error, string)
22
+ end
23
+ end
24
+
25
+ def dump(object, options={})
26
+ @@parser.dump(object, options)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "sensu-json"
5
+ spec.version = "0.0.1"
6
+ spec.authors = ["Sean Porter"]
7
+ spec.email = ["portertech@gmail.com"]
8
+ spec.summary = "The Sensu JSON parser abstraction library"
9
+ spec.description = "The Sensu JSON parser abstraction library"
10
+ spec.homepage = "https://github.com/sensu/sensu-json"
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files -z`.split("\x0")
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_dependency("oj", "2.14.6") unless RUBY_PLATFORM =~ /java/
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.6"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rspec"
23
+ spec.add_development_dependency "codeclimate-test-reporter"
24
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-json
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sean Porter
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: oj
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.14.6
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.14.6
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '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: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: codeclimate-test-reporter
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
+ description: The Sensu JSON parser abstraction library
84
+ email:
85
+ - portertech@gmail.com
86
+ executables:
87
+ - console
88
+ - setup
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - LICENSE.txt
96
+ - README.md
97
+ - Rakefile
98
+ - bin/console
99
+ - bin/setup
100
+ - lib/sensu/json.rb
101
+ - lib/sensu/json/java.rb
102
+ - lib/sensu/json/oj.rb
103
+ - lib/sensu/json/parse_error.rb
104
+ - sensu-json.gemspec
105
+ homepage: https://github.com/sensu/sensu-json
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.4.5.1
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: The Sensu JSON parser abstraction library
129
+ test_files: []