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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 068346818b05d9f0259cddf533796e7f5f308f97
4
- data.tar.gz: 0ad382b15559c8b0348819116597b93d057c3686
3
+ metadata.gz: 2cdd1c79b2ffd46742f13ea245d2f517037583ce
4
+ data.tar.gz: 6be888eda78740456c97dea11044ef35a8462845
5
5
  SHA512:
6
- metadata.gz: f5b260e21e77aeb155ba30ba499f5cddd6472211c80dcfb705af77159eae04786a870ee0de02cc920b399526eedd9edbfc1992b6d4d516e1f7cc4ed411e261f9
7
- data.tar.gz: 508b0461bfcdd916cb51f53f3a2909c37c08d75afeb2edb31497be78f3a05253fa9d8a786011ee6f53c58664582247119b9d7475e2ab9e6d0a2c41f7e217a6d4
6
+ metadata.gz: 07301944d677ed583f27b3f1b94662f0363c7657d098a57101d0ceae05f2d09e32cd3122296601d557feef6e16c51f579819b0ebd6dd6c282531c19a6c885de0
7
+ data.tar.gz: 7e2848125e2848358b2d65f4a769cfcc1209b3ac5821be7f1dba7132d607a1c393f7b6c40d084a7536e731ba3254759f60cd90a39884adacf1a599f50c9ec0f9
data/README.md CHANGED
@@ -34,6 +34,7 @@ end
34
34
 
35
35
  client = Evostream::Client.new
36
36
  client.liststreams
37
+ ```
37
38
 
38
39
  ## Contributing
39
40
 
data/evostream.gemspec CHANGED
@@ -22,5 +22,4 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
24
  spec.add_development_dependency "webmock"
25
- spec.add_runtime_dependency "rest-client"
26
25
  end
@@ -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? ? encode_params(args.first) : {}
25
- response = RestClient.get(service_url(method), { :params => params })
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 service_url(service)
36
- "#{base_url}/#{service}"
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
- base64_params = Base64.encode64(params.collect {|k, v| "#{k}=#{v}" }.join(' ')).chomp
45
- { :params => base64_params }
58
+ Base64.encode64(params.map {|k, v| "#{k}=#{v}" }.join(' ')).chomp
46
59
  end
47
60
 
48
61
  end # Client
@@ -1,4 +1,4 @@
1
1
  # coding: utf-8
2
2
  module Evostream
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
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.1
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-01 00:00:00.000000000 Z
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