striuct 0.6.0 → 0.6.1
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 -3
- data/example/README.rb +1 -2
- data/example/example1.rb +0 -40
- data/lib/striuct/classmethods/attributes.rb +11 -9
- data/lib/striuct/classmethods/inner.rb +0 -9
- data/lib/striuct/classmethods/macro.rb +0 -6
- data/lib/striuct/classmethods/predicate.rb +0 -9
- data/lib/striuct/instancemethods/delegate_class_methods.rb +5 -3
- data/lib/striuct/instancemethods/setter.rb +0 -4
- data/striuct.gemspec +1 -1
- data/test/test_subc-c-constructor.rb +1 -1
- data/test/test_subc-c-copy.rb +4 -4
- data/test/test_subc-c-inheritable.rb +1 -1
- data/test/test_subc-f-predicate.rb +0 -64
- data/test/test_subc-f_name.rb +1 -1
- data/test/test_subc-i-default_value.rb +2 -2
- metadata +2 -5
- data/History.old(~0.3.n).rdoc +0 -289
- data/test/test_subc-i-validation_inference.rb +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a5238390f14805baa497d1cd3acec45fc10faa233ce94af4782aa5570606b56
|
4
|
+
data.tar.gz: e703ea310209502b772938d9eee312e26fcfdec30189c41e071107b125574ebb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4650584be9988e6f8ed9b1a58cfa5912d099aed4377e035750ee158216fa8bc06c46c53386bc5b1188dd302847112c337d750ac1a103810bd83ab25ae5f920c4
|
7
|
+
data.tar.gz: 3edc0199746228322c017bf8eefc619352a53882cf908d9e525392faaa43a5314ec37529ce97cfc7b40917d2dbca5da393cb5580b3d8c1ae673cdeea22efdf42
|
data/README.md
CHANGED
@@ -68,8 +68,7 @@ ken.id #=> 2
|
|
68
68
|
```ruby
|
69
69
|
class Foo < Striuct
|
70
70
|
member :foo
|
71
|
-
member :bar, Numeric
|
72
|
-
inference: true # And use inference Validation
|
71
|
+
member :bar, Numeric
|
73
72
|
member :with_adjuster, Integer,
|
74
73
|
&->v{Integer v} # Use adjuster before a setter
|
75
74
|
end
|
@@ -86,7 +85,6 @@ foo.assigned?(:foo) #=> true
|
|
86
85
|
foo.lock(:foo)
|
87
86
|
foo.foo = nil #=> error
|
88
87
|
|
89
|
-
# Inference Validation
|
90
88
|
foo.bar = 1.2 #=> pass # memorize 1.2's class is Float
|
91
89
|
foo.bar = 1 #=> error # 1 is not Float
|
92
90
|
|
data/example/README.rb
CHANGED
data/example/example1.rb
CHANGED
@@ -75,46 +75,6 @@ module Game
|
|
75
75
|
debug db
|
76
76
|
end
|
77
77
|
|
78
|
-
# through "inference", and check under first passed object class
|
79
|
-
class FlexibleContainer < Striuct.new
|
80
|
-
member :anything, BasicObject, inference: true
|
81
|
-
member :number, Numeric, inference: true
|
82
|
-
end
|
83
|
-
|
84
|
-
fc1, fc2 = FlexibleContainer.new, FlexibleContainer.new
|
85
|
-
fc1.anything = 'str'
|
86
|
-
debug fc1
|
87
|
-
begin
|
88
|
-
fc1.anything = :sym
|
89
|
-
rescue
|
90
|
-
debug $!
|
91
|
-
end
|
92
|
-
|
93
|
-
begin
|
94
|
-
fc2.anything = :sym
|
95
|
-
rescue
|
96
|
-
debug $!
|
97
|
-
end
|
98
|
-
|
99
|
-
fc2.anything = 'string too'
|
100
|
-
|
101
|
-
debug fc2
|
102
|
-
|
103
|
-
begin
|
104
|
-
fc1.number = 'str'
|
105
|
-
rescue
|
106
|
-
debug $!
|
107
|
-
end
|
108
|
-
|
109
|
-
fc1.number = 1.0
|
110
|
-
debug fc1
|
111
|
-
|
112
|
-
begin
|
113
|
-
fc2.number = 1
|
114
|
-
rescue
|
115
|
-
debug $!
|
116
|
-
end
|
117
|
-
|
118
78
|
# Standard Struct not check member name.
|
119
79
|
NoGuard = Struct.new :__send__, :'? !'
|
120
80
|
noguard = NoGuard.new false
|
@@ -6,16 +6,18 @@ class Striuct; module ClassMethods
|
|
6
6
|
VALUES = [ :condition,
|
7
7
|
:adjuster ].freeze
|
8
8
|
|
9
|
-
BOOLEANS = [
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
BOOLEANS = [
|
10
|
+
:must,
|
11
|
+
:safety_setter,
|
12
|
+
:safety_getter
|
13
|
+
].freeze
|
14
|
+
|
14
15
|
def initialize
|
15
|
-
@hash =
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
@hash = {
|
17
|
+
must: false,
|
18
|
+
safety_setter: false,
|
19
|
+
safety_getter: false
|
20
|
+
}
|
19
21
|
end
|
20
22
|
|
21
23
|
VALUES.each do |role|
|
@@ -66,15 +66,6 @@ class Striuct; module ClassMethods
|
|
66
66
|
nil
|
67
67
|
end
|
68
68
|
|
69
|
-
def _found_family(autonym, other)
|
70
|
-
family = other.class
|
71
|
-
|
72
|
-
_attributes_for(autonym).condition = family
|
73
|
-
_attributes_for(autonym).inference = false
|
74
|
-
|
75
|
-
nil
|
76
|
-
end
|
77
|
-
|
78
69
|
# @endgroup
|
79
70
|
|
80
71
|
end; end
|
@@ -9,7 +9,6 @@ class Striuct; module ClassMethods
|
|
9
9
|
opt :default_value, aliases: [:default]
|
10
10
|
opt :default_proc, aliases: [:lazy_default]
|
11
11
|
conflict :default_value, :default_proc
|
12
|
-
opt :inference, default: false
|
13
12
|
opt :must, default: false
|
14
13
|
opt :setter_validation, aliases: [:writer_validation], default: true
|
15
14
|
opt :getter_validation, aliases: [:reader_validation], default: false
|
@@ -22,7 +21,6 @@ class Striuct; module ClassMethods
|
|
22
21
|
# @param [Hash] options
|
23
22
|
# @option options [BasicObject] :default
|
24
23
|
# @option options [Proc] :default_proc
|
25
|
-
# @option options [Boolean] :inference
|
26
24
|
# @option options [Boolean] :must
|
27
25
|
# @option options [Boolean] :reader_validation
|
28
26
|
# @option options [Boolean] :getter_validation
|
@@ -43,10 +41,6 @@ class Striuct; module ClassMethods
|
|
43
41
|
_attributes_for(autonym).safety_setter = !!options.setter_validation
|
44
42
|
_attributes_for(autonym).safety_getter = !!options.getter_validation
|
45
43
|
|
46
|
-
if options.inference
|
47
|
-
_attributes_for(autonym).inference = true
|
48
|
-
end
|
49
|
-
|
50
44
|
if options.must
|
51
45
|
_attributes_for(autonym).must = true
|
52
46
|
end
|
@@ -83,15 +83,6 @@ class Striuct; module ClassMethods
|
|
83
83
|
|
84
84
|
alias_method :restrict?, :with_condition?
|
85
85
|
|
86
|
-
# @param [Symbol, String, #to_sym, Integer, #to_int] key - name / index
|
87
|
-
def with_inference?(key)
|
88
|
-
autonym = autonym_for_key key
|
89
|
-
rescue Exception
|
90
|
-
false
|
91
|
-
else
|
92
|
-
_attributes_for(autonym).with_inference?
|
93
|
-
end
|
94
|
-
|
95
86
|
# @param [Symbol, String, #to_sym, Integer, #to_int] key - name / index
|
96
87
|
def with_must?(key)
|
97
88
|
autonym = autonym_for_key key
|
@@ -3,7 +3,6 @@ class Striuct; module InstanceMethods
|
|
3
3
|
# @group Delegate Class Methods
|
4
4
|
|
5
5
|
def_delegators :'self.class',
|
6
|
-
:_autonyms,
|
7
6
|
:autonym_for_alias,
|
8
7
|
:autonym_for_member,
|
9
8
|
:autonym_for_index,
|
@@ -21,14 +20,17 @@ class Striuct; module InstanceMethods
|
|
21
20
|
:condition_for,
|
22
21
|
:with_safety_getter?, :with_safety_reader?,
|
23
22
|
:with_safety_setter?, :with_safety_writer?,
|
24
|
-
:with_inference?,
|
25
23
|
:with_must?, :must?,
|
26
24
|
:with_default?,
|
27
25
|
:default_value_for, :default_type_for,
|
28
26
|
:with_adjuster?,
|
29
27
|
:adjuster_for
|
30
28
|
|
31
|
-
private
|
29
|
+
private
|
30
|
+
|
31
|
+
def _autonyms
|
32
|
+
self.class.__send__ :_autonyms
|
33
|
+
end
|
32
34
|
|
33
35
|
# @endgroup
|
34
36
|
|
@@ -39,10 +39,6 @@ class Striuct; module InstanceMethods
|
|
39
39
|
"#{value.inspect} is deficient for #{autonym} in #{self.class}"
|
40
40
|
end
|
41
41
|
|
42
|
-
if with_inference? autonym
|
43
|
-
self.class.__send__ :_found_family, autonym, value
|
44
|
-
end
|
45
|
-
|
46
42
|
@db[autonym] = value
|
47
43
|
rescue ::Validation::InvalidError
|
48
44
|
unless /in \[\]=/ =~ caller[1].slice(/([^:]+)\z/)
|
data/striuct.gemspec
CHANGED
data/test/test_subc-c-copy.rb
CHANGED
@@ -34,7 +34,7 @@ class Test_Striuct_Subclass_Class_Copy < Test::Unit::TestCase
|
|
34
34
|
|
35
35
|
def test_dup_deep
|
36
36
|
org_cls = Striuct.define do
|
37
|
-
member :foo, Numeric
|
37
|
+
member :foo, Numeric
|
38
38
|
end
|
39
39
|
|
40
40
|
foo = org_cls.new
|
@@ -42,7 +42,7 @@ class Test_Striuct_Subclass_Class_Copy < Test::Unit::TestCase
|
|
42
42
|
foo2 = cls2.new
|
43
43
|
foo2.foo = 0.1
|
44
44
|
assert_raises Validation::InvalidWritingError do
|
45
|
-
foo2.foo = 1
|
45
|
+
foo2.foo = '1'
|
46
46
|
end
|
47
47
|
|
48
48
|
foo.foo = 1
|
@@ -52,7 +52,7 @@ class Test_Striuct_Subclass_Class_Copy < Test::Unit::TestCase
|
|
52
52
|
|
53
53
|
def test_clone_deep
|
54
54
|
org_cls = Striuct.define do
|
55
|
-
member :foo, Numeric
|
55
|
+
member :foo, Numeric
|
56
56
|
end
|
57
57
|
|
58
58
|
foo = org_cls.new
|
@@ -60,7 +60,7 @@ class Test_Striuct_Subclass_Class_Copy < Test::Unit::TestCase
|
|
60
60
|
foo2 = cls2.new
|
61
61
|
foo2.foo = 0.1
|
62
62
|
assert_raises Validation::InvalidWritingError do
|
63
|
-
foo2.foo = 1
|
63
|
+
foo2.foo = '1'
|
64
64
|
end
|
65
65
|
|
66
66
|
foo.foo = 1
|
@@ -318,70 +318,6 @@ class Test_Striuct_Subclass_Predicate_Condition < Test::Unit::TestCase
|
|
318
318
|
|
319
319
|
end
|
320
320
|
|
321
|
-
class Test_Striuct_Subclass_Predicate_InferenceValidation < Test::Unit::TestCase
|
322
|
-
|
323
|
-
class Subclass < Striuct
|
324
|
-
member :no_with
|
325
|
-
alias_member :als_no_with, :no_with
|
326
|
-
member :with, nil, inference: true
|
327
|
-
alias_member :als_with, :with
|
328
|
-
member :with_any, BasicObject, inference: true
|
329
|
-
alias_member :als_with_any, :with_any
|
330
|
-
member :adj_with, nil, inference: true do |_|; end
|
331
|
-
alias_member :als_adj_with, :adj_with
|
332
|
-
|
333
|
-
close_member
|
334
|
-
end.freeze
|
335
|
-
|
336
|
-
INSTANCE = Subclass.new.freeze
|
337
|
-
|
338
|
-
TYPE_PAIRS = {
|
339
|
-
class: Subclass,
|
340
|
-
instance: INSTANCE
|
341
|
-
}.freeze
|
342
|
-
|
343
|
-
[:with_inference?].each do |predicate|
|
344
|
-
TYPE_PAIRS.each_pair do |type, reciever|
|
345
|
-
define_method :"test_#{type}_#{predicate}" do
|
346
|
-
assert_same false, reciever.public_send(predicate, :no_with)
|
347
|
-
assert_same false, reciever.public_send(predicate, :als_no_with)
|
348
|
-
assert_same false, reciever.public_send(predicate, 'no_with')
|
349
|
-
assert_same false, reciever.public_send(predicate, 'als_no_with')
|
350
|
-
assert_same false, reciever.public_send(predicate, 0)
|
351
|
-
assert_same false, reciever.public_send(predicate, 0.9)
|
352
|
-
|
353
|
-
assert_same true, reciever.public_send(predicate, :with)
|
354
|
-
assert_same true, reciever.public_send(predicate, :als_with)
|
355
|
-
assert_same true, reciever.public_send(predicate, 'with')
|
356
|
-
assert_same true, reciever.public_send(predicate, 'als_with')
|
357
|
-
assert_same true, reciever.public_send(predicate, 1)
|
358
|
-
assert_same true, reciever.public_send(predicate, 1.9)
|
359
|
-
|
360
|
-
assert_same true, reciever.public_send(predicate, :with_any)
|
361
|
-
assert_same true, reciever.public_send(predicate, :als_with_any)
|
362
|
-
assert_same true, reciever.public_send(predicate, 'with_any')
|
363
|
-
assert_same true, reciever.public_send(predicate, 'als_with_any')
|
364
|
-
assert_same true, reciever.public_send(predicate, 2)
|
365
|
-
assert_same true, reciever.public_send(predicate, 2.9)
|
366
|
-
|
367
|
-
assert_same true, reciever.public_send(predicate, :adj_with)
|
368
|
-
assert_same true, reciever.public_send(predicate, :als_adj_with)
|
369
|
-
assert_same true, reciever.public_send(predicate, 'adj_with')
|
370
|
-
assert_same true, reciever.public_send(predicate, 'als_adj_with')
|
371
|
-
assert_same true, reciever.public_send(predicate, 3)
|
372
|
-
assert_same true, reciever.public_send(predicate, 3.9)
|
373
|
-
|
374
|
-
assert_same false, reciever.public_send(predicate, :none)
|
375
|
-
assert_same false, reciever.public_send(predicate, 'none')
|
376
|
-
assert_same false, reciever.public_send(predicate, 4)
|
377
|
-
assert_same false, reciever.public_send(predicate, 4.9)
|
378
|
-
assert_same false, reciever.public_send(predicate, BasicObject.new)
|
379
|
-
end
|
380
|
-
end
|
381
|
-
end
|
382
|
-
|
383
|
-
end
|
384
|
-
|
385
321
|
class Test_Striuct_Subclass_Predicate_Must < Test::Unit::TestCase
|
386
322
|
|
387
323
|
class Subclass < Striuct
|
data/test/test_subc-f_name.rb
CHANGED
@@ -27,7 +27,7 @@ class Test_Striuct_Subclass_Name < Test::Unit::TestCase
|
|
27
27
|
[:_autonyms].each do |callee|
|
28
28
|
TYPE_PAIRS.each_pair do |type, reciever|
|
29
29
|
define_method :"test_#{type}_#{callee}" do
|
30
|
-
|
30
|
+
assert_equal true, reciever.private_methods.include?(callee)
|
31
31
|
|
32
32
|
assert_raises NoMethodError do
|
33
33
|
reciever.public_send(callee)
|
@@ -3,7 +3,7 @@ require_relative 'helper'
|
|
3
3
|
class Test_Striuct_Subclass_Instance_Default_Value < Test::Unit::TestCase
|
4
4
|
|
5
5
|
Sth = Striuct.new do
|
6
|
-
member :lank, OR(
|
6
|
+
member :lank, OR(Integer, Rational)
|
7
7
|
default :lank, 1
|
8
8
|
end
|
9
9
|
|
@@ -75,7 +75,7 @@ end
|
|
75
75
|
class Test_Striuct_Subclass_Instance_DefaultValue_Under_MemberMacro < Test::Unit::TestCase
|
76
76
|
|
77
77
|
Sth = Striuct.new do
|
78
|
-
member :lank, OR(
|
78
|
+
member :lank, OR(Integer, Rational), default: 1
|
79
79
|
end
|
80
80
|
|
81
81
|
def test_default
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: striuct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenichi Kamiya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: validation
|
@@ -150,7 +150,6 @@ files:
|
|
150
150
|
- ".travis.yml"
|
151
151
|
- ".yardopts"
|
152
152
|
- Gemfile
|
153
|
-
- History.old(~0.3.n).rdoc
|
154
153
|
- MIT-LICENSE
|
155
154
|
- README.md
|
156
155
|
- Rakefile
|
@@ -230,7 +229,6 @@ files:
|
|
230
229
|
- test/test_subc-i-lock.rb
|
231
230
|
- test/test_subc-i-must.rb
|
232
231
|
- test/test_subc-i-to_s_family.rb
|
233
|
-
- test/test_subc-i-validation_inference.rb
|
234
232
|
- test/test_subc-i-validation_specific_conditions.rb
|
235
233
|
- test/test_subc-i-validation_with_getter.rb
|
236
234
|
- test/test_version.rb
|
@@ -291,7 +289,6 @@ test_files:
|
|
291
289
|
- test/test_subc-i-lock.rb
|
292
290
|
- test/test_subc-i-must.rb
|
293
291
|
- test/test_subc-i-to_s_family.rb
|
294
|
-
- test/test_subc-i-validation_inference.rb
|
295
292
|
- test/test_subc-i-validation_specific_conditions.rb
|
296
293
|
- test/test_subc-i-validation_with_getter.rb
|
297
294
|
- test/test_version.rb
|
data/History.old(~0.3.n).rdoc
DELETED
@@ -1,289 +0,0 @@
|
|
1
|
-
=== 0.3.5.1 2012-9-14
|
2
|
-
|
3
|
-
* Too minor changed :)
|
4
|
-
Some doc & env
|
5
|
-
|
6
|
-
=== 0.3.5 2012-9-9
|
7
|
-
|
8
|
-
* fix:
|
9
|
-
* SubClass.dup, SubClass.clone
|
10
|
-
* SubClass#replace_values
|
11
|
-
|
12
|
-
=== 0.3.4 2012-9-8
|
13
|
-
|
14
|
-
* fix:
|
15
|
-
* SubClass.#to_struct
|
16
|
-
* SubClass#sufficient? (catch any error: error -> false)
|
17
|
-
|
18
|
-
=== 0.3.3 2012-9-7
|
19
|
-
|
20
|
-
* modify:
|
21
|
-
* SubClass#to_s
|
22
|
-
* SubClass#inspect
|
23
|
-
|
24
|
-
* fix:
|
25
|
-
* SubClass.freeze
|
26
|
-
|
27
|
-
* add:
|
28
|
-
* compatibility with keyvalidatable-API
|
29
|
-
|
30
|
-
=== 0.3.2 2012-9-4
|
31
|
-
|
32
|
-
* fix:
|
33
|
-
* #assign
|
34
|
-
* .for_pairs, .[]
|
35
|
-
|
36
|
-
=== 0.3.1 2012-9-2
|
37
|
-
|
38
|
-
* add:
|
39
|
-
* default value via member macro
|
40
|
-
|
41
|
-
=== 0.3.0 2012-4-3
|
42
|
-
|
43
|
-
* modify:
|
44
|
-
* use validation library (spin-off library)
|
45
|
-
|
46
|
-
=== 0.2.3 2012-4-2
|
47
|
-
|
48
|
-
* fix:
|
49
|
-
* Conditions.#NAND
|
50
|
-
* Conditions.#XOR
|
51
|
-
* Conditions.#XNOR
|
52
|
-
|
53
|
-
=== 0.2.2 2012-3-30
|
54
|
-
|
55
|
-
* add:
|
56
|
-
* aliases Conditions#[FUNC()] -> Conditions#[FUNC?()]
|
57
|
-
|
58
|
-
* fix:
|
59
|
-
* GENERICS check when build condition
|
60
|
-
* arity checker when default with block parameter
|
61
|
-
|
62
|
-
=== 0.2.1 2012-1-30
|
63
|
-
|
64
|
-
* delete:
|
65
|
-
* Conditions#ANY, ALL
|
66
|
-
|
67
|
-
* add:
|
68
|
-
* can choose timing of validation (member with option and safety_setter? and more)
|
69
|
-
* add Flavors (Useful flavor builders)
|
70
|
-
* .#to_struct_class, #to_struct
|
71
|
-
* #each_name_with_index (alias-> #each_member_with_index, #each_key_with_index)
|
72
|
-
|
73
|
-
=== 0.2.0 2012-1-27
|
74
|
-
|
75
|
-
* delete:
|
76
|
-
* constant StrictStruct
|
77
|
-
* Eigen.#sufficient? (alias -> valid?, accept?)
|
78
|
-
|
79
|
-
* modify:
|
80
|
-
* conditions to a condition (use condition generator Conditions#OR)
|
81
|
-
* to expr a flavor, before check condition
|
82
|
-
* inference flag under option parameter
|
83
|
-
* long macro names (define_xxx -> add_xxx)
|
84
|
-
|
85
|
-
* add:
|
86
|
-
* #each_pair_with_index
|
87
|
-
|
88
|
-
=== 0.1.7 2012-1-26
|
89
|
-
|
90
|
-
* add:
|
91
|
-
* default with Proc
|
92
|
-
* detail error message in Subclass.#[]=
|
93
|
-
|
94
|
-
* fix:
|
95
|
-
* class duplicating
|
96
|
-
|
97
|
-
=== 0.1.6 2012-1-25
|
98
|
-
|
99
|
-
* delete:
|
100
|
-
* import.rb
|
101
|
-
|
102
|
-
* modify:
|
103
|
-
* Subclass.#define
|
104
|
-
* naming risks (add bad name "_foo")
|
105
|
-
* Conditions.#GENERICS (enum prior all? to each_value.all?)
|
106
|
-
* timing of check default value
|
107
|
-
|
108
|
-
* add:
|
109
|
-
* detail error message in Subclass.#define
|
110
|
-
|
111
|
-
* fix:
|
112
|
-
* inherited behavior
|
113
|
-
|
114
|
-
=== 0.1.5 2012-1-17
|
115
|
-
|
116
|
-
* add:
|
117
|
-
* #lock, #lock?
|
118
|
-
* some Specific Conditions
|
119
|
-
|
120
|
-
* note:
|
121
|
-
multiple conditions for 'or', dupulicated for direct throw member macro
|
122
|
-
please use .#OR method in this case
|
123
|
-
|
124
|
-
=== 0.1.4 2012-1-16
|
125
|
-
|
126
|
-
* modify:
|
127
|
-
* trace logs
|
128
|
-
* naming risks(add bad name "to_foo")
|
129
|
-
* Subclass#unassign
|
130
|
-
|
131
|
-
* add:
|
132
|
-
* Specific Conditions
|
133
|
-
(for Syntax Sugar of useful Functional Conditions)
|
134
|
-
* Subclass.#each_index
|
135
|
-
* Subclass.#valid?
|
136
|
-
* Subclass#clear_at, reset_at
|
137
|
-
|
138
|
-
=== 0.1.3 2012-1-10
|
139
|
-
|
140
|
-
* add:
|
141
|
-
* Subclass.#alias_member
|
142
|
-
* Subclass.#valid?
|
143
|
-
* Subclass#valid?
|
144
|
-
|
145
|
-
=== 0.1.2 2012-1-9
|
146
|
-
|
147
|
-
* modify:
|
148
|
-
* Subclass.#hash
|
149
|
-
|
150
|
-
* add:
|
151
|
-
* Subclass.#to_yaml
|
152
|
-
|
153
|
-
=== 0.1.1 2011-12-26
|
154
|
-
|
155
|
-
* modify:
|
156
|
-
* Subclass.#sufficient?
|
157
|
-
|
158
|
-
* add:
|
159
|
-
* Subclass.#empty?
|
160
|
-
* Subclass.#has_value? (value?)
|
161
|
-
* Subclass.#flatten
|
162
|
-
* Subclass.#select! (keep_if)
|
163
|
-
* Subclass.#select
|
164
|
-
* Subclass.#reject! (delete_if)
|
165
|
-
* Subclass.#reject
|
166
|
-
* Subclass.#assoc
|
167
|
-
* Subclass.#rassoc
|
168
|
-
|
169
|
-
* fix
|
170
|
-
* Subclass.#sufficient?
|
171
|
-
|
172
|
-
=== 0.1.0 2011-12-25
|
173
|
-
|
174
|
-
* modify:
|
175
|
-
* Subclass.#define
|
176
|
-
|
177
|
-
* add:
|
178
|
-
* Subclass.#[] (alias load_pairs)
|
179
|
-
* Subclass.#to_h
|
180
|
-
|
181
|
-
=== 0.0.11 2011-12-23
|
182
|
-
|
183
|
-
* modify:
|
184
|
-
* Subclass.#cname?
|
185
|
-
|
186
|
-
* add:
|
187
|
-
* inference checker
|
188
|
-
|
189
|
-
=== 0.0.10 2011-12-23
|
190
|
-
|
191
|
-
* delete:
|
192
|
-
* Subclass.#lock, Subclass.#unlock?
|
193
|
-
|
194
|
-
* modify:
|
195
|
-
* Subclass.#freeze
|
196
|
-
* has_condition? -> has_conditions?
|
197
|
-
* Subclass.#lock, Subclass.#lock? -> .close, .closed?
|
198
|
-
|
199
|
-
* add:
|
200
|
-
* Subclass.#protect_level # class macro
|
201
|
-
* Subclass.#default?
|
202
|
-
|
203
|
-
=== 0.0.9 2011-12-21
|
204
|
-
|
205
|
-
* delete:
|
206
|
-
* Striuct.load_pairs
|
207
|
-
* Subclass.#conditions
|
208
|
-
* Subclass.#procedures
|
209
|
-
* Subclass.#defaults
|
210
|
-
|
211
|
-
* add:
|
212
|
-
* Striuct.define
|
213
|
-
* Subclass.#lock
|
214
|
-
* Subclass.#default_for
|
215
|
-
|
216
|
-
* fix:
|
217
|
-
* Subclass.#inspect
|
218
|
-
* Subclass.#to_s
|
219
|
-
|
220
|
-
* note:
|
221
|
-
* innner name changed "procedure" to "flavor"
|
222
|
-
|
223
|
-
=== 0.0.8 2011-12-18
|
224
|
-
|
225
|
-
* modify:
|
226
|
-
* Subclass.#define
|
227
|
-
* Subclass.#accept?
|
228
|
-
* functional checker's action:
|
229
|
-
Proc: context to instance
|
230
|
-
Method: === to call
|
231
|
-
|
232
|
-
* add:
|
233
|
-
* Subclass.#default
|
234
|
-
|
235
|
-
* fix:
|
236
|
-
* Subclass.#values_at
|
237
|
-
|
238
|
-
=== 0.0.7 2011-12-16
|
239
|
-
|
240
|
-
* modify:
|
241
|
-
* called macro's block to procedure
|
242
|
-
* public to private Subclass.#unlock
|
243
|
-
|
244
|
-
* add:
|
245
|
-
* Subclass.#define
|
246
|
-
* Subclass.#accept?
|
247
|
-
* Subclass.#restrict?
|
248
|
-
* Subclass.#assign?
|
249
|
-
* Subclass.#assign
|
250
|
-
|
251
|
-
* fix:
|
252
|
-
* use clone method ( initialize_copy )
|
253
|
-
|
254
|
-
=== 0.0.6 2011-12-14
|
255
|
-
|
256
|
-
* modify:
|
257
|
-
* error type in some methods
|
258
|
-
|
259
|
-
* add:
|
260
|
-
* Subclass.#sufficent?
|
261
|
-
* Subclass.#define
|
262
|
-
* Subclass.#sufficent?
|
263
|
-
* Subclass.#secure?
|
264
|
-
* Subclass.#lock?
|
265
|
-
* Subclass.#lock
|
266
|
-
* Subclass.#unlock
|
267
|
-
|
268
|
-
* fix:
|
269
|
-
* typo
|
270
|
-
|
271
|
-
=== 0.0.5 2011-12-14
|
272
|
-
|
273
|
-
* fix class constructor
|
274
|
-
* modify #inspect
|
275
|
-
* add arguments checks
|
276
|
-
|
277
|
-
=== 0.0.4 2011-12-13
|
278
|
-
|
279
|
-
* divide modules for Subclass.#methods
|
280
|
-
* modify return values for void methods
|
281
|
-
|
282
|
-
=== 0.0.3 2011-12-12
|
283
|
-
|
284
|
-
=== 0.0.2 2011-12-11
|
285
|
-
|
286
|
-
=== 0.0.1 2011-12-11
|
287
|
-
|
288
|
-
* 1 major enhancement:
|
289
|
-
* Initial release
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require_relative 'helper'
|
2
|
-
|
3
|
-
class Test_Striuct_Subclass_Instance_Inference < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def test_inference
|
6
|
-
klass = Striuct.define do
|
7
|
-
member :n, Numeric, inference: true
|
8
|
-
member :m, BasicObject, inference: true
|
9
|
-
end
|
10
|
-
|
11
|
-
sth, sth2 = klass.new, klass.new
|
12
|
-
|
13
|
-
assert_raises Validation::InvalidWritingError do
|
14
|
-
sth.n = '1'
|
15
|
-
end
|
16
|
-
|
17
|
-
sth.n = 1.1
|
18
|
-
|
19
|
-
assert_equal 1.1, sth.n
|
20
|
-
|
21
|
-
assert_raises Validation::InvalidWritingError do
|
22
|
-
sth.n = 1
|
23
|
-
end
|
24
|
-
|
25
|
-
assert_raises Validation::InvalidWritingError do
|
26
|
-
sth2.n = 1
|
27
|
-
end
|
28
|
-
|
29
|
-
sth.n = 2.1
|
30
|
-
|
31
|
-
assert_equal 2.1, sth.n
|
32
|
-
|
33
|
-
|
34
|
-
sth2.m = 1
|
35
|
-
|
36
|
-
assert_equal 1, sth2.m
|
37
|
-
|
38
|
-
assert_raises Validation::InvalidWritingError do
|
39
|
-
sth.m = 1.0
|
40
|
-
end
|
41
|
-
|
42
|
-
assert_raises Validation::InvalidWritingError do
|
43
|
-
sth2.m = 1.0
|
44
|
-
end
|
45
|
-
|
46
|
-
sth.m = 2
|
47
|
-
|
48
|
-
assert_equal 2, sth.m
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|