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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b3572b7bf5426c44e0887f4c77425129a96fd3d
4
- data.tar.gz: e7e3897e33a3c90d8d83bd63e3c5b04b7d11430a
3
+ metadata.gz: ac5798bc6129b6d8a6f76cf3eabe442adfe34e58
4
+ data.tar.gz: 5465b2574a554aa6bcbebf756143c30e9aa3baed
5
5
  SHA512:
6
- metadata.gz: 9d503217391a94ffe678eb940d0037557c32a5f9faf194f018c3f1065009ea61ffb266422f5bafa612894106ec24d968db3798852f3b23ef10b345d3cb7eacf3
7
- data.tar.gz: b0aea8b1285bf7c94cca0fc3431e32d6e36bc2bac1be29489c9bab0ac833db4aa810550d30c239f6111a1a635553f033fa6d4ea8a3554ea28ae8c96d571b00f5
6
+ metadata.gz: 97f2861d0f7da4650f1378d8e942fb47e9452a5b2fa305bdb0ce2b83e8ba185c4e81d87992121c413d251f79b56f1a57ae9ef11bfbb8258d83c8bab351be2586
7
+ data.tar.gz: 6943b6c4b4c4711e977d85ce859265d1ba0c7bd28fe385d7ef37c9ddcd71257b571a5a311a2cd039ddfa7d767af4dc242c5ea27214a740beffdb3c85bbf79320
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'httparty', '~> 0.10'
7
- gem 'hashie', '~> 2.0'
7
+ gem 'hashie'
8
8
 
9
9
  group :development, :test do
10
10
  gem 'rspec', '~> 2'
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  [![Build Status](https://travis-ci.org/curriculet/lexile.svg?branch=master)](https://travis-ci.org/Curriculet/Lexile)
2
2
  [![Code Climate](https://codeclimate.com/github/curriculet/lexile/badges/gpa.svg)](https://codeclimate.com/github/curriculet/lexile)
3
- [![Test Coverage](https://codeclimate.com/github/curriculet/lexile/badges/coverage.svg)](https://codeclimate.com/github/curriculet/lexile)
4
- [![GitHub version](https://badge.fury.io/gh/curriculet%2Flexile.svg)](http://badge.fury.io/gh/curriculet%2Flexile)
3
+ [![Test Coverage](https://codeclimate.com/github/curriculet/lexile/badges/coverage.svg)](https://codeclimate.com/github/curriculet/lexile)
4
+ [![Gem Version](https://badge.fury.io/rb/lexile.svg)](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/<my-github-username>/lexile/fork )
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.
@@ -21,17 +21,13 @@ module Lexile
21
21
 
22
22
  if configuration.is_a?(Module) && configuration.to_s == 'Lexile'
23
23
  config = configuration
24
- elsif configuration.is_a?(Hash)
25
- config = Hashie::Mash.new( configuration )
26
- config.api_url = [config.endpoint,config.api_version].join('/')
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
- get_options = build_get_options( params, headers)
55
- yield get_options if block_given?
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, get_options)
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
- # build_get_options
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 build_get_options( params={}, user_headers={})
88
- get_options = {}
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
- get_options[:query] = query
98
- get_options[:headers] = headers
99
- get_options[:basic_auth] = { username: Lexile.options[:username],
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
- get_options
99
+ get_args
102
100
  end
103
101
  end
104
102
  end
@@ -1,3 +1,3 @@
1
1
  module Lexile
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lexile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mauricio Alvarez