slowgrowl 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ .gem
2
+ .swp
data/Gemfile CHANGED
@@ -1,7 +1,12 @@
1
- source 'http://rubygems.org'
1
+ require 'lib/platform'
2
2
 
3
- gem 'growl'
3
+ source :rubygems
4
+ source :gemcutter
5
+
6
+ SlowGrowl::GEMS.each do |dep|
7
+ gem dep[:name], :require => (dep[:require] || dep[:name])
8
+ end
4
9
 
5
10
  # group :test do
6
11
  # gem 'rspec'
7
- # end
12
+ # end
data/README.md CHANGED
@@ -1,30 +1,30 @@
1
- SlowGrowl
2
- =========
3
-
4
- Rails 3 plugin which surfaces slow code paths in your Rails application by integrating with the new Notifications API in Rails 3 with your system Growl notification service. By default, any activity which takes longer than one second, will generate a growl alert, with the description of the action, time taken, and other meta data. A preview in action:
5
-
6
- ![slowgrowl notification](http://img.skitch.com/20100804-8w1wte8bad7tby418kmucs4hsm.png)
7
-
8
- Integrating with Rails 3
9
- ------------------------
10
-
11
- # in your Gemfile
12
- group :development do
13
- gem 'slowgrowl'
14
- end
15
-
16
- That's it.
17
-
18
- Optional Configuration for SlowGrowl
19
- ------------------------------------
20
-
21
- # in your config/environments/development.rb
22
- config.slowgrowl.warn = 1000 # growl any action which takes > 1000ms (1s)
23
- config.slowgrowl.sticky = true # make really slow (2x warn) alerts sticky
24
-
25
- Resources
26
- ---------
27
-
28
- * [Rails 3 Internals: Railtie & Creating Plugins](http://www.igvita.com/2010/08/04/rails-3-internals-railtie-creating-plugins/)
29
- * [Rails 3 Notifications API](http://edgeapi.rubyonrails.org/classes/ActiveSupport/Notifications.html)
30
- * [Railties](http://edgeapi.rubyonrails.org/classes/Rails/Railtie.html)
1
+ SlowGrowl
2
+ =========
3
+
4
+ Rails 3 plugin which surfaces slow code paths in your Rails application by integrating with the new Notifications API in Rails 3 with your system Growl (OSX) or libnotify (Linux) notification service. By default, any activity which takes longer than one second, will generate a growl alert, with the description of the action, time taken, and other meta data. A preview in action:
5
+
6
+ ![slowgrowl notification](http://img.skitch.com/20100804-8w1wte8bad7tby418kmucs4hsm.png)
7
+
8
+ Integrating with Rails 3
9
+ ------------------------
10
+
11
+ # in your Gemfile
12
+ group :development do
13
+ gem 'slowgrowl'
14
+ end
15
+
16
+ That's it.
17
+
18
+ Optional Configuration for SlowGrowl
19
+ ------------------------------------
20
+
21
+ # in your config/environments/development.rb
22
+ config.slowgrowl.warn = 1000 # growl any action which takes > 1000ms (1s)
23
+ config.slowgrowl.sticky = true # make really slow (2x warn) alerts sticky
24
+
25
+ Resources
26
+ ---------
27
+
28
+ * [Rails 3 Internals: Railtie & Creating Plugins](http://www.igvita.com/2010/08/04/rails-3-internals-railtie-creating-plugins/)
29
+ * [Rails 3 Notifications API](http://edgeapi.rubyonrails.org/classes/ActiveSupport/Notifications.html)
30
+ * [Railties](http://edgeapi.rubyonrails.org/classes/Rails/Railtie.html)
data/Rakefile CHANGED
@@ -3,18 +3,9 @@ require 'spec/rake/spectask'
3
3
 
4
4
  begin
5
5
  require 'jeweler'
6
- Jeweler::Tasks.new do |gemspec|
7
- gemspec.name = 'slowgrowl'
8
- gemspec.summary = 'Surface slow code paths in your Rails 3 app via Growl'
9
- gemspec.description = gemspec.summary
10
- gemspec.email = 'ilya@igvita.com'
11
- gemspec.homepage = 'http://github.com/igrigorik/slowgrowl'
12
- gemspec.authors = ['Ilya Grigorik']
13
- gemspec.add_dependency('growl')
14
- gemspec.rubyforge_project = 'slowgrowl'
15
- end
16
-
6
+ Jeweler::Tasks.new
17
7
  Jeweler::GemcutterTasks.new
18
- rescue LoadError
8
+ rescue LoadError => e
9
+ puts e.inspect
19
10
  puts 'Jeweler not available. Install it with: sudo gem install jeweler -s http://gemcutter.org'
20
- end
11
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/lib/platform.rb ADDED
@@ -0,0 +1,9 @@
1
+ module SlowGrowl
2
+ if RUBY_PLATFORM =~ /linux/i
3
+ NOTIFIER = :libnotify
4
+ GEMS = [{:name => 'gtk2'}, {:name => 'ruby-libnotify', :require => 'rnotify'}]
5
+ else
6
+ NOTIFIER = :growl
7
+ GEMS = [{:name => 'growl'}]
8
+ end
9
+ end
data/lib/slowgrowl.rb CHANGED
@@ -1,4 +1,8 @@
1
- require 'growl'
1
+ require 'platform'
2
+
3
+ SlowGrowl::GEMS.each do |dep|
4
+ require (dep[:require] || dep[:name])
5
+ end
2
6
 
3
7
  module SlowGrowl
4
8
  class Railtie < Rails::Railtie
@@ -7,9 +11,9 @@ module SlowGrowl
7
11
  config.slowgrowl.sticky = false # should error warnings be sticky?
8
12
 
9
13
  initializer "slowgrowl.initialize" do |app|
10
-
11
14
  ActiveSupport::Notifications.subscribe do |*args|
12
- if Growl.installed?
15
+
16
+ if NOTIFIER
13
17
  event = ActiveSupport::Notifications::Event.new(*args)
14
18
 
15
19
  sticky = false
@@ -59,14 +63,22 @@ module SlowGrowl
59
63
  end
60
64
 
61
65
  if alert
62
- Growl.send("notify_#{alert}", message, {
63
- :title => "%1.fms - %s : %s" % [event.duration, action.humanize, type.camelize],
64
- :sticky => sticky
65
- })
66
+ title = "%1.fms - %s : %s" % [event.duration, action.humanize, type.camelize]
67
+
68
+ case NOTIFIER
69
+ when :growl
70
+ if Growl.installed?
71
+ Growl.send("notify_#{alert}", message, {:title => title, :sticky => sticky})
72
+ end
73
+
74
+ when :libnotify
75
+ Notify::Notification.new(title, message, nil, nil).show
76
+ end
66
77
  end
78
+
67
79
  end
68
80
  end
69
81
 
70
82
  end
71
83
  end
72
- end
84
+ end
data/slowgrowl.gemspec ADDED
@@ -0,0 +1,44 @@
1
+ require 'lib/platform'
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{slowgrowl}
5
+ s.version = "0.1.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Ilya Grigorik", "Milan Dobrota"]
9
+ s.date = %q{2010-08-14}
10
+ s.description = %q{Surface slow code paths in your Rails 3 app via Growl / libnotify}
11
+ s.email = %q{ilya@igvita.com}
12
+ s.extra_rdoc_files = [
13
+ "README.md"
14
+ ]
15
+ s.files = [
16
+ ".gitignore",
17
+ "Gemfile",
18
+ "README.md",
19
+ "Rakefile",
20
+ "VERSION",
21
+ "lib/platform.rb",
22
+ "lib/slowgrowl.rb",
23
+ "slowgrowl.gemspec"
24
+ ]
25
+ s.homepage = %q{http://github.com/igrigorik/slowgrowl}
26
+ s.rdoc_options = ["--charset=UTF-8"]
27
+ s.require_paths = ["lib"]
28
+ s.rubyforge_project = %q{slowgrowl}
29
+ s.rubygems_version = %q{1.3.6}
30
+ s.summary = s.description
31
+
32
+ if s.respond_to? :specification_version then
33
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
34
+ s.specification_version = 3
35
+
36
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
37
+ SlowGrowl::GEMS.each { |dep| s.add_runtime_dependency(dep[:name], [">= 0"]) }
38
+ else
39
+ SlowGrowl::GEMS.each { |dep| s.add_dependency(dep[:name], [">= 0"]) }
40
+ end
41
+ else
42
+ SlowGrowl::GEMS.each { |dep| s.add_dependency(dep[:name], [">= 0"]) }
43
+ end
44
+ end
metadata CHANGED
@@ -5,16 +5,17 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ilya Grigorik
13
+ - Milan Dobrota
13
14
  autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-08-04 00:00:00 -04:00
18
+ date: 2010-08-14 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -29,7 +30,7 @@ dependencies:
29
30
  version: "0"
30
31
  type: :runtime
31
32
  version_requirements: *id001
32
- description: Surface slow code paths in your Rails 3 app via Growl
33
+ description: Surface slow code paths in your Rails 3 app via Growl / libnotify
33
34
  email: ilya@igvita.com
34
35
  executables: []
35
36
 
@@ -38,11 +39,14 @@ extensions: []
38
39
  extra_rdoc_files:
39
40
  - README.md
40
41
  files:
42
+ - .gitignore
41
43
  - Gemfile
42
44
  - README.md
43
45
  - Rakefile
44
46
  - VERSION
47
+ - lib/platform.rb
45
48
  - lib/slowgrowl.rb
49
+ - slowgrowl.gemspec
46
50
  has_rdoc: true
47
51
  homepage: http://github.com/igrigorik/slowgrowl
48
52
  licenses: []
@@ -72,6 +76,6 @@ rubyforge_project: slowgrowl
72
76
  rubygems_version: 1.3.6
73
77
  signing_key:
74
78
  specification_version: 3
75
- summary: Surface slow code paths in your Rails 3 app via Growl
79
+ summary: Surface slow code paths in your Rails 3 app via Growl / libnotify
76
80
  test_files: []
77
81