eotb 0.0.2 → 0.1.0

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/README CHANGED
@@ -9,9 +9,9 @@ $ gem install eotb
9
9
  Using in your apps
10
10
  ------------------
11
11
  require 'eotb'
12
- @eotb = new.Eotb(:api_key)
13
- @eotb.register_event(:user, :do_sth, { :user_name => "Vuvuzela" })
14
-
12
+ eotb = new.Eotb("your_api_key", "host", "port") # default host and port are 127.0.0.1 and 3000
13
+ eotb.register_event(:user, :do_sth, { :user_name => "Vuvuzela" })
14
+
15
15
  Copyright
16
16
  =========
17
17
  Copyright (c) 2010 Ragnarson. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.1.0
data/eotb.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{eotb}
8
- s.version = "0.0.2"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ragnarson"]
12
- s.date = %q{2010-06-22}
12
+ s.date = %q{2010-06-27}
13
13
  s.description = %q{Rails plugin which allow you easily track and observe your apps}
14
14
  s.email = %q{bartlomiej.kozal@ragnarson.com}
15
15
  s.extra_rdoc_files = [
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  ".gitignore",
23
23
  "Gemfile",
24
24
  "LICENSE",
25
+ "README",
25
26
  "Rakefile",
26
27
  "VERSION",
27
28
  "eotb.gemspec",
data/lib/eotb.rb CHANGED
@@ -1,22 +1,22 @@
1
- require 'json'
2
1
  require 'net/http'
2
+ require 'rubygems'
3
+ require 'json'
3
4
 
4
5
  class Eotb
5
6
 
6
- def initialize(api_key, host = '127.0.0.1:3000')
7
- @api_key = api_key
8
- @host = host
9
- @array = []
7
+ attr_reader :http
8
+
9
+ def initialize(api_key, host = '127.0.0.1', port = '3000')
10
+ @path = '/apps/' + api_key.to_s + '/events'
11
+ @http = Net::HTTP.new(host, port)
10
12
  end
11
13
 
12
- def to_json(array = @array)
14
+ def to_json(array)
13
15
  JSON.generate(array)
14
16
  end
15
17
 
16
- def register_event(actor, action, subject)
17
- @array << actor << action << subject
18
- @array.to_json
19
- # @array.clear
18
+ def register_event(actor, action, subject = nil)
19
+ @http.post(@path, [actor, action, subject].compact.to_json)
20
20
  end
21
21
 
22
22
  end
data/spec/eotb_spec.rb CHANGED
@@ -2,21 +2,21 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe Eotb do
4
4
 
5
- context "register_event method" do
6
-
7
- it "should return json" do
8
- subject = { :user_id => 10, :user_name => "Noname" }
9
- Eotb.new.register_event(:current_user, :bought_membership, subject).should eql JSON.generate([:current_user, :bought_membership, subject])
10
- end
11
-
5
+ before(:each) do
6
+ @eotb = Eotb.new('0')
7
+ @data = [:actor, :action, {:username => 'Vuvuzela'}]
12
8
  end
13
9
 
14
- context "connection with app" do
15
-
16
- it "should set connection"
17
-
18
- it "should send json by POST to app"
19
-
10
+ it "should check connection status" do
11
+ @eotb.http.get('/').code.should eql('200')
12
+ end
13
+
14
+ it "should have data in json" do
15
+ @eotb.to_json(@data).should eql(JSON.generate(@data))
16
+ end
17
+
18
+ it "should post data in json" do
19
+ @eotb.register_event(@data[0], @data[1], @data[2]).code.should eql('200')
20
20
  end
21
21
 
22
22
  end
data/spec/spec_helper.rb CHANGED
@@ -3,7 +3,6 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'eotb'
4
4
  require 'spec'
5
5
  require 'spec/autorun'
6
- require 'json'
7
6
 
8
7
  Spec::Runner.configure do |config|
9
8
 
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 2
10
- version: 0.0.2
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ragnarson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-22 00:00:00 +02:00
18
+ date: 2010-06-27 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -65,13 +65,13 @@ files:
65
65
  - .gitignore
66
66
  - Gemfile
67
67
  - LICENSE
68
+ - README
68
69
  - Rakefile
69
70
  - VERSION
70
71
  - eotb.gemspec
71
72
  - lib/eotb.rb
72
73
  - spec/eotb_spec.rb
73
74
  - spec/spec_helper.rb
74
- - README
75
75
  has_rdoc: true
76
76
  homepage: http://github.com/Quirke/eotb_rails_plugin
77
77
  licenses: []