instance_variable_hash 1.0.0 → 1.0.1

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -10,7 +10,7 @@ module InstanceVariableHash
10
10
  def instance_variables_get_as_hash(key)
11
11
  response = {} # we need a hash to have an object (id) to attach to
12
12
  self.instance_variables.each do |var|
13
- if var =~ /^@#{Regexp.escape(key)}(.*)$/ # we take the exact match and the subkeys
13
+ if var =~ /^@#{Regexp.escape(key.to_s)}(.*)$/ # we take the exact match and the subkeys
14
14
  keys, hsh, pre = $1.split('_'), response, []
15
15
  keys[0] = key # put the key itself into the result to have it in the loop
16
16
  stop = keys.size
@@ -26,6 +26,7 @@ class TestInstanceVarHash < Test::Unit::TestCase
26
26
  should "have several" do
27
27
  assert_equal 'res_a', @obj.get('a')
28
28
  assert_equal 'res_b', @obj.get('b')
29
+ assert_equal 'res_b', @obj.get(:b)
29
30
  end
30
31
  end
31
32
 
@@ -43,6 +44,7 @@ class TestInstanceVarHash < Test::Unit::TestCase
43
44
  assert_equal res1, @obj.get('a')
44
45
  res2 = {'c' => 'res_b_c', 'd' => 'res_b_d'}
45
46
  assert_equal res2, @obj.get('b')
47
+ assert_equal res2, @obj.get(:b)
46
48
  end
47
49
  end
48
50
 
@@ -59,6 +61,7 @@ class TestInstanceVarHash < Test::Unit::TestCase
59
61
  assert_equal res1, @obj.get('a')
60
62
  res2 = {'c' => {'d' => 'res_b_c_d'}, 'd' => {'e' => { 'f' => 'res_b_d_e_f' }}}
61
63
  assert_equal res2, @obj.get('b')
64
+ assert_equal res2, @obj.get(:b)
62
65
  end
63
66
  end
64
67
  end
@@ -77,7 +80,7 @@ class TestInstanceVarHash < Test::Unit::TestCase
77
80
  end
78
81
 
79
82
  should "handle a depth of 2" do
80
- @obj.set :a => { :b => 'res_a_b',
83
+ @obj.set :a => { 'b' => 'res_a_b',
81
84
  :c => 'res_a_c'}
82
85
 
83
86
  assert_equal 'res_a_b', @obj["@a_b"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instance_variable_hash
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marc Rene Arns