rash_alt 0.4.6 → 0.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rspec.yml +28 -0
- data/.gitignore +29 -26
- data/Dockerfile +10 -0
- data/README.md +86 -0
- data/lib/hashie/mash/rash.rb +46 -45
- data/lib/rash/version.rb +3 -3
- data/rash.gemspec +25 -25
- data/spec/rash_spec.rb +133 -127
- metadata +15 -15
- data/.travis.yml +0 -4
- data/README.rdoc +0 -77
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c484aa06757e57da16df5493e7556d017891abc9dc31602e7d7da2cb0afaf95
|
4
|
+
data.tar.gz: 65a185702f051d84d2b04f93a96c3f8bac0b60a2c5b48ef6fc22158a54cc8762
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f35863662ddca2a6e6191f2a515955df9950f37a5e587661df06f0c86ad47fabc1c28fd63ae2f6b07cb11b3bf5d9869d82aa053c331e3f767ecfe5a0725e550c
|
7
|
+
data.tar.gz: 6d07ba44559d89608ade5f1e6af1a7ec1e98493b0c9367dc62fbf7adf31940f57184cdeeec6431272e182dd3bdb41e9bc4a25c22e6a2aab44573696fc10e2472
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: rspec
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- master
|
6
|
+
pull_request:
|
7
|
+
branches:
|
8
|
+
- "*"
|
9
|
+
jobs:
|
10
|
+
rspec:
|
11
|
+
runs-on: ${{ matrix.os }}
|
12
|
+
strategy:
|
13
|
+
fail-fast: false
|
14
|
+
matrix:
|
15
|
+
os: [ubuntu-20.04, ubuntu-18.04]
|
16
|
+
ruby: [2.5, 2.6, 2.7, 3.0]
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v2
|
19
|
+
with:
|
20
|
+
fetch-depth: 1
|
21
|
+
- uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
24
|
+
bundler-cache: true
|
25
|
+
- name: install dependency
|
26
|
+
run: bundle install
|
27
|
+
- name: run spec
|
28
|
+
run: bundle exec rake spec
|
data/.gitignore
CHANGED
@@ -1,26 +1,29 @@
|
|
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
|
27
|
+
|
28
|
+
## VScode
|
29
|
+
.devcontainer
|
data/Dockerfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# rash
|
2
|
+
|
3
|
+
[![gem version](https://img.shields.io/gem/v/rash_alt.svg)](https://rubygems.org/gems/rash_alt)
|
4
|
+
[![build status](https://github.com/shishi/rash_alt/workflows/rspec/badge.svg)](https://github.com/shishi/rash_alt/actions?query=workflow%3Arspec)
|
5
|
+
|
6
|
+
Rash is an extension to Hashie ( http://github.com/hashie/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
|
11
|
+
hashes (including nested) that have camelCased keys.
|
12
|
+
|
13
|
+
You will now be able to access those keys through underscored key names
|
14
|
+
(camelCase still available).
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'rash_alt', require: 'rash'
|
22
|
+
```
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
```shell
|
27
|
+
$ bundle
|
28
|
+
```
|
29
|
+
|
30
|
+
Or install it yourself as:
|
31
|
+
|
32
|
+
```shell
|
33
|
+
$ gem install rash_alt
|
34
|
+
```
|
35
|
+
|
36
|
+
## Usage
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
@rash = Hashie::Mash::Rash.new({
|
40
|
+
"varOne" => 1,
|
41
|
+
"two" => 2,
|
42
|
+
:three => 3,
|
43
|
+
:varFour => 4,
|
44
|
+
"fiveHumpHumps" => 5,
|
45
|
+
:nested => {
|
46
|
+
"NestedOne" => "One",
|
47
|
+
:two => "two",
|
48
|
+
"nested_three" => "three"
|
49
|
+
},
|
50
|
+
"nestedTwo" => {
|
51
|
+
"nested_two" => 22,
|
52
|
+
:nestedThree => 23
|
53
|
+
}
|
54
|
+
})
|
55
|
+
|
56
|
+
@rash.var_one # => 1
|
57
|
+
@rash.two # => 2
|
58
|
+
@rash.three # => 3
|
59
|
+
@rash.var_four # => 4
|
60
|
+
@rash.five_hump_humps # => 5
|
61
|
+
@rash.nested.nested_one # => "One"
|
62
|
+
@rash.nested.two # => "two"
|
63
|
+
@rash.nested.nested_three # => "three"
|
64
|
+
@rash.nested_two.nested_two # => 22
|
65
|
+
@rash.nested_two.nested_three # => 23
|
66
|
+
```
|
67
|
+
|
68
|
+
## Note on Patches/Pull Requests
|
69
|
+
|
70
|
+
* Fork the project.
|
71
|
+
* Make your feature addition or bug fix.
|
72
|
+
* Add tests for it. This is important so I don't break it in a future version unintentionally.
|
73
|
+
* Commit, do not mess with rakefile, version, or history. (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)
|
74
|
+
* Send me a pull request. Bonus points for topic branches.
|
75
|
+
|
76
|
+
## Copyright
|
77
|
+
|
78
|
+
* Copyright (c) 2010 Tom Cocca.
|
79
|
+
* Copyright (c) 2016 Shigenobu Nishikawa.
|
80
|
+
|
81
|
+
### Acknowledgements
|
82
|
+
|
83
|
+
* Intridea (https://github.com/intridea) for Hashie
|
84
|
+
* Mislav Marohnić (https://github.com/mislav) for contributions to Rash
|
85
|
+
* Steve Agalloco (https://github.com/spagalloco) for updating Rash to use bundler, rspec 2.5, hashie 1.0 and fixing some load dependencies
|
86
|
+
|
data/lib/hashie/mash/rash.rb
CHANGED
@@ -1,45 +1,46 @@
|
|
1
|
-
require 'hashie/mash'
|
2
|
-
|
3
|
-
module Hashie
|
4
|
-
class Mash
|
5
|
-
class Rash < Mash
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
#
|
31
|
-
#
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
gsub(
|
36
|
-
gsub(/
|
37
|
-
gsub(/([
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
1
|
+
require 'hashie/mash'
|
2
|
+
|
3
|
+
module Hashie
|
4
|
+
class Mash
|
5
|
+
class Rash < Mash
|
6
|
+
# NOTE: I have no idea I should do all keys `disable_warnings` for avoiding Hashie v5's warnings
|
7
|
+
|
8
|
+
protected
|
9
|
+
|
10
|
+
def convert_key(key) #:nodoc:
|
11
|
+
underscore_string(key.to_s)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Unlike its parent Mash, a Rash will convert other Hashie::Hash values to a Rash when assigning
|
15
|
+
# instead of respecting the existing subclass
|
16
|
+
def convert_value(val, duping=false) #:nodoc:
|
17
|
+
case val
|
18
|
+
when self.class
|
19
|
+
val.dup
|
20
|
+
when ::Hash
|
21
|
+
val = val.dup if duping
|
22
|
+
self.class.new(val)
|
23
|
+
when ::Array
|
24
|
+
val.collect{ |e| convert_value(e) }
|
25
|
+
else
|
26
|
+
val
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# converts a camel_cased string to a underscore string
|
31
|
+
# subs spaces with underscores, strips whitespace
|
32
|
+
# Same way ActiveSupport does string.underscore
|
33
|
+
def underscore_string(str)
|
34
|
+
str.to_s.strip.
|
35
|
+
gsub(' ', '_').
|
36
|
+
gsub(/::/, '/').
|
37
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
38
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
39
|
+
tr("-", "_").
|
40
|
+
squeeze("_").
|
41
|
+
downcase
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
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.10'
|
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
|
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', '~>
|
17
|
-
s.add_development_dependency 'rake', '~>
|
18
|
-
s.add_development_dependency 'rdoc', '~> 6
|
19
|
-
s.add_development_dependency 'rspec', '~> 3
|
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@srevo.net}
|
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', '~> 5'
|
17
|
+
s.add_development_dependency 'rake', '~> 13'
|
18
|
+
s.add_development_dependency 'rdoc', '~> 6'
|
19
|
+
s.add_development_dependency 'rspec', '~> 3'
|
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,127 +1,133 @@
|
|
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
|
-
|
52
|
-
subject.varOne
|
53
|
-
|
54
|
-
subject.
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
merged
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
subject.
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
merged
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
subject.
|
116
|
-
subject.
|
117
|
-
subject
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
subject.
|
124
|
-
subject.
|
125
|
-
|
126
|
-
|
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
|
+
: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
|
+
#avoiding hashie v5- warnings
|
52
|
+
subject.class.disable_warnings(:varOne)
|
53
|
+
|
54
|
+
subject.varOne.should == 1
|
55
|
+
subject.varOne = "once"
|
56
|
+
subject.varOne.should == "once"
|
57
|
+
subject.var_one.should == "once"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should allow camelCased accessors on nested hashes" do
|
61
|
+
# avoiding hashie v5- warnings
|
62
|
+
subject.class.disable_warnings(:nestedOne)
|
63
|
+
|
64
|
+
subject.nested.nestedOne.should == "One"
|
65
|
+
subject.nested.nestedOne = "once"
|
66
|
+
subject.nested.nested_one.should == "once"
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should merge well with a Mash" do
|
70
|
+
merged = subject.merge Hashie::Mash.new(
|
71
|
+
:nested => {:fourTimes => "a charm"},
|
72
|
+
:nested3 => {:helloWorld => "hi"}
|
73
|
+
)
|
74
|
+
|
75
|
+
merged.nested.four_times.should == "a charm"
|
76
|
+
merged.nested.fourTimes.should == "a charm"
|
77
|
+
merged.nested3.should be_a(Hashie::Mash::Rash)
|
78
|
+
merged.nested3.hello_world.should == "hi"
|
79
|
+
merged.nested3.helloWorld.should == "hi"
|
80
|
+
merged[:nested3][:helloWorld].should == "hi"
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should update well with a Mash" do
|
84
|
+
subject.update Hashie::Mash.new(
|
85
|
+
:nested => {:fourTimes => "a charm"},
|
86
|
+
:nested3 => {:helloWorld => "hi"}
|
87
|
+
)
|
88
|
+
|
89
|
+
subject.nested.four_times.should == "a charm"
|
90
|
+
subject.nested.fourTimes.should == "a charm"
|
91
|
+
subject.nested3.should be_a(Hashie::Mash::Rash)
|
92
|
+
subject.nested3.hello_world.should == "hi"
|
93
|
+
subject.nested3.helloWorld.should == "hi"
|
94
|
+
subject[:nested3][:helloWorld].should == "hi"
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should merge well with a Hash" do
|
98
|
+
merged = subject.merge({
|
99
|
+
:nested => {:fourTimes => "work like a charm"},
|
100
|
+
:nested3 => {:helloWorld => "hi"}
|
101
|
+
})
|
102
|
+
|
103
|
+
merged.nested.four_times.should == "work like a charm"
|
104
|
+
merged.nested.fourTimes.should == "work like a charm"
|
105
|
+
merged.nested3.should be_a(Hashie::Mash::Rash)
|
106
|
+
merged.nested3.hello_world.should == "hi"
|
107
|
+
merged.nested3.helloWorld.should == "hi"
|
108
|
+
merged[:nested3][:helloWorld].should == "hi"
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should handle assigning a new Hash and convert it to a rash" do
|
112
|
+
subject.nested3 = {:helloWorld => "hi"}
|
113
|
+
|
114
|
+
subject.nested3.should be_a(Hashie::Mash::Rash)
|
115
|
+
subject.nested3.hello_world.should == "hi"
|
116
|
+
subject.nested3.helloWorld.should == "hi"
|
117
|
+
subject[:nested3][:helloWorld].should == "hi"
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should convert an array of Hashes" do
|
121
|
+
subject.nested_three.should be_a(Array)
|
122
|
+
subject.nested_three[0].should be_a(Hashie::Mash::Rash)
|
123
|
+
subject.nested_three[0].nested_four.should == 4
|
124
|
+
subject.nested_three[1].should be_a(Hashie::Mash::Rash)
|
125
|
+
subject.nested_three[1].nested_four.should == 4
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should allow initializing reader" do
|
129
|
+
subject.nested3!.helloWorld = "hi"
|
130
|
+
subject.nested3.hello_world.should == "hi"
|
131
|
+
end
|
132
|
+
|
133
|
+
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.10
|
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: 2022-02-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashie
|
@@ -17,69 +17,70 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: '5'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: '5'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version:
|
34
|
+
version: '13'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version:
|
41
|
+
version: '13'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rdoc
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 6
|
48
|
+
version: '6'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 6
|
55
|
+
version: '6'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rspec
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 3
|
62
|
+
version: '3'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 3
|
69
|
+
version: '3'
|
70
70
|
description: simple extension to Hashie::Mash for rubyified keys, all keys are converted
|
71
71
|
to underscore to eliminate horrible camelCasing
|
72
|
-
email: tom.cocca@gmail.com, shishi
|
72
|
+
email: tom.cocca@gmail.com, shishi@srevo.net
|
73
73
|
executables: []
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
+
- ".github/workflows/rspec.yml"
|
77
78
|
- ".gitignore"
|
78
79
|
- ".rspec"
|
79
|
-
-
|
80
|
+
- Dockerfile
|
80
81
|
- Gemfile
|
81
82
|
- LICENSE
|
82
|
-
- README.
|
83
|
+
- README.md
|
83
84
|
- Rakefile
|
84
85
|
- lib/hashie/mash/rash.rb
|
85
86
|
- lib/rash.rb
|
@@ -106,8 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
107
|
- !ruby/object:Gem::Version
|
107
108
|
version: '0'
|
108
109
|
requirements: []
|
109
|
-
|
110
|
-
rubygems_version: 2.7.3
|
110
|
+
rubygems_version: 3.2.3
|
111
111
|
signing_key:
|
112
112
|
specification_version: 4
|
113
113
|
summary: simple extension to Hashie::Mash for rubyified keys
|
data/.travis.yml
DELETED
data/README.rdoc
DELETED
@@ -1,77 +0,0 @@
|
|
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
|