condition 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/condition.gemspec +1 -1
- data/lib/condition/param.rb +6 -6
- data/lib/condition/param_item.rb +2 -23
- data/lib/condition/storage/db.rb +36 -0
- data/lib/condition/version.rb +1 -1
- data/spec/condition_spec.rb +5 -3
- data/spec/spec_helper.rb +2 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9ac4108f5c2b04fafdc90724e8f8b52c7b90c2d
|
4
|
+
data.tar.gz: f40b96478445f6dabd7e5b7816f566428de235a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10869fa4ba4ccb3b0cf550120e2d8c1d61e27c417dc268cfb892e29e241da1aea54d464986899d8daba6718a3dda9274c32a8a06ee337456ddedfd9548703426
|
7
|
+
data.tar.gz: 618c9f8738a6e655fb29be2087adc7d47a0228c7d8e93302301f02503a890852e72a65ed821bc3cd01197a6c424df69939904320f5711cf872e4bb33974f83dd
|
data/README.md
CHANGED
data/condition.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
24
|
spec.add_development_dependency "pg"
|
25
|
+
spec.add_development_dependency "sequel"
|
25
26
|
spec.add_dependency "roo"
|
26
|
-
spec.add_dependency "sequel"
|
27
27
|
spec.add_dependency "json"
|
28
28
|
end
|
data/lib/condition/param.rb
CHANGED
@@ -65,17 +65,17 @@ module Condition
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
def pre(
|
68
|
+
def pre(storage, default=nil)
|
69
69
|
@item_map.each_value do |item|
|
70
|
-
|
71
|
-
|
72
|
-
|
70
|
+
storage.delete(item)
|
71
|
+
storage.insert(item, default)
|
72
|
+
storage.exec_after(item)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
def post(
|
76
|
+
def post(storage)
|
77
77
|
@item_map.each_value do |item|
|
78
|
-
list =
|
78
|
+
list = storage.all(item)
|
79
79
|
list.each do |line|
|
80
80
|
item.check_line(line)
|
81
81
|
end
|
data/lib/condition/param_item.rb
CHANGED
@@ -67,29 +67,8 @@ module Condition
|
|
67
67
|
@params
|
68
68
|
end
|
69
69
|
|
70
|
-
def
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
def delete(db)
|
75
|
-
db["DELETE FROM #{@name}"].delete
|
76
|
-
end
|
77
|
-
|
78
|
-
def insert(db, default)
|
79
|
-
item = default.item(@name) if default
|
80
|
-
ds = db[@name.to_sym].prepare(
|
81
|
-
:insert,
|
82
|
-
:insert_with_name,
|
83
|
-
item ? item.params.merge(@params) : @params)
|
84
|
-
@values.each do |it|
|
85
|
-
ds.call(item ? item.value.merge(it) : it)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def exec_after(db)
|
90
|
-
@options.each do |key|
|
91
|
-
db.run key
|
92
|
-
end
|
70
|
+
def options
|
71
|
+
@options
|
93
72
|
end
|
94
73
|
|
95
74
|
def value_match?(expected, real)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Condition
|
4
|
+
module Storage
|
5
|
+
class Db
|
6
|
+
def initialize(db)
|
7
|
+
@db = db
|
8
|
+
end
|
9
|
+
|
10
|
+
def all(param_item)
|
11
|
+
@db["SELECT * FROM #{param_item.name}"].all
|
12
|
+
end
|
13
|
+
|
14
|
+
def delete(param_item)
|
15
|
+
@db["DELETE FROM #{param_item.name}"].delete
|
16
|
+
end
|
17
|
+
|
18
|
+
def insert(param_item, default)
|
19
|
+
default_item = default.item(param_item.name) if default
|
20
|
+
ds = @db[param_item.name.to_sym].prepare(
|
21
|
+
:insert,
|
22
|
+
:insert_with_name,
|
23
|
+
default_item ? default_item.params.merge(param_item.params) : param_item.params)
|
24
|
+
param_item.values.each do |it|
|
25
|
+
ds.call(default_item ? default_item.value.merge(it) : it)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def exec_after(param_item)
|
30
|
+
param_item.options.each do |key|
|
31
|
+
@db.run key
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/condition/version.rb
CHANGED
data/spec/condition_spec.rb
CHANGED
@@ -8,17 +8,19 @@ describe Condition do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'pre and post' do
|
11
|
+
storage = Condition::Storage::Db.new(DB)
|
11
12
|
param = Condition::Param.new(FILES + '/t_user.ods')
|
12
13
|
default = Condition::Param.new(FILES + '/t_user.ods', 3)
|
13
|
-
param.pre(
|
14
|
+
param.pre(storage, default)
|
14
15
|
param = Condition::Param.new(FILES + '/t_user.ods', 1)
|
15
|
-
param.post(
|
16
|
+
param.post(storage)
|
16
17
|
end
|
17
18
|
|
18
19
|
it 'pre and params' do
|
20
|
+
storage = Condition::Storage::Db.new(DB)
|
19
21
|
param = Condition::Param.new(FILES + '/t_user.ods')
|
20
22
|
default = Condition::Param.new(FILES + '/t_user.ods', 3)
|
21
|
-
param.pre(
|
23
|
+
param.pre(storage, default)
|
22
24
|
|
23
25
|
param = Condition::Param.new(FILES + '/t_user.ods', 2)
|
24
26
|
item = default.item('t_user')
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aoyagikouhei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-04-
|
11
|
+
date: 2013-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,13 +67,13 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: sequel
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
|
-
type: :
|
76
|
+
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: roo
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - '>='
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/condition.rb
|
125
125
|
- lib/condition/param.rb
|
126
126
|
- lib/condition/param_item.rb
|
127
|
+
- lib/condition/storage/db.rb
|
127
128
|
- lib/condition/version.rb
|
128
129
|
- spec/condition_spec.rb
|
129
130
|
- spec/files/t_user.ods
|