eshq 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/eshq.gemspec CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  # specify any dependencies here; for example:
22
22
  s.add_development_dependency "mocha"
23
23
  s.add_development_dependency "timecop"
24
+ s.add_development_dependency "fakeweb"
24
25
 
25
26
  s.add_runtime_dependency "json"
26
27
  end
data/lib/eshq/client.rb CHANGED
@@ -8,20 +8,22 @@ module ESHQ
8
8
  attr_reader :url, :key, :secret
9
9
 
10
10
  def initialize(url, api_key, api_secret)
11
+ puts "NEW"
11
12
  @url = url
12
13
  @key = api_key
13
14
  @secret = api_secret
14
15
  end
15
16
 
16
- def get(path, params = {})
17
- uri = url_for(path)
18
- uri.query = params.merge(credentials).map {|k,v| [k, "=", v].join }.join("&")
19
- response = Net::HTTP.get_response(uri)
20
- response.body
21
- end
22
-
23
17
  def post(path, params)
24
- response = Net::HTTP.post_form(url_for(path), params.merge(credentials))
18
+ url = url_for(path)
19
+
20
+ request = Net::HTTP::Post.new(url.path)
21
+ request.set_form_data(params.merge(credentials))
22
+
23
+ http = Net::HTTP.new(url.host, url.port)
24
+ http.use_ssl = true if url.scheme == "https"
25
+
26
+ response = http.request(request)
25
27
  if response.code == "200"
26
28
  response.content_type == "application/json" ? JSON.parse(response.body) : true
27
29
  else
data/lib/eshq/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ESHQ
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/test/client_test.rb CHANGED
@@ -2,7 +2,7 @@ require "test/unit"
2
2
  require "mocha"
3
3
  require "timecop"
4
4
  require "digest/sha1"
5
- require "net/http"
5
+ require "fakeweb"
6
6
 
7
7
  require "eshq/client"
8
8
 
@@ -14,10 +14,11 @@ class TestClient < Test::Unit::TestCase
14
14
  end
15
15
 
16
16
  def test_post
17
- Net::HTTP.expects(:post_form).with() { |uri, params|
18
- uri.to_s == "http://example.com/socket" &&
19
- params.keys.sort == [:key, :presence_id, :timestamp, :token]
20
- }.returns(stub(:body => '{"socket": "12345"}'))
17
+ FakeWeb.register_uri(:post, "http://example.com/socket",
18
+ :body => '{"socket": "12345"}',
19
+ :content_type => "application/json"
20
+ )
21
+
21
22
  res = client.post("/socket", :presence_id => "Mathias")
22
23
  assert_equal "12345", res["socket"]
23
24
  end
metadata CHANGED
@@ -1,71 +1,87 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: eshq
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 4
9
- version: 0.0.4
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Mathias Biilmann Christensen
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-10-16 00:00:00 +02:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-09-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: mocha
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
31
22
  type: :development
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
34
31
  name: timecop
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
35
39
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
37
41
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- version: "0"
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: fakeweb
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
44
54
  type: :development
45
- version_requirements: *id002
46
- - !ruby/object:Gem::Dependency
47
- name: json
48
55
  prerelease: false
49
- requirement: &id003 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: json
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- segments:
55
- - 0
56
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
57
70
  type: :runtime
58
- version_requirements: *id003
59
- description: ""
60
- email:
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: ''
79
+ email:
61
80
  - mathiasch@eventsourcehq.com
62
81
  executables: []
63
-
64
82
  extensions: []
65
-
66
83
  extra_rdoc_files: []
67
-
68
- files:
84
+ files:
69
85
  - .gitignore
70
86
  - Gemfile
71
87
  - README.md
@@ -76,38 +92,30 @@ files:
76
92
  - lib/eshq/version.rb
77
93
  - test/client_test.rb
78
94
  - test/eshq_test.rb
79
- has_rdoc: true
80
- homepage: ""
95
+ homepage: ''
81
96
  licenses: []
82
-
83
97
  post_install_message:
84
98
  rdoc_options: []
85
-
86
- require_paths:
99
+ require_paths:
87
100
  - lib
88
- required_ruby_version: !ruby/object:Gem::Requirement
101
+ required_ruby_version: !ruby/object:Gem::Requirement
89
102
  none: false
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- segments:
94
- - 0
95
- version: "0"
96
- required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
108
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- segments:
102
- - 0
103
- version: "0"
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
104
113
  requirements: []
105
-
106
114
  rubyforge_project: eshq
107
- rubygems_version: 1.3.7
115
+ rubygems_version: 1.8.23
108
116
  signing_key:
109
117
  specification_version: 3
110
118
  summary: EventSource HQ API Client
111
- test_files:
119
+ test_files:
112
120
  - test/client_test.rb
113
121
  - test/eshq_test.rb