growl_notifier 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
File without changes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -0,0 +1,48 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{growl_notifier}
8
+ s.version = "1.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Satoshi Nakagawa", "Eloy Duran", "JP Hastings-Spital"]
12
+ s.date = %q{2010-08-02}
13
+ s.description = %q{A ruby library which allows you to send Growl notifications.}
14
+ s.email = ["psychs@limechat.net", "e.duran@superalloy.nl", "jphastings@gmail.com"]
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc",
18
+ "TODO"
19
+ ]
20
+ s.files = [
21
+ ".gitignore",
22
+ "History.txt",
23
+ "LICENSE",
24
+ "Manifest.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "TODO",
28
+ "VERSION",
29
+ "growl_notifier.gemspec",
30
+ "lib/growl_notifier.rb"
31
+ ]
32
+ s.homepage = %q{http://github.com/jphastings/growl_notifier}
33
+ s.rdoc_options = ["--charset=UTF-8"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.3.7}
36
+ s.summary = %q{Growl::Notifier is a OSX RubyCocoa class that allows your application to post notifications to the Growl daemon.}
37
+
38
+ if s.respond_to? :specification_version then
39
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
40
+ s.specification_version = 3
41
+
42
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
+ else
44
+ end
45
+ else
46
+ end
47
+ end
48
+
@@ -1,9 +1,50 @@
1
1
  require 'osx/cocoa'
2
2
 
3
3
  module Growl
4
- class Notifier < OSX::NSObject
5
- VERSION = '1.0.2'
4
+ class Logger
5
+ attr_accessor :level
6
+
7
+ LEVELS = [:debug,:info,:warn,:error,:fatal]
8
+
9
+ def initialize(app_name = "#{__FILE__} logger", default_notifications = nil, application_icon = nil)
10
+ # Check to see if Growl is available?
11
+ @log = Notifier.sharedInstance
12
+ @log.register(app_name,LEVELS.collect{|w| w.to_s.capitalize},default_notifications, application_icon)
13
+ @level = :info
14
+ end
6
15
 
16
+ def level=(level)
17
+ @level = parse_level(level)
18
+ end
19
+
20
+ def fatal(message,title=nil); log(:fatal,message,title); end
21
+ def error(message,title=nil); log(:error,message,title); end
22
+ def warn(message,title=nil); log(:warn,message,title); end
23
+ def info(message,title=nil); log(:info,message,title); end
24
+ def debug(message,title=nil); log(:debug,message,title); end
25
+
26
+ def log(level,message,title=nil)
27
+ level = parse_level(level)
28
+ if LEVELS.index(@level) <= LEVELS.index(level)
29
+ title ||= level.to_s.capitalize
30
+ @log.notify(level.to_s.capitalize, title, message)
31
+ end
32
+ end
33
+
34
+ private
35
+ def parse_level(level)
36
+ case level
37
+ when Symbol,String
38
+ (LEVELS.include? level.to_sym) ? level.to_sym : :info
39
+ when 0..5
40
+ LEVELS[level]
41
+ else
42
+ raise ArgumentError, "Please use Symbols (see Growl::Logger::LEVELS) or Logger Constants (eg. Logger::WARN)"
43
+ end
44
+ end
45
+ end
46
+
47
+ class Notifier < OSX::NSObject
7
48
  GROWL_IS_READY = "Lend Me Some Sugar; I Am Your Neighbor!"
8
49
  GROWL_NOTIFICATION_CLICKED = "GrowlClicked!"
9
50
  GROWL_NOTIFICATION_TIMED_OUT = "GrowlTimedOut!"
@@ -167,4 +208,4 @@ module Growl
167
208
  notification_center.addObserver_selector_name_object self, selector, name, nil
168
209
  end
169
210
  end
170
- end
211
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: growl_notifier
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Satoshi Nakagawa
@@ -32,18 +32,18 @@ extensions: []
32
32
 
33
33
  extra_rdoc_files:
34
34
  - LICENSE
35
- - README.txt
35
+ - README.rdoc
36
36
  - TODO
37
37
  files:
38
38
  - .gitignore
39
39
  - History.txt
40
40
  - LICENSE
41
41
  - Manifest.txt
42
- - README.txt
42
+ - README.rdoc
43
43
  - Rakefile
44
44
  - TODO
45
45
  - VERSION
46
- - init.rb
46
+ - growl_notifier.gemspec
47
47
  - lib/growl_notifier.rb
48
48
  has_rdoc: true
49
49
  homepage: http://github.com/jphastings/growl_notifier
data/init.rb DELETED
@@ -1,2 +0,0 @@
1
- require File.expand_path('../lib/growl', __FILE__)
2
- require File.expand_path('../lib/growl_helpers', __FILE__)