rash_alt 0.4.5 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +26 -26
- data/.travis.yml +4 -4
- data/README.rdoc +77 -77
- data/lib/hashie/mash/rash.rb +45 -45
- data/lib/rash/version.rb +3 -3
- data/rash.gemspec +25 -25
- data/spec/rash_spec.rb +127 -115
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f6233a2dcb91699ecb655ac9e48b6f1b414a762f2a053f5c4963838d2ff48a7c
|
4
|
+
data.tar.gz: 94d3b5c8f9cbd4d2a188915041554c6fb7077d484c9dc9e99f455666b1aa55d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8aacd03fc128ca74b8fd71f2cd5d4fe21e51ce1f4f2dba714c5296ccaee6f086541ab0b5dcd42304af7d9bce5b942e0db6d4c02f17b2e9169f2e22076bc3cd11
|
7
|
+
data.tar.gz: c57e26e12d7fbb1ed114d60146452648b7485dfabfd6b17f9db598c8d15e82777503fbc0c1f155eeac1fe16ccff68f17377c51483320832e11257f23d92ba40d
|
data/.gitignore
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
## MAC OS
|
2
|
-
.DS_Store
|
3
|
-
|
4
|
-
## TEXTMATE
|
5
|
-
*.tmproj
|
6
|
-
tmtags
|
7
|
-
|
8
|
-
## EMACS
|
9
|
-
*~
|
10
|
-
\#*
|
11
|
-
.\#*
|
12
|
-
|
13
|
-
## VIM
|
14
|
-
*.swp
|
15
|
-
|
16
|
-
## INTELLIJ
|
17
|
-
.idea
|
18
|
-
|
19
|
-
## PROJECT::GENERAL
|
20
|
-
coverage
|
21
|
-
rdoc
|
22
|
-
pkg
|
23
|
-
|
24
|
-
## PROJECT::SPECIFIC
|
25
|
-
Gemfile.lock
|
26
|
-
*.gem
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## INTELLIJ
|
17
|
+
.idea
|
18
|
+
|
19
|
+
## PROJECT::GENERAL
|
20
|
+
coverage
|
21
|
+
rdoc
|
22
|
+
pkg
|
23
|
+
|
24
|
+
## PROJECT::SPECIFIC
|
25
|
+
Gemfile.lock
|
26
|
+
*.gem
|
data/.travis.yml
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
language: ruby
|
2
|
-
script: 'bundle exec rake spec'
|
3
|
-
rvm:
|
4
|
-
- 2.4.2
|
1
|
+
language: ruby
|
2
|
+
script: 'bundle exec rake spec'
|
3
|
+
rvm:
|
4
|
+
- 2.4.2
|
data/README.rdoc
CHANGED
@@ -1,77 +1,77 @@
|
|
1
|
-
= rash
|
2
|
-
|
3
|
-
{<img src="https://badge.fury.io/rb/rash_alt.svg" alt="Gem Version" />}[https://badge.fury.io/rb/rash_alt]
|
4
|
-
{<img src="https://travis-ci.org/shishi/
|
5
|
-
|
6
|
-
Rash is an extension to Hashie ( http://github.com/intridea/hashie )
|
7
|
-
|
8
|
-
Rash subclasses Hashie::Mash to convert all keys in the hash to underscore
|
9
|
-
|
10
|
-
The purpose of this is when working w/ Java (or any other apis) that return hashes (including nested) that have camelCased keys
|
11
|
-
|
12
|
-
You will now be able to access those keys through underscored key names (camelCase still available)
|
13
|
-
|
14
|
-
== Installation
|
15
|
-
|
16
|
-
Add this line to your application's Gemfile:
|
17
|
-
|
18
|
-
gem 'rash_alt', require: 'rash'
|
19
|
-
|
20
|
-
And then execute:
|
21
|
-
|
22
|
-
$ bundle
|
23
|
-
|
24
|
-
Or install it yourself as:
|
25
|
-
|
26
|
-
$ gem install rash_alt
|
27
|
-
|
28
|
-
== Usage
|
29
|
-
|
30
|
-
@rash = Hashie::Mash::Rash.new({
|
31
|
-
"varOne" => 1,
|
32
|
-
"two" => 2,
|
33
|
-
:three => 3,
|
34
|
-
:varFour => 4,
|
35
|
-
"fiveHumpHumps" => 5,
|
36
|
-
:nested => {
|
37
|
-
"NestedOne" => "One",
|
38
|
-
:two => "two",
|
39
|
-
"nested_three" => "three"
|
40
|
-
},
|
41
|
-
"nestedTwo" => {
|
42
|
-
"nested_two" => 22,
|
43
|
-
:nestedThree => 23
|
44
|
-
}
|
45
|
-
})
|
46
|
-
|
47
|
-
@rash.var_one # => 1
|
48
|
-
@rash.two # => 2
|
49
|
-
@rash.three # => 3
|
50
|
-
@rash.var_four # => 4
|
51
|
-
@rash.five_hump_humps # => 5
|
52
|
-
@rash.nested.nested_one # => "One"
|
53
|
-
@rash.nested.two # => "two"
|
54
|
-
@rash.nested.nested_three # => "three"
|
55
|
-
@rash.nested_two.nested_two # => 22
|
56
|
-
@rash.nested_two.nested_three # => 23
|
57
|
-
|
58
|
-
== Note on Patches/Pull Requests
|
59
|
-
|
60
|
-
* Fork the project.
|
61
|
-
* Make your feature addition or bug fix.
|
62
|
-
* Add tests for it. This is important so I don't break it in a
|
63
|
-
future version unintentionally.
|
64
|
-
* Commit, do not mess with rakefile, version, or history.
|
65
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
66
|
-
* Send me a pull request. Bonus points for topic branches.
|
67
|
-
|
68
|
-
== Copyright
|
69
|
-
|
70
|
-
* Copyright (c) 2010 Tom Cocca.
|
71
|
-
* Copyright (c) 2016 Shigenobu Nishikawa.
|
72
|
-
|
73
|
-
=== Acknowledgements
|
74
|
-
|
75
|
-
* Intridea (https://github.com/intridea) for Hashie
|
76
|
-
* Mislav Marohnić (https://github.com/mislav) for contributions to Rash
|
77
|
-
* Steve Agalloco (https://github.com/spagalloco) for updating Rash to use bundler, rspec 2.5, hashie 1.0 and fixing some load dependencies
|
1
|
+
= rash
|
2
|
+
|
3
|
+
{<img src="https://badge.fury.io/rb/rash_alt.svg" alt="Gem Version" />}[https://badge.fury.io/rb/rash_alt]
|
4
|
+
{<img src="https://travis-ci.org/shishi/rash.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/shishi/rash_alt]
|
5
|
+
|
6
|
+
Rash is an extension to Hashie ( http://github.com/intridea/hashie )
|
7
|
+
|
8
|
+
Rash subclasses Hashie::Mash to convert all keys in the hash to underscore
|
9
|
+
|
10
|
+
The purpose of this is when working w/ Java (or any other apis) that return hashes (including nested) that have camelCased keys
|
11
|
+
|
12
|
+
You will now be able to access those keys through underscored key names (camelCase still available)
|
13
|
+
|
14
|
+
== Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
gem 'rash_alt', require: 'rash'
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install rash_alt
|
27
|
+
|
28
|
+
== Usage
|
29
|
+
|
30
|
+
@rash = Hashie::Mash::Rash.new({
|
31
|
+
"varOne" => 1,
|
32
|
+
"two" => 2,
|
33
|
+
:three => 3,
|
34
|
+
:varFour => 4,
|
35
|
+
"fiveHumpHumps" => 5,
|
36
|
+
:nested => {
|
37
|
+
"NestedOne" => "One",
|
38
|
+
:two => "two",
|
39
|
+
"nested_three" => "three"
|
40
|
+
},
|
41
|
+
"nestedTwo" => {
|
42
|
+
"nested_two" => 22,
|
43
|
+
:nestedThree => 23
|
44
|
+
}
|
45
|
+
})
|
46
|
+
|
47
|
+
@rash.var_one # => 1
|
48
|
+
@rash.two # => 2
|
49
|
+
@rash.three # => 3
|
50
|
+
@rash.var_four # => 4
|
51
|
+
@rash.five_hump_humps # => 5
|
52
|
+
@rash.nested.nested_one # => "One"
|
53
|
+
@rash.nested.two # => "two"
|
54
|
+
@rash.nested.nested_three # => "three"
|
55
|
+
@rash.nested_two.nested_two # => 22
|
56
|
+
@rash.nested_two.nested_three # => 23
|
57
|
+
|
58
|
+
== Note on Patches/Pull Requests
|
59
|
+
|
60
|
+
* Fork the project.
|
61
|
+
* Make your feature addition or bug fix.
|
62
|
+
* Add tests for it. This is important so I don't break it in a
|
63
|
+
future version unintentionally.
|
64
|
+
* Commit, do not mess with rakefile, version, or history.
|
65
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
66
|
+
* Send me a pull request. Bonus points for topic branches.
|
67
|
+
|
68
|
+
== Copyright
|
69
|
+
|
70
|
+
* Copyright (c) 2010 Tom Cocca.
|
71
|
+
* Copyright (c) 2016 Shigenobu Nishikawa.
|
72
|
+
|
73
|
+
=== Acknowledgements
|
74
|
+
|
75
|
+
* Intridea (https://github.com/intridea) for Hashie
|
76
|
+
* Mislav Marohnić (https://github.com/mislav) for contributions to Rash
|
77
|
+
* Steve Agalloco (https://github.com/spagalloco) for updating Rash to use bundler, rspec 2.5, hashie 1.0 and fixing some load dependencies
|
data/lib/hashie/mash/rash.rb
CHANGED
@@ -1,45 +1,45 @@
|
|
1
|
-
require 'hashie/mash'
|
2
|
-
|
3
|
-
module Hashie
|
4
|
-
class Mash
|
5
|
-
class Rash < Mash
|
6
|
-
|
7
|
-
protected
|
8
|
-
|
9
|
-
def convert_key(key) #:nodoc:
|
10
|
-
underscore_string(key.to_s)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Unlike its parent Mash, a Rash will convert other Hashie::Hash values to a Rash when assigning
|
14
|
-
# instead of respecting the existing subclass
|
15
|
-
def convert_value(val, duping=false) #:nodoc:
|
16
|
-
case val
|
17
|
-
when self.class
|
18
|
-
val.dup
|
19
|
-
when ::Hash
|
20
|
-
val = val.dup if duping
|
21
|
-
self.class.new(val)
|
22
|
-
when Array
|
23
|
-
val.collect{ |e| convert_value(e) }
|
24
|
-
else
|
25
|
-
val
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# converts a camel_cased string to a underscore string
|
30
|
-
# subs spaces with underscores, strips whitespace
|
31
|
-
# Same way ActiveSupport does string.underscore
|
32
|
-
def underscore_string(str)
|
33
|
-
str.to_s.strip.
|
34
|
-
gsub(' ', '_').
|
35
|
-
gsub(/::/, '/').
|
36
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
37
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
38
|
-
tr("-", "_").
|
39
|
-
squeeze("_").
|
40
|
-
downcase
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
1
|
+
require 'hashie/mash'
|
2
|
+
|
3
|
+
module Hashie
|
4
|
+
class Mash
|
5
|
+
class Rash < Mash
|
6
|
+
|
7
|
+
protected
|
8
|
+
|
9
|
+
def convert_key(key) #:nodoc:
|
10
|
+
underscore_string(key.to_s)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Unlike its parent Mash, a Rash will convert other Hashie::Hash values to a Rash when assigning
|
14
|
+
# instead of respecting the existing subclass
|
15
|
+
def convert_value(val, duping=false) #:nodoc:
|
16
|
+
case val
|
17
|
+
when self.class
|
18
|
+
val.dup
|
19
|
+
when ::Hash
|
20
|
+
val = val.dup if duping
|
21
|
+
self.class.new(val)
|
22
|
+
when ::Array
|
23
|
+
val.collect{ |e| convert_value(e) }
|
24
|
+
else
|
25
|
+
val
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# converts a camel_cased string to a underscore string
|
30
|
+
# subs spaces with underscores, strips whitespace
|
31
|
+
# Same way ActiveSupport does string.underscore
|
32
|
+
def underscore_string(str)
|
33
|
+
str.to_s.strip.
|
34
|
+
gsub(' ', '_').
|
35
|
+
gsub(/::/, '/').
|
36
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
37
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
38
|
+
tr("-", "_").
|
39
|
+
squeeze("_").
|
40
|
+
downcase
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/rash/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Rash
|
2
|
-
VERSION = '0.4.
|
3
|
-
end
|
1
|
+
module Rash
|
2
|
+
VERSION = '0.4.6'
|
3
|
+
end
|
data/rash.gemspec
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "rash/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = %q{rash_alt}
|
7
|
-
s.authors = ["tcocca", "Shigenobu Nishikawa"]
|
8
|
-
s.description = %q{simple extension to Hashie::Mash for rubyified keys, all keys are converted to underscore to eliminate horrible camelCasing}
|
9
|
-
s.email = %q{tom.cocca@gmail.com, shishi.s.n@gmail.com}
|
10
|
-
s.homepage = "https://github.com/shishi/rash_alt"
|
11
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
12
|
-
s.summary = %q{simple extension to Hashie::Mash for rubyified keys}
|
13
|
-
|
14
|
-
s.version = Rash::VERSION
|
15
|
-
|
16
|
-
s.add_dependency 'hashie', '~> 3.5.6'
|
17
|
-
s.add_development_dependency 'rake', '~> 12.3.0'
|
18
|
-
s.add_development_dependency 'rdoc', '~> 6.0.0'
|
19
|
-
s.add_development_dependency 'rspec', '~> 3.7.0'
|
20
|
-
|
21
|
-
s.require_paths = ['lib']
|
22
|
-
s.files = `git ls-files`.split("\n")
|
23
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
25
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rash/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = %q{rash_alt}
|
7
|
+
s.authors = ["tcocca", "Shigenobu Nishikawa"]
|
8
|
+
s.description = %q{simple extension to Hashie::Mash for rubyified keys, all keys are converted to underscore to eliminate horrible camelCasing}
|
9
|
+
s.email = %q{tom.cocca@gmail.com, shishi.s.n@gmail.com}
|
10
|
+
s.homepage = "https://github.com/shishi/rash_alt"
|
11
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
12
|
+
s.summary = %q{simple extension to Hashie::Mash for rubyified keys}
|
13
|
+
|
14
|
+
s.version = Rash::VERSION
|
15
|
+
|
16
|
+
s.add_dependency 'hashie', '~> 3.5.6'
|
17
|
+
s.add_development_dependency 'rake', '~> 12.3.0'
|
18
|
+
s.add_development_dependency 'rdoc', '~> 6.0.0'
|
19
|
+
s.add_development_dependency 'rspec', '~> 3.7.0'
|
20
|
+
|
21
|
+
s.require_paths = ['lib']
|
22
|
+
s.files = `git ls-files`.split("\n")
|
23
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
25
|
+
end
|
data/spec/rash_spec.rb
CHANGED
@@ -1,115 +1,127 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Hashie::Mash::Rash do
|
4
|
-
subject {
|
5
|
-
Hashie::Mash::Rash.new({
|
6
|
-
"varOne" => 1,
|
7
|
-
"two" => 2,
|
8
|
-
:three => 3,
|
9
|
-
:varFour => 4,
|
10
|
-
"fiveHumpHumps" => 5,
|
11
|
-
:nested => {
|
12
|
-
"NestedOne" => "One",
|
13
|
-
:two => "two",
|
14
|
-
"nested_three" => "three"
|
15
|
-
},
|
16
|
-
"nestedTwo" => {
|
17
|
-
"nested_two" => 22,
|
18
|
-
:nestedThree => 23
|
19
|
-
},
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
subject.
|
34
|
-
subject.
|
35
|
-
subject.
|
36
|
-
subject.
|
37
|
-
subject.
|
38
|
-
subject.
|
39
|
-
subject.
|
40
|
-
subject.
|
41
|
-
subject.
|
42
|
-
subject.
|
43
|
-
subject.
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
subject.
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
subject.
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
merged.
|
70
|
-
merged
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
subject.
|
84
|
-
subject
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
merged.
|
98
|
-
merged
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
subject.nested3
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
subject
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hashie::Mash::Rash do
|
4
|
+
subject {
|
5
|
+
Hashie::Mash::Rash.new({
|
6
|
+
"varOne" => 1,
|
7
|
+
"two" => 2,
|
8
|
+
:three => 3,
|
9
|
+
:varFour => 4,
|
10
|
+
"fiveHumpHumps" => 5,
|
11
|
+
:nested => {
|
12
|
+
"NestedOne" => "One",
|
13
|
+
:two => "two",
|
14
|
+
"nested_three" => "three"
|
15
|
+
},
|
16
|
+
"nestedTwo" => {
|
17
|
+
"nested_two" => 22,
|
18
|
+
:nestedThree => 23
|
19
|
+
},
|
20
|
+
:nestedThree => [
|
21
|
+
{ :nestedFour => 4 },
|
22
|
+
{ "nestedFour" => 4 }
|
23
|
+
],
|
24
|
+
"spaced Key" => "When would this happen?",
|
25
|
+
"trailing spaces " => "better safe than sorry",
|
26
|
+
"extra spaces" => "hopefully this never happens"
|
27
|
+
})
|
28
|
+
}
|
29
|
+
|
30
|
+
it { should be_a(Hashie::Mash) }
|
31
|
+
|
32
|
+
it "should create a new rash where all the keys are underscored instead of camelcased" do
|
33
|
+
subject.var_one.should == 1
|
34
|
+
subject.two.should == 2
|
35
|
+
subject.three.should == 3
|
36
|
+
subject.var_four.should == 4
|
37
|
+
subject.five_hump_humps.should == 5
|
38
|
+
subject.nested.should be_a(Hashie::Mash::Rash)
|
39
|
+
subject.nested.nested_one.should == "One"
|
40
|
+
subject.nested.two.should == "two"
|
41
|
+
subject.nested.nested_three.should == "three"
|
42
|
+
subject.nested_two.should be_a(Hashie::Mash::Rash)
|
43
|
+
subject.nested_two.nested_two.should == 22
|
44
|
+
subject.nested_two.nested_three.should == 23
|
45
|
+
subject.spaced_key.should == "When would this happen?"
|
46
|
+
subject.trailing_spaces.should == "better safe than sorry"
|
47
|
+
subject.extra_spaces.should == "hopefully this never happens"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should allow camelCased accessors" do
|
51
|
+
subject.varOne.should == 1
|
52
|
+
subject.varOne = "once"
|
53
|
+
subject.varOne.should == "once"
|
54
|
+
subject.var_one.should == "once"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should allow camelCased accessors on nested hashes" do
|
58
|
+
subject.nested.nestedOne.should == "One"
|
59
|
+
subject.nested.nestedOne = "once"
|
60
|
+
subject.nested.nested_one.should == "once"
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should merge well with a Mash" do
|
64
|
+
merged = subject.merge Hashie::Mash.new(
|
65
|
+
:nested => {:fourTimes => "a charm"},
|
66
|
+
:nested3 => {:helloWorld => "hi"}
|
67
|
+
)
|
68
|
+
|
69
|
+
merged.nested.four_times.should == "a charm"
|
70
|
+
merged.nested.fourTimes.should == "a charm"
|
71
|
+
merged.nested3.should be_a(Hashie::Mash::Rash)
|
72
|
+
merged.nested3.hello_world.should == "hi"
|
73
|
+
merged.nested3.helloWorld.should == "hi"
|
74
|
+
merged[:nested3][:helloWorld].should == "hi"
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should update well with a Mash" do
|
78
|
+
subject.update Hashie::Mash.new(
|
79
|
+
:nested => {:fourTimes => "a charm"},
|
80
|
+
:nested3 => {:helloWorld => "hi"}
|
81
|
+
)
|
82
|
+
|
83
|
+
subject.nested.four_times.should == "a charm"
|
84
|
+
subject.nested.fourTimes.should == "a charm"
|
85
|
+
subject.nested3.should be_a(Hashie::Mash::Rash)
|
86
|
+
subject.nested3.hello_world.should == "hi"
|
87
|
+
subject.nested3.helloWorld.should == "hi"
|
88
|
+
subject[:nested3][:helloWorld].should == "hi"
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should merge well with a Hash" do
|
92
|
+
merged = subject.merge({
|
93
|
+
:nested => {:fourTimes => "work like a charm"},
|
94
|
+
:nested3 => {:helloWorld => "hi"}
|
95
|
+
})
|
96
|
+
|
97
|
+
merged.nested.four_times.should == "work like a charm"
|
98
|
+
merged.nested.fourTimes.should == "work like a charm"
|
99
|
+
merged.nested3.should be_a(Hashie::Mash::Rash)
|
100
|
+
merged.nested3.hello_world.should == "hi"
|
101
|
+
merged.nested3.helloWorld.should == "hi"
|
102
|
+
merged[:nested3][:helloWorld].should == "hi"
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should handle assigning a new Hash and convert it to a rash" do
|
106
|
+
subject.nested3 = {:helloWorld => "hi"}
|
107
|
+
|
108
|
+
subject.nested3.should be_a(Hashie::Mash::Rash)
|
109
|
+
subject.nested3.hello_world.should == "hi"
|
110
|
+
subject.nested3.helloWorld.should == "hi"
|
111
|
+
subject[:nested3][:helloWorld].should == "hi"
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should convert an array of Hashes" do
|
115
|
+
subject.nested_three.should be_a(Array)
|
116
|
+
subject.nested_three[0].should be_a(Hashie::Mash::Rash)
|
117
|
+
subject.nested_three[0].nested_four.should == 4
|
118
|
+
subject.nested_three[1].should be_a(Hashie::Mash::Rash)
|
119
|
+
subject.nested_three[1].nested_four.should == 4
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should allow initializing reader" do
|
123
|
+
subject.nested3!.helloWorld = "hi"
|
124
|
+
subject.nested3.hello_world.should == "hi"
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rash_alt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tcocca
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashie
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
109
|
rubyforge_project:
|
110
|
-
rubygems_version: 2.
|
110
|
+
rubygems_version: 2.7.3
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: simple extension to Hashie::Mash for rubyified keys
|