prolenea 0.1.6 → 0.1.7

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: 95dd963629ded0c8be266348b42edbee701bbc53
4
- data.tar.gz: 596900a000e6d91a43f5a05e043fe7eb9065da48
3
+ metadata.gz: f14e65123f0c90425e0dce900e0b77e848f9957f
4
+ data.tar.gz: 1682edbcb29dcb9497828cd20df667a7b3e8f447
5
5
  SHA512:
6
- metadata.gz: dffbdb0add81e757612a72e60192df1b4dfffdb7779be42c9d7e32bb8bfa02e850ea64428dacc4fb7cd0fecd13bfaa779b7f9486b1dc6b1fb1111ca082ee188d
7
- data.tar.gz: 51d317cf5c3f10cca59830641285f09bb9315a07e7987cb69a03493c41a1e292ac6c43e607b25a7354510888fdb947c47dafcdcc8fd3758ae2ce695a3929ea7a
6
+ metadata.gz: cf514838418638329181a70fa701c69eb2159deaf895c274e12594c1d007e84d2bbdecd5c0930a419b0bed4fcd4629528433c2d6570dadd4e52d7cc0a9a60041
7
+ data.tar.gz: 826ecd0918f98ad47fcebfb351040befb4315b8d38799645fc6ff2299bee8fc202379d279d7a76dcc15bb8b75cec36db004ed8c39fb0b50c333a1cd9e791f116
data/README.md CHANGED
@@ -35,8 +35,8 @@ puts JSON.pretty_generate result
35
35
  ```javascript
36
36
  {
37
37
  "number": "2125551000",
38
- "local_routing_number": null,
39
- "ported_date": null,
38
+ "local_routing_number": "6465550000",
39
+ "ported_date": "2015-07-09T15:00:00-05:00",
40
40
  "alternative_spid": null,
41
41
  "alternative_spid_name": null,
42
42
  "line_type": null,
@@ -17,6 +17,10 @@ OptionParser.new do |opts|
17
17
  opts.on("-n", "--number Number", String, "Number to lookup") do |number|
18
18
  options[:number] = number
19
19
  end
20
+
21
+ opts.on("-c", "--console") do
22
+ options[:console] = true
23
+ end
20
24
  end.parse!
21
25
 
22
26
  begin
@@ -25,9 +29,12 @@ begin
25
29
 
26
30
  Prolenea.connect config
27
31
 
28
- result = Prolenea.lookup_number number
29
-
30
- puts JSON.pretty_generate result
32
+ if options[:console]
33
+ pry.binding
34
+ elsif number
35
+ result = Prolenea.lookup_number(number)
36
+ puts JSON.pretty_generate result
37
+ end
31
38
  rescue ProleneaError => pe
32
39
  STDERR.puts pe.message
33
40
  STDERR.puts pe.backtrace.join("\n")
@@ -9,13 +9,18 @@ require 'prolenea/middleware/prolenea_response_middleware'
9
9
  module Prolenea
10
10
  include Error
11
11
 
12
+ DEFAULT_TIMEOUT = 10
13
+
12
14
  module ClassMethods
13
15
 
16
+ attr_accessor :default_timeout
17
+
14
18
  def connection
15
- @connection ? @connection : (raise ProleneaNoConnectionError)
19
+ @connection ? @connection : (raise ProleneaNoConnectionError.new({}), 'Connection is not setup')
16
20
  end
17
21
 
18
22
  def connect(config = {})
23
+ @default_timeout = config[:default_timeout] || DEFAULT_TIMEOUT
19
24
  @connection = Connection.new(:uri => config[:uri])
20
25
  end
21
26
 
@@ -23,10 +28,10 @@ module Prolenea
23
28
  !@connection.nil?
24
29
  end
25
30
 
26
- def lookup_number(number)
31
+ def lookup_number(number, options = {})
27
32
  params = {:dial => number}
28
33
 
29
- response = self.connection.get '/', params
34
+ response = self.connection.get '/', params, options
30
35
 
31
36
  response.env[:parsed_body]
32
37
  rescue ProleneaError => pe
@@ -51,6 +51,9 @@ module Prolenea
51
51
  request.body = params unless params.empty?
52
52
  end
53
53
 
54
+ request.options[:timeout] = (options[:timeout] ? options[:timeout] : Prolenea.default_timeout)
55
+ request.options[:open_timeout] = (options[:open_timeout] ? options[:open_timeout] : Prolenea.default_timeout)
56
+
54
57
  request
55
58
  end
56
59
 
@@ -1,3 +1,3 @@
1
1
  module Prolenea
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prolenea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Larrimore