condition 0.0.28 → 0.0.29

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: 5a71ca9f6eeadb13b4693a1225abb81daf9aac06
4
- data.tar.gz: 5c5bc5b440e4df1144986b9ed14a86a12c66e9fd
3
+ metadata.gz: dc140f7ce336d58df81295af5edbab22002dccd6
4
+ data.tar.gz: fcbf594d790d3912d2b7f197ef88c9460a068ff4
5
5
  SHA512:
6
- metadata.gz: f034d5dae5c0b284d232fb5d28c54e8b5e5a192401f36f796f96570c8bda4db2390e24438cf5930803f7d9324292b4557a7c1715440bd75c95f3ac7bace0e591
7
- data.tar.gz: c8b61d6e3da820a82aa467607ba15f8f78fc50126d0c5e5b0e2b4df07b5d00a51ca30336dc8d4dbb889db6011bbbdb555ce72d633ed7fe24ed24537792eba0fc
6
+ metadata.gz: c206bdb9382adc94c87a1eb7244673ef554df14a905920b8601968f06847ecfe93f2b04cc732a4da6004932144f20a4f18a9c4bad2534fd3fa44045bdde62395
7
+ data.tar.gz: 6febe78e3c5cd4669a296e7c67f03cd27f3eb84a9ec468ce15f73778d2339450cc79dcd0047d2a109968caba8df8d37501bc679dfd5b6730bca0bc76b3652355
data/README.md CHANGED
@@ -30,6 +30,9 @@ TODO: Write usage instructions here
30
30
 
31
31
  ## Changes
32
32
 
33
+ 2014-08-19 0.0.29
34
+ add activerecord storage
35
+
33
36
  2014-02-19 0.0.28
34
37
  modify bug order check in no options
35
38
 
@@ -0,0 +1,64 @@
1
+ module Condition
2
+ module Storage
3
+ class RailsDb
4
+ LOG_NAME = 'SQL'
5
+
6
+ def initialize(db: nil)
7
+ @conn = db.nil? ? ActiveRecord::Base.connection : db
8
+ end
9
+
10
+ def commit
11
+ @conn.commit_db_transaction
12
+ end
13
+
14
+ def all(param_item)
15
+ sql = "SELECT * FROM #{param_item.name}"
16
+ res = exec(sql)
17
+ res.to_hash
18
+ end
19
+
20
+ def delete(param_item)
21
+ sql = "DELETE FROM #{param_item.name}"
22
+ exec sql
23
+ end
24
+
25
+ def insert(param_item, default)
26
+ default_item = default.item(param_item.name) if default
27
+ prms = default_item ? default_item.params.merge(param_item.params) : param_item.params
28
+ i1 = ''
29
+ prms.each_pair do |k, v|
30
+ if i1 != ''
31
+ i1 = i1 + ', '
32
+ end
33
+ i1 = i1 + k.to_s
34
+ end
35
+ param_item.values.each do |it|
36
+ prms = default_item ? default_item.value.merge(it) : it
37
+ ary = []
38
+ prms.each_pair do |k, v|
39
+ ary << quote_value(v)
40
+ end
41
+ i2 = ary.join(',')
42
+ sql = "INSERT INTO #{param_item.name.to_s} (#{i1}) VALUES (#{i2})"
43
+ exec sql
44
+ end
45
+ end
46
+
47
+ def exec_after(param_item)
48
+ param_item.options.each do |key|
49
+ exec key
50
+ end
51
+ end
52
+
53
+ private
54
+ def quote_value(val)
55
+ v = val.gsub(/'/, "''")
56
+ "'#{v}'"
57
+ end
58
+
59
+ def exec(sql)
60
+ @conn.exec_query(sql, LOG_NAME, [])
61
+ end
62
+ end
63
+ end
64
+ end
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Condition
4
- VERSION = "0.0.28"
4
+ VERSION = "0.0.29"
5
5
  end
@@ -194,6 +194,15 @@ describe Condition do
194
194
  {val1: "1", val2: "2"},
195
195
  {val1: "1", val2: "1"},
196
196
  ])
197
+
198
+ expect do
199
+ param.check('output_order', [
200
+ {val1: "1", val2: "4"},
201
+ {val1: "1", val2: "2"},
202
+ {val1: "1", val2: "3"},
203
+ {val1: "1", val2: "1"},
204
+ ])
205
+ end.to raise_error
197
206
  end
198
207
 
199
208
  end
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.28
4
+ version: 0.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - aoyagikouhei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-18 00:00:00.000000000 Z
11
+ date: 2014-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -171,6 +171,7 @@ files:
171
171
  - lib/condition/reader/roo_reader.rb
172
172
  - lib/condition/storage/db.rb
173
173
  - lib/condition/storage/mongo.rb
174
+ - lib/condition/storage/rails_db.rb
174
175
  - lib/condition/version.rb
175
176
  - spec/condition_spec.rb
176
177
  - spec/files/mongo.ods
@@ -198,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
199
  version: '0'
199
200
  requirements: []
200
201
  rubyforge_project:
201
- rubygems_version: 2.2.2
202
+ rubygems_version: 2.4.1
202
203
  signing_key:
203
204
  specification_version: 4
204
205
  summary: Condition Test