collectable 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmU1ZGIxYTY3YmRkOGQ0ODkxZWYyYTM2NDI4NzE2YWY3NTA1YTY3Ng==
4
+ ZGQ4MDQxM2RjMmExNzllOWQ4Y2M1M2YxMDQ2NjMyYjlmYWE2OTVlZA==
5
5
  data.tar.gz: !binary |-
6
- ZWRiNTQ1NDVkMjA3ZmJiZGFkM2JkMTg5NDhkMTNhYThiMThlOTVjYg==
6
+ NzViZTNlNjlhNGM4ODc4NTI3MTc1ZjM2NmZmMjIxMTI0YzVjNDVlYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Yjk0NzUzYzg4Y2Q4M2FmYTgxMmUzMTdiYWMyMDQ0Yjk1MzYwY2I3MmNjODcx
10
- NDE5YmJmYWY1ZTNkZDU5YmQxNWI5ZGU5OGY1ZDY1YjdmMTVhYzUzZjI2Nzc1
11
- NGUzNjc5OWVhMjJmMTgyMDQ0MjI3OGI4YTEwM2IwZWJmYmFjNjg=
9
+ MTJiM2JjZDZiOGRjNjg5MzA1NjNiZTJjOThmM2JlOTA2ZGJlMjc3MDI3Y2I5
10
+ NTEwMDI4MDA3ZDAzOWFhZjVlOWZmMTg3NzdjN2NmZThkOGVhZWVhNjJjYThl
11
+ MjIwODI2NmNhY2ViZGE5N2EzM2ZlOWZkZThiNDllYjgxZTgwYmM=
12
12
  data.tar.gz: !binary |-
13
- MWNhODlmZGRjYjEzNmE5MmIwNzE1ZmRjYmIwY2Y5NDkwOTcxZTJkZTYxZDgx
14
- NTZhZGZhNWE3OTE0ODMwZmU0YjNlNTBjMDZhYTI3NGIzYmI1MTIwNTQ4ZGMy
15
- MGJjZmRhNWE0N2Y1YTZiMjNjYzcwNjlmMjBjYTBmMGE4NTc4ZDE=
13
+ NGY5YzdhZWFlOWI1ZWNlMmRkZjQ4NWU2YzgwMzIyZWQyODhkOTU3OTYyNmY2
14
+ NjA1NDE3ZTlkNWViMjJiY2IyMTFkN2I4ZDQ3MTg4Nzg4MGY1M2E5OTVhZWUx
15
+ ODMwNTNkNmI4MmRjZjA2M2UzOTU0MmZiY2Y3MDk4ZWEwNGQwNWM=
data/README.md CHANGED
@@ -20,19 +20,19 @@ gem 'collectable'
20
20
  ```
21
21
  ## Basic usage ##
22
22
 
23
- The short version is "include the module and define some traits." That's also
24
- the long version, as it were.
23
+ The short version is "include the module and define some characteristics."
24
+ That's also the long version, as it were.
25
25
 
26
26
  ```ruby
27
27
  class HairColor
28
28
  include Collectable
29
29
 
30
- trait :blonde
31
- trait :brown
32
- trait :red
33
- trait :black
34
- trait :purple
35
- trait :tie_dye
30
+ characteristic :blonde
31
+ characteristic :brown
32
+ characteristic :red
33
+ characteristic :black
34
+ characteristic :purple
35
+ characteristic :tie_dye
36
36
  end
37
37
  ```
38
38
 
@@ -55,6 +55,7 @@ Do you use git-flow? I sure do. Please base anything you do off of
55
55
 
56
56
  ## History ##
57
57
 
58
+ * 0.0.4 - Renamed "traits" to "characteristics"
58
59
  * 0.0.3 - .value and .name actually added
59
60
  * 0.0.2 - Renamed collected_item#val to collected_item#value
60
61
  * 0.0.1 - Public release
data/lib/collectable.rb CHANGED
@@ -14,17 +14,17 @@ module Collectable
14
14
  :name
15
15
  end
16
16
 
17
- def traits
18
- @traits ||= []
17
+ def characteristics
18
+ @characteristics ||= []
19
19
  end
20
20
 
21
- def trait(trait_name)
22
- traits.push(trait_name.to_s.downcase)
23
- traits.uniq!
21
+ def characteristic(characteristic_name)
22
+ characteristics.push(characteristic_name.to_s.downcase)
23
+ characteristics.uniq!
24
24
  end
25
25
 
26
26
  def collected(sort_field = :name)
27
- traits.each_with_index.map {|name, index|
27
+ characteristics.each_with_index.map {|name, index|
28
28
  OpenStruct.new(name: name, value: index)
29
29
  }.sort {|a,b|
30
30
  a.send(sort_field) <=> b.send(sort_field)
@@ -1,3 +1,3 @@
1
1
  module Collectable
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -5,11 +5,11 @@ class Dummy
5
5
  include Collectable
6
6
  end
7
7
 
8
- class TraitDummy
8
+ class CharacteristicDummy
9
9
  include Collectable
10
10
  end
11
11
 
12
- class TraitsDummy
12
+ class CharacteristicsDummy
13
13
  include Collectable
14
14
  end
15
15
 
@@ -23,23 +23,23 @@ describe Collectable do
23
23
  context 'when included' do
24
24
  let(:dummy) {Dummy}
25
25
 
26
- it 'knows how to define traits' do
27
- expect(dummy).to respond_to(:trait)
26
+ it 'knows how to define characteristics' do
27
+ expect(dummy).to respond_to(:characteristic)
28
28
  end
29
29
 
30
30
  it 'can report its tratis' do
31
- expect(dummy).to respond_to(:traits)
31
+ expect(dummy).to respond_to(:characteristics)
32
32
  end
33
33
 
34
- it 'knows how to collect the traits' do
34
+ it 'knows how to collect the characteristics' do
35
35
  expect(dummy).to respond_to(:collected)
36
36
  end
37
37
 
38
- it 'knows what method gets a value for a collected trait' do
38
+ it 'knows what method gets a value for a collected characteristic' do
39
39
  expect(dummy).to respond_to(:value)
40
40
  end
41
41
 
42
- it 'knows what method gets a name for a collected trait' do
42
+ it 'knows what method gets a name for a collected characteristic' do
43
43
  expect(dummy).to respond_to(:name)
44
44
  end
45
45
  end
@@ -56,42 +56,45 @@ describe Collectable do
56
56
  end
57
57
  end
58
58
 
59
- describe '.trait' do
60
- let(:trait_dummy) {
61
- TraitDummy
59
+ describe '.characteristic' do
60
+ let(:characteristic_dummy) {
61
+ CharacteristicDummy
62
62
  }
63
63
 
64
64
  it 'can take a symbol' do
65
- expect {trait_dummy.trait :Blah}.not_to raise_error
65
+ expect {characteristic_dummy.characteristic :Blah}.not_to raise_error
66
66
  end
67
67
 
68
68
  it 'can take a string' do
69
- expect {trait_dummy.trait 'Trait 2'}.not_to raise_error
69
+ expect {characteristic_dummy.characteristic 'characteristic 2'}.
70
+ not_to raise_error
70
71
  end
71
72
 
72
- it 'adds a trait to the collectable traits' do
73
- new_trait = :New_Trait
74
- trait_dummy.trait new_trait
75
- expect(trait_dummy.traits).to include(new_trait.to_s.downcase)
73
+ it 'adds a characteristic to the collectable characteristics' do
74
+ new_characteristic = :New_Characteristic
75
+ characteristic_dummy.characteristic new_characteristic
76
+ expect(characteristic_dummy.characteristics).
77
+ to include(new_characteristic.to_s.downcase)
76
78
  end
77
79
  end
78
80
 
79
- describe '.traits' do
80
- let(:traits_dummy) {
81
- TraitsDummy
81
+ describe '.characteristics' do
82
+ let(:characteristics_dummy) {
83
+ CharacteristicsDummy
82
84
  }
83
85
 
84
- let(:new_trait) {:new_trait}
86
+ let(:new_characteristic) {:new_characteristic}
85
87
 
86
88
  it 'is an array' do
87
- expect(traits_dummy.traits).to be_a(Array)
89
+ expect(characteristics_dummy.characteristics).to be_a(Array)
88
90
  end
89
91
 
90
- it 'contains the traits defined by the class' do
91
- expect(traits_dummy.traits).to be_empty
92
+ it 'contains the characteristics defined by the class' do
93
+ expect(characteristics_dummy.characteristics).to be_empty
92
94
 
93
- traits_dummy.trait new_trait
94
- expect(traits_dummy.traits).to include(new_trait.to_s.downcase)
95
+ characteristics_dummy.characteristic new_characteristic
96
+ expect(characteristics_dummy.characteristics).
97
+ to include(new_characteristic.to_s.downcase)
95
98
  end
96
99
  end
97
100
 
@@ -104,12 +107,12 @@ describe Collectable do
104
107
  expect(collected_dummy.collected).to be_a(Array)
105
108
  end
106
109
 
107
- it 'contains OpenStruct representations of the known traits' do
108
- collected_dummy.trait :trait_1
109
- collected_dummy.trait :trait_2
110
+ it 'contains OpenStruct representations of the known characteristics' do
111
+ collected_dummy.characteristic :characteristic_1
112
+ collected_dummy.characteristic :characteristic_2
110
113
 
111
114
  expect(collected_dummy.collected.map(&:name)).
112
- to eql(collected_dummy.traits.sort)
115
+ to eql(collected_dummy.characteristics.sort)
113
116
  end
114
117
  end
115
118
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collectable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dennis Walters