infostrada 0.1.1 → 0.1.2

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: 0400ee91f7d81abbcb4e4497725a576da61c80fe
4
- data.tar.gz: a1365e64e78f37720d3d2e3342e50c17d5cba1f4
3
+ metadata.gz: 9cb216bea03a16c37f03cca2c416d543d5bdf7de
4
+ data.tar.gz: 89d9960e4d39a615f6c586865e00ca13d809a324
5
5
  SHA512:
6
- metadata.gz: cbd07f6433f35d2127380ef0146388add157c878c4e3b893e1f0feb13f64eac037832b42eaf72198f2da5ef17d7621dd8a5da1a6b114f6e09c1f0ba416c07adc
7
- data.tar.gz: c18b1bf31061cf68423209d9845af9e54825054adc935899d3b9b7c860e7755d7d963188a6acd80420ccfd7f207c5c38c26a826159ef9d63e8a09b8214a8aa23
6
+ metadata.gz: 69159ff76dac53119ce4f3c9aa6f8fe31d284a92010cd154ea7cc1e77f27dcb71459244be674ba3da9e180d3c7d36b724c48c522e5e04fae2f62575c74dc71df
7
+ data.tar.gz: 45cc35ea3bfd1af4135e85042d61109a066651e0bcead9b2c504a584e1f47dfb97f7edebe5430768eca9954b280be665080b5d9255211ab23473800bec5da870
data/Gemfile.lock CHANGED
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- infostrada (0.1.0)
4
+ infostrada (0.1.1)
5
5
  colored (~> 1.2)
6
6
  eventmachine (~> 1.0, >= 1.0.3)
7
7
  httparty (~> 0.13, >= 0.13.0)
8
- tzinfo (~> 0.3.37)
8
+ tzinfo (~> 0.3, >= 0.3.37)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
@@ -6,12 +6,12 @@ module Infostrada
6
6
  include HTTParty
7
7
 
8
8
  # How many times should we retry the request if Timeout::Error is raised?
9
- RETRIES = 5
9
+ RETRIES = Infostrada.configuration.retries || 5
10
10
 
11
11
  # Uncomment to debug HTTParty calls.
12
12
  # debug_output $stdout
13
13
 
14
- basic_auth 'APIdemo', 'saTo1991W&dy'
14
+ basic_auth Infostrada.configuration.username, Infostrada.configuration.password
15
15
 
16
16
  # The default format of the requests. Used on HTTP header 'Content-Type'.
17
17
  format :json
@@ -33,7 +33,7 @@ module Infostrada
33
33
  default_params languageCode: 2
34
34
 
35
35
  # Default request timeout in seconds. This can be overriden by module configuration.
36
- default_timeout 15
36
+ default_timeout Infostrada.configuration.timeout || 15
37
37
 
38
38
  # Disable the use of rails query string format.
39
39
  #
@@ -1,3 +1,3 @@
1
1
  module Infostrada
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
data/lib/infostrada.rb CHANGED
@@ -2,6 +2,42 @@ require 'rubygems'
2
2
 
3
3
  require 'httparty'
4
4
 
5
+ module Infostrada
6
+ # The configuration of the API requests.
7
+ class Configuration
8
+ attr_reader :username, :password, :timeout, :retries
9
+
10
+ def username=(username)
11
+ BaseRequest.default_options[:basic_auth].merge!(username: username)
12
+ @username = username
13
+ end
14
+
15
+ def password=(password)
16
+ BaseRequest.default_options[:basic_auth].merge!(password: password)
17
+ @password = password
18
+ end
19
+
20
+ def timeout=(timeout)
21
+ BaseRequest.default_options[:basic_auth].merge!(password: password)
22
+ @timeout = timeout
23
+ end
24
+
25
+ def retries=(retries)
26
+ @retries = retries
27
+ end
28
+ end
29
+
30
+ class << self
31
+ def configuration
32
+ @configuration ||= Configuration.new
33
+ end
34
+
35
+ def configure
36
+ yield(configuration)
37
+ end
38
+ end
39
+ end
40
+
5
41
  require 'infostrada/core_ext/string'
6
42
 
7
43
  require 'infostrada/competition'
@@ -29,46 +65,4 @@ require 'infostrada/person_info'
29
65
 
30
66
  require 'infostrada/call_refresh'
31
67
 
32
- require 'infostrada/version'
33
-
34
- module Infostrada
35
- # The configuration of the API requests. This configuration is also shared by
36
- # <Infostrada::BaseRequest> where the HTTParty configuration is done.
37
- class Configuration
38
- attr_reader :user, :password, :timeout, :timezone
39
-
40
- def initialize
41
- BaseRequest.default_options[:basic_auth] ||= {}
42
- end
43
-
44
- def user=(user)
45
- BaseRequest.default_options[:basic_auth].merge!(username: user)
46
- @user = user
47
- self
48
- end
49
-
50
- def password=(password)
51
- BaseRequest.default_options[:basic_auth].merge!(password: password)
52
- @password = password
53
- self
54
- end
55
-
56
- def timeout=(timeout)
57
- BaseRequest.default_options[:timeout] = timeout
58
- @timeout = timeout
59
- self
60
- end
61
- end
62
-
63
- def self.configuration
64
- @configuration ||= Configuration.new
65
- end
66
-
67
- def self.endpoints
68
- @endpoints ||= []
69
- end
70
-
71
- def self.configure
72
- yield(configuration) if block_given?
73
- end
74
- end
68
+ require 'infostrada/version'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infostrada
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Otero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-07 00:00:00.000000000 Z
11
+ date: 2014-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler