eotb 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
1
  source :rubygems
2
- gem "json", ">= 1.4.3"
2
+ gem "json", ">= 1.4.3"
data/README CHANGED
@@ -3,14 +3,30 @@ EotB Gem
3
3
  Rails plugin which allow you easily track and observe your apps.
4
4
 
5
5
  Installation
6
- ------------
6
+ ------------------
7
+ Install gem in traditional way:
8
+
7
9
  $ gem install eotb
8
10
 
11
+ or add this line to Gemfile in your rails application:
12
+
13
+ gem 'eotb'
14
+
15
+ and run
16
+
17
+ $ bundle install
18
+
19
+ Getting API KEY:
20
+ ------------------
21
+ Register your application on EOTB site by clicking "New application" and giving application name in text field.
22
+ As a result you will get API KEY of your application.
23
+
9
24
  Using in your apps
10
25
  ------------------
11
- require 'eotb'
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" })
26
+ Add file eotb.rb in directory config/initializers of your rails application with content:
27
+
28
+ Eotb.configure("your_API KEY", "host", "port") # default host and port are 127.0.0.1 and 3000
29
+ Eotb.register_event(:user, :do_sth, { :user_name => "Vuvuzela" })
14
30
 
15
31
  Copyright
16
32
  =========
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
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.1.0"
8
+ s.version = "0.1.1"
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-27}
12
+ s.date = %q{2010-06-28}
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 = [
@@ -26,7 +26,9 @@ Gem::Specification.new do |s|
26
26
  "Rakefile",
27
27
  "VERSION",
28
28
  "eotb.gemspec",
29
+ "lib/.eotb.rb.swp",
29
30
  "lib/eotb.rb",
31
+ "rails/init.rb",
30
32
  "spec/eotb_spec.rb",
31
33
  "spec/spec_helper.rb"
32
34
  ]
data/lib/.eotb.rb.swp ADDED
Binary file
data/lib/eotb.rb CHANGED
@@ -3,20 +3,22 @@ require 'rubygems'
3
3
  require 'json'
4
4
 
5
5
  class Eotb
6
-
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)
6
+
7
+ 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)
12
10
  end
13
11
 
14
12
  def to_json(array)
15
13
  JSON.generate(array)
16
14
  end
17
15
 
18
- def register_event(actor, action, subject = nil)
19
- @http.post(@path, [actor, action, subject].compact.to_json)
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)
20
22
  end
21
23
 
22
24
  end
data/rails/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'eotb'
data/spec/eotb_spec.rb CHANGED
@@ -3,20 +3,17 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  describe Eotb do
4
4
 
5
5
  before(:each) do
6
- @eotb = Eotb.new('0')
6
+ Eotb.new()
7
+ Eotb.configure('0', '127.0.0.1', '3000')
7
8
  @data = [:actor, :action, {:username => 'Vuvuzela'}]
8
9
  end
9
10
 
10
11
  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))
12
+ Eotb.http.get('/').code.should eql('200')
16
13
  end
17
14
 
18
15
  it "should post data in json" do
19
- @eotb.register_event(@data[0], @data[1], @data[2]).code.should eql('200')
16
+ Eotb.register_event(@data[0], @data[1], @data[2]).code.should eql('200')
20
17
  end
21
18
 
22
19
  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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
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-27 00:00:00 +02:00
18
+ date: 2010-06-28 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -69,7 +69,9 @@ files:
69
69
  - Rakefile
70
70
  - VERSION
71
71
  - eotb.gemspec
72
+ - lib/.eotb.rb.swp
72
73
  - lib/eotb.rb
74
+ - rails/init.rb
73
75
  - spec/eotb_spec.rb
74
76
  - spec/spec_helper.rb
75
77
  has_rdoc: true