Skip to content

Commit

Permalink
ruby-growl => ruby_gntp
Browse files Browse the repository at this point in the history
  • Loading branch information
jugyo committed Nov 14, 2011
1 parent 2b5e8af commit f71748c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
13 changes: 7 additions & 6 deletions Rakefile
Expand Up @@ -11,15 +11,16 @@ begin
gem.homepage = "http://github.com/jugyo/g"
gem.authors = ["jugyo"]
gem.add_development_dependency "rspec", ">= 0"
gem.add_dependency "ruby-growl", ">= 1.0.1"
gem.add_dependency "ruby_gntp", ">= 1.0.1"
end
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
end

require 'spec/rake/spectask'
desc 'run all specs'
Spec::Rake::SpecTask.new do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_opts = ['-c']
require 'rspec/core'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end

task :default => :spec
7 changes: 4 additions & 3 deletions lib/g.rb
@@ -1,5 +1,5 @@
require 'rubygems'
require 'ruby-growl'
require 'ruby_gntp'
require 'pp'

$g_host ||= "localhost"
Expand All @@ -8,7 +8,7 @@

module Kernel
def g(*args, &block)
growl = Growl.new $g_host, 'g', [$0]
# growl = Growl.new $g_host, 'g', [$0]

args.push(block) if block

Expand All @@ -19,7 +19,8 @@ def g(*args, &block)
args.map { |i| i.pretty_inspect }
end

messages.each { |i| growl.notify $0, 'g', i, $g_priority, $g_sticky }
# messages.each { |i| growl.notify $0, 'g', i, $g_priority, $g_sticky }
messages.each { |i| GNTP.notify :app_name => $0, :title => 'g', :text => i, :sticky => $g_sticky }

if args.empty?
nil
Expand Down
13 changes: 4 additions & 9 deletions spec/g_spec.rb
Expand Up @@ -2,30 +2,25 @@
require 'g'

describe 'g' do
before do
@g = Object.new
Growl.should_receive(:new).and_return(@g)
end

it 'calls with a arg' do
@g.should_receive(:notify).with($0, "g", 'foo'.pretty_inspect, 0, true)
GNTP.should_receive(:notify).with(:app_name => $0, :title => "g", :text => "foo".pretty_inspect, :sticky=>true)
g('foo').should == 'foo'
end

it 'calls with block' do
block = Proc.new {}
@g.should_receive(:notify).with($0, "g", block.pretty_inspect, 0, true)
GNTP.should_receive(:notify).with(:app_name => $0, :title => "g", :text => block.pretty_inspect, :sticky=>true)
g(&block).should == block
end

it 'calls with args' do
block = Proc.new {}
@g.should_receive(:notify).exactly(3).times
GNTP.should_receive(:notify).exactly(3).times
g('foo', 1, &block).should == ['foo', 1, block]
end

it 'calls without args' do
@g.should_receive(:notify).with($0, "g", "g!", 0, true)
GNTP.should_receive(:notify).with(:app_name => $0, :title => "g", :text => "g!", :sticky=>true)
g.should == nil
end
end

0 comments on commit f71748c

Please sign in to comment.