value 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README +12 -2
- data/Rakefile +1 -5
- data/lib/value-1.0/version.rb +17 -4
- metadata +78 -52
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97cc4677ebc164667860fc336c82abdf97070316
|
4
|
+
data.tar.gz: 2665017ee58f54e594c9c4c6553258a9facf2b37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 514aec6acb5b175a9ad1d4339d0bb57e4cd2e3b9b298deff3352842c2811f8f90aae1e7de35f978074429aa69c3ccc3a7966df3bd57e093b7bbc0bc830a83c83
|
7
|
+
data.tar.gz: 69f82e7a8c488697c0118355f7022c854bf5518047c6656f187cad8c137a14ca63f19b2bcf62a725f11478ce21a75194aff5d60fb3240b2fe2c28cf30eccf509
|
data/README
CHANGED
@@ -136,7 +136,7 @@
|
|
136
136
|
Check out the {full API documentation}¹ for a more explicit description,
|
137
137
|
should you need it or should you want to extend it.
|
138
138
|
|
139
|
-
¹ http://disu.se/software/value/api/
|
139
|
+
¹ See http://disu.se/software/value/api/
|
140
140
|
|
141
141
|
§ Financing
|
142
142
|
|
@@ -151,7 +151,7 @@
|
|
151
151
|
donation to now@disu.se¹. Thanks! Your support won’t go unnoticed!
|
152
152
|
|
153
153
|
¹ Send a donation:
|
154
|
-
https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=now%40disu%2ese&item_name=
|
154
|
+
https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=now%40disu%2ese&item_name=Value
|
155
155
|
|
156
156
|
§ Reporting Bugs
|
157
157
|
|
@@ -163,3 +163,13 @@
|
|
163
163
|
|
164
164
|
Nikolai Weibull wrote the code, the tests, the manual pages, and this
|
165
165
|
README.
|
166
|
+
|
167
|
+
§ Licensing
|
168
|
+
|
169
|
+
Value is free software: you may redistribute it and/or modify it under the
|
170
|
+
terms of the {GNU Lesser General Public License, version 3}¹ or later², as
|
171
|
+
published by the {Free Software Foundation}³.
|
172
|
+
|
173
|
+
¹ See http://disu.se/licenses/lgpl-3.0/
|
174
|
+
² See http://gnu.org/licenses/
|
175
|
+
³ See http://fsf.org/
|
data/Rakefile
CHANGED
@@ -4,11 +4,7 @@ require 'inventory-rake-1.0'
|
|
4
4
|
|
5
5
|
load File.expand_path('../lib/value-1.0/version.rb', __FILE__)
|
6
6
|
|
7
|
-
Inventory::Rake::Tasks.define Value::Version
|
8
|
-
s.author = 'Nikolai Weibull'
|
9
|
-
s.email = 'now@bitwi.se'
|
10
|
-
s.homepage = 'https://github.com/now/value'
|
11
|
-
}
|
7
|
+
Inventory::Rake::Tasks.define Value::Version
|
12
8
|
|
13
9
|
Inventory::Rake::Tasks.unless_installing_dependencies do
|
14
10
|
require 'lookout-rake-3.0'
|
data/lib/value-1.0/version.rb
CHANGED
@@ -3,14 +3,27 @@
|
|
3
3
|
require 'inventory-1.0'
|
4
4
|
|
5
5
|
module Value
|
6
|
-
Version = Inventory.new(1, 1,
|
6
|
+
Version = Inventory.new(1, 1, 3){
|
7
|
+
authors{
|
8
|
+
author 'Nikolai Weibull', 'now@disu.se'
|
9
|
+
}
|
10
|
+
|
11
|
+
homepage 'http://disu.se/software/value'
|
12
|
+
|
13
|
+
licenses{
|
14
|
+
license 'LGPLv3+',
|
15
|
+
'GNU Lesser General Public License, version 3 or later',
|
16
|
+
'http://www.gnu.org/licenses/'
|
17
|
+
}
|
18
|
+
|
7
19
|
def dependencies
|
8
20
|
super + Inventory::Dependencies.new{
|
9
|
-
development 'inventory-rake', 1,
|
21
|
+
development 'inventory-rake', 1, 6, 0
|
22
|
+
development 'inventory-rake-tasks-yard', 1, 4, 0
|
10
23
|
development 'lookout', 3, 0, 0
|
11
|
-
development 'lookout-rake', 3,
|
24
|
+
development 'lookout-rake', 3, 1, 0
|
12
25
|
development 'yard', 0, 8, 0
|
13
|
-
development 'yard-heuristics', 1,
|
26
|
+
development 'yard-heuristics', 1, 2, 0
|
14
27
|
}
|
15
28
|
end
|
16
29
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: value
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikolai Weibull
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04
|
11
|
+
date: 2013-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inventory
|
@@ -16,16 +16,30 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: inventory-rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: inventory-rake-tasks-yard
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - ~>
|
@@ -58,14 +72,14 @@ dependencies:
|
|
58
72
|
requirements:
|
59
73
|
- - ~>
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
75
|
+
version: '3.1'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - ~>
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
82
|
+
version: '3.1'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: yard
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,65 +100,65 @@ dependencies:
|
|
86
100
|
requirements:
|
87
101
|
- - ~>
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: '1.
|
103
|
+
version: '1.2'
|
90
104
|
type: :development
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - ~>
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: '1.
|
110
|
+
version: '1.2'
|
97
111
|
description: |2
|
98
112
|
Value
|
99
113
|
|
100
114
|
Value is a library for defining immutable value objects in Ruby. A value
|
101
115
|
object is an object whose equality to other objects is determined by its
|
102
116
|
value, not its identity, think dates and amounts of money. A value object
|
103
|
-
should also be immutable, as you don
|
104
|
-
change but the current date to change from
|
105
|
-
That is, you don
|
117
|
+
should also be immutable, as you donΓÇÖt want the date ΓÇ£2013-04-22ΓÇ¥ itself to
|
118
|
+
change but the current date to change from ΓÇ£2013-04-22ΓÇ¥ to ΓÇ£2013-04-23ΓÇ¥.
|
119
|
+
That is, you donΓÇÖt want entries in a calendar for 2013-04-22 to move to
|
106
120
|
2013-04-23 simply because the current date changes from 2013-04-22 to
|
107
121
|
2013-04-23.
|
108
122
|
|
109
123
|
A value object consists of one or more attributes stored in instance
|
110
|
-
variables. Value sets up an #initialize method for you that let
|
111
|
-
these attributes, as, value objects being immutable, this
|
112
|
-
chance to do so. Value also adds equality checks
|
113
|
-
are themselves equivalent), a
|
124
|
+
variables. Value sets up an #initialize method for you that letΓÇÖs you set
|
125
|
+
these attributes, as, value objects being immutable, thisΓÇÖll be your only
|
126
|
+
chance to do so. Value also adds equality checks ‹#==› and ‹#eql?› (which
|
127
|
+
are themselves equivalent), a ‹#hash› method, a nice ‹#inspect› method, and a
|
114
128
|
protected attribute reader for each attribute. You may of course add any
|
115
129
|
additional methods that your value object will benefit from.
|
116
130
|
|
117
|
-
That
|
131
|
+
ThatΓÇÖs basically all thereΓÇÖs too it. LetΓÇÖs now look at using the Value
|
118
132
|
library.
|
119
133
|
|
120
|
-
|
134
|
+
§ Usage
|
121
135
|
|
122
|
-
You create value object class by invoking
|
123
|
-
(module) you wish to make into a value object class. Let
|
136
|
+
You create value object class by invoking ‹#Value› inside the class
|
137
|
+
(module) you wish to make into a value object class. LetΓÇÖs create a class
|
124
138
|
that represent points on a plane:
|
125
139
|
|
126
140
|
class Point
|
127
141
|
Value :x, :y
|
128
142
|
end
|
129
143
|
|
130
|
-
A
|
131
|
-
(the coordinates). Just from invoking
|
132
|
-
a constructor that takes two arguments to set instance variables
|
133
|
-
|
134
|
-
method, a nice
|
135
|
-
and
|
144
|
+
A ‹Point› is thus a value object consisting of two sub-values ‹x› and ‹y›
|
145
|
+
(the coordinates). Just from invoking ‹#Value›, a ‹Point› object will have
|
146
|
+
a constructor that takes two arguments to set instance variables ‹@x› and
|
147
|
+
‹@y›, equality checks ‹#==› and ‹#eql?› (which are the same), a ‹#hash›
|
148
|
+
method, a nice ‹#inspect› method, and two protected attribute readers ‹#x›
|
149
|
+
and ‹#y›. We can thus already creat ‹Point›s:
|
136
150
|
|
137
151
|
origo = Point.new(0, 0)
|
138
152
|
|
139
153
|
The default of making the attribute readers protected is often good
|
140
|
-
practice, but for a
|
154
|
+
practice, but for a ‹Point› it probably makes sense to be able to access
|
141
155
|
its coordinates:
|
142
156
|
|
143
157
|
class Point
|
144
158
|
public(*attributes)
|
145
159
|
end
|
146
160
|
|
147
|
-
This
|
161
|
+
This’ll make all attributes of ‹Point› public. You can of course choose to
|
148
162
|
only make certain attributes public:
|
149
163
|
|
150
164
|
class Point
|
@@ -152,7 +166,7 @@ description: |2
|
|
152
166
|
end
|
153
167
|
|
154
168
|
Note that this public is standard Ruby functionality. Adding a method to
|
155
|
-
|
169
|
+
‹Point› is of course also possible and very much Rubyish:
|
156
170
|
|
157
171
|
class Point
|
158
172
|
def distance(other)
|
@@ -168,8 +182,8 @@ description: |2
|
|
168
182
|
Value :amount, [:currency, :USD]
|
169
183
|
end
|
170
184
|
|
171
|
-
Here, the
|
172
|
-
|
185
|
+
Here, the ‹currency› attribute will default to ‹:USD›. You can create
|
186
|
+
‹Money› via
|
173
187
|
|
174
188
|
dollars = Money.new(2)
|
175
189
|
|
@@ -200,42 +214,42 @@ description: |2
|
|
200
214
|
|
201
215
|
Block attributes are optional.
|
202
216
|
|
203
|
-
Comparison beyond
|
204
|
-
to
|
217
|
+
Comparison beyond ‹#==› is possible by specifingy the ‹:comparable› option
|
218
|
+
to ‹#Value›, listing one or more attributes that should be included in the
|
205
219
|
comparison:
|
206
220
|
|
207
221
|
class Vector
|
208
222
|
Value :a, :b, :comparable => :a
|
209
223
|
end
|
210
224
|
|
211
|
-
Note that equality (
|
212
|
-
attributes, regardless of arguments to
|
225
|
+
Note that equality (‹#==› and ‹#eql?›) is always defined based on all
|
226
|
+
attributes, regardless of arguments to ‹:comparable›.
|
213
227
|
|
214
|
-
Here we say that comparisons between
|
215
|
-
values of the
|
228
|
+
Here we say that comparisons between ‹Vector›s should be made between the
|
229
|
+
values of the ‹a› attribute only. We can also make comparisons between all
|
216
230
|
attributes of a value object:
|
217
231
|
|
218
232
|
class Vector
|
219
233
|
Value :a, :b, :comparable => true
|
220
234
|
end
|
221
235
|
|
222
|
-
To sum things up, let
|
236
|
+
To sum things up, let’s use all possible arguments to ‹#Value› at once:
|
223
237
|
|
224
238
|
class Method
|
225
239
|
Value :file, :line, [:name, 'unnamed'], :'*args', :'&block',
|
226
240
|
:comparable => [:file, :line]
|
227
241
|
end
|
228
242
|
|
229
|
-
A
|
243
|
+
A ‹Method› consists of file and line information, a possible name, some
|
230
244
|
arguments, possibly a block, and is comparable on the file and line on
|
231
245
|
which they appear.
|
232
246
|
|
233
|
-
Check out the {full API documentation}
|
247
|
+
Check out the {full API documentation}┬╣ for a more explicit description,
|
234
248
|
should you need it or should you want to extend it.
|
235
249
|
|
236
|
-
|
250
|
+
┬╣ See http://disu.se/software/value/api/
|
237
251
|
|
238
|
-
|
252
|
+
§ Financing
|
239
253
|
|
240
254
|
Currently, most of my time is spent at my day job and in my rather busy
|
241
255
|
private life. Please motivate me to spend time on this piece of software
|
@@ -245,22 +259,33 @@ description: |2
|
|
245
259
|
to have other people give me the things that I need to continue living
|
246
260
|
under the rules of said society. So, if you feel that this piece of
|
247
261
|
software has helped you out enough to warrant a reward, please PayPal a
|
248
|
-
donation to now@disu.se
|
262
|
+
donation to now@disu.se┬╣. Thanks! Your support wonΓÇÖt go unnoticed!
|
249
263
|
|
250
|
-
|
251
|
-
https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=now%40disu%2ese&item_name=
|
264
|
+
┬╣ Send a donation:
|
265
|
+
https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=now%40disu%2ese&item_name=Value
|
252
266
|
|
253
|
-
|
267
|
+
§ Reporting Bugs
|
254
268
|
|
255
|
-
Please report any bugs that you encounter to the {issue tracker}
|
269
|
+
Please report any bugs that you encounter to the {issue tracker}┬╣.
|
256
270
|
|
257
|
-
|
271
|
+
┬╣ See https://github.com/now/value/issues
|
258
272
|
|
259
|
-
|
273
|
+
§ Authors
|
260
274
|
|
261
275
|
Nikolai Weibull wrote the code, the tests, the manual pages, and this
|
262
276
|
README.
|
263
|
-
|
277
|
+
|
278
|
+
§ Licensing
|
279
|
+
|
280
|
+
Value is free software: you may redistribute it and/or modify it under the
|
281
|
+
terms of the {GNU Lesser General Public License, version 3}┬╣ or later┬▓, as
|
282
|
+
published by the {Free Software Foundation}┬│.
|
283
|
+
|
284
|
+
┬╣ See http://disu.se/licenses/lgpl-3.0/
|
285
|
+
┬▓ See http://gnu.org/licenses/
|
286
|
+
┬│ See http://fsf.org/
|
287
|
+
email:
|
288
|
+
- now@disu.se
|
264
289
|
executables: []
|
265
290
|
extensions: []
|
266
291
|
extra_rdoc_files: []
|
@@ -275,8 +300,9 @@ files:
|
|
275
300
|
- test/unit/value-1.0/version.rb
|
276
301
|
- README
|
277
302
|
- Rakefile
|
278
|
-
homepage:
|
279
|
-
licenses:
|
303
|
+
homepage: http://disu.se/software/value
|
304
|
+
licenses:
|
305
|
+
- LGPLv3+
|
280
306
|
metadata: {}
|
281
307
|
post_install_message:
|
282
308
|
rdoc_options: []
|
@@ -294,7 +320,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
294
320
|
version: '0'
|
295
321
|
requirements: []
|
296
322
|
rubyforge_project:
|
297
|
-
rubygems_version: 2.0.
|
323
|
+
rubygems_version: 2.0.2
|
298
324
|
signing_key:
|
299
325
|
specification_version: 4
|
300
326
|
summary: Value is a library for defining immutable value objects in Ruby.
|