lexile 0.0.2 → 0.0.3
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/Gemfile +1 -1
- data/README.md +10 -4
- data/lib/lexile/api/client.rb +18 -20
- data/lib/lexile/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac5798bc6129b6d8a6f76cf3eabe442adfe34e58
|
4
|
+
data.tar.gz: 5465b2574a554aa6bcbebf756143c30e9aa3baed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97f2861d0f7da4650f1378d8e942fb47e9452a5b2fa305bdb0ce2b83e8ba185c4e81d87992121c413d251f79b56f1a57ae9ef11bfbb8258d83c8bab351be2586
|
7
|
+
data.tar.gz: 6943b6c4b4c4711e977d85ce859265d1ba0c7bd28fe385d7ef37c9ddcd71257b571a5a311a2cd039ddfa7d767af4dc242c5ea27214a740beffdb3c85bbf79320
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
[](https://travis-ci.org/Curriculet/Lexile)
|
2
2
|
[](https://codeclimate.com/github/curriculet/lexile)
|
3
|
-
[](https://codeclimate.com/github/curriculet/lexile)
|
4
|
-
[](https://codeclimate.com/github/curriculet/lexile)
|
4
|
+
[](http://badge.fury.io/rb/lexile)
|
5
5
|
|
6
6
|
# Lexile®
|
7
7
|
|
@@ -32,6 +32,12 @@ Or install it yourself as:
|
|
32
32
|
|
33
33
|
$ gem install lexile
|
34
34
|
|
35
|
+
## Configuration
|
36
|
+
Lexile.configure do |c|
|
37
|
+
c.username = <YOUR USERNAME>
|
38
|
+
c.password = <YOUR PASSWORD>
|
39
|
+
end
|
40
|
+
|
35
41
|
## Usage
|
36
42
|
|
37
43
|
>> b = Lexile.books.show("315833")
|
@@ -62,7 +68,7 @@ Or install it yourself as:
|
|
62
68
|
|
63
69
|
## Contributing
|
64
70
|
|
65
|
-
1. Fork it ( http://github.com
|
71
|
+
1. Fork it ( http://github.com/curriculet/lexile/fork )
|
66
72
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
67
73
|
3. Commit your changes and specs(`git commit -am 'Add some feature'`)
|
68
74
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -90,4 +96,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
90
96
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
91
97
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
92
98
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
93
|
-
THE SOFTWARE.
|
99
|
+
THE SOFTWARE.
|
data/lib/lexile/api/client.rb
CHANGED
@@ -21,17 +21,13 @@ module Lexile
|
|
21
21
|
|
22
22
|
if configuration.is_a?(Module) && configuration.to_s == 'Lexile'
|
23
23
|
config = configuration
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
else
|
25
|
+
if configuration.is_a?(Hash)
|
26
|
+
config = Hashie::Mash.new( configuration )
|
27
|
+
config.api_url = [config.endpoint,config.api_version].join('/')
|
28
|
+
end
|
27
29
|
end
|
28
30
|
|
29
|
-
#if config.api_key
|
30
|
-
#self.class.default_params({ 'api_key' => config.api_key})
|
31
|
-
#else
|
32
|
-
#raise Lexile::InvalidCredentials.new("Api Key is not present but it is required.")
|
33
|
-
#end
|
34
|
-
|
35
31
|
self.class.base_uri( config.api_url ) if config.api_url
|
36
32
|
self.class.default_timeout config.timeout.to_f if config.timeout
|
37
33
|
self.class.debug_output if config.testing
|
@@ -51,11 +47,13 @@ module Lexile
|
|
51
47
|
# @return [String]. The raw response body (JSON is expected) Raises appropriate exception if it fails
|
52
48
|
# @raise Lexile::HTTPError when any HTTP error response is received
|
53
49
|
def get( path, params={}, headers={})
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
|
51
|
+
get_args = build_get_args( params, headers)
|
52
|
+
|
53
|
+
yield get_args if block_given?
|
54
|
+
|
57
55
|
#puts "CALLING API: #{Lexile.api_url}#{path} ===#{get_options}"
|
58
|
-
response = self.class.get( path,
|
56
|
+
response = self.class.get( path, get_args)
|
59
57
|
|
60
58
|
case response.code
|
61
59
|
when 200..201
|
@@ -77,15 +75,15 @@ module Lexile
|
|
77
75
|
end
|
78
76
|
end
|
79
77
|
|
80
|
-
#
|
78
|
+
# build_get_args
|
81
79
|
# Build the hash of options for an HTTP get request.
|
82
80
|
#
|
83
81
|
# @param params [Hash] optional. Any query parameters to add to the request.
|
84
82
|
# @param user_headers [Hash] optional. Any query parameters to add to the request.
|
85
83
|
#
|
86
84
|
# @return [Hash] The properly formated get_options.
|
87
|
-
def
|
88
|
-
|
85
|
+
def build_get_args( params={}, user_headers={})
|
86
|
+
get_args = {}
|
89
87
|
query ={ format: 'json'} #all requests get this query params
|
90
88
|
|
91
89
|
query.merge!(params)
|
@@ -94,11 +92,11 @@ module Lexile
|
|
94
92
|
headers ={}
|
95
93
|
headers.merge!( user_headers )
|
96
94
|
|
97
|
-
|
98
|
-
|
99
|
-
|
95
|
+
get_args[:query] = query
|
96
|
+
get_args[:headers] = headers
|
97
|
+
get_args[:basic_auth] = { username: Lexile.options[:username],
|
100
98
|
password: Lexile.options[:password]}
|
101
|
-
|
99
|
+
get_args
|
102
100
|
end
|
103
101
|
end
|
104
102
|
end
|
data/lib/lexile/version.rb
CHANGED