Checked 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/Checked/Arch.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  class Checked
2
2
 
3
3
  module Arch
4
- include DSL::Ruby
4
+ include DSL::Racked
5
5
 
6
6
  def self.included klass
7
7
  klass.send :include, Sin_Arch::Arch
@@ -4,6 +4,13 @@ class Checked
4
4
  class Strings < Sinatra::Base
5
5
 
6
6
  include Checked::Arch
7
+
8
+ private
9
+ def strippable_route?
10
+ params['name'][%r![^\?\!]\Z!] && !%w{chop_slash_r}.include?(params['name'])
11
+ end
12
+
13
+ public
7
14
 
8
15
  map '/string!'
9
16
 
@@ -11,10 +18,6 @@ class Checked
11
18
  def strip_val
12
19
  return!( return!.strip ) if strippable_route?
13
20
  end
14
-
15
- def strippable_route?
16
- params['name'][%r![^\?\!]\Z!] && !%w{chop_slash_r}.include?(params['name'])
17
- end
18
21
 
19
22
  get
20
23
  def untar
data/lib/Checked/DSL.rb CHANGED
@@ -90,24 +90,11 @@ class Checked
90
90
 
91
91
  module Ruby
92
92
 
93
- def demand *args
94
- case args.size
95
- when 2
96
- bool, raw_msg = args
97
- msg = raw_msg.sub(%r!\A\.\.\.!, "#{target_name || return!.class}, #{return!.inspect}, ")
98
- fail!(msg) unless bool
99
- return!
100
- when 3
101
- val, bool, raw_msg = args
102
- if respond_to?(:return!) && return! == val
103
- return demand( bool, raw_msg )
104
- end
105
- msg = raw_msg.sub(%r!\A\.\.\.!, "#{val.class}, #{val.inspect}, ")
106
- fail!(msg) unless bool
107
- val
108
- else
109
- raise ArgumentError, "Too many arguments: #{args.inspect}"
110
- end
93
+ def demand val, bool, raw_msg
94
+ return val if bool
95
+
96
+ fail! raw_msg.sub(%r!\A\.\.\.!, "#{val.class}, #{val.inspect}, ")
97
+ val
111
98
  end
112
99
 
113
100
  def fail! msg
@@ -197,10 +184,27 @@ class Checked
197
184
  end
198
185
  ~
199
186
  }
187
+
188
+ def demand *pars
189
+ if pars.size == 2
190
+ val = return!
191
+ bool, raw_msg = pars
192
+ elsif respond_to?(:return!) && return! == pars[0]
193
+ val, bool, raw_msg = pars
194
+ else
195
+ return super
196
+ end
197
+
198
+ msg = raw_msg.sub(%r!\A\.\.\.!, "#{target_name || return!.class}, #{return!.inspect}, ")
199
+
200
+ super( return!, bool, msg )
201
+ end
200
202
 
201
203
  def Stripped! *args
202
204
  v = String!(*args)
203
- String!(v.strip)
205
+ n = v.strip
206
+ n.Checked<< v.Checked
207
+ n
204
208
  end
205
209
 
206
210
  def Check! ns, *name_and_or_val
@@ -1,5 +1,5 @@
1
1
  require 'Sin_Arch'
2
2
 
3
3
  class Checked < Sinatra::Base
4
- VERSION = "2.0.1"
4
+ VERSION = "2.0.2"
5
5
  end
data/spec/tests/DSL.rb CHANGED
@@ -101,6 +101,9 @@ describe "Stripped!" do
101
101
  Stripped!(" n ").empty?.should.be === false
102
102
  end
103
103
 
104
+ it 'returns string with original name' do
105
+ Stripped!("Test String", 'test').Checked.name.should == 'Test String'
106
+ end
104
107
 
105
108
  end # === describe Stripped!
106
109
 
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: 2.0.1
4
+ version: 2.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-01-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: Sin_Arch
16
- requirement: &20263140 !ruby/object:Gem::Requirement
16
+ requirement: &7738600 !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: :runtime
23
23
  prerelease: false
24
- version_requirements: *20263140
24
+ version_requirements: *7738600
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &20261900 !ruby/object:Gem::Requirement
27
+ requirement: &7738060 !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: *20261900
35
+ version_requirements: *7738060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bacon
38
- requirement: &20260680 !ruby/object:Gem::Requirement
38
+ requirement: &7737440 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *20260680
46
+ version_requirements: *7737440
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: Bacon_Colored
49
- requirement: &20258300 !ruby/object:Gem::Requirement
49
+ requirement: &7736560 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *20258300
57
+ version_requirements: *7736560
58
58
  description: ! "\n Various DSLs to clean, question (Ask), and validate (Demand)
59
59
  your objects,\n their classes (data types), and their properties.\n "
60
60
  email: