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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5256b4a3e535f123be0295d4049fec34b64f441b
4
- data.tar.gz: c5e6eb31c072e2b0c416db88ade397b1598eb2ab
3
+ metadata.gz: f663bf99b57b8e6bf0ba73b8630788ec64cf2b01
4
+ data.tar.gz: 837a18813c62111c9a009989f40720b1a93b8dad
5
5
  SHA512:
6
- metadata.gz: 4e07873e37e0d041787493bdca2cc169d16e60551e548491ec70380dc1e7f0bedd5a21a5a1bb36c2e0b62cd649125c4e9a04e25b4c840e5558f2c430dad04964
7
- data.tar.gz: d04857e49797516d9c812906c17888f261368cfbc87c1d67d2dc7528b4f9665ad7d80745ae0888a234de00f8508fb71195fb0e09198c430bca51282f0daf6ab0
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
@@ -32,4 +32,5 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency "rspec"
33
33
  spec.add_development_dependency "json"
34
34
  spec.add_development_dependency "pry"
35
+ spec.add_development_dependency "rubocop", "~> 0.37.2"
35
36
  end
data/lib/hash.rb CHANGED
@@ -16,11 +16,7 @@ class Hash
16
16
 
17
17
  prop = create_prop(method)
18
18
 
19
- if self[prop].nil? && prop_present?(prop)
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
- self.use_dot_syntax || self.class.use_dot_syntax
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
- setter?(method) ? method.chop : method
45
+ prop = basic_prop_from_method(method)
46
+
47
+ key?(prop.to_s) ? prop.to_s : prop
50
48
  end
51
49
 
52
- def prop_present?(prop)
53
- self.has_key?(prop) || self.has_key?(prop.to_s)
50
+ def basic_prop_from_method(method)
51
+ setter?(method) ? method.chop : method
54
52
  end
55
53
  end
@@ -1,3 +1,3 @@
1
1
  module HashDot
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2".freeze
3
3
  end
data/lib/hash_dot.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "hash_dot/version"
2
- require 'symbol'
3
- require 'hash'
2
+ require "symbol"
3
+ require "hash"
4
4
 
5
5
  module HashDot
6
6
  end
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.1
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