condition 0.0.20 → 0.0.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1600a1f079b5dda433b728ebcefd9f31e9341074
4
- data.tar.gz: baead12e5cb94c49937c7fb63ba0203bf4885c55
3
+ metadata.gz: a35a3befff8b198904309c0b89f9aefd3e7882f4
4
+ data.tar.gz: 4464c12614d73dd49721c9feb5db1ac28efd1f02
5
5
  SHA512:
6
- metadata.gz: 94272e37d660028c6799028690d59c9f19ee6bad37e6cba832a654453f23415a24cd3130f8a5b7f895cc46e86b4790d0bf2ffeba25ee807bac851ff6f3d3f4a1
7
- data.tar.gz: fda4ea6d4f5e3d5af1f8a76cc437f25cf36c13ec507325887569a31cc71f1969f25b4821679bb5345a888309d9fbdb48f5dc6993e42be154e42dc5916a4e45da
6
+ metadata.gz: 2a6c22a9ec01f890b6b1b987a2990064cee78700963088bdf44c6b3e79f03ba14607b6382f1fa213bc7b72572b8ce30c72da6c602cfcf2858a821e5ee6c6a171
7
+ data.tar.gz: cf32216dd84543a2ed579050a222ac3d30bf0b7f48fef5e6abee7d97c081e272892bd95e1e06dc0471b034edf1defe1b96a8f0d7be4834bcaf0e731ba8629aad
data/README.md CHANGED
@@ -30,6 +30,10 @@ TODO: Write usage instructions here
30
30
 
31
31
  ## Changes
32
32
 
33
+ 2013-12-13 0.0.21
34
+ bugfix options array
35
+ bugfix check_line over or lack
36
+
33
37
  2013-12-13 0.0.20
34
38
  check redis key not found
35
39
 
@@ -50,9 +50,11 @@ module Condition
50
50
 
51
51
  def check(name, data)
52
52
  item = item(name)
53
+ item.clear_used_values
53
54
  data.each do |line|
54
55
  item.check_line(line)
55
56
  end
57
+ raise "#{item.name} not exists row" if item.is_remain_value
56
58
  end
57
59
 
58
60
  def pre(storage, default=nil)
@@ -6,7 +6,7 @@ module Condition
6
6
  class ParamItem
7
7
  def initialize(rows)
8
8
  @name = rows[0][0].to_sym
9
- @options = rows[0].size > 1 ? rows[0][1..rows.size - 1] : []
9
+ @options = rows[0].size > 1 ? rows[0][1..rows[0].size - 1] : []
10
10
  body = rows[1..rows.size - 1]
11
11
  @values = []
12
12
  @keys = []
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Condition
4
- VERSION = "0.0.20"
4
+ VERSION = "0.0.21"
5
5
  end
@@ -35,9 +35,14 @@ describe Condition do
35
35
  ds = DB[:t_user].prepare(:insert, :insert_with_name, item.params.merge({user_id: :$user_id, user_name: :$user_name}))
36
36
  ds.call(item.value.merge(param.get('ins', 0)))
37
37
 
38
- list = DB["SELECT * FROM t_user"].all
38
+ list = DB["SELECT * FROM t_user order by user_id"].all
39
39
  param.check('list', list)
40
- param.check('list', [{user_id: 1, user_name: "aaax"}])
40
+ param.check('list', [
41
+ {user_id: 1, user_name: "aaax"},
42
+ {user_id: 2, user_name: "bbbx"},
43
+ {user_id: 3, user_name: "cccx"},
44
+ {user_id: 4, user_name: "ddd"},
45
+ ])
41
46
  end
42
47
 
43
48
  it 'ref and json' do
@@ -117,4 +122,24 @@ describe Condition do
117
122
  Condition::Param.set_reader(nil)
118
123
  expect { Condition::Param.new('files_aaa', reader: reader) }.to raise_error("redis key name files_aaa not found")
119
124
  end
125
+
126
+ it 'output count' do
127
+ reader = Condition::Reader::RedisReader.new(REDIS)
128
+ Condition::Param.set_reader(nil)
129
+ param = Condition::Param.new('files_t_user_params', reader: reader)
130
+
131
+ param.check('output_count', [{l: [{id: "1"}, {id: "2"}, {id: "3"}]}])
132
+ expect { param.check('output_count', [{id: "1"}, {id: "2"}]) }.to raise_error
133
+ expect { param.check('output_count', [{id: "1"}, {id: "2"}, {id: "3"}, {id: "4"}]) }.to raise_error
134
+ end
135
+
136
+ it 'options count' do
137
+ reader = Condition::Reader::RedisReader.new(REDIS)
138
+ Condition::Param.set_reader(nil)
139
+ param = Condition::Param.new('files_t_user_params', reader: reader)
140
+
141
+ item = param.item('options')
142
+ expect(item.options.length).to eq(4)
143
+ end
144
+
120
145
  end
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.20
4
+ version: 0.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - aoyagikouhei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-12 00:00:00.000000000 Z
11
+ date: 2013-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler