hash-proxy 0.1.5 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f8eb13d235ef7982d3e5198f8a0162e5ffab73b7
4
+ data.tar.gz: 2d8917c67b98c0053da4b5a13cbe6fea23d330a3
5
+ SHA512:
6
+ metadata.gz: 33047135a972c9592132d6562515f8f9f787c70e23ef36e1bff8e6ed00c7ffe5f1e1754f1f041d6716af9456426d8890ec626d94cafb9f86cda4f17c6105eba8
7
+ data.tar.gz: 9222c1f4376fae7060388d95ae2781474f8abf6064081c59e8161b6f79192fa2c573255c16be9c7c70d6b43825746562dd2313b3ea1d84c91f07499142b5e5a3
@@ -0,0 +1 @@
1
+ hash-proxy
@@ -0,0 +1 @@
1
+ ruby-2.4.1
data/Gemfile CHANGED
@@ -1,5 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'rspec'
3
4
  gem 'bones'
4
5
  gem 'bones-rspec'
5
6
  gem 'bones-git'
@@ -1,34 +1,40 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- bones (3.8.0)
5
- little-plugger (~> 1.1.3)
6
- loquacious (~> 1.9.1)
7
- rake (>= 0.8.7)
8
- bones-git (1.3.0)
9
- bones (>= 3.6)
10
- git (>= 1.2.5)
4
+ bones (3.8.4)
5
+ little-plugger (~> 1.1)
6
+ loquacious (~> 1.9)
7
+ rake (~> 12.0)
8
+ rdoc (~> 5.0)
9
+ bones-git (1.3.1)
10
+ git (~> 1.2)
11
11
  bones-rspec (2.0.1)
12
12
  bones (>= 3.6)
13
13
  rspec (>= 1.3)
14
14
  bones-yard (1.0.0)
15
15
  bones (>= 3.5.0)
16
16
  yard (>= 0.5.8)
17
- diff-lcs (1.2.1)
18
- git (1.2.5)
19
- little-plugger (1.1.3)
17
+ diff-lcs (1.3)
18
+ git (1.5.0)
19
+ little-plugger (1.1.4)
20
20
  loquacious (1.9.1)
21
- rake (10.0.3)
22
- redcarpet (2.2.2)
23
- rspec (2.13.0)
24
- rspec-core (~> 2.13.0)
25
- rspec-expectations (~> 2.13.0)
26
- rspec-mocks (~> 2.13.0)
27
- rspec-core (2.13.1)
28
- rspec-expectations (2.13.0)
29
- diff-lcs (>= 1.1.3, < 2.0)
30
- rspec-mocks (2.13.0)
31
- yard (0.8.5.2)
21
+ rake (12.3.1)
22
+ rdoc (5.1.0)
23
+ redcarpet (3.4.0)
24
+ rspec (3.8.0)
25
+ rspec-core (~> 3.8.0)
26
+ rspec-expectations (~> 3.8.0)
27
+ rspec-mocks (~> 3.8.0)
28
+ rspec-core (3.8.0)
29
+ rspec-support (~> 3.8.0)
30
+ rspec-expectations (3.8.2)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.8.0)
33
+ rspec-mocks (3.8.0)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.8.0)
36
+ rspec-support (3.8.0)
37
+ yard (0.9.16)
32
38
 
33
39
  PLATFORMS
34
40
  ruby
@@ -39,3 +45,7 @@ DEPENDENCIES
39
45
  bones-rspec
40
46
  bones-yard
41
47
  redcarpet
48
+ rspec
49
+
50
+ BUNDLED WITH
51
+ 1.15.4
@@ -1,3 +1,7 @@
1
+ # == Version 0.1.6 / 2014-09-25
2
+ # * Pin to rspec < 3
3
+ # * fix a warning
4
+ #
1
5
  # == Version 0.1.5 / 2013-03-12
2
6
  # * Support #to_json
3
7
  #
data/README.md CHANGED
@@ -83,6 +83,10 @@ Original author: Douglas A. Seifert (doug@dseifert.net)
83
83
  History
84
84
  -------
85
85
 
86
+ ### Version 0.1.6 / 2014-09-25
87
+ * Pin to rspec < 3
88
+ * fix a warning
89
+
86
90
  ### Version 0.1.5 / 2013-03-12
87
91
  * Support #to_json
88
92
 
data/Rakefile CHANGED
@@ -13,11 +13,11 @@ Bones {
13
13
  authors 'Douglas A. Seifert'
14
14
  email 'doug@dseifert.net'
15
15
  url 'https://github.com/seifertd/hash-proxy'
16
- depend_on 'bones', :development => true
17
- depend_on 'bones-rspec', :development => true
18
- depend_on 'bones-git', :development => true
19
- depend_on 'bones-yard', :development => true
20
- depend_on 'redcarpet', :development => true
16
+ #depend_on 'bones', :development => true
17
+ #depend_on 'bones-rspec', :development => true
18
+ #depend_on 'bones-git', :development => true
19
+ #depend_on 'bones-yard', :development => true
20
+ #depend_on 'redcarpet', :development => true
21
21
 
22
22
  yard.exclude ['version.txt']
23
23
  }
@@ -121,7 +121,7 @@ module HashProxy
121
121
  # p.stuff => NullObject
122
122
  # p.respond_to?(:stuff) => true
123
123
  #
124
- def respond_to?(method)
124
+ def respond_to?(method, include_all = false)
125
125
  method_name = method.to_s
126
126
  method_name.gsub(/=$/, '')
127
127
  (@hash && @converted && (@hash.keys.map(&:to_s) + @converted.keys.map(&:to_s)).include?(method_name)) || super
@@ -6,55 +6,55 @@ describe HashProxy do
6
6
  proxy = HashProxy.create_from(:size => 42, :bar => :foo)
7
7
  data = Marshal.dump(proxy)
8
8
  proxy2 = Marshal.load(data)
9
- proxy.keys.should eq(proxy2.keys)
10
- proxy.values.should eq(proxy2.values)
9
+ expect(proxy.keys).to eq(proxy2.keys)
10
+ expect(proxy.values).to eq(proxy2.values)
11
11
  end
12
12
 
13
13
  it "works with null values" do
14
14
  proxy = HashProxy.create_from(:null => nil)
15
- proxy.size.should eq(1)
16
- proxy.null.should be_nil
17
- proxy.null.class.should eq(HashProxy::NullObject)
18
- proxy.null.to_a.should eq([])
19
- proxy.null.to_ary.should eq([])
15
+ expect(proxy.size).to eq(1)
16
+ expect(proxy.null).to be_nil
17
+ expect(proxy.null.class).to eq(HashProxy::NullObject)
18
+ expect(proxy.null.to_a).to eq([])
19
+ expect(proxy.null.to_ary).to eq([])
20
20
  end
21
21
 
22
22
  it "works with keys called size" do
23
23
  proxy = HashProxy.create_from(:size => 42, :bar => :foo)
24
- proxy.size.should eq(2)
25
- proxy[:size].should == 42
24
+ expect(proxy.size).to eq(2)
25
+ expect(proxy[:size]).to eq(42)
26
26
  end
27
27
 
28
28
 
29
29
  it "handles booleans" do
30
30
  proxy = HashProxy.create_from(:indexed => false, :followed => true)
31
- proxy.indexed.should eq(false)
32
- proxy.followed.should == true
31
+ expect(proxy.indexed).to eq(false)
32
+ expect(proxy.followed).to eq(true)
33
33
  end
34
34
 
35
35
  it "does not get confused by methods defined on Kernel" do
36
36
  proxy = HashProxy::Proxy.new({})
37
- lambda { proxy[:format] }.should_not raise_error
38
- proxy.format.should be_nil
37
+ expect(lambda { proxy[:format] }).to_not raise_error
38
+ expect(proxy.format).to be_nil
39
39
  end
40
40
 
41
41
  it "supports enumerable" do
42
42
  hash = {foo: 'bar', baz: 'bip', smee: 'cree'}
43
43
  proxy = HashProxy::Proxy.new(hash)
44
44
  iterator = proxy.each
45
- iterator.to_a.should eq([[:foo, 'bar'], [:baz, 'bip'], [:smee, 'cree']])
45
+ expect(iterator.to_a).to eq([[:foo, 'bar'], [:baz, 'bip'], [:smee, 'cree']])
46
46
 
47
- proxy.take(1).should eq([[:foo, 'bar']])
47
+ expect(proxy.take(1)).to eq([[:foo, 'bar']])
48
48
  end
49
49
 
50
50
  it "behaves kind of like a hash" do
51
51
  hash = {foo: 'bar', baz: 'bip', smee: 'cree'}
52
52
  proxy = HashProxy::Proxy.new(hash)
53
- proxy.size.should eq(3)
54
- proxy.each.to_a.size.should eq(3)
55
- proxy.each.to_a.map{|a| a.first}.should eq([:foo, :baz, :smee])
56
- proxy.each.to_a.map{|a| a.last}.should eq(['bar', 'bip', 'cree'])
57
- proxy[:foo].should eq('bar')
53
+ expect(proxy.size).to eq(3)
54
+ expect(proxy.each.to_a.size).to eq(3)
55
+ expect(proxy.each.to_a.map{|a| a.first}).to eq([:foo, :baz, :smee])
56
+ expect(proxy.each.to_a.map{|a| a.last}).to eq(['bar', 'bip', 'cree'])
57
+ expect(proxy[:foo]).to eq('bar')
58
58
  end
59
59
 
60
60
  it "can call setters" do
@@ -62,79 +62,79 @@ describe HashProxy do
62
62
  proxy.foo = 'foo val'
63
63
  proxy.bar = {:bip => :baz, :smoo => :smee}
64
64
 
65
- proxy.size.should eq(2)
66
- proxy[:bar].class.should eq(HashProxy::Proxy)
65
+ expect(proxy.size).to eq(2)
66
+ expect(proxy[:bar].class).to eq(HashProxy::Proxy)
67
67
  end
68
68
 
69
69
  it "handles crappy method calls" do
70
70
  proxy = HashProxy::Proxy.new({})
71
- lambda { proxy.send(:'=', 'crap') }.should raise_error(NoMethodError)
71
+ expect(lambda { proxy.send(:'=', 'crap') }).to raise_error(NoMethodError)
72
72
  end
73
73
 
74
- it "turns hash keys into method calls" do
74
+ it "turns hash keys i).to method calls" do
75
75
  hash = {foo: 'bar', baz: 'bip'}
76
76
  proxy = HashProxy::Proxy.new(hash)
77
- proxy.foo.should eq('bar')
78
- proxy.baz.should eq('bip')
77
+ expect(proxy.foo).to eq('bar')
78
+ expect(proxy.baz).to eq('bip')
79
79
  end
80
80
 
81
81
  it "handles nested hashes" do
82
82
  hash = {foo: {bar: 'barvalue', baz: 'bazvalue'}, bip: 'bipvalue'}
83
83
  proxy = HashProxy::Proxy.new(hash)
84
- proxy.foo.bar.should eq('barvalue')
85
- proxy.foo.baz.should eq('bazvalue')
86
- proxy.bip.should eq('bipvalue')
84
+ expect(proxy.foo.bar).to eq('barvalue')
85
+ expect(proxy.foo.baz).to eq('bazvalue')
86
+ expect(proxy.bip).to eq('bipvalue')
87
87
  end
88
88
 
89
89
  it "handles string keys" do
90
90
  hash = {'foo' => 'bar', 'baz' => 'bip'}
91
91
  proxy = HashProxy::Proxy.new(hash)
92
- proxy.foo.should eq('bar')
93
- proxy.baz.should eq('bip')
92
+ expect(proxy.foo).to eq('bar')
93
+ expect(proxy.baz).to eq('bip')
94
94
  end
95
95
 
96
96
  it "handles simple arrays" do
97
97
  hash = {'foo' => 'bar', 'arr1' => [1,2,3], 'baz' => 'bip'}
98
98
  proxy = HashProxy::Proxy.new(hash)
99
- proxy.arr1.should eq([1,2,3])
99
+ expect(proxy.arr1).to eq([1,2,3])
100
100
  end
101
101
 
102
102
  it "handles complicated arrays" do
103
103
  hash = {'foo' => 'bar', 'arr1' => [{'subkey' => 'subkeyval', 'more' => 'moreval'}, 3, {'subkey' => 'subkeyval2', 'more' => 'moreval2'}], 'baz' => 'bip'}
104
104
  proxy = HashProxy::Proxy.new(hash)
105
- proxy.arr1.first.subkey.should eq('subkeyval')
106
- proxy.arr1.last.subkey.should eq('subkeyval2')
107
- proxy.arr1[1].should eq(3)
105
+ expect(proxy.arr1.first.subkey).to eq('subkeyval')
106
+ expect(proxy.arr1.last.subkey).to eq('subkeyval2')
107
+ expect(proxy.arr1[1]).to eq(3)
108
108
  end
109
109
 
110
110
  it "should not convert values if nothing is referenced" do
111
111
  hash = {'foo' => 'bar', 'arr1' => [1,2,3], 'baz' => 'bip'}
112
- proxy = HashProxy::Proxy.new(hash)
113
- HashProxy::Proxy.should_not_receive(:convert_value)
114
- proxy.to_s
112
+ HashProxy::Proxy.new(hash)
113
+ expect(HashProxy::Proxy).not_to receive(:convert_value)
115
114
  end
116
115
 
117
116
  it "should convert values if they are referenced" do
118
117
  hash = {foo: 'bar', baz: 'bip'}
119
118
  proxy = HashProxy::Proxy.new(hash)
120
- proxy.should_receive(:convert_value).once.with('bar').and_return('bar')
121
- proxy.foo.should eq('bar')
119
+ #proxy.should_receive(:convert_value).once.with('bar').and_return('bar')
120
+ expect(proxy).to receive(:convert_value).once.with('bar').and_return('bar')
121
+ expect(proxy.foo).to eq('bar')
122
122
  end
123
123
 
124
124
  it "can be created using the factory method" do
125
125
  hash = {foo: 'bar', baz: 'bip'}
126
126
  proxy = HashProxy.create_from(hash)
127
- proxy.foo.should eq('bar')
127
+ expect(proxy.foo).to eq('bar')
128
128
  end
129
129
 
130
130
  it "handles keys that do not exist" do
131
131
  hash = {foo: 'bar', baz: 'bip'}
132
132
  proxy = HashProxy.create_from(hash)
133
- proxy.key.does.not.exist.to_s.should eq('')
134
- proxy.key.does.not.exist.nil?.should eq(true)
135
- proxy.key.does.not.exist.blank?.should eq(true)
136
- proxy.key.does.not.exist.empty?.should eq(true)
137
- proxy.key.does.not.exist.to_a.should eq([])
133
+ expect(proxy.key.does.not.exist.to_s).to eq('')
134
+ expect(proxy.key.does.not.exist.nil?).to eq(true)
135
+ expect(proxy.key.does.not.exist.blank?).to eq(true)
136
+ expect(proxy.key.does.not.exist.empty?).to eq(true)
137
+ expect(proxy.key.does.not.exist.to_a).to eq([])
138
138
  end
139
139
 
140
140
  describe "json conversion" do
@@ -142,35 +142,35 @@ describe HashProxy do
142
142
  it "should work when no keys are converted" do
143
143
  hash = {foo: 'bar', baz: {subkey: 'sub1', subkey2: 'sub2'}}
144
144
  proxy = HashProxy.create_from hash
145
- proxy.to_json.should eq(hash.to_json)
145
+ expect(proxy.to_json).to eq(hash.to_json)
146
146
  end
147
147
  it "should work when normal value has been converted" do
148
148
  orig = {foo: 'bar', baz: {subkey: 'sub1', subkey2: 'sub2'}}
149
149
  hash = Marshal.load(Marshal.dump(orig))
150
150
  proxy = HashProxy.create_from hash
151
- proxy.foo.should eq('bar')
151
+ expect(proxy.foo).to eq('bar')
152
152
  # Need to parse back to ruby arrays so we can use the ruby == operator
153
153
  # to compare
154
- JSON.parse(proxy.to_json).should eq(JSON.parse(orig.to_json))
154
+ expect(JSON.parse(proxy.to_json)).to eq(JSON.parse(orig.to_json))
155
155
  end
156
156
  it "should work when nested value has been converted" do
157
157
  orig = {foo: 'bar', baz: {subkey: 'sub1', subkey2: 'sub2'}}
158
158
  hash = Marshal.load(Marshal.dump(orig))
159
159
  proxy = HashProxy.create_from hash
160
160
  proxy.baz.each do |key, val|
161
- orig[:baz][key].should eq(val)
161
+ expect(orig[:baz][key]).to eq(val)
162
162
  end
163
163
  # Need to parse back to ruby arrays so we can use the ruby == operator
164
164
  # to compare
165
- JSON.parse(proxy.to_json).should eq(JSON.parse(orig.to_json))
165
+ expect(JSON.parse(proxy.to_json)).to eq(JSON.parse(orig.to_json))
166
166
  end
167
167
  end
168
168
 
169
- # TODO: Am I itching badly enough to make this pass? ....
169
+ # TODO: Am I itching badly enough).to make this pass? ....
170
170
  #it "should lazily handle nested arrays" do
171
171
  # hash = {:foo => [{:key1 => 'val11', :key2 => 'val12'}, {:key1 => 'val21', :key2 => 'val22'}], :bar => :baz}
172
172
  # proxy = HashProxy.create_from(hash)
173
- # proxy.foo.should eq([{:key1 => 'val11', :key2 => 'val12'}, {:key1 => 'val21', :key2 => 'val22'}])
173
+ # expect(proxy.foo).to eq([{:key1 => 'val11', :key2 => 'val12'}, {:key1 => 'val21', :key2 => 'val22'}])
174
174
  #end
175
175
 
176
176
  end
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
metadata CHANGED
@@ -1,123 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash-proxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
5
- prerelease:
4
+ version: 0.1.7
6
5
  platform: ruby
7
6
  authors:
8
7
  - Douglas A. Seifert
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-12 00:00:00.000000000 Z
11
+ date: 2018-11-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bones
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: 3.8.0
19
+ version: 3.8.4
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 3.8.0
30
- - !ruby/object:Gem::Dependency
31
- name: bones-rspec
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: 2.0.1
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: 2.0.1
46
- - !ruby/object:Gem::Dependency
47
- name: bones-git
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: 1.3.0
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: 1.3.0
62
- - !ruby/object:Gem::Dependency
63
- name: bones-yard
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: 1.0.0
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: 1.0.0
78
- - !ruby/object:Gem::Dependency
79
- name: redcarpet
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: 2.2.2
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: 2.2.2
94
- - !ruby/object:Gem::Dependency
95
- name: bones
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: 3.8.0
102
- type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: 3.8.0
110
- description: ! 'An object that proxies method calls to a Hash object as hash key lookups.
111
-
112
- Handles nested hashes and arrays.'
26
+ version: 3.8.4
27
+ description: |-
28
+ An object that proxies method calls to a Hash object as hash key lookups.
29
+ Handles nested hashes and arrays.
113
30
  email: doug@dseifert.net
114
31
  executables: []
115
32
  extensions: []
116
- extra_rdoc_files: []
33
+ extra_rdoc_files:
34
+ - History.txt
117
35
  files:
118
- - .bnsignore
119
- - .gitignore
120
- - .rvmrc
36
+ - ".bnsignore"
37
+ - ".gitignore"
38
+ - ".ruby-gemset"
39
+ - ".ruby-version"
121
40
  - Gemfile
122
41
  - Gemfile.lock
123
42
  - History.txt
@@ -131,29 +50,27 @@ files:
131
50
  - version.txt
132
51
  homepage: https://github.com/seifertd/hash-proxy
133
52
  licenses: []
53
+ metadata: {}
134
54
  post_install_message:
135
- rdoc_options: []
55
+ rdoc_options:
56
+ - "--main"
57
+ - README.md
136
58
  require_paths:
137
59
  - lib
138
60
  required_ruby_version: !ruby/object:Gem::Requirement
139
- none: false
140
61
  requirements:
141
- - - ! '>='
62
+ - - ">="
142
63
  - !ruby/object:Gem::Version
143
64
  version: '0'
144
- segments:
145
- - 0
146
- hash: -4040495455569849470
147
65
  required_rubygems_version: !ruby/object:Gem::Requirement
148
- none: false
149
66
  requirements:
150
- - - ! '>='
67
+ - - ">="
151
68
  - !ruby/object:Gem::Version
152
69
  version: '0'
153
70
  requirements: []
154
71
  rubyforge_project: hash-proxy
155
- rubygems_version: 1.8.24
72
+ rubygems_version: 2.6.12
156
73
  signing_key:
157
- specification_version: 3
74
+ specification_version: 4
158
75
  summary: An object that proxies method calls to a Hash object as hash key lookups.
159
76
  test_files: []
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm gemset use hash-proxy --create