evostream 0.0.5 → 0.0.6

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: 14ea04b4151d2d2a9ef074f7f004b89432188d85
4
- data.tar.gz: 974e7fc12371d28fc283e14ff369ba24a7088d3e
3
+ metadata.gz: 0e76ba8eccda48e9ec79ec46cbba0a238fb82d80
4
+ data.tar.gz: 0cc754e2467f0b99ae948b169f96b5243a0a38e9
5
5
  SHA512:
6
- metadata.gz: d85030f211c44b27dd65ebdf9e331aa299ab1a023f9bde2d91f8d6b4dba7785b4eaab5d40fe3f15410aac8c3a86d714ad20d30b213f9bbd1068f82cfc39da00a
7
- data.tar.gz: 10b3452d3c8b4be7bc352709a46797d569ef0a0a72b703f3d04297a31c146c7287ca88f6fa32cba0e5e55efa8674f4923e31dcd6bd462ca4fb1441309740ea0c
6
+ metadata.gz: 175350db99016bc504e363e2b52464a18a431b16d0f4420ce57018ad2bb2712e8e8445149108ada538dd75df276ce6271e1bc4c59bdf6541713b6cb89591fe34
7
+ data.tar.gz: b0bf1cb3763f61940a519666dd090e335cac9338cab0505f2bb23a3bafa2918711508957470b62d72e8f3e0f7b8258c742c602c61da2c76541f817dee310b9ae
data/evostream.gemspec CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec"
24
- spec.add_development_dependency "webmock"
25
- spec.add_development_dependency "debugger"
22
+ spec.add_development_dependency "rake", "~> 10.3"
23
+ spec.add_development_dependency "rspec", "~> 2.14"
24
+ spec.add_development_dependency "webmock", "~> 1.13"
25
+ spec.add_development_dependency "debugger", "~> 1.6"
26
26
  end
@@ -2,6 +2,7 @@
2
2
  require 'base64'
3
3
  require 'json'
4
4
  require 'net/http'
5
+ require 'debugger'
5
6
 
6
7
  module Evostream
7
8
  class Client
@@ -39,8 +40,11 @@ module Evostream
39
40
  end
40
41
 
41
42
  def api_call(method, params)
42
- url = URI.parse(service_url(method, params))
43
- Net::HTTP.get_response(url)
43
+ uri = URI.parse(service_url(method, params))
44
+ http = Net::HTTP.new(uri.host, uri.port)
45
+ http.read_timeout = @timeout
46
+ http.open_timeout = @timeout
47
+ http.request_get(uri.request_uri)
44
48
  end
45
49
 
46
50
  def service_url(service, params)
@@ -1,11 +1,12 @@
1
1
  # coding: utf-8
2
2
  module Evostream
3
3
  module Configuration
4
- VALID_CONFIG_KEYS = [:host, :port, :path_prefix].freeze
4
+ VALID_CONFIG_KEYS = [:host, :port, :path_prefix, :timeout].freeze
5
5
  OPTIONAL_CONFIG_KEYS = VALID_CONFIG_KEYS - [:host]
6
6
 
7
7
  DEFAULT_PORT = 80
8
8
  DEFAULT_PATH_PREFIX = ''
9
+ DEFAULT_TIMEOUT = 5
9
10
 
10
11
  # Build accessor methods for every config options so we can do this, for example:
11
12
  # Evostream.host = 'evostream.example.com'
@@ -19,6 +20,7 @@ module Evostream
19
20
  def reset
20
21
  self.port = DEFAULT_PORT
21
22
  self.path_prefix = DEFAULT_PATH_PREFIX
23
+ self.timeout = DEFAULT_TIMEOUT
22
24
  end
23
25
 
24
26
  # config/initializers/evostream.rb (for instance)
@@ -1,4 +1,4 @@
1
1
  # coding: utf-8
2
2
  module Evostream
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
data/spec/client_spec.rb CHANGED
@@ -69,4 +69,26 @@ describe Evostream::Client do
69
69
  subject.some_service(:first_param => 'xxx', :second_param => 'xxx', :third_param => 'xxx')
70
70
  WebMock.should have_requested(:get, "http://somehost:80/some_path/some_service?params=Zmlyc3RfcGFyYW09eHh4IHNlY29uZF9wYXJhbT14eHggdGhpcmRfcGFyYW09eHh4")
71
71
  end
72
+
73
+ describe "timeout" do
74
+ before do
75
+ WebMock.allow_net_connect!
76
+ end
77
+
78
+ after do
79
+ WebMock.disable_net_connect!
80
+ end
81
+
82
+ it "should be able to specify a timeout value" do
83
+ evo = Evostream::Client.new(:host => '10.10.10.10', :path_prefix => '/some_path', :timeout => 1)
84
+ expect { evo.liststreams }.to raise_error(Net::OpenTimeout)
85
+ end
86
+
87
+ it "should timeout by the default timeout value (#{Evostream::Configuration::DEFAULT_TIMEOUT})" do
88
+ start = Time.now
89
+ evo = Evostream::Client.new(:host => '10.10.10.10', :path_prefix => '/some_path')
90
+ expect { evo.liststreams }.to raise_error(Net::OpenTimeout)
91
+ expect(Time.now - start).to be < (Evostream::Configuration::DEFAULT_TIMEOUT + 0.01)
92
+ end
93
+ end
72
94
  end
metadata CHANGED
@@ -1,85 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evostream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Mundim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-05 00:00:00.000000000 Z
11
+ date: 2014-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '10.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '10.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '2.14'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '2.14'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: webmock
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '1.13'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '1.13'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: debugger
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '1.6'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '1.6'
83
83
  description: Ruby wrapper for the Evostream API
84
84
  email:
85
85
  - lucas.mundim@corp.globo.com
@@ -87,11 +87,11 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
91
- - .rspec
92
- - .ruby-gemset
93
- - .ruby-version
94
- - .travis.yml
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".ruby-gemset"
93
+ - ".ruby-version"
94
+ - ".travis.yml"
95
95
  - Gemfile
96
96
  - LICENSE.txt
97
97
  - README.md
@@ -115,17 +115,17 @@ require_paths:
115
115
  - lib
116
116
  required_ruby_version: !ruby/object:Gem::Requirement
117
117
  requirements:
118
- - - '>='
118
+ - - ">="
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - '>='
123
+ - - ">="
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.0.3
128
+ rubygems_version: 2.2.2
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Ruby wrapper for the Evostream API