Checked 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/Checked/Arch.rb +12 -3
- data/lib/Checked/DSL.rb +28 -51
- data/lib/Checked/version.rb +1 -1
- metadata +8 -8
data/lib/Checked/Arch.rb
CHANGED
@@ -14,9 +14,18 @@ class Checked
|
|
14
14
|
|
15
15
|
include DSL::Racked
|
16
16
|
|
17
|
-
def initialize *
|
18
|
-
|
19
|
-
|
17
|
+
def initialize *name_and_or_val
|
18
|
+
name, val = case name_and_or_val.size
|
19
|
+
when 1
|
20
|
+
[ nil, name_and_or_val.first ]
|
21
|
+
when 2
|
22
|
+
name_and_or_val
|
23
|
+
else
|
24
|
+
raise ArgumentError, "Unknown values for name/value: #{name_and_or_val.inspect}"
|
25
|
+
end
|
26
|
+
self.target_name = name
|
27
|
+
return! val
|
28
|
+
check!
|
20
29
|
end
|
21
30
|
|
22
31
|
def request
|
data/lib/Checked/DSL.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
class Object
|
2
2
|
|
3
3
|
def Checked= val
|
4
|
-
@
|
4
|
+
@checked_arch = val
|
5
5
|
val.return! self
|
6
6
|
val
|
7
7
|
end
|
8
8
|
|
9
9
|
def Checked
|
10
10
|
raise "Not defined yet." unless Checked_applys?
|
11
|
-
@
|
11
|
+
@checked_arch
|
12
12
|
end
|
13
13
|
|
14
14
|
def Checked_applys?
|
15
|
-
instance_variable_defined?(:@
|
15
|
+
instance_variable_defined?(:@checked_arch)
|
16
16
|
end
|
17
17
|
|
18
18
|
def method_missing meth_name, *args
|
@@ -29,7 +29,10 @@ class Object
|
|
29
29
|
result = Checked().send meth_name, *args
|
30
30
|
@count = 1
|
31
31
|
|
32
|
-
result.
|
32
|
+
if result.object_id != object_id && meth_name.to_s['!'] && self.class == result.class
|
33
|
+
result.Checked= Checked()
|
34
|
+
end
|
35
|
+
|
33
36
|
result
|
34
37
|
end
|
35
38
|
|
@@ -118,23 +121,6 @@ class Checked
|
|
118
121
|
|
119
122
|
include Ruby
|
120
123
|
|
121
|
-
def self.eval! m
|
122
|
-
caller(1).first =~ %r!([^\:]+):(\d+):in `.!
|
123
|
-
if $1 && $2
|
124
|
-
eval m, nil, $1, $2.to_i - m.split("\n").size + 1
|
125
|
-
else
|
126
|
-
eval m, nil
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
%w{ Array Bool File_Path Hash String Symbol Var }.each { |name|
|
131
|
-
eval! %~
|
132
|
-
def #{name}!( *args )
|
133
|
-
Check!( '#{name}s', *args ).check!
|
134
|
-
end
|
135
|
-
~
|
136
|
-
}
|
137
|
-
|
138
124
|
def demand *pars
|
139
125
|
if pars.size == 2
|
140
126
|
val = return!
|
@@ -150,6 +136,26 @@ class Checked
|
|
150
136
|
super( return!, bool, msg )
|
151
137
|
end
|
152
138
|
|
139
|
+
def self.eval! m
|
140
|
+
caller(1).first =~ %r!([^\:]+):(\d+):in `.!
|
141
|
+
if $1 && $2
|
142
|
+
eval m, nil, $1, $2.to_i - m.split("\n").size + 1
|
143
|
+
else
|
144
|
+
eval m, nil
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
%w{ Array Bool File_Path Hash String Symbol Var }.each { |name|
|
149
|
+
eval! %~
|
150
|
+
def #{name}! *args
|
151
|
+
c = Checked::#{name}s.new(*args )
|
152
|
+
val = c.return!
|
153
|
+
val.Checked= c
|
154
|
+
val.return!
|
155
|
+
end
|
156
|
+
~
|
157
|
+
}
|
158
|
+
|
153
159
|
def Stripped! *args
|
154
160
|
v = String!(*args)
|
155
161
|
n = v.strip
|
@@ -157,36 +163,7 @@ class Checked
|
|
157
163
|
n
|
158
164
|
end
|
159
165
|
|
160
|
-
|
161
|
-
name, val = case name_and_or_val.size
|
162
|
-
when 1
|
163
|
-
[ nil, name_and_or_val.first ]
|
164
|
-
when 2
|
165
|
-
name_and_or_val
|
166
|
-
else
|
167
|
-
raise ArgumentError, "Unknown values for name/value: #{name_and_or_val.inspect}"
|
168
|
-
end
|
169
|
-
|
170
|
-
val.Checked=Checked.const_get(ns.to_sym).new
|
171
|
-
val.Checked.target_name = name
|
172
|
-
val.Checked.return! val
|
173
|
-
val.Checked.check!
|
174
|
-
val
|
175
|
-
end
|
176
|
-
|
177
|
-
# ============= Ask ================
|
178
|
-
|
179
|
-
def any? target, *args
|
180
|
-
raise "No block allowed." if block_given?
|
181
|
-
|
182
|
-
args.map { |a|
|
183
|
-
send "#{klass}?", target, a
|
184
|
-
check_it( 'ask', _main_class_(target), nil, target).send( a ).request.response.body
|
185
|
-
}.compact == [true]
|
186
|
-
end
|
187
|
-
|
188
|
-
|
189
|
-
end # === module Rack_Arch
|
166
|
+
end # === module Rack_Arch
|
190
167
|
|
191
168
|
end # === module DSL
|
192
169
|
|
data/lib/Checked/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Checked
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &20014300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *20014300
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bacon
|
27
|
-
requirement: &
|
27
|
+
requirement: &20013620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *20013620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: Bacon_Colored
|
38
|
-
requirement: &
|
38
|
+
requirement: &20012980 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *20012980
|
47
47
|
description: ! "\n Various DSLs to clean, question (Ask), and validate (Demand)
|
48
48
|
your objects,\n their classes (data types), and their properties.\n "
|
49
49
|
email:
|