thebigdb 1.3.0 → 1.4.0
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 +4 -4
- data/README.md +23 -3
- data/lib/thebigdb.rb +2 -1
- data/lib/thebigdb/request.rb +1 -1
- data/lib/thebigdb/version.rb +1 -1
- data/thebigdb.gemspec +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 497657ac10b1d270d7a6827074c8f24bc00bc31c
|
4
|
+
data.tar.gz: d21318628a21382b4d99dc28e84ee50dbcccf539
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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|
|
data/lib/thebigdb/request.rb
CHANGED
@@ -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 =
|
91
|
+
@http_response = TheBigDB.http_request_executor.call(@http, @http_request)
|
92
92
|
|
93
93
|
# Setting @response
|
94
94
|
begin
|
data/lib/thebigdb/version.rb
CHANGED
data/thebigdb.gemspec
CHANGED
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.
|
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-
|
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: []
|