esv_api 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.md +7 -0
- data/README.md +0 -4
- data/esv_api.gemspec +1 -1
- data/lib/esv_api/client.rb +28 -1
- data/lib/esv_api/version.rb +1 -1
- data/spec/esv_api/client_spec.rb +1 -1
- metadata +7 -6
data/LICENSE.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2012 Jeff McFadden
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
data/esv_api.gemspec
CHANGED
data/lib/esv_api/client.rb
CHANGED
@@ -3,6 +3,17 @@ require 'esv_api/config'
|
|
3
3
|
require 'httparty'
|
4
4
|
|
5
5
|
module ESV
|
6
|
+
begin
|
7
|
+
require "dalli"
|
8
|
+
HAS_DALLI = true
|
9
|
+
rescue LoadError
|
10
|
+
HAS_DALLI = false
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.should_cache?
|
14
|
+
HAS_DALLI
|
15
|
+
end
|
16
|
+
|
6
17
|
# Wrapper for the ESV API
|
7
18
|
#
|
8
19
|
class Client
|
@@ -20,6 +31,10 @@ module ESV
|
|
20
31
|
Config::VALID_OPTIONS_KEYS.each do |key|
|
21
32
|
instance_variable_set("@#{key}".to_sym, attrs[key])
|
22
33
|
end
|
34
|
+
|
35
|
+
if ESV.should_cache?
|
36
|
+
@dc = Dalli::Client.new('localhost:11211')
|
37
|
+
end
|
23
38
|
end
|
24
39
|
|
25
40
|
def passage_query(passage, options={})
|
@@ -30,7 +45,19 @@ module ESV
|
|
30
45
|
|
31
46
|
query = options.merge( query )
|
32
47
|
|
33
|
-
ESV
|
48
|
+
if ESV.should_cache?
|
49
|
+
cache_key = Digest::MD5.hexdigest( "esv_api_" + query.to_s )
|
50
|
+
|
51
|
+
cached_value = @dc.get( cache_key )
|
52
|
+
|
53
|
+
return cached_value unless cached_value.nil?
|
54
|
+
end
|
55
|
+
|
56
|
+
esv_text = ESV::Client.get( self.endpoint + '/passageQuery', { :query => query } )
|
57
|
+
|
58
|
+
@dc.set( cache_key, esv_text ) if ESV.should_cache?
|
59
|
+
|
60
|
+
return esv_text
|
34
61
|
end
|
35
62
|
|
36
63
|
def query( q, options={} )
|
data/lib/esv_api/version.rb
CHANGED
data/spec/esv_api/client_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: esv_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-26 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &70177774736500 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70177774736500
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70177774736080 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70177774736080
|
36
36
|
description: ESV API Wrapper.
|
37
37
|
email:
|
38
38
|
- jeff@forgeapps.com
|
@@ -42,6 +42,7 @@ extra_rdoc_files: []
|
|
42
42
|
files:
|
43
43
|
- .gitignore
|
44
44
|
- Gemfile
|
45
|
+
- LICENSE.md
|
45
46
|
- README.md
|
46
47
|
- Rakefile
|
47
48
|
- esv_api.gemspec
|