evostream 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/evostream.gemspec +0 -1
- data/lib/evostream/client.rb +20 -7
- data/lib/evostream/version.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cdd1c79b2ffd46742f13ea245d2f517037583ce
|
4
|
+
data.tar.gz: 6be888eda78740456c97dea11044ef35a8462845
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07301944d677ed583f27b3f1b94662f0363c7657d098a57101d0ceae05f2d09e32cd3122296601d557feef6e16c51f579819b0ebd6dd6c282531c19a6c885de0
|
7
|
+
data.tar.gz: 7e2848125e2848358b2d65f4a769cfcc1209b3ac5821be7f1dba7132d607a1c393f7b6c40d084a7536e731ba3254759f60cd90a39884adacf1a599f50c9ec0f9
|
data/README.md
CHANGED
data/evostream.gemspec
CHANGED
data/lib/evostream/client.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
require 'base64'
|
3
|
-
require 'rest-client'
|
4
3
|
require 'json'
|
4
|
+
require 'net/http'
|
5
5
|
|
6
6
|
module Evostream
|
7
7
|
class Client
|
@@ -21,8 +21,8 @@ module Evostream
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def method_missing(method, *args)
|
24
|
-
params = !args.empty? ?
|
25
|
-
response =
|
24
|
+
params = !args.empty? ? args.first : {}
|
25
|
+
response = api_call(method, params)
|
26
26
|
json = JSON.parse(response.body)
|
27
27
|
if json['status'] == 'SUCCESS'
|
28
28
|
json['data']
|
@@ -32,8 +32,22 @@ module Evostream
|
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
35
|
-
def
|
36
|
-
|
35
|
+
def api_call(method, params)
|
36
|
+
url = URI.parse(service_url(method, params))
|
37
|
+
request = Net::HTTP::Get.new(url.to_s)
|
38
|
+
response = Net::HTTP.start(url.host, url.port) {|http|
|
39
|
+
http.request(request)
|
40
|
+
}
|
41
|
+
response
|
42
|
+
end
|
43
|
+
|
44
|
+
def service_url(service, params)
|
45
|
+
url = "#{base_url}/#{service}"
|
46
|
+
unless params.empty?
|
47
|
+
url + "?params=#{encode_params(params)}"
|
48
|
+
else
|
49
|
+
url
|
50
|
+
end
|
37
51
|
end
|
38
52
|
|
39
53
|
def base_url
|
@@ -41,8 +55,7 @@ module Evostream
|
|
41
55
|
end
|
42
56
|
|
43
57
|
def encode_params(params)
|
44
|
-
|
45
|
-
{ :params => base64_params }
|
58
|
+
Base64.encode64(params.map {|k, v| "#{k}=#{v}" }.join(' ')).chomp
|
46
59
|
end
|
47
60
|
|
48
61
|
end # Client
|
data/lib/evostream/version.rb
CHANGED
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Mundim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rest-client
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
description: Ruby wrapper for the Evostream API
|
84
70
|
email:
|
85
71
|
- lucas.mundim@corp.globo.com
|