ethos 0.2.0.beta8 → 0.2.0.beta9
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 +4 -4
- data/README.md +1 -0
- data/lib/ethos/collection.rb +14 -0
- data/lib/ethos/entity.rb +5 -1
- data/lib/ethos/version.rb +1 -1
- data/spec/ethos/entity.rb +52 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c2f6a1140e86c69125e19a29e1311e8f04e1fdc
|
4
|
+
data.tar.gz: 007a0305bcc6e6fc0d12dd2641d963aed721982c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf2dc5f9078df0a69884104d8a6594a65b91ed65805bc3168979768d991ba1930193f31324bbe5842f57a74de7dbfe938c06234ab6f02e102bb3267352551e30
|
7
|
+
data.tar.gz: 0d63dd3628d6fd94d2c42ecfd9863db4b37ff2356cbe42bd9c135df293182ef571e4b3d2722250a853ad723bf3ecc76991b5265908b138d5687448a0260cd0c5
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[](https://travis-ci.org/Erol/ethos)
|
1
2
|
[](https://codeclimate.com/github/Erol/ethos)
|
2
3
|
[](https://codeclimate.com/github/Erol/ethos)
|
3
4
|
|
data/lib/ethos/collection.rb
CHANGED
@@ -28,6 +28,20 @@ module Ethos
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
def map
|
32
|
+
array = []
|
33
|
+
|
34
|
+
self.each do |member|
|
35
|
+
array << yield(member)
|
36
|
+
end
|
37
|
+
|
38
|
+
array
|
39
|
+
end
|
40
|
+
|
41
|
+
def join(separator = '')
|
42
|
+
self.map { |member| String member }.join separator
|
43
|
+
end
|
44
|
+
|
31
45
|
def ==(other)
|
32
46
|
return false unless other.is_a? self.class
|
33
47
|
return false unless self.size == other.size
|
data/lib/ethos/entity.rb
CHANGED
@@ -36,11 +36,15 @@ module Ethos
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def initialize(values = {})
|
39
|
-
|
39
|
+
self.attributes = values
|
40
40
|
|
41
41
|
super()
|
42
42
|
end
|
43
43
|
|
44
|
+
def attributes=(values)
|
45
|
+
@_attributes = Ethos::Attributes.new self.class.schema, values: values
|
46
|
+
end
|
47
|
+
|
44
48
|
def attributes
|
45
49
|
@_attributes
|
46
50
|
end
|
data/lib/ethos/version.rb
CHANGED
data/spec/ethos/entity.rb
CHANGED
@@ -26,6 +26,13 @@ scope do
|
|
26
26
|
|
27
27
|
asserts(entity.value) == 1
|
28
28
|
end
|
29
|
+
|
30
|
+
spec do
|
31
|
+
entity = Entity.new
|
32
|
+
entity.attributes = {value: 1}
|
33
|
+
|
34
|
+
asserts(entity.value) == 1
|
35
|
+
end
|
29
36
|
end
|
30
37
|
|
31
38
|
scope do
|
@@ -48,6 +55,20 @@ scope do
|
|
48
55
|
|
49
56
|
asserts(entity.value) == 2
|
50
57
|
end
|
58
|
+
|
59
|
+
spec do
|
60
|
+
entity = Entity.new
|
61
|
+
entity.attributes = {value: 2}
|
62
|
+
|
63
|
+
asserts(entity.value) == 2
|
64
|
+
end
|
65
|
+
|
66
|
+
spec do
|
67
|
+
entity = Entity.new
|
68
|
+
entity.attributes = {}
|
69
|
+
|
70
|
+
asserts(entity.value) == 1
|
71
|
+
end
|
51
72
|
end
|
52
73
|
|
53
74
|
scope do
|
@@ -126,7 +147,9 @@ scope do
|
|
126
147
|
end
|
127
148
|
|
128
149
|
spec do
|
129
|
-
|
150
|
+
parent = Entity.new name: 'Parent'
|
151
|
+
|
152
|
+
asserts(entity.parent) == parent
|
130
153
|
end
|
131
154
|
end
|
132
155
|
end
|
@@ -157,15 +180,15 @@ scope do
|
|
157
180
|
end
|
158
181
|
|
159
182
|
spec do
|
160
|
-
|
183
|
+
child = Entity.new name: 'Child 1'
|
161
184
|
|
162
|
-
asserts(entity.children[0]) ==
|
185
|
+
asserts(entity.children[0]) == child
|
163
186
|
end
|
164
187
|
|
165
188
|
spec do
|
166
|
-
|
189
|
+
child = Entity.new name: 'Child 2'
|
167
190
|
|
168
|
-
asserts(entity.children[1]) ==
|
191
|
+
asserts(entity.children[1]) == child
|
169
192
|
end
|
170
193
|
|
171
194
|
spec do
|
@@ -177,6 +200,30 @@ scope do
|
|
177
200
|
|
178
201
|
asserts(names) == ['Child 1', 'Child 2']
|
179
202
|
end
|
203
|
+
|
204
|
+
spec do
|
205
|
+
names = entity.children.map do |child| child.name end
|
206
|
+
|
207
|
+
asserts(names) == ['Child 1', 'Child 2']
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
scope do
|
213
|
+
setup do
|
214
|
+
class Entity
|
215
|
+
prepend Ethos::Entity
|
216
|
+
|
217
|
+
collection :tags, String
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
define entity: -> { Entity.new tags: %w[lorem ipsum dolor] }
|
222
|
+
|
223
|
+
spec do
|
224
|
+
tags = entity.tags.join(",")
|
225
|
+
|
226
|
+
asserts(tags) == 'lorem,ipsum,dolor'
|
180
227
|
end
|
181
228
|
end
|
182
229
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ethos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0.
|
4
|
+
version: 0.2.0.beta9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erol Fornoles
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
112
|
version: 1.3.1
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
|
-
rubygems_version: 2.4.
|
115
|
+
rubygems_version: 2.4.6
|
116
116
|
signing_key:
|
117
117
|
specification_version: 4
|
118
118
|
summary: Lightweight entity library for Ruby
|