evostream 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Dockerfile +7 -0
- data/README.md +18 -0
- data/docker-compose.yml +15 -0
- data/evostream.gemspec +5 -1
- data/lib/evostream/client.rb +5 -2
- data/lib/evostream/configuration.rb +12 -1
- data/lib/evostream/version.rb +1 -1
- data/spec/client_spec.rb +30 -0
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 691b18e5956fbe15ec386296740bc4da5fa561ea
|
4
|
+
data.tar.gz: 092e0bb15101b4b4469a330732295d9bb77ecaf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cfae522284c3d9869ed1a3893d82920e8a61f3fa81191058c4e6e88a308ef707f1a73fc786b78f07b0f3dd9d971871eaf14fca8c2a65cdf0ec3c3bea7667e94
|
7
|
+
data.tar.gz: 540a86b8f618438eb3fdf5c85aab2c14c0997604eb52147713e3a089d29ec3756e588ab65920bac2495edda68b4211b20665c0705ad6cdff64e7869f58597d7b
|
data/Dockerfile
ADDED
data/README.md
CHANGED
@@ -37,6 +37,14 @@ Evostream.configure do |config|
|
|
37
37
|
config.host = 'evostream.example.com'
|
38
38
|
config.port = 80
|
39
39
|
config.path_prefix = '/evo'
|
40
|
+
|
41
|
+
# Set the username and password when using http basic auth
|
42
|
+
# config.username = 'evostream'
|
43
|
+
# config.password = 'passw0rd'
|
44
|
+
|
45
|
+
# Set the protocol and port for using HTTPS
|
46
|
+
# config.protocol = 'https'
|
47
|
+
# config.port = 443
|
40
48
|
end
|
41
49
|
|
42
50
|
# elsewhere
|
@@ -45,6 +53,16 @@ client = Evostream::Client.new
|
|
45
53
|
client.liststreams
|
46
54
|
```
|
47
55
|
|
56
|
+
## Running tests
|
57
|
+
|
58
|
+
### Local
|
59
|
+
|
60
|
+
$ bundle exec rake spec
|
61
|
+
|
62
|
+
### Docker
|
63
|
+
|
64
|
+
$ docker-compose run --rm test
|
65
|
+
|
48
66
|
## Contributing
|
49
67
|
|
50
68
|
1. Fork it
|
data/docker-compose.yml
ADDED
data/evostream.gemspec
CHANGED
@@ -22,5 +22,9 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "rake", "~> 10.3"
|
23
23
|
spec.add_development_dependency "rspec", "~> 2.14"
|
24
24
|
spec.add_development_dependency "webmock", "~> 1.13"
|
25
|
-
|
25
|
+
if RUBY_VERSION >= '2.0'
|
26
|
+
spec.add_development_dependency "byebug", "~> 9.0"
|
27
|
+
else
|
28
|
+
spec.add_development_dependency "debugger", "~> 1.6"
|
29
|
+
end
|
26
30
|
end
|
data/lib/evostream/client.rb
CHANGED
@@ -43,7 +43,10 @@ module Evostream
|
|
43
43
|
http = Net::HTTP.new(uri.host, uri.port)
|
44
44
|
http.read_timeout = @timeout
|
45
45
|
http.open_timeout = @timeout
|
46
|
-
http.
|
46
|
+
http.use_ssl = true if @protocol == "https"
|
47
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
48
|
+
request.basic_auth(@username, @password)
|
49
|
+
http.request(request)
|
47
50
|
end
|
48
51
|
|
49
52
|
def service_url(service, params)
|
@@ -56,7 +59,7 @@ module Evostream
|
|
56
59
|
end
|
57
60
|
|
58
61
|
def base_url
|
59
|
-
"
|
62
|
+
"#{@protocol}://#{@host}:#{@port}#{@path_prefix}"
|
60
63
|
end
|
61
64
|
|
62
65
|
def encode_params(params)
|
@@ -1,11 +1,16 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
module Evostream
|
3
3
|
module Configuration
|
4
|
-
VALID_CONFIG_KEYS = [
|
4
|
+
VALID_CONFIG_KEYS = [
|
5
|
+
:host, :protocol, :port, :path_prefix, :timeout, :username, :password
|
6
|
+
].freeze
|
5
7
|
OPTIONAL_CONFIG_KEYS = VALID_CONFIG_KEYS - [:host]
|
6
8
|
|
9
|
+
DEFAULT_PROTOCOL = 'http'
|
7
10
|
DEFAULT_PORT = 80
|
8
11
|
DEFAULT_PATH_PREFIX = ''
|
12
|
+
DEFAULT_USERNAME = ''
|
13
|
+
DEFAULT_PASSWORD = ''
|
9
14
|
DEFAULT_TIMEOUT = 5
|
10
15
|
|
11
16
|
# Build accessor methods for every config options so we can do this, for example:
|
@@ -18,8 +23,11 @@ module Evostream
|
|
18
23
|
end
|
19
24
|
|
20
25
|
def reset
|
26
|
+
self.protocol = DEFAULT_PROTOCOL
|
21
27
|
self.port = DEFAULT_PORT
|
22
28
|
self.path_prefix = DEFAULT_PATH_PREFIX
|
29
|
+
self.username = DEFAULT_USERNAME
|
30
|
+
self.password = DEFAULT_PASSWORD
|
23
31
|
self.timeout = DEFAULT_TIMEOUT
|
24
32
|
end
|
25
33
|
|
@@ -27,8 +35,11 @@ module Evostream
|
|
27
35
|
#
|
28
36
|
# Evostream.configure do |config|
|
29
37
|
# config.host = 'evostream.example.com'
|
38
|
+
# config.protocol = 'http'
|
30
39
|
# config.port = 80
|
31
40
|
# config.path_prefix = '/evo'
|
41
|
+
# config.username = 'evo'
|
42
|
+
# config.password = 'password'
|
32
43
|
# end
|
33
44
|
#
|
34
45
|
# elsewhere
|
data/lib/evostream/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -70,6 +70,36 @@ describe Evostream::Client do
|
|
70
70
|
WebMock.should have_requested(:get, "http://somehost:80/some_path/some_service?params=Zmlyc3RfcGFyYW09eHh4IHNlY29uZF9wYXJhbT14eHggdGhpcmRfcGFyYW09eHh4")
|
71
71
|
end
|
72
72
|
|
73
|
+
describe "https" do
|
74
|
+
it "should be able to specify https as protocol" do
|
75
|
+
auth_evo = Evostream::Client.new({
|
76
|
+
:host => 'somehost',
|
77
|
+
:path_prefix => '/some_path',
|
78
|
+
:protocol => 'https',
|
79
|
+
:port => '443'
|
80
|
+
})
|
81
|
+
stub_request(:get, /.*some_service.*/).
|
82
|
+
to_return(status: 200, body: '{"data":null,"description":"","status":"SUCCESS"}')
|
83
|
+
auth_evo.some_service(:first_param => 'xxx', :second_param => 'xxx', :third_param => 'xxx')
|
84
|
+
WebMock.should have_requested(:get, "https://somehost:443/some_path/some_service?params=Zmlyc3RfcGFyYW09eHh4IHNlY29uZF9wYXJhbT14eHggdGhpcmRfcGFyYW09eHh4")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "basic auth" do
|
89
|
+
it "should encode the username and the password to support basic auth" do
|
90
|
+
auth_evo = Evostream::Client.new({
|
91
|
+
:host => 'somehost',
|
92
|
+
:path_prefix => '/some_path',
|
93
|
+
:username => 'user',
|
94
|
+
:password => 'password'
|
95
|
+
})
|
96
|
+
stub_request(:get, /.*some_service.*/).
|
97
|
+
to_return(status: 200, body: '{"data":null,"description":"","status":"SUCCESS"}')
|
98
|
+
auth_evo.some_service(:first_param => 'xxx', :second_param => 'xxx', :third_param => 'xxx')
|
99
|
+
WebMock.should have_requested(:get, "http://user:password@somehost:80/some_path/some_service?params=Zmlyc3RfcGFyYW09eHh4IHNlY29uZF9wYXJhbT14eHggdGhpcmRfcGFyYW09eHh4")
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
73
103
|
describe "timeout" do
|
74
104
|
before do
|
75
105
|
WebMock.allow_net_connect!
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evostream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Mundim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,19 +67,19 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.13'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: byebug
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '9.0'
|
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: '
|
82
|
+
version: '9.0'
|
83
83
|
description: Ruby wrapper for the Evostream API
|
84
84
|
email:
|
85
85
|
- lucas.mundim@corp.globo.com
|
@@ -92,10 +92,12 @@ files:
|
|
92
92
|
- ".ruby-gemset"
|
93
93
|
- ".ruby-version"
|
94
94
|
- ".travis.yml"
|
95
|
+
- Dockerfile
|
95
96
|
- Gemfile
|
96
97
|
- LICENSE.txt
|
97
98
|
- README.md
|
98
99
|
- Rakefile
|
100
|
+
- docker-compose.yml
|
99
101
|
- evostream.gemspec
|
100
102
|
- lib/evostream.rb
|
101
103
|
- lib/evostream/client.rb
|
@@ -125,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
127
|
version: '0'
|
126
128
|
requirements: []
|
127
129
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.6.6
|
129
131
|
signing_key:
|
130
132
|
specification_version: 4
|
131
133
|
summary: Ruby wrapper for the Evostream API
|