eotb 0.5.12 → 0.5.14

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -4,3 +4,5 @@ rdoc
4
4
  pkg
5
5
  *.swp
6
6
  .bundle
7
+ *~
8
+ *.class
data/README.rdoc CHANGED
@@ -27,7 +27,7 @@ Install gem from GitHub repository
27
27
  $ git clone git://github.com/Quirke/eotb_rails_plugin.git
28
28
  $ cd eotb_rails_plugin
29
29
  $ rake build
30
- $ gem install ./pkg/eotb-0.5.11.gem
30
+ $ gem install ./pkg/eotb-0.5.14.gem
31
31
 
32
32
  == Getting API Key
33
33
 
@@ -38,22 +38,31 @@ As a result you will get API Key of your application.
38
38
 
39
39
  === Rails 3
40
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:
41
+ To configure your rails 3 app just run the generator with your_api_key, app login and password:
42
42
 
43
- rails generate eotb --api-key=your_api_key
43
+ rails generate eotb --api-key=your_api_key --login=app_login --password=app_password
44
44
 
45
45
  === Rails 2
46
46
 
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:
47
+ To configure your rails 2 app just run the generator with your_api_key, app login and password:
48
48
 
49
- script/generate eotb --api-key=your_api_key
49
+ script/generate eotb --api-key=your_api_key --login=app_login --password=app_password
50
50
 
51
51
  === Configuration file
52
52
 
53
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:
54
54
 
55
55
  require 'Eotb'
56
- Eotb.configure("your_api_key")
56
+ Eotb.configure("your_api_key", "app_login", "app_password")
57
+
58
+ === Deprecated methods
59
+
60
+ Please note that methods:
61
+
62
+ Eotb.configure("your_api_key")
63
+ Eotb.configure("your_api_key", events, "host", "port")
64
+
65
+ are deprecated and will be removed in Eotb --version=0.5.17.
57
66
 
58
67
  == Using in your apps
59
68
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.12
1
+ 0.5.14
data/bin/eotb CHANGED
@@ -13,8 +13,8 @@ class EotbConfigurator
13
13
  opts.on("-a", "--api-key=[ARG]", "Your API Key") do |opt|
14
14
  @app[:apikey] = opt
15
15
  end
16
- opts.on("-e", "--events=[ARG]", "Number of events") do |opt|
17
- @app[:events] = opt
16
+ opts.on("-d", "--dir=[ARG]", "Directory of app") do |opt|
17
+ @app[:dir] = opt
18
18
  end
19
19
  end
20
20
  options.parse!(ARGV)
@@ -37,8 +37,8 @@ class EotbConfigurator
37
37
  else
38
38
  command = "script/generate eotb --api-key=#{@app[:apikey]}"
39
39
  end
40
- if @app[:events]
41
- command = command + " --events=#{@app[:events]}"
40
+ if @app[:dir]
41
+ command = "cd "+@app[:dir]+";"+command
42
42
  end
43
43
  command
44
44
  end
@@ -49,8 +49,7 @@ class EotbConfigurator
49
49
  ensure_parameter_was_set
50
50
  recognize_rails_version
51
51
  command = prepare_command
52
- # exec( command )
53
- puts "Will execute: "+command
52
+ system( command )
54
53
  end
55
54
  end
56
55
 
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.12"
8
+ s.version = "0.5.14"
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-09-27}
12
+ s.date = %q{2010-10-18}
13
13
  s.default_executable = %q{eotb}
14
14
  s.description = %q{Rails plugin which allow you easily track and observe your apps}
15
15
  s.email = %q{bartlomiej.kozal@ragnarson.com}
@@ -2,12 +2,14 @@ class EotbGenerator < Rails::Generator::Base
2
2
 
3
3
  def add_options!(opt)
4
4
  opt.on('-k', '--api-key=key', String, "Your Beholder API key") {|v| options[:api_key] = v}
5
+ opt.on('-l', '--login=login', String, "Your Beholder app login") {|v| options[:email] = v}
6
+ opt.on('-d', '--password=password', String, "Your Beholder app password") {|v| options[:password] = v}
5
7
  end
6
8
 
7
9
  def manifest
8
10
  record do |m|
9
11
  ensure_parameter_was_set
10
- m.template "initializer.rb", "config/initializers/eotb.rb", :assigns => {:api_key => api_key_exp}
12
+ m.template "initializer.rb", "config/initializers/eotb.rb", :assigns => {:api_key => api_key_exp, :login => login_exp, :password => password_exp}
11
13
  end
12
14
 
13
15
  end
@@ -15,14 +17,24 @@ class EotbGenerator < Rails::Generator::Base
15
17
  def api_key_exp
16
18
  "#{options[:api_key]}"
17
19
  end
20
+ def login_exp
21
+ "#{options[:login]}"
22
+ end
23
+ def password_exp
24
+ "#{options[:password]}"
25
+ end
18
26
 
19
27
  def ensure_parameter_was_set
20
28
  if !options[:api_key]
21
- puts "Must pass --api-key or create config/initializers/eotb.rb"
29
+ puts "Must pass --api-key='your_api_key' or -k 'your_api_key'"
30
+ exit
31
+ elsif !options[:login]
32
+ puts "Must pass --login='app_login' or -l 'app_login'"
33
+ exit
34
+ elsif !options[:password]
35
+ puts "Must pass --password='app_password' or -d 'app_password'"
22
36
  exit
23
37
  end
24
38
  end
25
39
 
26
-
27
-
28
40
  end
@@ -1,3 +1,3 @@
1
1
  require 'eotb'
2
2
 
3
- Eotb.configure("<%= api_key_exp %>")
3
+ Eotb.configure("<%= api_key_exp %>", "<%= login_exp %>", "<%= password_exp %>")
data/lib/eotb.rb CHANGED
@@ -10,15 +10,32 @@ class Eotb
10
10
  @@api_key = nil
11
11
  METHODS = [:to_actor, :to_subject, :to_json, :to_hash, :inspect]
12
12
 
13
- def self.configure(api_key)
13
+ def self.configure(*params) #(api_key, email, password)
14
14
  @@host = "beta.beholder.ragnarson.com"
15
15
  @@port = '80'
16
- @@api_key = api_key
17
- @@uri = URI.parse('http://' + @@host + ':' + @@port + '/events/' + api_key)
18
- @@post = Net::HTTP::Post.new(@@uri.path)
16
+ @@api_key = params[0] if params.size > 0
17
+ @@reset = 100
18
+ if params.size == 1 # DEPRECATED - remove on Eotb 0.5.17
19
+ puts 'DEPRECATION WARNING'
20
+ puts 'Eotb.configure(api_key) -- method will be removed in eotb 0.5.17'
21
+ elsif params.size == 4 # DEPRECATED - remove on Eotb 0.5.17
22
+ puts 'DEPRECATION WARNING'
23
+ puts 'Eotb.configure(api_key, events, host, port) -- method will be removed in eotb 0.5.17'
24
+ @@host = params[2]
25
+ @@port = params[3]
26
+ params[1].to_i >= 1 ? @@reset = params[1].to_i : @@reset = 1
27
+ @@uri = URI.parse('http://' + @@host + ':' + @@port + '/events/' + @@api_key)
28
+ @@post = Net::HTTP::Post.new(@@uri.path)
29
+ elsif params.size == 3
30
+ @@uri = URI.parse('http://' + @@host + ':' + @@port + '/events/' + @@api_key)
31
+ @@post = Net::HTTP::Post.new(@@uri.path)
32
+ @@post.basic_auth params[1], params[2]
33
+ else
34
+ raise ArgumentError, 'Wrong number of arguments. Check Eotb.configure parameters!'
35
+ end
36
+
19
37
  @@events = {}
20
38
  @@counter = 1
21
- @@reset = 100
22
39
 
23
40
  Thread.new do
24
41
  Timer.every(600.0) { |elapsed|
@@ -111,5 +128,4 @@ class Eotb
111
128
  end
112
129
  eval "{#{h.to_s}}"
113
130
  end
114
-
115
131
  end
@@ -7,6 +7,8 @@ class EotbGenerator < Rails::Generators::Base
7
7
  source_root File.expand_path('../../../../generators/eotb/templates', __FILE__)
8
8
 
9
9
  class_option :api_key, :aliases => "-k", :type => :string, :desc => "Your Beholder API key"
10
+ class_option :login, :aliases => "-l", :type => :string, :desc => "Your Beholder app login"
11
+ class_option :password, :aliases => "-d", :type => :string, :desc => "Your Beholder app password"
10
12
 
11
13
  def generator
12
14
  ensure_parameters_was_set
@@ -28,6 +30,12 @@ class EotbGenerator < Rails::Generators::Base
28
30
  def api_key_exp
29
31
  "#{options[:api_key]}"
30
32
  end
33
+ def login_exp
34
+ "#{options[:login]}"
35
+ end
36
+ def password_exp
37
+ "#{options[:password]}"
38
+ end
31
39
 
32
40
  def generate_initializer
33
41
  template 'initializer.rb', 'config/initializers/eotb.rb'
@@ -35,10 +43,16 @@ class EotbGenerator < Rails::Generators::Base
35
43
 
36
44
  def api_key_configured?
37
45
  if !options[:api_key]
38
- puts "Must pass --api-key='your_api_key'"
46
+ puts "Must pass --api-key='your_api_key' or -k 'your_api_key'"
47
+ exit
48
+ elsif !options[:email]
49
+ puts "Must pass --email='app_email' or -l 'app_email'"
50
+ exit
51
+ elsif !options[:password]
52
+ puts "Must pass --password='app_password' or -d 'app_password'"
39
53
  exit
40
54
  end
41
- File.exists?('config/initializers/eotb.rb') && options[:api_key].empty?
55
+ File.exists?('config/initializers/eotb.rb') && options[:api_key].empty? && options[:login].empty? && options[:password].empty?
42
56
  end
43
57
 
44
58
  end
data/spec/eotb_spec.rb CHANGED
@@ -25,8 +25,7 @@ describe Eotb do
25
25
 
26
26
  before(:each) do
27
27
  @response = "200"
28
-
29
- Eotb.configure("0"*40)
28
+ Eotb.configure("test_api_key", 'email', 'passwords')
30
29
  @@counter = 100
31
30
  Net::HTTP.stub(:new) { Net::HTTP }
32
31
  Net::HTTP.stub(:start) { Net::HTTP }
@@ -71,7 +70,7 @@ describe Eotb do
71
70
 
72
71
  before(:each) do
73
72
  @response = "200"
74
- Eotb.configure("0"*40)
73
+ Eotb.configure("0"*40, 'email', 'passwords')
75
74
  @@counter = 96
76
75
  Net::HTTP.stub(:new) { Net::HTTP }
77
76
  Net::HTTP.stub(:start) { Net::HTTP }
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: 19
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 12
10
- version: 0.5.12
9
+ - 14
10
+ version: 0.5.14
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-09-27 00:00:00 +02:00
18
+ date: 2010-10-18 00:00:00 +02:00
19
19
  default_executable: eotb
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency