Permalink
Browse files

Added backward compatible check for ruby 1.8.7 and system_timer

  • Loading branch information...
1 parent e0fb83b commit 29c41f44390c16d53116dbe41665f3a765884124 @aforward committed Oct 26, 2011
Showing with 41 additions and 33 deletions.
  1. +1 −1 Gemfile.lock
  2. +1 −1 Gemfile.lock.rails2
  3. +8 −0 lib/appstats.rb
  4. +1 −1 lib/appstats/version.rb
  5. +8 −8 spec/entry_spec.rb
  6. +22 −22 spec/logger_spec.rb
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- appstats (0.23.3)
+ appstats (0.23.4)
daemons
net-scp
rails (>= 2.3.0)
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- appstats (0.23.3)
+ appstats (0.23.4)
daemons
net-scp
rails (>= 2.3.0)
View
@@ -16,6 +16,14 @@ def env
end
end
+unless `ruby -v`.index("ruby 1.8.7").nil?
+ begin
+ require 'system_timer'
+ rescue LoadError
+ puts "INSTALL System Timer (gem install system_timer) or upgrade to ruby >= 1.9.2"
+ end
+end
+
require "#{File.dirname(__FILE__)}/appstats/acts_as_appstatsable"
require "#{File.dirname(__FILE__)}/appstats/acts_as_auditable"
require "#{File.dirname(__FILE__)}/appstats/benchmarker"
View
@@ -1,3 +1,3 @@
module Appstats
- VERSION = "0.23.3"
+ VERSION = "0.23.4"
end
View
@@ -193,18 +193,18 @@ module Appstats
end
it "should understand an entry without contexts" do
- entry = Entry.create_from_logger_string("0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search")
+ entry = Entry.create_from_logger_string("0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search")
Entry.count.should == @before_count + 1
entry.action.should == "address_search"
- entry.raw_entry.should == "0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search"
+ entry.raw_entry.should == "0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search"
entry.occurred_at.should == Time.parse("2010-09-21 23:15:20")
end
it "should understand contexts" do
- entry = Entry.create_from_logger_string("0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live")
+ entry = Entry.create_from_logger_string("0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live")
Entry.count.should == @before_count + 1
entry.action.should == "address_filter"
- entry.raw_entry.should == "0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live"
+ entry.raw_entry.should == "0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live"
entry.occurred_at.should == Time.parse("2010-09-21 23:15:20")
entry.contexts.size.should == 2
entry.contexts[0].context_key = "app_name"
@@ -214,10 +214,10 @@ module Appstats
end
it "should handle 'action' as a context" do
- entry = Entry.create_from_logger_string('0.23.3 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : action=save_ovcen : app_name=cdb')
+ entry = Entry.create_from_logger_string('0.23.4 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : action=save_ovcen : app_name=cdb')
Entry.count.should == @before_count + 1
entry.action.should == "page-view"
- entry.raw_entry.should == "0.23.3 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : action=save_ovcen : app_name=cdb"
+ entry.raw_entry.should == "0.23.4 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : action=save_ovcen : app_name=cdb"
entry.occurred_at.should == Time.parse("2011-02-24 12:59:57")
entry.contexts.size.should == 2
entry.contexts[0].context_key = "action"
@@ -228,10 +228,10 @@ module Appstats
end
it "should handle multiple of the same 'context'" do
- entry = Entry.create_from_logger_string('0.23.3 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : app_name=market : app_name=cdb')
+ entry = Entry.create_from_logger_string('0.23.4 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : app_name=market : app_name=cdb')
Entry.count.should == @before_count + 1
entry.action.should == "page-view"
- entry.raw_entry.should == "0.23.3 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : app_name=market : app_name=cdb"
+ entry.raw_entry.should == "0.23.4 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : app_name=market : app_name=cdb"
entry.occurred_at.should == Time.parse("2011-02-24 12:59:57")
entry.contexts.size.should == 2
entry.contexts[0].context_key = "app_name"
View
@@ -122,12 +122,12 @@ module Appstats
it "should accept numbers" do
Appstats::Logger.entry(5, :blah => 6)
- Appstats::Logger.raw_read.should == ["0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=5 : blah=6"]
+ Appstats::Logger.raw_read.should == ["0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=5 : blah=6"]
end
it "should accept arrays" do
Appstats::Logger.entry('search', :provider => [ 'one', 'two' ])
- Appstats::Logger.raw_read.should == ["0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=search : provider=one : provider=two"]
+ Appstats::Logger.raw_read.should == ["0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=search : provider=one : provider=two"]
end
@@ -137,7 +137,7 @@ module Appstats
it "should look similar to regular entry" do
Appstats::Logger.exception_entry(RuntimeError.new("blah"),:on => "login")
- Appstats::Logger.raw_read.should == ["0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=appstats-exception : error=blah : on=login"]
+ Appstats::Logger.raw_read.should == ["0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=appstats-exception : error=blah : on=login"]
end
end
@@ -154,47 +154,47 @@ module Appstats
it "should handle a statistics entry" do
expected = { :action => "address_search", :timestamp => "2010-09-21 23:15:20" }
- actual = Appstats::Logger.entry_to_hash("0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search")
+ actual = Appstats::Logger.entry_to_hash("0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search")
actual.should == expected
end
it "should handle contexts" do
expected = { :action => "address_filter", :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => 'Market' }
- actual = Appstats::Logger.entry_to_hash("0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live")
+ actual = Appstats::Logger.entry_to_hash("0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live")
actual.should == expected
end
it "should handle multiple actions" do
expected = { :action => ["address_filter", "blah"], :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => 'Market' }
- actual = Appstats::Logger.entry_to_hash("0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : action=blah : app_name=Market : server=Live")
+ actual = Appstats::Logger.entry_to_hash("0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : action=blah : app_name=Market : server=Live")
actual.should == expected
end
it "should handle multiple of same context" do
expected = { :action => "address_filter", :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => ['Sin','Market'] }
- actual = Appstats::Logger.entry_to_hash("0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Sin : app_name=Market : server=Live")
+ actual = Appstats::Logger.entry_to_hash("0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Sin : app_name=Market : server=Live")
actual.should == expected
end
it "should handle no actions" do
expected = { :action => "UNKNOWN_ACTION", :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => 'Market' }
- actual = Appstats::Logger.entry_to_hash("0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 app_name=Market : server=Live")
+ actual = Appstats::Logger.entry_to_hash("0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 app_name=Market : server=Live")
actual.should == expected
end
it "should handle actions with the delimiter (and change the delimiter)" do
expected = { :action => "address:=search-n", :timestamp => "2010-09-21 23:15:20" }
- actual = Appstats::Logger.entry_to_hash("0.23.3 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=search-n")
+ actual = Appstats::Logger.entry_to_hash("0.23.4 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=search-n")
actual.should == expected
expected = { :action => "address::search==--n", :timestamp => "2010-09-21 23:15:20" }
- actual = Appstats::Logger.entry_to_hash("0.23.3 setup[:::,===,---n] 2010-09-21 23:15:20 action===address::search==--n")
+ actual = Appstats::Logger.entry_to_hash("0.23.4 setup[:::,===,---n] 2010-09-21 23:15:20 action===address::search==--n")
actual.should == expected
end
it "should handle contexts with the delimiter (and change the delimiter)" do
expected = { :action => "address", :timestamp => "2010-09-21 23:15:20", :server => "market:eval=-n" }
- actual = Appstats::Logger.entry_to_hash("0.23.3 setup[::,==,--n] 2010-09-21 23:15:20 action==address :: server==market:eval=-n")
+ actual = Appstats::Logger.entry_to_hash("0.23.4 setup[::,==,--n] 2010-09-21 23:15:20 action==address :: server==market:eval=-n")
actual.should == expected
end
@@ -203,66 +203,66 @@ module Appstats
describe "#entry_to_s" do
it "should handle a statistics entry" do
- expected = "0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search"
+ expected = "0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search"
actual = Appstats::Logger.entry_to_s("address_search")
actual.should == expected
end
it "should handle numbers" do
- expected = "0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=1 : note=2.2"
+ expected = "0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=1 : note=2.2"
actual = Appstats::Logger.entry_to_s(1,:note => 2.2)
actual.should == expected
end
it "should handle default contexts" do
Appstats::Logger.default_contexts[:app_name] = "market"
- expected = "0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search : app_name=market"
+ expected = "0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search : app_name=market"
actual = Appstats::Logger.entry_to_s("address_search")
actual.should == expected
end
it "should handle contexts (and sort them by symbol)" do
- expected = "0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live"
+ expected = "0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live"
actual = Appstats::Logger.entry_to_s("address_filter", { :server => "Live", :app_name => 'Market' })
actual.should == expected
end
it "should handle actions with the delimiter (and change the delimiter)" do
- expected = "0.23.3 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=search-n"
+ expected = "0.23.4 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=search-n"
actual = Appstats::Logger.entry_to_s("address:=search-n")
actual.should == expected
- expected = "0.23.3 setup[:::,===,---n] 2010-09-21 23:15:20 action===address::search==--n"
+ expected = "0.23.4 setup[:::,===,---n] 2010-09-21 23:15:20 action===address::search==--n"
actual = Appstats::Logger.entry_to_s("address::search==--n")
actual.should == expected
end
it "should handle contexts with the delimiter (and change the delimiter)" do
- expected = "0.23.3 setup[::,==,--n] 2010-09-21 23:15:20 action==address :: server==market:eval=-n"
+ expected = "0.23.4 setup[::,==,--n] 2010-09-21 23:15:20 action==address :: server==market:eval=-n"
actual = Appstats::Logger.entry_to_s("address", :server => 'market:eval=-n')
actual.should == expected
end
it "should ignore spaces" do
- expected = "0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address search"
+ expected = "0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address search"
actual = Appstats::Logger.entry_to_s("address search")
actual.should == expected
end
it "should convert newlines in action" do
- expected = "0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_-nsearch"
+ expected = "0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_-nsearch"
actual = Appstats::Logger.entry_to_s("address_\nsearch")
actual.should == expected
end
it "should convert newlines in context" do
- expected = "0.23.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search : blah=some-nlong-nstatement"
+ expected = "0.23.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search : blah=some-nlong-nstatement"
actual = Appstats::Logger.entry_to_s("address_search",:blah => "some\nlong\nstatement")
actual.should == expected
end
it "should convert newlines based on the delimiter" do
- expected = "0.23.3 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=--nsearch-n"
+ expected = "0.23.4 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=--nsearch-n"
actual = Appstats::Logger.entry_to_s("address:=\nsearch-n")
actual.should == expected
end

0 comments on commit 29c41f4

Please sign in to comment.