ethos 0.2.0.beta8 → 0.2.0.beta9

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: 21a639ff006e2a991e8510d10824323f5fb9bd5b
4
- data.tar.gz: 8a0ae3f45e616db8f6999b807dd0a771a11b5bdb
3
+ metadata.gz: 6c2f6a1140e86c69125e19a29e1311e8f04e1fdc
4
+ data.tar.gz: 007a0305bcc6e6fc0d12dd2641d963aed721982c
5
5
  SHA512:
6
- metadata.gz: 51cb2d833989754a23dd37c5c8e6d207d653e87ea53777a7b48fa5834632c8d313ccf7dd2a4a5f98cddf9a69d3506ac2c997d7c48dac830e360839079ccc8bb5
7
- data.tar.gz: 982e1e65dca7041cb4723ea4f542e906d4d34111b2c6a49d6798b0056dd5fda081dcb6e12557428096f5777584c42f3fa9b6a63d5a9b8abb4a7f9e18e3b39a51
6
+ metadata.gz: cf2dc5f9078df0a69884104d8a6594a65b91ed65805bc3168979768d991ba1930193f31324bbe5842f57a74de7dbfe938c06234ab6f02e102bb3267352551e30
7
+ data.tar.gz: 0d63dd3628d6fd94d2c42ecfd9863db4b37ff2356cbe42bd9c135df293182ef571e4b3d2722250a853ad723bf3ecc76991b5265908b138d5687448a0260cd0c5
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ [![Build Status](https://travis-ci.org/Erol/ethos.svg?branch=master)](https://travis-ci.org/Erol/ethos)
1
2
  [![Code Climate Score](http://img.shields.io/codeclimate/github/Erol/ethos.svg?style=flat)](https://codeclimate.com/github/Erol/ethos)
2
3
  [![Test Coverage](https://codeclimate.com/github/Erol/ethos/badges/coverage.svg)](https://codeclimate.com/github/Erol/ethos)
3
4
 
@@ -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
- @_attributes = Ethos::Attributes.new self.class.schema, values: values
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
@@ -1,3 +1,3 @@
1
1
  module Ethos
2
- VERSION = '0.2.0.beta8'
2
+ VERSION = '0.2.0.beta9'
3
3
  end
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
- asserts(entity.parent.name) == 'Parent'
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
- expected = Entity.new name: 'Child 1'
183
+ child = Entity.new name: 'Child 1'
161
184
 
162
- asserts(entity.children[0]) == expected
185
+ asserts(entity.children[0]) == child
163
186
  end
164
187
 
165
188
  spec do
166
- expected = Entity.new name: 'Child 2'
189
+ child = Entity.new name: 'Child 2'
167
190
 
168
- asserts(entity.children[1]) == expected
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.beta8
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-03-20 00:00:00.000000000 Z
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.5
115
+ rubygems_version: 2.4.6
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: Lightweight entity library for Ruby