striuct 0.3.3 → 0.3.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.
Files changed (88) hide show
  1. data/.gitignore +35 -34
  2. data/.travis.yml +6 -6
  3. data/Gemfile +12 -12
  4. data/History.rdoc +279 -273
  5. data/LICENSE +21 -21
  6. data/Manifest.txt +91 -90
  7. data/README.ja.old.rdoc +297 -297
  8. data/README.md +128 -128
  9. data/Rakefile +11 -11
  10. data/benchmark/basics.rb +56 -56
  11. data/example/README.rb +44 -44
  12. data/example/example.old.rdoc +187 -187
  13. data/example/example1.rb +233 -233
  14. data/example/example2.rb +22 -22
  15. data/example/see_trace.rb +32 -32
  16. data/lib/striuct/classmethods/README.md +5 -5
  17. data/lib/striuct/classmethods/adjustment.rb +32 -32
  18. data/lib/striuct/classmethods/constructor.rb +63 -63
  19. data/lib/striuct/classmethods/default.rb +27 -27
  20. data/lib/striuct/classmethods/enum.rb +48 -48
  21. data/lib/striuct/classmethods/inner.rb +91 -91
  22. data/lib/striuct/classmethods/length.rb +14 -14
  23. data/lib/striuct/classmethods/macro.rb +144 -144
  24. data/lib/striuct/classmethods/named.rb +113 -113
  25. data/lib/striuct/classmethods/object.rb +54 -54
  26. data/lib/striuct/classmethods/prevent_conflicts.rb +89 -89
  27. data/lib/striuct/classmethods/requiremnets.rb +11 -11
  28. data/lib/striuct/classmethods/to_struct.rb +23 -25
  29. data/lib/striuct/classmethods/validation.rb +55 -55
  30. data/lib/striuct/classmethods.rb +1 -1
  31. data/lib/striuct/instancemethods/README.md +5 -5
  32. data/lib/striuct/instancemethods/assign.rb +30 -30
  33. data/lib/striuct/instancemethods/cast.rb +34 -34
  34. data/lib/striuct/instancemethods/compare.rb +30 -30
  35. data/lib/striuct/instancemethods/default.rb +13 -13
  36. data/lib/striuct/instancemethods/delegate_class_methods.rb +28 -28
  37. data/lib/striuct/instancemethods/enum.rb +103 -103
  38. data/lib/striuct/instancemethods/hashy.rb +121 -121
  39. data/lib/striuct/instancemethods/inner.rb +60 -60
  40. data/lib/striuct/instancemethods/keyvalidatable.rb +14 -14
  41. data/lib/striuct/instancemethods/lock.rb +61 -61
  42. data/lib/striuct/instancemethods/object.rb +52 -52
  43. data/lib/striuct/instancemethods/requirements.rb +14 -14
  44. data/lib/striuct/instancemethods/safety.rb +11 -11
  45. data/lib/striuct/instancemethods/subscript.rb +55 -55
  46. data/lib/striuct/instancemethods/validation.rb +29 -25
  47. data/lib/striuct/instancemethods/values.rb +57 -57
  48. data/lib/striuct/instancemethods.rb +1 -1
  49. data/lib/striuct/requirements.rb +5 -5
  50. data/lib/striuct/singleton_class.rb +66 -66
  51. data/lib/striuct/specificcontainer.rb +19 -19
  52. data/lib/striuct/structs.rb +7 -7
  53. data/lib/striuct/version.rb +5 -5
  54. data/lib/striuct.rb +13 -13
  55. data/striuct.gemspec +24 -24
  56. data/test/helper.rb +5 -5
  57. data/test/test_striuct-singleton_class-define.rb +19 -19
  58. data/test/test_striuct-subclass-class-cloning.rb +20 -20
  59. data/test/test_striuct-subclass-class-close.rb +36 -36
  60. data/test/test_striuct-subclass-class-constructor.rb +82 -82
  61. data/test/test_striuct-subclass-class-freeze.rb +36 -36
  62. data/test/test_striuct-subclass-class-inheritable.rb +57 -57
  63. data/test/test_striuct-subclass-class-macro.rb +13 -13
  64. data/test/test_striuct-subclass-class-safety_naming.rb +72 -72
  65. data/test/test_striuct-subclass-class-validation.rb +26 -26
  66. data/test/test_striuct-subclass-feature-alias_member.rb +53 -53
  67. data/test/test_striuct-subclass-feature-to_struct.rb +61 -25
  68. data/test/test_striuct-subclass-feature-validation_util.rb +57 -0
  69. data/test/test_striuct-subclass-instance-accessor.rb +137 -137
  70. data/test/test_striuct-subclass-instance-adjuster.rb +94 -94
  71. data/test/test_striuct-subclass-instance-assign.rb +30 -30
  72. data/test/test_striuct-subclass-instance-basic.rb +32 -32
  73. data/test/test_striuct-subclass-instance-cloning.rb +22 -22
  74. data/test/test_striuct-subclass-instance-compare.rb +51 -51
  75. data/test/test_striuct-subclass-instance-default_value.rb +128 -128
  76. data/test/test_striuct-subclass-instance-enum.rb +92 -92
  77. data/test/test_striuct-subclass-instance-freeze.rb +19 -19
  78. data/test/test_striuct-subclass-instance-hashlike.rb +153 -153
  79. data/test/test_striuct-subclass-instance-keyvalidatable.rb +24 -24
  80. data/test/test_striuct-subclass-instance-lock.rb +39 -39
  81. data/test/test_striuct-subclass-instance-to_s_family.rb +25 -25
  82. data/test/test_striuct-subclass-instance-validation_functional_condition.rb +50 -50
  83. data/test/test_striuct-subclass-instance-validation_inference.rb +50 -50
  84. data/test/test_striuct-subclass-instance-validation_specific_conditions.rb +247 -247
  85. data/test/test_striuct-subclass-instance-validation_with_getter.rb +33 -33
  86. data/test/test_striuct-subclass-instance_names.rb +18 -18
  87. data/test/test_striuct-version.rb +10 -10
  88. metadata +4 -2
data/.gitignore CHANGED
@@ -1,34 +1,35 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- coverage
6
- coverage.data
7
- InstalledFiles
8
- lib/bundler/man
9
- pkg
10
- rdoc
11
- spec/reports
12
- test/tmp
13
- test/version_tmp
14
- tmp
15
-
16
- # bundler
17
- vendor/
18
-
19
- # YARD artifacts
20
- .yardoc
21
- _yardoc
22
- doc/
23
-
24
- # tmp-old
25
- .old
26
-
27
- # editor
28
- *~
29
- .redcar
30
-
31
- # other
32
- *.lock
33
- *.bak
34
- tool/
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ coverage.data
7
+ InstalledFiles
8
+ lib/bundler/man
9
+ pkg
10
+ rdoc
11
+ spec/reports
12
+ test/tmp
13
+ test/version_tmp
14
+ tmp
15
+
16
+ # bundler
17
+ vendor/
18
+
19
+ # YARD artifacts
20
+ .yardoc
21
+ _yardoc
22
+ doc/
23
+
24
+ # tmp-old
25
+ .old
26
+
27
+ # editor
28
+ *~
29
+ .redcar
30
+
31
+ # other
32
+ *.lock
33
+ *.bak
34
+ tool/
35
+ *\#*
data/.travis.yml CHANGED
@@ -1,6 +1,6 @@
1
- language: ruby
2
- rvm:
3
- - ruby-head
4
- - 1.9.3
5
- - 1.9.2
6
- - rbx-19mode # Rubinius in 1.9 mode
1
+ language: ruby
2
+ rvm:
3
+ - ruby-head
4
+ - 1.9.3
5
+ - 1.9.2
6
+ - rbx-19mode # Rubinius in 1.9 mode
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- group :development do
6
- gem 'rake'
7
- gem 'yard', '>=0.8.2.1'
8
- end
9
-
10
- group :test do
11
- gem 'rake'
12
- end
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rake'
7
+ gem 'yard', '>=0.8.2.1'
8
+ end
9
+
10
+ group :test do
11
+ gem 'rake'
12
+ end
data/History.rdoc CHANGED
@@ -1,273 +1,279 @@
1
- === 0.3.3 2012-9-7
2
-
3
- * modify:
4
- * SubClass#to_s
5
- * SubClass#inspect
6
-
7
- * fix:
8
- * SubClass.freeze
9
-
10
- * add:
11
- * compatibility with keyvalidatable-API
12
-
13
- === 0.3.2 2012-9-4
14
-
15
- * fix:
16
- * #assign
17
- * .for_pairs, .[]
18
-
19
- === 0.3.1 2012-9-2
20
-
21
- * add:
22
- * default value via member macro
23
-
24
- === 0.3.0 2012-4-3
25
-
26
- * modify:
27
- * use validation library (spin-off library)
28
-
29
- === 0.2.3 2012-4-2
30
-
31
- * fix:
32
- * Conditions.#NAND
33
- * Conditions.#XOR
34
- * Conditions.#XNOR
35
-
36
- === 0.2.2 2012-3-30
37
-
38
- * add:
39
- * aliases Conditions#[FUNC()] -> Conditions#[FUNC?()]
40
-
41
- * fix:
42
- * GENERICS check when build condition
43
- * arity checker when default with block parameter
44
-
45
- === 0.2.1 2012-1-30
46
-
47
- * delete:
48
- * Conditions#ANY, ALL
49
-
50
- * add:
51
- * can choose timing of validation (member with option and safety_setter? and more)
52
- * add Flavors (Useful flavor builders)
53
- * .#to_struct_class, #to_struct
54
- * #each_name_with_index (alias-> #each_member_with_index, #each_key_with_index)
55
-
56
- === 0.2.0 2012-1-27
57
-
58
- * delete:
59
- * constant StrictStruct
60
- * Eigen.#sufficient? (alias -> valid?, accept?)
61
-
62
- * modify:
63
- * conditions to a condition (use condition generator Conditions#OR)
64
- * to expr a flavor, before check condition
65
- * inference flag under option parameter
66
- * long macro names (define_xxx -> add_xxx)
67
-
68
- * add:
69
- * #each_pair_with_index
70
-
71
- === 0.1.7 2012-1-26
72
-
73
- * add:
74
- * default with Proc
75
- * detail error message in Subclass.#[]=
76
-
77
- * fix:
78
- * class duplicating
79
-
80
- === 0.1.6 2012-1-25
81
-
82
- * delete:
83
- * import.rb
84
-
85
- * modify:
86
- * Subclass.#define
87
- * naming risks (add bad name "_foo")
88
- * Conditions.#GENERICS (enum prior all? to each_value.all?)
89
- * timing of check default value
90
-
91
- * add:
92
- * detail error message in Subclass.#define
93
-
94
- * fix:
95
- * inherited behavior
96
-
97
- === 0.1.5 2012-1-17
98
-
99
- * add:
100
- * #lock, #lock?
101
- * some Specific Conditions
102
-
103
- * note:
104
- multiple conditions for 'or', dupulicated for direct throw member macro
105
- please use .#OR method in this case
106
-
107
- === 0.1.4 2012-1-16
108
-
109
- * modify:
110
- * trace logs
111
- * naming risks(add bad name "to_foo")
112
- * Subclass#unassign
113
-
114
- * add:
115
- * Specific Conditions
116
- (for Syntax Sugar of useful Functional Conditions)
117
- * Subclass.#each_index
118
- * Subclass.#valid?
119
- * Subclass#clear_at, reset_at
120
-
121
- === 0.1.3 2012-1-10
122
-
123
- * add:
124
- * Subclass.#alias_member
125
- * Subclass.#valid?
126
- * Subclass#valid?
127
-
128
- === 0.1.2 2012-1-9
129
-
130
- * modify:
131
- * Subclass.#hash
132
-
133
- * add:
134
- * Subclass.#to_yaml
135
-
136
- === 0.1.1 2011-12-26
137
-
138
- * modify:
139
- * Subclass.#sufficient?
140
-
141
- * add:
142
- * Subclass.#empty?
143
- * Subclass.#has_value? (value?)
144
- * Subclass.#flatten
145
- * Subclass.#select! (keep_if)
146
- * Subclass.#select
147
- * Subclass.#reject! (delete_if)
148
- * Subclass.#reject
149
- * Subclass.#assoc
150
- * Subclass.#rassoc
151
-
152
- * fix
153
- * Subclass.#sufficient?
154
-
155
- === 0.1.0 2011-12-25
156
-
157
- * modify:
158
- * Subclass.#define
159
-
160
- * add:
161
- * Subclass.#[] (alias load_pairs)
162
- * Subclass.#to_h
163
-
164
- === 0.0.11 2011-12-23
165
-
166
- * modify:
167
- * Subclass.#cname?
168
-
169
- * add:
170
- * inference checker
171
-
172
- === 0.0.10 2011-12-23
173
-
174
- * delete:
175
- * Subclass.#lock, Subclass.#unlock?
176
-
177
- * modify:
178
- * Subclass.#freeze
179
- * has_condition? -> has_conditions?
180
- * Subclass.#lock, Subclass.#lock? -> .close, .closed?
181
-
182
- * add:
183
- * Subclass.#protect_level # class macro
184
- * Subclass.#default?
185
-
186
- === 0.0.9 2011-12-21
187
-
188
- * delete:
189
- * Striuct.load_pairs
190
- * Subclass.#conditions
191
- * Subclass.#procedures
192
- * Subclass.#defaults
193
-
194
- * add:
195
- * Striuct.define
196
- * Subclass.#lock
197
- * Subclass.#default_for
198
-
199
- * fix:
200
- * Subclass.#inspect
201
- * Subclass.#to_s
202
-
203
- * note:
204
- * innner name changed "procedure" to "flavor"
205
-
206
- === 0.0.8 2011-12-18
207
-
208
- * modify:
209
- * Subclass.#define
210
- * Subclass.#accept?
211
- * functional checker's action:
212
- Proc: context to instance
213
- Method: === to call
214
-
215
- * add:
216
- * Subclass.#default
217
-
218
- * fix:
219
- * Subclass.#values_at
220
-
221
- === 0.0.7 2011-12-16
222
-
223
- * modify:
224
- * called macro's block to procedure
225
- * public to private Subclass.#unlock
226
-
227
- * add:
228
- * Subclass.#define
229
- * Subclass.#accept?
230
- * Subclass.#restrict?
231
- * Subclass.#assign?
232
- * Subclass.#assign
233
-
234
- * fix:
235
- * use clone method ( initialize_copy )
236
-
237
- === 0.0.6 2011-12-14
238
-
239
- * modify:
240
- * error type in some methods
241
-
242
- * add:
243
- * Subclass.#sufficent?
244
- * Subclass.#define
245
- * Subclass.#sufficent?
246
- * Subclass.#secure?
247
- * Subclass.#lock?
248
- * Subclass.#lock
249
- * Subclass.#unlock
250
-
251
- * fix:
252
- * typo
253
-
254
- === 0.0.5 2011-12-14
255
-
256
- * fix class constructor
257
- * modify #inspect
258
- * add arguments checks
259
-
260
- === 0.0.4 2011-12-13
261
-
262
- * divide modules for Subclass.#methods
263
- * modify return values for void methods
264
-
265
- === 0.0.3 2011-12-12
266
-
267
- === 0.0.2 2011-12-11
268
-
269
- === 0.0.1 2011-12-11
270
-
271
- * 1 major enhancement:
272
- * Initial release
273
-
1
+ === 0.3.4 2012-9-8
2
+
3
+ * fix:
4
+ * SubClass.#to_struct
5
+ * SubClass#sufficient? (catch any error: error -> false)
6
+
7
+ === 0.3.3 2012-9-7
8
+
9
+ * modify:
10
+ * SubClass#to_s
11
+ * SubClass#inspect
12
+
13
+ * fix:
14
+ * SubClass.freeze
15
+
16
+ * add:
17
+ * compatibility with keyvalidatable-API
18
+
19
+ === 0.3.2 2012-9-4
20
+
21
+ * fix:
22
+ * #assign
23
+ * .for_pairs, .[]
24
+
25
+ === 0.3.1 2012-9-2
26
+
27
+ * add:
28
+ * default value via member macro
29
+
30
+ === 0.3.0 2012-4-3
31
+
32
+ * modify:
33
+ * use validation library (spin-off library)
34
+
35
+ === 0.2.3 2012-4-2
36
+
37
+ * fix:
38
+ * Conditions.#NAND
39
+ * Conditions.#XOR
40
+ * Conditions.#XNOR
41
+
42
+ === 0.2.2 2012-3-30
43
+
44
+ * add:
45
+ * aliases Conditions#[FUNC()] -> Conditions#[FUNC?()]
46
+
47
+ * fix:
48
+ * GENERICS check when build condition
49
+ * arity checker when default with block parameter
50
+
51
+ === 0.2.1 2012-1-30
52
+
53
+ * delete:
54
+ * Conditions#ANY, ALL
55
+
56
+ * add:
57
+ * can choose timing of validation (member with option and safety_setter? and more)
58
+ * add Flavors (Useful flavor builders)
59
+ * .#to_struct_class, #to_struct
60
+ * #each_name_with_index (alias-> #each_member_with_index, #each_key_with_index)
61
+
62
+ === 0.2.0 2012-1-27
63
+
64
+ * delete:
65
+ * constant StrictStruct
66
+ * Eigen.#sufficient? (alias -> valid?, accept?)
67
+
68
+ * modify:
69
+ * conditions to a condition (use condition generator Conditions#OR)
70
+ * to expr a flavor, before check condition
71
+ * inference flag under option parameter
72
+ * long macro names (define_xxx -> add_xxx)
73
+
74
+ * add:
75
+ * #each_pair_with_index
76
+
77
+ === 0.1.7 2012-1-26
78
+
79
+ * add:
80
+ * default with Proc
81
+ * detail error message in Subclass.#[]=
82
+
83
+ * fix:
84
+ * class duplicating
85
+
86
+ === 0.1.6 2012-1-25
87
+
88
+ * delete:
89
+ * import.rb
90
+
91
+ * modify:
92
+ * Subclass.#define
93
+ * naming risks (add bad name "_foo")
94
+ * Conditions.#GENERICS (enum prior all? to each_value.all?)
95
+ * timing of check default value
96
+
97
+ * add:
98
+ * detail error message in Subclass.#define
99
+
100
+ * fix:
101
+ * inherited behavior
102
+
103
+ === 0.1.5 2012-1-17
104
+
105
+ * add:
106
+ * #lock, #lock?
107
+ * some Specific Conditions
108
+
109
+ * note:
110
+ multiple conditions for 'or', dupulicated for direct throw member macro
111
+ please use .#OR method in this case
112
+
113
+ === 0.1.4 2012-1-16
114
+
115
+ * modify:
116
+ * trace logs
117
+ * naming risks(add bad name "to_foo")
118
+ * Subclass#unassign
119
+
120
+ * add:
121
+ * Specific Conditions
122
+ (for Syntax Sugar of useful Functional Conditions)
123
+ * Subclass.#each_index
124
+ * Subclass.#valid?
125
+ * Subclass#clear_at, reset_at
126
+
127
+ === 0.1.3 2012-1-10
128
+
129
+ * add:
130
+ * Subclass.#alias_member
131
+ * Subclass.#valid?
132
+ * Subclass#valid?
133
+
134
+ === 0.1.2 2012-1-9
135
+
136
+ * modify:
137
+ * Subclass.#hash
138
+
139
+ * add:
140
+ * Subclass.#to_yaml
141
+
142
+ === 0.1.1 2011-12-26
143
+
144
+ * modify:
145
+ * Subclass.#sufficient?
146
+
147
+ * add:
148
+ * Subclass.#empty?
149
+ * Subclass.#has_value? (value?)
150
+ * Subclass.#flatten
151
+ * Subclass.#select! (keep_if)
152
+ * Subclass.#select
153
+ * Subclass.#reject! (delete_if)
154
+ * Subclass.#reject
155
+ * Subclass.#assoc
156
+ * Subclass.#rassoc
157
+
158
+ * fix
159
+ * Subclass.#sufficient?
160
+
161
+ === 0.1.0 2011-12-25
162
+
163
+ * modify:
164
+ * Subclass.#define
165
+
166
+ * add:
167
+ * Subclass.#[] (alias load_pairs)
168
+ * Subclass.#to_h
169
+
170
+ === 0.0.11 2011-12-23
171
+
172
+ * modify:
173
+ * Subclass.#cname?
174
+
175
+ * add:
176
+ * inference checker
177
+
178
+ === 0.0.10 2011-12-23
179
+
180
+ * delete:
181
+ * Subclass.#lock, Subclass.#unlock?
182
+
183
+ * modify:
184
+ * Subclass.#freeze
185
+ * has_condition? -> has_conditions?
186
+ * Subclass.#lock, Subclass.#lock? -> .close, .closed?
187
+
188
+ * add:
189
+ * Subclass.#protect_level # class macro
190
+ * Subclass.#default?
191
+
192
+ === 0.0.9 2011-12-21
193
+
194
+ * delete:
195
+ * Striuct.load_pairs
196
+ * Subclass.#conditions
197
+ * Subclass.#procedures
198
+ * Subclass.#defaults
199
+
200
+ * add:
201
+ * Striuct.define
202
+ * Subclass.#lock
203
+ * Subclass.#default_for
204
+
205
+ * fix:
206
+ * Subclass.#inspect
207
+ * Subclass.#to_s
208
+
209
+ * note:
210
+ * innner name changed "procedure" to "flavor"
211
+
212
+ === 0.0.8 2011-12-18
213
+
214
+ * modify:
215
+ * Subclass.#define
216
+ * Subclass.#accept?
217
+ * functional checker's action:
218
+ Proc: context to instance
219
+ Method: === to call
220
+
221
+ * add:
222
+ * Subclass.#default
223
+
224
+ * fix:
225
+ * Subclass.#values_at
226
+
227
+ === 0.0.7 2011-12-16
228
+
229
+ * modify:
230
+ * called macro's block to procedure
231
+ * public to private Subclass.#unlock
232
+
233
+ * add:
234
+ * Subclass.#define
235
+ * Subclass.#accept?
236
+ * Subclass.#restrict?
237
+ * Subclass.#assign?
238
+ * Subclass.#assign
239
+
240
+ * fix:
241
+ * use clone method ( initialize_copy )
242
+
243
+ === 0.0.6 2011-12-14
244
+
245
+ * modify:
246
+ * error type in some methods
247
+
248
+ * add:
249
+ * Subclass.#sufficent?
250
+ * Subclass.#define
251
+ * Subclass.#sufficent?
252
+ * Subclass.#secure?
253
+ * Subclass.#lock?
254
+ * Subclass.#lock
255
+ * Subclass.#unlock
256
+
257
+ * fix:
258
+ * typo
259
+
260
+ === 0.0.5 2011-12-14
261
+
262
+ * fix class constructor
263
+ * modify #inspect
264
+ * add arguments checks
265
+
266
+ === 0.0.4 2011-12-13
267
+
268
+ * divide modules for Subclass.#methods
269
+ * modify return values for void methods
270
+
271
+ === 0.0.3 2011-12-12
272
+
273
+ === 0.0.2 2011-12-11
274
+
275
+ === 0.0.1 2011-12-11
276
+
277
+ * 1 major enhancement:
278
+ * Initial release
279
+