hash_dot 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +26 -0
- data/hash_dot.gemspec +1 -0
- data/lib/hash.rb +7 -9
- data/lib/hash_dot/version.rb +1 -1
- data/lib/hash_dot.rb +2 -2
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f663bf99b57b8e6bf0ba73b8630788ec64cf2b01
|
4
|
+
data.tar.gz: 837a18813c62111c9a009989f40720b1a93b8dad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b104681a233fa104b6281663782b0126d1f0a6705f9dfbb4a9a05b04c067a66a242b2e0fcfb8977547f69d2f9abaca0b5d645464524cd203bdd6606b371ec1e
|
7
|
+
data.tar.gz: 7432c40f0d0c5a7eb820b1958c9e9ec41f250f6e2f364f8441576db92ba1db901d95b43368dec60eb6e98ed17ab13c22858f802a49b37afed411dde5d50a142b
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.0
|
3
|
+
Include:
|
4
|
+
- 'lib/**/*'
|
5
|
+
- 'spec/**/*'
|
6
|
+
|
7
|
+
Metrics/LineLength:
|
8
|
+
Max: 120
|
9
|
+
|
10
|
+
Style/Style/BlockDelimiters:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Style/Documentation:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/MutableConstant:
|
17
|
+
Enabled: true
|
18
|
+
|
19
|
+
Style/SpaceBeforeBlockBraces:
|
20
|
+
EnforcedStyle: space
|
21
|
+
|
22
|
+
Style/SpaceInsideParens:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/StringLiterals:
|
26
|
+
EnforcedStyle: double_quotes
|
data/hash_dot.gemspec
CHANGED
data/lib/hash.rb
CHANGED
@@ -16,11 +16,7 @@ class Hash
|
|
16
16
|
|
17
17
|
prop = create_prop(method)
|
18
18
|
|
19
|
-
|
20
|
-
self[prop] = self.delete(prop.to_s)
|
21
|
-
end
|
22
|
-
|
23
|
-
super(method, args) and return unless prop_present?(prop)
|
19
|
+
super(method, args) && return unless key?(prop)
|
24
20
|
|
25
21
|
if setter?(method)
|
26
22
|
self[prop] = args.first
|
@@ -38,7 +34,7 @@ class Hash
|
|
38
34
|
end
|
39
35
|
|
40
36
|
def to_dot?
|
41
|
-
|
37
|
+
use_dot_syntax || self.class.use_dot_syntax
|
42
38
|
end
|
43
39
|
|
44
40
|
def setter?(method)
|
@@ -46,10 +42,12 @@ class Hash
|
|
46
42
|
end
|
47
43
|
|
48
44
|
def create_prop(method)
|
49
|
-
|
45
|
+
prop = basic_prop_from_method(method)
|
46
|
+
|
47
|
+
key?(prop.to_s) ? prop.to_s : prop
|
50
48
|
end
|
51
49
|
|
52
|
-
def
|
53
|
-
|
50
|
+
def basic_prop_from_method(method)
|
51
|
+
setter?(method) ? method.chop : method
|
54
52
|
end
|
55
53
|
end
|
data/lib/hash_dot/version.rb
CHANGED
data/lib/hash_dot.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_dot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Steel
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.37.2
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.37.2
|
83
97
|
description: HashDot allows you to call hash properties with a dot the same way you
|
84
98
|
would call, say, ActiveRecord relationships and attributes. More traversable and
|
85
99
|
often faster than OpenStruct.
|
@@ -91,6 +105,7 @@ extra_rdoc_files: []
|
|
91
105
|
files:
|
92
106
|
- ".gitignore"
|
93
107
|
- ".rspec"
|
108
|
+
- ".rubocop.yml"
|
94
109
|
- ".travis.yml"
|
95
110
|
- CODE_OF_CONDUCT.md
|
96
111
|
- Gemfile
|