super_recursive_open_struct 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0e47e061abf1c5d9daca2995714e188677fea62f
4
- data.tar.gz: 03f821f35f28e32f1afebd56fec77e8a5d06a475
3
+ metadata.gz: 3f72b725a955a8c5035f68becc11c5aca1f87427
4
+ data.tar.gz: a4f844945f7152bb33d9bdca989e13140af68101
5
5
  SHA512:
6
- metadata.gz: 995a0373e906ab5a040cc69facdb612fa4ddfc08389496542643870e1d74677f64119b6b3178f6da993fb95d16e6b27d3008019113f3a2c43842a5fd20077bef
7
- data.tar.gz: ec8418932147642a76483e864a0c59a7a78c472c0b0e4be18b5dfa0824d7829d8b1f4f92c0371c4480259d2a36c2ad5fdf5e54b724e040b87e39c59bd1d4cf4d
6
+ metadata.gz: 88def8fde6e0de1eeda4b1d1644617383f8749f47d6a838ba5c5de2edd48dfcc51daba77f86d7aa8f121a9130dbccdd3a850704c121ade14262f743e7f6e9fd1
7
+ data.tar.gz: 1bca4351f172bb421e303409e5e8e384f62427ebddb737e39a28c5602982b9810449592570f1b91aec24b18abca8ceb2cf89790a47d0fc38dfc69376ef6a2c77
@@ -2,11 +2,13 @@ language: ruby
2
2
  rvm:
3
3
  - 2.1
4
4
  - ruby-head
5
- - rbx-19mode
5
+ - rbx
6
+ - rbx-head
6
7
  matrix:
7
8
  allow_failures:
8
9
  - rvm: ruby-head
9
- - rvm: rbx-19mode
10
+ - rvm: rbx
11
+ - rvm: rbx-head
10
12
  notifications:
11
13
  email:
12
14
  on_success: always
@@ -1,4 +1,5 @@
1
1
  require "recursive_open_struct"
2
+ require "active_support/json/encoding"
2
3
 
3
4
  class SuperRecursiveOpenStruct
4
5
  def initialize(hash, args = {})
@@ -25,6 +26,10 @@ class SuperRecursiveOpenStruct
25
26
  @target.respond_to?(method, include_private)
26
27
  end
27
28
 
29
+ def to_json
30
+ ActiveSupport::JSON.encode @target
31
+ end
32
+
28
33
  alias_method :to_s, def inspect
29
34
  contents = @target.inspect.gsub(/\A#<RecursiveOpenStruct (.+)>\Z/, "\\1")
30
35
  "#<SuperRecursiveOpenStruct:0x#{__id__.to_s(16)} #{contents}>".freeze
@@ -30,6 +30,13 @@ describe SuperRecursiveOpenStruct do
30
30
  end
31
31
  end
32
32
 
33
+ describe "#to_json" do
34
+ it "delegates to the target object" do
35
+ expect(SuperRecursiveOpenStruct.new({a: 1}).to_json).to eq '{"a":1}'
36
+ expect(SuperRecursiveOpenStruct.new([{a: 'A'}, {b: 0.1}]).to_json).to eq '[{"a":"A"},{"b":0.1}]'
37
+ end
38
+ end
39
+
33
40
  describe "#respond_to?" do
34
41
  it "is implemented properly with #respond_to_missing?" do
35
42
  sros = SuperRecursiveOpenStruct.new(a: 1)
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "super_recursive_open_struct"
7
- spec.version = "1.0.1"
7
+ spec.version = "1.0.2"
8
8
  spec.authors = ["Cédric Félizard"]
9
9
  spec.email = ["cedric@felizard.fr"]
10
10
  spec.summary = %q{Like recursive-open-struct but slightly different}
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "recursive-open-struct", ">= 0.5.0"
21
+ spec.add_dependency "activesupport", ">= 3.2", "< 5"
21
22
 
22
23
  spec.add_development_dependency "bundler", ">= 1.6"
23
24
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_recursive_open_struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cédric Félizard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-06 00:00:00.000000000 Z
11
+ date: 2014-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: recursive-open-struct
@@ -24,6 +24,26 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.5.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '3.2'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '5'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '3.2'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '5'
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: bundler
29
49
  requirement: !ruby/object:Gem::Requirement