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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e9911878ada221b8a707fa6626c4cf2083f7b40
4
- data.tar.gz: 1be92956f8bde24a2287ccca3c98546c961cebf4
3
+ metadata.gz: c825532ba96f60bba20e1d6a05345b34d20566e3
4
+ data.tar.gz: 6b42917a9047f6037121e0c9d2f25d3b9d0dbfc2
5
5
  SHA512:
6
- metadata.gz: 36334f95dea98b136880b993a5ee6efb6278fd26649a7c718556ee619a564aa77fbdef7d63a02b1a453cf4377da9bb4e12befb832d5da3061bffcad4f70dc7f2
7
- data.tar.gz: 8da0eaeb57a448fcda3e270696c13e73c0aaf23da966a6a50fae8652971cf77fc306a5994003b80e077794c183000b684ccb585083fbf442d2ef1e8b8991f437
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
 
@@ -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
@@ -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).each
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
 
@@ -1,3 +1,3 @@
1
1
  module GrosCalin
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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').returns(result=mock)
13
- result.expects(:each).returns(data=[])
14
- subject.new(options).query('id', 'select').must_equal data
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.2
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-05 00:00:00.000000000 Z
11
+ date: 2015-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler