triad 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -3
- data/Rakefile +1 -0
- data/lib/triad/version.rb +1 -1
- data/lib/triad.rb +18 -6
- data/test/triad_test.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5de1aa1907fddfc9cdb328084386536141ce5e09
|
4
|
+
data.tar.gz: 79b81e26aae062079861a4cce8890aac7597d10c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cb09666780c5019f2042069aedeedb3e61e1983184676f6ffd590d20deaea93b2ef3939f6b7bcdb54c15b07e2c1a9791c33e5abaaa823187bf79e55b405c5ab
|
7
|
+
data.tar.gz: 20c8e8809ae5a84ab6aa2e93da4d12e290fb0284d0be47e50748a4f6c8db47be226d8c76d872bfd36f362e2c5fac304a861326822c1cec0c6f95c84a85ae3dc6
|
data/README.md
CHANGED
@@ -21,15 +21,18 @@ map << [:admin, 'Admin', user]
|
|
21
21
|
|
22
22
|
map.keys('Admin') #=> [:admin]
|
23
23
|
map.values('Admin') #=> [user]
|
24
|
-
map.descriptors('Admin') #=> ['Admin']
|
24
|
+
map.descriptors('Admin') #=> ['Admin']
|
25
|
+
# or raise Triad::DescriptorNotPresent
|
25
26
|
|
26
27
|
map.descriptors(user) #=> ['Admin']
|
27
28
|
map.keys(user) #=> [:admin]
|
28
|
-
map.values(user) #=> [user]
|
29
|
+
map.values(user) #=> [user]
|
30
|
+
# or raise Triad::ValueNotPresent
|
29
31
|
|
30
32
|
map.values(:admin) #=> [user]
|
31
33
|
map.descriptors(:admin) #=> ['Admin']
|
32
|
-
map.keys(:admin) #=> [:admin]
|
34
|
+
map.keys(:admin) #=> [:admin]
|
35
|
+
# or raise Triad::KeyNotPresent
|
33
36
|
|
34
37
|
map.each do |key, descriptor, value|
|
35
38
|
#...
|
data/Rakefile
CHANGED
data/lib/triad/version.rb
CHANGED
data/lib/triad.rb
CHANGED
@@ -19,16 +19,28 @@ class Triad
|
|
19
19
|
attr_reader :storage
|
20
20
|
private :storage
|
21
21
|
|
22
|
-
def keys(arg)
|
23
|
-
|
22
|
+
def keys(arg=:__no_argument_given__)
|
23
|
+
if arg == :__no_argument_given__
|
24
|
+
storage.keys
|
25
|
+
else
|
26
|
+
with_interest(arg).map{|key, _, _| key }
|
27
|
+
end
|
24
28
|
end
|
25
29
|
|
26
|
-
def descriptors(arg)
|
27
|
-
|
30
|
+
def descriptors(arg=:__no_argument_given__)
|
31
|
+
if arg == :__no_argument_given__
|
32
|
+
storage.map{|_,(descriptor,_)| descriptor }
|
33
|
+
else
|
34
|
+
with_interest(arg).map{|_, descriptor, _| descriptor }
|
35
|
+
end
|
28
36
|
end
|
29
37
|
|
30
|
-
def values(arg)
|
31
|
-
|
38
|
+
def values(arg=:__no_argument_given__)
|
39
|
+
if arg == :__no_argument_given__
|
40
|
+
storage.map{|_,(_,value)| value }.uniq
|
41
|
+
else
|
42
|
+
with_interest(arg).map{|_, _, value| value }
|
43
|
+
end
|
32
44
|
end
|
33
45
|
|
34
46
|
def <<(array)
|
data/test/triad_test.rb
CHANGED
@@ -69,6 +69,11 @@ describe Triad, '#keys' do
|
|
69
69
|
assert_equal [:admin], triad.keys(:admin)
|
70
70
|
end
|
71
71
|
|
72
|
+
it 'returns all keys when given no argument' do
|
73
|
+
triad << [:other, 'Other', user]
|
74
|
+
assert_equal [:admin, :other], triad.keys
|
75
|
+
end
|
76
|
+
|
72
77
|
it 'errors when the given key is not found' do
|
73
78
|
assert_raises(Triad::KeyNotPresent){
|
74
79
|
triad.keys(:invalid_key)
|
@@ -108,6 +113,11 @@ describe Triad, '#descriptors' do
|
|
108
113
|
assert_equal ['Admin'], triad.descriptors('Admin')
|
109
114
|
end
|
110
115
|
|
116
|
+
it 'returns all descriptors when given no argument' do
|
117
|
+
triad << [:other, 'Other', user]
|
118
|
+
assert_equal ['Admin', 'Other'], triad.descriptors
|
119
|
+
end
|
120
|
+
|
111
121
|
it 'errors when the given descriptor is not found' do
|
112
122
|
assert_raises(Triad::DescriptorNotPresent){
|
113
123
|
triad.descriptors('Not Present')
|
@@ -143,6 +153,12 @@ describe Triad, '#values' do
|
|
143
153
|
assert_equal [user], triad.values('Admin')
|
144
154
|
end
|
145
155
|
|
156
|
+
it 'returns all values when given no argument' do
|
157
|
+
triad << [:other, 'Other', user]
|
158
|
+
assert_equal [user], triad.values
|
159
|
+
end
|
160
|
+
|
161
|
+
|
146
162
|
it 'errors when the given key is not found' do
|
147
163
|
assert_raises(Triad::KeyNotPresent){
|
148
164
|
triad.values(:invalid_key)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: triad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- '''Jim Gay'''
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|