enrichment_db 0.1.13 → 0.1.14

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: a737f15fb5aadd35c06a71fc51b3ef9405263b4f
4
- data.tar.gz: efa874a6971330e778cbc7208de3570bb9506a77
3
+ metadata.gz: 784632b18200a93e79ba0e9411dad4fa8fbba1f7
4
+ data.tar.gz: 22e53ab18054544013097f19600306f030bb270a
5
5
  SHA512:
6
- metadata.gz: 3a02a38e45100ecb1384ada2e32378d7f8344a0284f6d3b3487b33044b1db1e6e8b423549082a994d122f7f0f57bbb4df627b88735c6aeb19485d0897fbf6faf
7
- data.tar.gz: 1d5fa5bc513ff0f9988a7ccd6422ea889154d15d7f9745d7223be2b5db4c7de6eb53cbd6337f0d8d087a5f227cc36c9db63690a2c150ef13148472923891e480
6
+ metadata.gz: 1c16290deff38ea9f34469e63227a9f20a80821217d106e4371cfcfbbeb91f93e3a66b77f889f991de05ef1fd6baf9d4854afa4ed68150303682748bc678151b
7
+ data.tar.gz: ecd9cd06d69fc6356b9042fdc300291f46a8c06bfa2fc16e74b869357e2d9508b57b46dc96a74a9baa567503a2118b6dbe558cd0b0d1682ce22c6623abe803c7
@@ -41,7 +41,9 @@ module EnrichmentDb
41
41
 
42
42
  case type
43
43
  when :select, 'select', '\d'
44
- get_or_request(query, values)
44
+ return EnrichmentDb::db_connection.exec(query, values) if values
45
+
46
+ EnrichmentDb::db_connection.exec(query)
45
47
  when :insert, :drop, :delete, 'insert', 'drop', 'delete'
46
48
  fail EnrichmentDb::RequestError, "Postgres method '#{type}' is unsupported"
47
49
  else
@@ -49,18 +51,6 @@ module EnrichmentDb
49
51
  end
50
52
  end
51
53
 
52
- def self.get_or_request(query, values = nil)
53
- result = EnrichmentDb::Cache.get(query, values)
54
- return result unless result.nil?
55
-
56
- result = if values
57
- EnrichmentDb::db_connection.exec(query, values)
58
- else
59
- EnrichmentDb::db_connection.exec(query)
60
- end
61
- EnrichmentDb::Cache.set(query, values, result)
62
- end
63
-
64
54
  def self.request_type(query)
65
55
  result = query.downcase.match(/(^(?:drop|select|insert|delete|\\d))/)
66
56
  return unless result
@@ -1,3 +1,3 @@
1
1
  module EnrichmentDb
2
- VERSION = '0.1.13'
2
+ VERSION = '0.1.14'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enrichment_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Wallis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-25 00:00:00.000000000 Z
11
+ date: 2016-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -69,7 +69,6 @@ files:
69
69
  - lib/enrichment_db/.DS_Store
70
70
  - lib/enrichment_db/ato.rb
71
71
  - lib/enrichment_db/ato/datum.rb
72
- - lib/enrichment_db/cache.rb
73
72
  - lib/enrichment_db/census.rb
74
73
  - lib/enrichment_db/census/datum.rb
75
74
  - lib/enrichment_db/datum.rb
@@ -89,7 +88,6 @@ files:
89
88
  - lib/enrichment_db/language.rb
90
89
  - lib/enrichment_db/language/datum.rb
91
90
  - lib/enrichment_db/version.rb
92
- - test/cache_test.rb
93
91
  - test/census/datum_test.rb
94
92
  - test/datum_test.rb
95
93
  - test/db_test.rb
@@ -140,7 +138,6 @@ test_files:
140
138
  - lib/enrichment_db/.DS_Store
141
139
  - lib/enrichment_db/ato.rb
142
140
  - lib/enrichment_db/ato/datum.rb
143
- - lib/enrichment_db/cache.rb
144
141
  - lib/enrichment_db/census.rb
145
142
  - lib/enrichment_db/census/datum.rb
146
143
  - lib/enrichment_db/datum.rb
@@ -160,7 +157,6 @@ test_files:
160
157
  - lib/enrichment_db/language.rb
161
158
  - lib/enrichment_db/language/datum.rb
162
159
  - lib/enrichment_db/version.rb
163
- - test/cache_test.rb
164
160
  - test/census/datum_test.rb
165
161
  - test/datum_test.rb
166
162
  - test/db_test.rb
@@ -1,17 +0,0 @@
1
- $LOAD_PATH.unshift("#{File.dirname(__FILE__)}")
2
-
3
- module EnrichmentDb::Cache
4
- def self.get(query, values = nil)
5
- query_cache(query, values)
6
- end
7
-
8
- def self.set(query, values = nil, result = nil)
9
- query_cache(query, values, result)
10
- end
11
-
12
- def self.query_cache(query, values, result = nil)
13
- key = query + values.to_s
14
- @query_cache ||= {}
15
- @query_cache[key] ||= result
16
- end
17
- end
data/test/cache_test.rb DELETED
@@ -1,31 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/test_helper"
2
-
3
- describe EnrichmentDb::Cache do
4
- before do
5
- EnrichmentDb::Cache.instance_variable_set(:@query_cache, nil)
6
- end
7
-
8
- it 'should return nil as value hasn\'t been set when no values' do
9
- query = 'do stuff'
10
- assert_nil EnrichmentDb::Cache.get(query)
11
- end
12
-
13
- it 'should return nil as value hasn\'t been set when non-empty values' do
14
- query = 'do stuff'
15
- values = ['er']
16
- assert_nil EnrichmentDb::Cache.get(query, values)
17
- end
18
-
19
- it 'should set value on cache and get it' do
20
- query = 'do stuff'
21
- values = ['er']
22
- record = 'This here is a gut dang it record'
23
- set_result = EnrichmentDb::Cache.set(query, values, record)
24
-
25
- get_result = EnrichmentDb::Cache.set(query, values)
26
-
27
- refute_nil set_result
28
- refute_nil get_result
29
- assert_equal set_result, get_result
30
- end
31
- end