thebigdb 1.3.0 → 1.4.0

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: 208086548323d779597adb12e40c415503bb4dc8
4
- data.tar.gz: 3b2ed441b52ac2c9c386f8652f8cb16c7ca5fc45
3
+ metadata.gz: 497657ac10b1d270d7a6827074c8f24bc00bc31c
4
+ data.tar.gz: d21318628a21382b4d99dc28e84ee50dbcccf539
5
5
  SHA512:
6
- metadata.gz: 84e73081cd80956a93279d9582d88c8e5fe96697563f93734c123510ec289c1446a45c99300f317af0b5698eedbdc6b417f032578c5fc20af132933b9501c6f0
7
- data.tar.gz: 786aaa6c59bb08c373a8b896397738f99408944111d5a5bc05ece4fde65a607230f8f21b5d91a0c0a46d43c16d06b5f067de6545e97af332b974508e5ab02bbe
6
+ metadata.gz: 02ab00730de9b280d70d3fe8c3bfee5806ee363d574df346c843b41b77a2fc0c3f26346627859fd186d062802002d05e062c53983f124cd556ecb78c7227da89
7
+ data.tar.gz: cc76d9296128d5b537d4e6fdba61bf2f27eeed2f27710462e617c614b1e719a09bbf68c1b591ee7e06f8dbe7f384894c99e08cecb878a40e90a9a38c76934417
data/README.md CHANGED
@@ -72,15 +72,35 @@ You can modify the TheBigDB module with several configuration options:
72
72
  # your code here
73
73
  end
74
74
 
75
+ ### Caching
76
+
77
+ If you want to cache the http requests made, you can change the option ``http_request_executor``:
78
+
79
+ TheBigDB.http_request_executor # default: Proc.new {|http, http_request| http.request(http_request) }
80
+
81
+ If you're using Rails caching system, you may want to do something like this:
82
+
83
+ TheBigDB.http_request_executor = Proc.new do |http, http_request|
84
+ cache_key = "thebigdb-request-" + Digest::SHA1.hexdigest(Marshal.dump(http_request))
85
+
86
+ marshalled_response = Rails.cache.fetch(cache_key) do
87
+ Marshal.dump(http.request(http_request))
88
+ end
89
+
90
+ Marshal.load(marshalled_response)
91
+ end
92
+
93
+ Please remember that all the callbacks (``before_request_execution`` and ``after_request_execution``) will still be executed: ``http_request_executor`` only surrounds the actual execution of the http request by the ``http`` object.
75
94
 
76
95
  ## Contributing
77
96
 
78
97
  Don't hesitate to send a pull request !
79
98
 
80
99
  ## Testing
81
-
82
- rspec spec/
100
+
101
+ $ bundle install
102
+ $ bundle exec rspec spec/
83
103
 
84
104
  ## License
85
105
 
86
- This software is distributed under the MIT License. Copyright (c) 2013, Christophe Maximin <christophe@thebigdb.com>
106
+ This software is distributed under the MIT License. Copyright (c) 2013-2014, Christophe Maximin <christophe@thebigdb.com>
data/lib/thebigdb.rb CHANGED
@@ -25,7 +25,8 @@ module TheBigDB
25
25
  "verify_ssl_certificates" => false,
26
26
  "before_request_execution" => Proc.new{},
27
27
  "after_request_execution" => Proc.new{},
28
- "raise_on_api_status_error" => false
28
+ "raise_on_api_status_error" => false,
29
+ "http_request_executor" => Proc.new {|http, http_request| http.request(http_request) }
29
30
  }
30
31
 
31
32
  DEFAULT_CONFIGURATION.each_key do |configuration_key|
@@ -88,7 +88,7 @@ module TheBigDB
88
88
  TheBigDB.before_request_execution.call(self)
89
89
 
90
90
  # Here is where the request is actually executed
91
- @http_response = @http.request(@http_request)
91
+ @http_response = TheBigDB.http_request_executor.call(@http, @http_request)
92
92
 
93
93
  # Setting @response
94
94
  begin
@@ -1,7 +1,7 @@
1
1
  module TheBigDB
2
2
  module VERSION
3
3
  MAJOR = 1
4
- MINOR = 3
4
+ MINOR = 4
5
5
  TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].compact.join('.')
data/thebigdb.gemspec CHANGED
@@ -9,6 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.authors = ["Christophe Maximin"]
10
10
  s.email = "christophe@thebigdb.com"
11
11
  s.homepage = "http://thebigdb.com"
12
+ s.licenses = ['MIT']
12
13
 
13
14
  s.platform = Gem::Platform::RUBY
14
15
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thebigdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christophe Maximin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-03 00:00:00.000000000 Z
11
+ date: 2014-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -154,7 +154,8 @@ files:
154
154
  - spec/thebigdb_spec.rb
155
155
  - thebigdb.gemspec
156
156
  homepage: http://thebigdb.com
157
- licenses: []
157
+ licenses:
158
+ - MIT
158
159
  metadata: {}
159
160
  post_install_message:
160
161
  rdoc_options: []