dot_hash 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/README.md +5 -1
- data/Rakefile +2 -0
- data/lib/dot_hash/properties.rb +5 -0
- data/lib/dot_hash/version.rb +1 -1
- data/test/dot_hash/properties_test.rb +14 -0
- metadata +5 -4
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
|
1
2
|
# DotHash
|
3
|
+
[![Build Status](https://travis-ci.org/3den/dot_hash.png?branch=master)](https://travis-ci.org/3den/dot_hash)
|
2
4
|
|
3
|
-
A very efficient gem that lets you use hashes as object properties. It is almost as fast as a plain Hash
|
5
|
+
A very efficient gem that lets you use hashes as object properties. It is almost as fast as a plain Hash
|
4
6
|
since it's complexity is also linear, `O(n) # where N is the number of nested parents of the given property`.
|
5
7
|
|
6
8
|
## Installation
|
@@ -25,6 +27,8 @@ properties = some_hash.to_properties
|
|
25
27
|
|
26
28
|
properties.size.height # returns 100, it is the same as some_hash[:size][:height]
|
27
29
|
properties.color # returns "red", it works with Strings and Symbol keys
|
30
|
+
properties[:color] # returns "red", can be used like a hash with string keys
|
31
|
+
properties["color"] # returns "red", can be used like a hash with symbol keys
|
28
32
|
```
|
29
33
|
|
30
34
|
## Contributing
|
data/Rakefile
CHANGED
data/lib/dot_hash/properties.rb
CHANGED
data/lib/dot_hash/version.rb
CHANGED
@@ -39,6 +39,20 @@ module DotHash
|
|
39
39
|
settings.user.info.is_admin.must_equal false
|
40
40
|
end
|
41
41
|
end
|
42
|
+
|
43
|
+
describe "#[]" do
|
44
|
+
before do
|
45
|
+
@settings = Properties.new user: { name: "dude" }
|
46
|
+
end
|
47
|
+
|
48
|
+
it "accesses properties like a symbol hash" do
|
49
|
+
settings[:user][:name].must_equal "dude"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "accesses properties like a string hash" do
|
53
|
+
settings["user"]["name"].must_equal "dude"
|
54
|
+
end
|
55
|
+
end
|
42
56
|
end
|
43
57
|
|
44
58
|
describe "#respond_to?" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dot_hash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -35,6 +35,7 @@ extensions: []
|
|
35
35
|
extra_rdoc_files: []
|
36
36
|
files:
|
37
37
|
- .gitignore
|
38
|
+
- .travis.yml
|
38
39
|
- Gemfile
|
39
40
|
- LICENSE
|
40
41
|
- README.md
|
@@ -61,7 +62,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
62
|
version: '0'
|
62
63
|
segments:
|
63
64
|
- 0
|
64
|
-
hash: -
|
65
|
+
hash: -937726017345117898
|
65
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
67
|
none: false
|
67
68
|
requirements:
|
@@ -70,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
71
|
version: '0'
|
71
72
|
segments:
|
72
73
|
- 0
|
73
|
-
hash: -
|
74
|
+
hash: -937726017345117898
|
74
75
|
requirements: []
|
75
76
|
rubyforge_project:
|
76
77
|
rubygems_version: 1.8.24
|