condition 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9912e8fdea45ff07344c66c7a7b9968c2e5528f0
4
- data.tar.gz: cb3c7b60487f3a1f79d21d3d9cd32d3302b14fbe
3
+ metadata.gz: fb3eb3d5b4acee42ce9121918d0d613ebaed8365
4
+ data.tar.gz: 03e56423e7cbe951ee1689a16d06fc313538bcd3
5
5
  SHA512:
6
- metadata.gz: e535a51008d8386707d41546ab02030ae237ee293b642c3f1c4d8d953da8177c64b28b65e66dd082a0ce01ddacc977277f23e7154488c89951a0141bb588bde0
7
- data.tar.gz: 888b72eb5e372602e7bc67411c7735cffc67a15b5db33484dada9df457aebbccb95b6e264905899a6c8be0e16ef3a935de2c0d01aedb835ea58b8d7662da1d5d
6
+ metadata.gz: 70b5494197bf56f1014513e8f4336fe624f3798aa9ff3d59705dbb73fe2f9840df3fb93bf5fad704aae1a59ce7dcfef70b2ee8d7a6bc721e9fa44f20a695f2ac
7
+ data.tar.gz: 5d6456c00c1cfca1854fb4463eb4e96c921d637c5155282b822ead45c9bfe794e9fe2529d705b93e4d890d04b905b4830c9090e2b32369fac2774affbab22c2d
data/README.md CHANGED
@@ -30,6 +30,9 @@ TODO: Write usage instructions here
30
30
 
31
31
  ## Changes
32
32
 
33
+ 2013-12-03 0.0.15
34
+ add present and regexp check
35
+
33
36
  2013-05-22 0.0.14
34
37
  modify view not match
35
38
 
@@ -75,4 +78,4 @@ add param, param_item
75
78
  delete pre, post, reader, table
76
79
 
77
80
  2013-04-10 0.0.1
78
- first release
81
+ first release
@@ -48,6 +48,8 @@ module Condition
48
48
  Time.parse($1)
49
49
  elsif /^#INT\((.+)\)$/ =~ item
50
50
  $1.to_i
51
+ elsif /^#REGEXP\((.+)\)$/ =~ item
52
+ Regexp.new($1)
51
53
  else
52
54
  item
53
55
  end
@@ -80,8 +82,12 @@ module Condition
80
82
  end
81
83
 
82
84
  def value_match?(expected, real)
83
- if expected == nil && real != nil || expected != nil && real == nil
85
+ if "#PRESENT" == expected
86
+ (!real.nil?) && ("" != real.to_s)
87
+ elsif expected == nil && real != nil || expected != nil && real == nil
84
88
  false
89
+ elsif Regexp === expected
90
+ expected =~ real.to_s
85
91
  elsif Time === real
86
92
  real == Time.parse(expected)
87
93
  elsif nil == real
@@ -157,4 +163,4 @@ module Condition
157
163
  end
158
164
 
159
165
  end
160
- end
166
+ end
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Condition
4
- VERSION = "0.0.14"
4
+ VERSION = "0.0.15"
5
5
  end
@@ -42,6 +42,19 @@ describe Condition do
42
42
  lambda{param.check('unmatch', [{id: 1, name: "bbb", val: 456}])}.should raise_error
43
43
  end
44
44
 
45
+ it 'present' do
46
+ param = Condition::Param.new(FILES + '/t_user.ods', 2)
47
+ param.check('present', [{val1: "a"}])
48
+ lambda{param.check('present', [{val1: ""}])}.should raise_error
49
+ lambda{param.check('present', [{val1: nil}])}.should raise_error
50
+ end
51
+
52
+ it 'regex' do
53
+ param = Condition::Param.new(FILES + '/t_user.ods', 2)
54
+ param.check('regex', [{val1: "abbbbbc"}])
55
+ lambda{param.check('regex', [{val1: "ac"}])}.should raise_error
56
+ end
57
+
45
58
  it 'mongo' do
46
59
  storage = Condition::Storage::Mongo.new(MONGO)
47
60
  param = Condition::Param.new(FILES + '/mongo.ods')
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: condition
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - aoyagikouhei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-29 00:00:00.000000000 Z
11
+ date: 2013-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -179,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  version: '0'
180
180
  requirements: []
181
181
  rubyforge_project:
182
- rubygems_version: 2.0.3
182
+ rubygems_version: 2.1.10
183
183
  signing_key:
184
184
  specification_version: 4
185
185
  summary: Condition Test