eotb 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,74 @@
1
+ = EotB Gem
2
+
3
+ Rails plugin which allow you easily track and observe your apps.
4
+
5
+ == Installation
6
+
7
+ Install gem in traditional way
8
+
9
+ $ gem install eotb
10
+
11
+ Install gem from GitHub repository
12
+
13
+ $ git clone git://github.com/Quirke/eotb_rails_plugin.git
14
+ $ cd eotb_rails_plugin
15
+ $ rake build
16
+ $ gem install ./pkg/eotb-0.2.0.gem
17
+
18
+ Add this line to Gemfile in your rails application
19
+
20
+ gem 'eotb'
21
+
22
+ And run
23
+
24
+ $ bundle install
25
+
26
+ === Getting API Key
27
+
28
+ Create new account on Eotb website and add new application by clicking "Applications » Add application".
29
+ As a result you will get API Key of your application.
30
+
31
+ == Using in your apps
32
+
33
+ Add file <tt>eotb.rb</tt> in directory <tt>config/initializers</tt> of your rails application with content:
34
+
35
+ require 'Eotb'
36
+ Eotb.configure("your_api_key", "host", "port") # default host and port are 127.0.0.1 and 3000
37
+
38
+ Register events by:
39
+
40
+ Eotb.register_event("user", "did_sth", {:username => "John", :time => "12:39:00"}) # actor, action, subject
41
+
42
+ === Examples
43
+
44
+ Register actor and his action
45
+
46
+ Eotb.register_event("user", "registered")
47
+
48
+ Register subject of event (<b>it must be a Hash!</b>)
49
+
50
+ Eotb.register_event("user", "registered", {:username => "John", :when => "today"})
51
+
52
+ Use Symbols instead of Strings
53
+
54
+ Eotb.register_event(:admin, :deleted, {:what => "News", :category => "Ruby"})
55
+
56
+ You can register any type of objects (for example Arrays) by using <tt>to_actor</tt> and <tt>to_subject</tt> methods
57
+
58
+ Eotb.register_event(["User", "Admin"].to_actor, :connected, {:values => [28, 3]}.to_subject)
59
+
60
+ Eotb.register_event(Object.new.to_actor, :fed, {:pet => Dog.new}.to_subject)
61
+
62
+ Parse subject to JSON by
63
+
64
+ {:username => "John"}.to_subject.to_json
65
+
66
+ And inspect your actors and subjects
67
+
68
+ "Josh".to_actor.inspect
69
+
70
+ {:username => "John"}.to_subject.inspect
71
+
72
+ == Copyright
73
+
74
+ Copyright (c) 2010 Ragnarson. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
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.2.0"
8
+ s.version = "0.2.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"]
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.email = %q{bartlomiej.kozal@ragnarson.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  "Gemfile",
23
23
  "Gemfile.lock",
24
24
  "LICENSE",
25
- "README",
25
+ "README.rdoc",
26
26
  "Rakefile",
27
27
  "VERSION",
28
28
  "eotb.gemspec",
data/lib/eotb.rb CHANGED
@@ -19,10 +19,10 @@ class Eotb
19
19
  api_key = { "event[app_id]" => @@api_key }
20
20
  action = { "event[action]" => action }
21
21
  actor = { "event[actor]" => actor }
22
+ subject_to_post = {}
23
+ subject.each { |key, value| subject_to_post["event[subject][#{key.to_s}]"] = value.to_s }
22
24
 
23
- subject.each { |key, value| subject["event[subject][#{key.to_s}]"] = value.to_s }
24
-
25
- event = api_key.merge(actor).merge(action).merge(subject)
25
+ event = api_key.merge(actor).merge(action).merge(subject_to_post)
26
26
  @@post.set_form_data(event)
27
27
  Net::HTTP.new(@@uri.host, @@uri.port).start.request(@@post)
28
28
  end
data/spec/eotb_spec.rb CHANGED
@@ -4,7 +4,7 @@ describe Eotb do
4
4
 
5
5
  before(:each) do
6
6
  @response = "302"
7
- Eotb.configure("4c30fc21b3dfae0b18000078")
7
+ Eotb.configure("4c3128cfb3dfae0b180000e8")
8
8
  end
9
9
 
10
10
  it "should register only two arguments" do
@@ -24,7 +24,7 @@ describe Eotb do
24
24
  end
25
25
 
26
26
  it "should generate JSON from subject" do
27
- {:username => "John"}.to_subject.to_json.should == JSON.generate({:username => "String"})
27
+ {:username => "John"}.to_subject.to_json.should == JSON.generate({:username => "John"})
28
28
  end
29
29
 
30
30
  # it "should parse JSON from subject" do
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: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ragnarson
@@ -58,14 +58,14 @@ extensions: []
58
58
 
59
59
  extra_rdoc_files:
60
60
  - LICENSE
61
- - README
61
+ - README.rdoc
62
62
  files:
63
63
  - .document
64
64
  - .gitignore
65
65
  - Gemfile
66
66
  - Gemfile.lock
67
67
  - LICENSE
68
- - README
68
+ - README.rdoc
69
69
  - Rakefile
70
70
  - VERSION
71
71
  - eotb.gemspec
data/README DELETED
@@ -1,44 +0,0 @@
1
- EotB Gem
2
- ========
3
- Rails plugin which allow you easily track and observe your apps.
4
-
5
- Installation
6
- ------------------
7
- * Install gem in traditional way:
8
-
9
- $ gem install eotb
10
-
11
- * Install gem from GitHub repository:
12
-
13
- $ git clone git://github.com/Quirke/eotb_rails_plugin.git
14
- $ cd eotb_rails_plugin
15
- $ rake build
16
- $ gem install ./pkg/eotb-0.1.3.gem
17
-
18
- * Add this line to Gemfile in your rails application:
19
-
20
- gem 'eotb'
21
-
22
- and run
23
-
24
- $ bundle install
25
-
26
- Getting API KEY:
27
- ------------------
28
- Register your application on EOTB site by clicking "New application" and giving application name in text field.
29
- As a result you will get API KEY of your application.
30
-
31
- Using in your apps
32
- ------------------
33
- Add file eotb.rb in directory config/initializers of your rails application with content:
34
-
35
- require 'Eotb'
36
- Eotb.configure("your_api_key", "host", "port") # default host and port are 127.0.0.1 and 3000
37
-
38
- Register events by:
39
-
40
- Eotb.register_event("user", "did_sth", {:username => "John", :time => "12:39:00"}) # Eotb.register_event(actor, action, subject)
41
-
42
- Copyright
43
- =========
44
- Copyright (c) 2010 Ragnarson. See LICENSE for details.