gros_calin 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/gros_calin/mongo_db.rb +0 -12
- data/lib/gros_calin/mysql.rb +7 -1
- data/lib/gros_calin/version.rb +1 -1
- data/spec/gros_calin/mysql_spec.rb +4 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c825532ba96f60bba20e1d6a05345b34d20566e3
|
4
|
+
data.tar.gz: 6b42917a9047f6037121e0c9d2f25d3b9d0dbfc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21d3741c1b3876a7613a2eeac6c415ada85c47e74e607566671fb33a36b59eca7fdea463728f86ec0298eb91d86176f734e032e421bd901d7c753027e1aa2a67
|
7
|
+
data.tar.gz: 8730aae78b1318d512d9c8e9d0f580950b8f007bc668e1fe43df3b296df9bc41cfa8c4e65c164b9113ce8043090e4e7d0ee5a2c318a9d5e3409f22095dc8396d
|
data/README.md
CHANGED
@@ -70,7 +70,7 @@ myapp_datasource:
|
|
70
70
|
password: "secret"
|
71
71
|
database: "myapp"
|
72
72
|
hugs:
|
73
|
-
sign_ups: "SELECT count(id) AS sign_ups, country_code FROM users WHERE created_at DATE_SUB( NOW(), INTERVAL 24 HOUR) GROUP by country_code;"
|
73
|
+
sign_ups: "SELECT count(id) AS sign_ups, country_code FROM users WHERE created_at > DATE_SUB( NOW(), INTERVAL 24 HOUR) GROUP by country_code;"
|
74
74
|
# another_datasource:
|
75
75
|
```
|
76
76
|
|
data/lib/gros_calin/mongo_db.rb
CHANGED
@@ -27,18 +27,6 @@ module GrosCalin
|
|
27
27
|
yield session
|
28
28
|
end
|
29
29
|
|
30
|
-
def mandatory(options, attr)
|
31
|
-
raise "\"#{attr}\" has not been specified" unless options[attr]
|
32
|
-
options[attr]
|
33
|
-
end
|
34
|
-
|
35
|
-
def whitelist(query)
|
36
|
-
query.select{|descriptor|
|
37
|
-
name = descriptor.is_a?(Hash) && descriptor.keys.first || descriptor
|
38
|
-
ALLOWED_METHODS.include?(name)
|
39
|
-
}
|
40
|
-
end
|
41
|
-
|
42
30
|
end
|
43
31
|
|
44
32
|
rescue LoadError
|
data/lib/gros_calin/mysql.rb
CHANGED
@@ -9,7 +9,13 @@ module GrosCalin
|
|
9
9
|
register 'mysql'
|
10
10
|
|
11
11
|
def query(id, sql)
|
12
|
-
Mysql2::Client.new(@options).query(sql).
|
12
|
+
Mysql2::Client.new(@options).query(sql).map do |row|
|
13
|
+
{}.tap do |result|
|
14
|
+
row.each do|key, value|
|
15
|
+
result[key] = value.is_a?(BigDecimal) ? value.to_f : value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
13
19
|
end
|
14
20
|
end
|
15
21
|
|
data/lib/gros_calin/version.rb
CHANGED
@@ -9,9 +9,10 @@ describe GrosCalin::Mysql do
|
|
9
9
|
it 'queries the database' do
|
10
10
|
Mysql2::Client.expects(:new).with(options={an_option: 1}).
|
11
11
|
returns(client=mock)
|
12
|
-
client.expects(:query).with('select').
|
13
|
-
|
14
|
-
subject.new(options).query('id', 'select').
|
12
|
+
client.expects(:query).with('select').
|
13
|
+
returns(result=[{ 'id'=>1, 'value'=>BigDecimal.new(0.0075, 2) }])
|
14
|
+
subject.new(options).query('id', 'select').
|
15
|
+
must_equal [{'id'=>1, 'value'=> 0.0075}]
|
15
16
|
end
|
16
17
|
|
17
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gros_calin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jef Mathiot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|