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 CHANGED
@@ -2,3 +2,4 @@
2
2
  coverage
3
3
  rdoc
4
4
  pkg
5
+ *.swp
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/eotb.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{eotb}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ragnarson"]
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
- @@path = '/apps/' + api_key.to_s + '/events'
9
- @@http = Net::HTTP.new(host, port)
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.http
17
- @@http
18
- end
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 = [:actor, :action, {:username => 'Vuvuzela'}]
8
+ @data = ['actor', 'action', 'username']
9
9
  end
10
10
 
11
- it "should check connection status" do
12
- Eotb.http.get('/').code.should eql('200')
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
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eotb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ragnarson