eotb 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/VERSION +1 -1
- data/eotb.gemspec +1 -1
- data/lib/eotb.rb +7 -8
- data/spec/eotb_spec.rb +3 -7
- metadata +3 -3
data/.gitignore
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/eotb.gemspec
CHANGED
data/lib/eotb.rb
CHANGED
@@ -1,24 +1,23 @@
|
|
1
1
|
require 'net/http'
|
2
|
+
require 'uri'
|
2
3
|
require 'rubygems'
|
3
4
|
require 'json'
|
4
5
|
|
5
6
|
class Eotb
|
6
7
|
|
7
8
|
def self.configure(api_key, host = '127.0.0.1', port = '3000')
|
8
|
-
@@
|
9
|
-
@@http = Net::HTTP.new(
|
9
|
+
@@uri = URI.parse('http://' + host + ':' + port + '/apps/' + api_key + '/events')
|
10
|
+
@@http = Net::HTTP::Post.new(@@uri.path)
|
11
|
+
@@api_key = api_key
|
10
12
|
end
|
11
13
|
|
12
14
|
def to_json(array)
|
13
15
|
JSON.generate(array)
|
14
16
|
end
|
15
17
|
|
16
|
-
def self.
|
17
|
-
@@http
|
18
|
-
|
19
|
-
|
20
|
-
def self.register_event(actor, action, subject = nil)
|
21
|
-
@@http.post(@@path, [actor, action, subject].compact.to_json)
|
18
|
+
def self.register_event(actor, action, subject)
|
19
|
+
@@http.set_form_data({"event[actor][name]" => actor, "event[action]" => action, "event[subject][name]" => subject, "event[app_id]" => @@api_key}, ';')
|
20
|
+
Net::HTTP.new(@@uri.host, @@uri.port).start { |http| http.request(@@http) }
|
22
21
|
end
|
23
22
|
|
24
23
|
end
|
data/spec/eotb_spec.rb
CHANGED
@@ -5,15 +5,11 @@ describe Eotb do
|
|
5
5
|
before(:each) do
|
6
6
|
Eotb.new()
|
7
7
|
Eotb.configure('0', '127.0.0.1', '3000')
|
8
|
-
@data = [
|
8
|
+
@data = ['actor', 'action', 'username']
|
9
9
|
end
|
10
10
|
|
11
|
-
it "should
|
12
|
-
Eotb.
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should post data in json" do
|
16
|
-
Eotb.register_event(@data[0], @data[1], @data[2]).code.should eql('200')
|
11
|
+
it "should post data to unknown server" do
|
12
|
+
Eotb.register_event(@data[0], @data[1], @data[2]).code.should eql('500')
|
17
13
|
end
|
18
14
|
|
19
15
|
end
|
metadata
CHANGED