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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b102ba1a28f4a9bf80e239083ec5cfa6ecfa02cd
4
- data.tar.gz: a2fbdcae55dae2126fdc315060bc2f9109b7a2aa
3
+ metadata.gz: 5de1aa1907fddfc9cdb328084386536141ce5e09
4
+ data.tar.gz: 79b81e26aae062079861a4cce8890aac7597d10c
5
5
  SHA512:
6
- metadata.gz: 42e73cadff398ec9c7c751be0f4492990b0b2f7ac122694d750684ded08511f1f60e8a3addad520a61d2bf18e10a1467f23c4b3a13d88d9c037cac0610b278d5
7
- data.tar.gz: eef77531a5080e84015c3c2664dba5f3222107a9d7c2b4139dcc21814deec4117827657706b8f968c42952fe69df33bdf1e3f45057f9e6a679b61c1c4e184a81
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'] or raise DescriptorNotPresent
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] or raise ValueNotPresent
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] or raise KeyNotPresent
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
@@ -5,6 +5,7 @@ require 'rake/testtask'
5
5
  Rake::TestTask.new do |t|
6
6
  t.libs << 'test'
7
7
  t.test_files = FileList['test/*_test.rb']
8
+ t.ruby_opts = ["-w"]
8
9
  t.verbose = true
9
10
  end
10
11
 
data/lib/triad/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Triad
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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
- with_interest(arg).map{|key, _, _| key }
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
- with_interest(arg).map{|_, descriptor, _| descriptor }
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
- with_interest(arg).map{|_, _, value| value }
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.0
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-06-19 00:00:00.000000000 Z
11
+ date: 2013-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler