eotb 0.5.3 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -31,16 +31,36 @@ And run
31
31
 
32
32
  == Getting API Key
33
33
 
34
- Create new account on Eotb website and add new application by clicking "Applications » Add application".
34
+ Create new account on Beholder website and add new application by clicking "Applications » Add application".
35
35
  As a result you will get API Key of your application.
36
36
 
37
- == Using in your apps
37
+ == Configure eotb in you app
38
+
39
+ === Rails 3
40
+
41
+ To configure your rails 3 app just run the generator with your_api_key and optional number of events sent in one package to Beholder:
42
+
43
+ rails generate eotb --api-key=your_api_key [--events=number_of_events]
44
+
45
+ === Rails 2
38
46
 
39
- Add file <tt>eotb.rb</tt> in directory <tt>config/initializers</tt> of your rails application with content:
47
+ To configure your rails 2 app just run the generator with your_api_key and optional number of events sent in one package to Beholder:
48
+
49
+ script/generate eotb --api-key=your_api_key [--events=number_of_events]
50
+
51
+ === Configuration file
52
+
53
+ If you didn't use rails generator you can manualy create a file <tt>eotb.rb</tt> in directory <tt>config/initializers</tt> in your rails application with content:
40
54
 
41
55
  require 'Eotb'
42
- Eotb.configure("your_api_key", "events", "host", "port") # default host and port are 127.0.0.1 and 3000
43
- #events - number of events sent in one package/request to beholder, default 1.
56
+ Eotb.configure("your_api_key", "events", "host", "port")
57
+ # default host and port are 127.0.0.1 and 3000
58
+ # to use it with Beholder:
59
+ # host = "beta.beholder.ragnarson.com"
60
+ # port = "80"
61
+ # events - number of events sent in one package/request to beholder, default 1.
62
+
63
+ == Using in your apps
44
64
 
45
65
  Register events by:
46
66
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.3
1
+ 0.5.7
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.5.3"
8
+ s.version = "0.5.7"
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-08-30}
12
+ s.date = %q{2010-09-09}
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,13 @@ Gem::Specification.new do |s|
26
26
  "Rakefile",
27
27
  "VERSION",
28
28
  "eotb.gemspec",
29
+ "generators/eotb/USAGE",
30
+ "generators/eotb/eotb_generator.rb",
31
+ "generators/eotb/templates/initializer.rb",
29
32
  "lib/eotb.rb",
33
+ "lib/generators/eotb/USAGE",
34
+ "lib/generators/eotb/eotb_generator.rb",
35
+ "lib/generators/eotb/templates/initializer.rb",
30
36
  "spec/eotb_spec.rb",
31
37
  "spec/spec_helper.rb"
32
38
  ]
@@ -36,8 +42,8 @@ Gem::Specification.new do |s|
36
42
  s.rubygems_version = %q{1.3.7}
37
43
  s.summary = %q{Rails plugin which allow you easily track and observe your apps}
38
44
  s.test_files = [
39
- "spec/eotb_spec.rb",
40
- "spec/spec_helper.rb"
45
+ "spec/spec_helper.rb",
46
+ "spec/eotb_spec.rb"
41
47
  ]
42
48
 
43
49
  if s.respond_to? :specification_version then
@@ -0,0 +1,9 @@
1
+ Description:
2
+ Creates eotb initializer in confing/initializers/eotb.rb, setting your app to work with Beholder.
3
+
4
+
5
+ Example:
6
+ rails generate eotb --api-key=your_api_key [--events=number_of_events]
7
+
8
+ This will create:
9
+ config/initializers/eotb.rb
@@ -0,0 +1,37 @@
1
+ class EotbGenerator < Rails::Generator::Base
2
+
3
+ def add_options!(opt)
4
+ opt.on('-k', '--api-key=key', String, "Your Beholder API key") {|v| options[:api_key] = v}
5
+ opt.on('-e', '--events=number_of_event', Integer, "Number of events sent in one package to Beholder") {|v| options[:events] = v}
6
+ end
7
+
8
+ def manifest
9
+ record do |m|
10
+ ensure_parameter_was_set
11
+ m.template "initializer.rb", "config/initializers/eotb.rb", :assigns => {:api_key => api_key_exp, :events => events_exp}
12
+ end
13
+
14
+ end
15
+
16
+ def api_key_exp
17
+ "#{options[:api_key]}"
18
+ end
19
+
20
+ def events_exp
21
+ s = if options[:events]
22
+ "#{options[:events]}"
23
+ else
24
+ "1"
25
+ end
26
+ end
27
+
28
+ def ensure_parameter_was_set
29
+ if !options[:api_key]
30
+ puts "Must pass --api-key or create config/initializers/eotb.rb"
31
+ exit
32
+ end
33
+ end
34
+
35
+
36
+
37
+ end
@@ -0,0 +1,3 @@
1
+ require 'eotb'
2
+
3
+ Eotb.configure("<%= api_key_exp %>", <%= events_exp %>, "beta.beholder.ragnarson.com", "80")
data/lib/eotb.rb CHANGED
@@ -30,6 +30,9 @@ class Eotb
30
30
  Net::HTTP.new(@@uri.host, @@uri.port).start.request(@@post)
31
31
  }
32
32
  rescue => e
33
+ logger = Logger.new("log/#{ENV['RAILS_ENV']}.log")
34
+ logger.error "ERROR eotb gem: " + e.to_s
35
+ rescue Timeout::Error => e
33
36
  logger = Logger.new("log/#{ENV['RAILS_ENV']}.log")
34
37
  logger.error "ERROR eotb gem: " + e.to_s
35
38
  end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Creates eotb initializer in confing/initializers/eotb.rb, setting your app to work with Beholder.
3
+
4
+ Example:
5
+ rails generate eotb --api-key=your_api_key [--events=number_of_events]
6
+
7
+ This will create:
8
+ config/initializers/eotb.rb
@@ -0,0 +1,48 @@
1
+ require 'rails/generators'
2
+
3
+ class EotbGenerator < Rails::Generators::Base
4
+
5
+ desc "Creates eotb initializer in confing/initializers/eotb.rb, setting your app to work with Beholder."
6
+
7
+ source_root File.expand_path('../templates', __FILE__)
8
+
9
+ class_option :api_key, :aliases => "-k", :type => :string, :desc => "Your Beholder API key"
10
+ class_option :events, :aliases => "-e",:type => :numeric, :desc => "Number of events sent in one package to Beholder", :default => "1"
11
+
12
+ def generator
13
+ ensure_parameters_was_set
14
+ generate_initializer unless api_key_configured?
15
+ puts "Eotb is configured!"
16
+ puts "File 'config/initializers/eotb.rb' was created!"
17
+ puts "Start using eotb now!"
18
+ end
19
+
20
+ private
21
+
22
+ def ensure_parameters_was_set
23
+ if api_key_configured?
24
+ puts "Configuration file already exists: config/initializers/eotb.rb"
25
+ exit
26
+ end
27
+ end
28
+
29
+ def api_key
30
+ "#{options[:api_key]}"
31
+ end
32
+ def events
33
+ s = if options[:events]
34
+ "#{options[:events]}"
35
+ else
36
+ "1"
37
+ end
38
+ end
39
+
40
+ def generate_initializer
41
+ template 'initializer.rb', 'config/initializers/eotb.rb'
42
+ end
43
+
44
+ def api_key_configured?
45
+ File.exists?('config/initializers/eotb.rb')
46
+ end
47
+
48
+ end
@@ -0,0 +1,3 @@
1
+ require 'eotb'
2
+
3
+ Eotb.configure("<%= api_key %>", <%= events %>, "beta.beholder.ragnarson.com", "80")
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: 13
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 3
10
- version: 0.5.3
9
+ - 7
10
+ version: 0.5.7
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-08-30 00:00:00 +02:00
18
+ date: 2010-09-09 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -101,7 +101,13 @@ files:
101
101
  - Rakefile
102
102
  - VERSION
103
103
  - eotb.gemspec
104
+ - generators/eotb/USAGE
105
+ - generators/eotb/eotb_generator.rb
106
+ - generators/eotb/templates/initializer.rb
104
107
  - lib/eotb.rb
108
+ - lib/generators/eotb/USAGE
109
+ - lib/generators/eotb/eotb_generator.rb
110
+ - lib/generators/eotb/templates/initializer.rb
105
111
  - spec/eotb_spec.rb
106
112
  - spec/spec_helper.rb
107
113
  has_rdoc: true
@@ -139,5 +145,5 @@ signing_key:
139
145
  specification_version: 3
140
146
  summary: Rails plugin which allow you easily track and observe your apps
141
147
  test_files:
142
- - spec/eotb_spec.rb
143
148
  - spec/spec_helper.rb
149
+ - spec/eotb_spec.rb