bullet 2.0.0.beta.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +1 -1
- data/README.textile +2 -3
- data/README_for_rails2.textile +2 -3
- data/lib/bullet/notification/base.rb +7 -9
- data/lib/bullet/rack.rb +5 -3
- data/lib/bullet/version.rb +5 -0
- data/lib/bullet.rb +27 -38
- metadata +46 -51
- data/.rspec +0 -1
- data/Hacking.textile +0 -100
- data/Rakefile +0 -51
- data/VERSION +0 -1
- data/autotest/discover.rb +0 -1
- data/bullet.gemspec +0 -90
- data/lib/bullet/presenter/base.rb +0 -9
- data/lib/bullet/presenter/bullet_logger.rb +0 -28
- data/lib/bullet/presenter/growl.rb +0 -40
- data/lib/bullet/presenter/javascript_alert.rb +0 -15
- data/lib/bullet/presenter/javascript_console.rb +0 -28
- data/lib/bullet/presenter/javascript_helpers.rb +0 -13
- data/lib/bullet/presenter/rails_logger.rb +0 -15
- data/lib/bullet/presenter/xmpp.rb +0 -56
- data/lib/bullet/presenter.rb +0 -13
- data/rails/init.rb +0 -1
- data/spec/bullet/association_for_chris_spec.rb +0 -96
- data/spec/bullet/association_for_peschkaj_spec.rb +0 -86
- data/spec/bullet/association_spec.rb +0 -899
- data/spec/bullet/counter_spec.rb +0 -136
- data/spec/spec_helper.rb +0 -79
- data/tasks/bullet_tasks.rake +0 -9
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
module Bullet
|
|
2
|
-
module Presenter
|
|
3
|
-
class BulletLogger < Base
|
|
4
|
-
@logger_file = nil
|
|
5
|
-
@logger = nil
|
|
6
|
-
|
|
7
|
-
def self.active?
|
|
8
|
-
@logger
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def self.out_of_channel( notice )
|
|
12
|
-
return unless active?
|
|
13
|
-
@logger.info notice.full_notice
|
|
14
|
-
@logger_file.flush
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def self.setup
|
|
18
|
-
@logger_file = File.open( Rails.root.join('log/bullet.log'), 'a+' )
|
|
19
|
-
@logger = Logger.new( @logger_file )
|
|
20
|
-
|
|
21
|
-
def @logger.format_message( severity, timestamp, progname, msg )
|
|
22
|
-
"#{timestamp.to_formatted_s(:db)}[#{severity}] #{msg}\n"
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
module Bullet
|
|
2
|
-
module Presenter
|
|
3
|
-
class Growl < Base
|
|
4
|
-
@growl = nil
|
|
5
|
-
|
|
6
|
-
def self.active?
|
|
7
|
-
@growl
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def self.out_of_channel( notice )
|
|
11
|
-
return unless active?
|
|
12
|
-
notify( notice.standard_notice )
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def self.setup_connection( password )
|
|
16
|
-
require 'ruby-growl'
|
|
17
|
-
@password = password
|
|
18
|
-
@growl = connect
|
|
19
|
-
|
|
20
|
-
notify 'Bullet Growl notifications have been turned on'
|
|
21
|
-
rescue MissingSourceFile
|
|
22
|
-
@growl = nil
|
|
23
|
-
raise NotificationError.new( 'You must install the ruby-growl gem to use Growl notifications: `sudo gem install ruby-growl`' )
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
private
|
|
27
|
-
def self.connect
|
|
28
|
-
::Growl.new 'localhost',
|
|
29
|
-
'ruby-growl',
|
|
30
|
-
[ 'Bullet Notification' ],
|
|
31
|
-
nil,
|
|
32
|
-
@password
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def self.notify( message )
|
|
36
|
-
@growl.notify( 'Bullet Notification', 'Bullet Notification', message )
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module Bullet
|
|
2
|
-
module Presenter
|
|
3
|
-
class JavascriptAlert < Base
|
|
4
|
-
def self.active?
|
|
5
|
-
Bullet.alert
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def self.inline( notice )
|
|
9
|
-
return '' unless self.active?
|
|
10
|
-
|
|
11
|
-
JavascriptHelpers::wrap_js_association "alert( #{notice.standard_notice.inspect} ); "
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
module Bullet
|
|
2
|
-
module Presenter
|
|
3
|
-
class JavascriptConsole < Base
|
|
4
|
-
def self.active?
|
|
5
|
-
Bullet.console
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def self.inline( notice )
|
|
9
|
-
return '' unless active?
|
|
10
|
-
|
|
11
|
-
code = <<-CODE
|
|
12
|
-
if (typeof(console) !== 'undefined') {
|
|
13
|
-
if (console.groupCollapsed && console.groupEnd && console.log) {
|
|
14
|
-
console.groupCollapsed(#{notice.title.inspect});
|
|
15
|
-
console.log(#{notice.body_with_caller.inspect});
|
|
16
|
-
console.groupEnd();
|
|
17
|
-
|
|
18
|
-
} else if (console.log) {
|
|
19
|
-
console.log(#{notice.full_notice.inspect});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
CODE
|
|
23
|
-
|
|
24
|
-
JavascriptHelpers::wrap_js_association code
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module Bullet
|
|
2
|
-
module Presenter
|
|
3
|
-
class RailsLogger < Base
|
|
4
|
-
def self.active?
|
|
5
|
-
Bullet.rails_logger
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def self.out_of_channel( notice )
|
|
9
|
-
return unless active?
|
|
10
|
-
Rails.logger.warn ''
|
|
11
|
-
Rails.logger.warn notice.full_notice
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
module Bullet
|
|
2
|
-
module Presenter
|
|
3
|
-
class Xmpp < Base
|
|
4
|
-
@receiver = nil
|
|
5
|
-
@xmpp = nil
|
|
6
|
-
@password = nil
|
|
7
|
-
|
|
8
|
-
def self.active?
|
|
9
|
-
@xmpp
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def self.out_of_channel( notice )
|
|
13
|
-
return unless active?
|
|
14
|
-
notify( notice.standard_notice )
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def self.setup_connection( xmpp_information )
|
|
18
|
-
require 'xmpp4r'
|
|
19
|
-
|
|
20
|
-
@receiver = xmpp_information[:receiver]
|
|
21
|
-
@password = xmpp_information[:password]
|
|
22
|
-
@account = xmpp_information[:account]
|
|
23
|
-
@show_online_status = xmpp_information[:show_online_status]
|
|
24
|
-
|
|
25
|
-
connect
|
|
26
|
-
rescue MissingSourceFile
|
|
27
|
-
@xmpp = nil
|
|
28
|
-
raise NotificationError.new( 'You must install the xmpp4r gem to use XMPP notifications: `sudo gem install xmpp4r`' )
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
private
|
|
32
|
-
def self.connect
|
|
33
|
-
jid = Jabber::JID.new( @account )
|
|
34
|
-
@xmpp = Jabber::Client.new( jid )
|
|
35
|
-
@xmpp.connect
|
|
36
|
-
@xmpp.auth( @password )
|
|
37
|
-
@xmpp.send( presence_status ) if @show_online_status
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def self.notify( message )
|
|
41
|
-
message = Jabber::Message.new( @receiver, message ).
|
|
42
|
-
set_type( :normal ).
|
|
43
|
-
set_id( '1' ).
|
|
44
|
-
set_subject( 'Bullet Notification' )
|
|
45
|
-
@xmpp.send( message )
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def self.presence_status
|
|
49
|
-
project_name = Rails.root.basename.to_s.camelcase
|
|
50
|
-
time = Time.now
|
|
51
|
-
|
|
52
|
-
Jabber::Presence.new.set_status( "Bullet in project '#{project_name}' started on #{time}" )
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
data/lib/bullet/presenter.rb
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module Bullet
|
|
2
|
-
module Presenter
|
|
3
|
-
autoload :Base, 'bullet/presenter/base'
|
|
4
|
-
autoload :JavascriptAlert, 'bullet/presenter/javascript_alert'
|
|
5
|
-
autoload :JavascriptConsole, 'bullet/presenter/javascript_console'
|
|
6
|
-
autoload :Growl, 'bullet/presenter/growl'
|
|
7
|
-
autoload :Xmpp, 'bullet/presenter/xmpp'
|
|
8
|
-
autoload :RailsLogger, 'bullet/presenter/rails_logger'
|
|
9
|
-
autoload :BulletLogger, 'bullet/presenter/bullet_logger'
|
|
10
|
-
|
|
11
|
-
autoload :JavascriptHelpers, 'bullet/presenter/javascript_helpers'
|
|
12
|
-
end
|
|
13
|
-
end
|
data/rails/init.rb
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require 'bullet'
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
-
|
|
3
|
-
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
|
|
4
|
-
# This test is just used for http://github.com/flyerhzm/bullet/issues/#issue/14
|
|
5
|
-
describe Bullet::Detector::Association do
|
|
6
|
-
|
|
7
|
-
describe "for chris" do
|
|
8
|
-
def setup_db
|
|
9
|
-
ActiveRecord::Schema.define(:version => 1) do
|
|
10
|
-
create_table :locations do |t|
|
|
11
|
-
t.column :name, :string
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
create_table :hotels do |t|
|
|
15
|
-
t.column :name, :string
|
|
16
|
-
t.column :location_id, :integer
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
create_table :deals do |t|
|
|
20
|
-
t.column :name, :string
|
|
21
|
-
t.column :hotel_id, :integer
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def teardown_db
|
|
27
|
-
ActiveRecord::Base.connection.tables.each do |table|
|
|
28
|
-
ActiveRecord::Base.connection.drop_table(table)
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
class Location < ActiveRecord::Base
|
|
33
|
-
has_many :hotels
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
class Hotel < ActiveRecord::Base
|
|
37
|
-
belongs_to :location
|
|
38
|
-
has_many :deals
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
class Deal < ActiveRecord::Base
|
|
42
|
-
belongs_to :hotel
|
|
43
|
-
has_one :location, :through => :hotel
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
before(:all) do
|
|
47
|
-
setup_db
|
|
48
|
-
|
|
49
|
-
location1 = Location.create(:name => "location1")
|
|
50
|
-
location2 = Location.create(:name => "location2")
|
|
51
|
-
|
|
52
|
-
hotel1 = location1.hotels.create(:name => "hotel1")
|
|
53
|
-
hotel2 = location1.hotels.create(:name => "hotel2")
|
|
54
|
-
hotel3 = location2.hotels.create(:name => "hotel3")
|
|
55
|
-
hotel4 = location2.hotels.create(:name => "hotel4")
|
|
56
|
-
|
|
57
|
-
deal1 = hotel1.deals.create(:name => "deal1")
|
|
58
|
-
deal2 = hotel2.deals.create(:name => "deal2")
|
|
59
|
-
deal3 = hotel3.deals.create(:name => "deal3")
|
|
60
|
-
deal4 = hotel4.deals.create(:name => "deal4")
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
after(:all) do
|
|
64
|
-
teardown_db
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
before(:each) do
|
|
68
|
-
Bullet.start_request
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
after(:each) do
|
|
72
|
-
Bullet.end_request
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it "should detect unpreload association from deal to hotel" do
|
|
76
|
-
Deal.all.each do |deal|
|
|
77
|
-
deal.hotel.location.name
|
|
78
|
-
end
|
|
79
|
-
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Deal, :hotel)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
it "should detect unpreload association from hotel to location" do
|
|
83
|
-
Deal.includes(:hotel).each do |deal|
|
|
84
|
-
deal.hotel.location.name
|
|
85
|
-
end
|
|
86
|
-
Bullet::Detector::Association.should be_detecting_unpreloaded_association_for(Hotel, :location)
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it "should not detect unpreload association" do
|
|
90
|
-
Deal.includes({:hotel => :location}).each do |deal|
|
|
91
|
-
deal.hotel.location.name
|
|
92
|
-
end
|
|
93
|
-
Bullet::Detector::Association.should_not be_has_unused_preload_associations
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
-
|
|
3
|
-
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
|
|
4
|
-
# This test is just used for http://github.com/flyerhzm/bullet/issues#issue/20
|
|
5
|
-
describe Bullet::Detector::Association do
|
|
6
|
-
|
|
7
|
-
describe "for peschkaj" do
|
|
8
|
-
def setup_db
|
|
9
|
-
ActiveRecord::Schema.define(:version => 1) do
|
|
10
|
-
create_table :categories do |t|
|
|
11
|
-
t.column :name, :string
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
create_table :submissions do |t|
|
|
15
|
-
t.column :name, :string
|
|
16
|
-
t.column :category_id, :integer
|
|
17
|
-
t.column :user_id, :integer
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
create_table :users do |t|
|
|
21
|
-
t.column :name, :string
|
|
22
|
-
t.column :category_id, :integer
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def teardown_db
|
|
28
|
-
ActiveRecord::Base.connection.tables.each do |table|
|
|
29
|
-
ActiveRecord::Base.connection.drop_table(table)
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
class Category < ActiveRecord::Base
|
|
34
|
-
has_many :submissions
|
|
35
|
-
has_many :users
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
class Submission < ActiveRecord::Base
|
|
39
|
-
belongs_to :category
|
|
40
|
-
belongs_to :user
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
class User < ActiveRecord::Base
|
|
44
|
-
has_one :submission
|
|
45
|
-
belongs_to :category
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
before(:all) do
|
|
49
|
-
setup_db
|
|
50
|
-
|
|
51
|
-
category1 = Category.create(:name => "category1")
|
|
52
|
-
category2 = Category.create(:name => "category2")
|
|
53
|
-
|
|
54
|
-
user1 = User.create(:name => 'user1', :category => category1)
|
|
55
|
-
user2 = User.create(:name => 'user2', :category => category1)
|
|
56
|
-
|
|
57
|
-
submission1 = category1.submissions.create(:name => "submission1", :user => user1)
|
|
58
|
-
submission2 = category1.submissions.create(:name => "submission2", :user => user2)
|
|
59
|
-
submission3 = category2.submissions.create(:name => "submission3", :user => user1)
|
|
60
|
-
submission4 = category2.submissions.create(:name => "submission4", :user => user2)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
after(:all) do
|
|
64
|
-
teardown_db
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
before(:each) do
|
|
68
|
-
Bullet.start_request
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
after(:each) do
|
|
72
|
-
Bullet.end_request
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
it "should not detect unused preload associations" do
|
|
76
|
-
category = Category.includes({:submissions => :user}).order("id DESC").find_by_name('category1')
|
|
77
|
-
category.submissions.map do |submission|
|
|
78
|
-
submission.name
|
|
79
|
-
submission.user.name
|
|
80
|
-
end
|
|
81
|
-
Bullet::Detector::UnusedEagerAssociation.check_unused_preload_associations
|
|
82
|
-
Bullet::Detector::Association.should_not be_unused_preload_associations_for(Category, :submissions)
|
|
83
|
-
Bullet::Detector::Association.should_not be_unused_preload_associations_for(Submission, :user)
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
end
|