g 1.1.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/.gitignore +3 -0
  2. data/Rakefile +18 -31
  3. data/VERSION +1 -0
  4. data/g.gemspec +16 -0
  5. data/lib/g.rb +11 -4
  6. data/spec/g_spec.rb +18 -12
  7. metadata +30 -15
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ pkg
3
+
data/Rakefile CHANGED
@@ -1,4 +1,21 @@
1
- $:.unshift File.dirname(__FILE__) + '/lib/'
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "g"
8
+ gem.summary = %Q{g is like p}
9
+ gem.description = %Q{The Kernel.g that works like Kernel.p on growl :)}
10
+ gem.email = "jugyo.org@gmail.com"
11
+ gem.homepage = "http://github.com/jugyo/g"
12
+ gem.authors = ["jugyo"]
13
+ gem.add_development_dependency "rspec", ">= 0"
14
+ gem.add_dependency "ruby-growl", ">= 1.0.1"
15
+ end
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
18
+ end
2
19
 
3
20
  require 'spec/rake/spectask'
4
21
  desc 'run all specs'
@@ -6,33 +23,3 @@ Spec::Rake::SpecTask.new do |t|
6
23
  t.spec_files = FileList['spec/**/*_spec.rb']
7
24
  t.spec_opts = ['-c']
8
25
  end
9
-
10
- desc 'Generate gemspec'
11
- task :gemspec do |t|
12
- open('g.gemspec', "wb" ) do |file|
13
- file << <<-EOS
14
- Gem::Specification.new do |s|
15
- s.name = 'g'
16
- s.version = '1.1.0'
17
- s.summary = "The Kernel.g that works like Kernel.p on growl :)"
18
- s.description = "The Kernel.g that works like Kernel.p on growl :)"
19
- s.files = %w( #{Dir['lib/**/*.rb'].join(' ')}
20
- #{Dir['spec/**/*.rb'].join(' ')}
21
- README.markdown
22
- Rakefile )
23
- s.add_dependency("ruby-growl", ">= 1.0.1")
24
- s.author = 'jugyo'
25
- s.email = 'jugyo.org@gmail.com'
26
- s.homepage = 'http://github.com/jugyo/g'
27
- s.rubyforge_project = 'kernelg'
28
- s.has_rdoc = false
29
- end
30
- EOS
31
- end
32
- puts "Generate gemspec"
33
- end
34
-
35
- desc 'Generate gem'
36
- task :gem => :gemspec do |t|
37
- system 'gem', 'build', 'g.gemspec'
38
- end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.3.0
data/g.gemspec ADDED
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'g'
3
+ s.version = '1.2.0'
4
+ s.summary = "The Kernel.g that works like Kernel.p on growl :)"
5
+ s.description = "The Kernel.g that works like Kernel.p on growl :)"
6
+ s.files = %w( lib/g.rb
7
+ spec/g_spec.rb
8
+ README.markdown
9
+ Rakefile )
10
+ s.add_dependency("ruby-growl", ">= 1.0.1")
11
+ s.author = 'jugyo'
12
+ s.email = 'jugyo.org@gmail.com'
13
+ s.homepage = 'http://github.com/jugyo/g'
14
+ s.rubyforge_project = 'kernelg'
15
+ s.has_rdoc = false
16
+ end
data/lib/g.rb CHANGED
@@ -2,17 +2,24 @@ require 'rubygems'
2
2
  require 'ruby-growl'
3
3
  require 'pp'
4
4
 
5
+ $g_host ||= "localhost"
6
+ $g_priority ||= 0
7
+ $g_sticky ||= true
8
+
5
9
  module Kernel
6
- GROWL = Growl.new "localhost", $0, ["Kernel.g"]
7
- def g(*args)
10
+ def g(*args, &block)
11
+ growl = Growl.new $g_host, 'g', [$0]
12
+
13
+ args.push(block) if block
14
+
8
15
  messages =
9
16
  if args.empty?
10
- [nil.pretty_inspect]
17
+ ['g!']
11
18
  else
12
19
  args.map { |i| i.pretty_inspect }
13
20
  end
14
21
 
15
- messages.each { |i| GROWL.notify "Kernel.g", $0, i }
22
+ messages.each { |i| growl.notify $0, 'g', i, $g_priority, $g_sticky }
16
23
 
17
24
  if args.empty?
18
25
  nil
data/spec/g_spec.rb CHANGED
@@ -2,24 +2,30 @@ $:.unshift File.dirname(__FILE__) + '/../lib'
2
2
  require 'g'
3
3
 
4
4
  describe 'g' do
5
+ before do
6
+ @g = Object.new
7
+ Growl.should_receive(:new).and_return(@g)
8
+ end
9
+
5
10
  it 'calls with a arg' do
6
- Kernel::GROWL.should_receive(:notify).with("Kernel.g", $0, 'foo'.pretty_inspect)
7
- g 'foo'
11
+ @g.should_receive(:notify).with($0, "g", 'foo'.pretty_inspect, 0, true)
12
+ g('foo').should == 'foo'
8
13
  end
9
14
 
10
- it 'calls with args' do
11
- Kernel::GROWL.should_receive(:notify).twice
12
- g 'foo', 'bar'
15
+ it 'calls with block' do
16
+ block = Proc.new {}
17
+ @g.should_receive(:notify).with($0, "g", block.pretty_inspect, 0, true)
18
+ g(&block).should == block
13
19
  end
14
20
 
15
- it 'calls without args' do
16
- Kernel::GROWL.should_receive(:notify).with("Kernel.g", $0, nil.pretty_inspect)
17
- g
21
+ it 'calls with args' do
22
+ block = Proc.new {}
23
+ @g.should_receive(:notify).exactly(3).times
24
+ g('foo', 1, &block).should == ['foo', 1, block]
18
25
  end
19
26
 
20
- it 'should return original args' do
21
- g('foo').should == 'foo'
22
- g('foo', 'bar').should == ['foo', 'bar']
23
- g().should == nil
27
+ it 'calls without args' do
28
+ @g.should_receive(:notify).with($0, "g", "g!", 0, true)
29
+ g.should == nil
24
30
  end
25
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: g
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jugyo
@@ -9,9 +9,19 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-23 00:00:00 +09:00
12
+ date: 2009-12-15 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
15
25
  - !ruby/object:Gem::Dependency
16
26
  name: ruby-growl
17
27
  type: :runtime
@@ -28,18 +38,23 @@ executables: []
28
38
 
29
39
  extensions: []
30
40
 
31
- extra_rdoc_files: []
32
-
41
+ extra_rdoc_files:
42
+ - README.markdown
33
43
  files:
34
- - lib/g.rb
35
- - spec/g_spec.rb
44
+ - .gitignore
36
45
  - README.markdown
37
46
  - Rakefile
38
- has_rdoc: false
47
+ - VERSION
48
+ - g.gemspec
49
+ - lib/g.rb
50
+ - spec/g_spec.rb
51
+ has_rdoc: true
39
52
  homepage: http://github.com/jugyo/g
40
- post_install_message:
41
- rdoc_options: []
53
+ licenses: []
42
54
 
55
+ post_install_message:
56
+ rdoc_options:
57
+ - --charset=UTF-8
43
58
  require_paths:
44
59
  - lib
45
60
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -56,10 +71,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
71
  version:
57
72
  requirements: []
58
73
 
59
- rubyforge_project: kernelg
60
- rubygems_version: 1.3.1
74
+ rubyforge_project:
75
+ rubygems_version: 1.3.5
61
76
  signing_key:
62
- specification_version: 2
63
- summary: The Kernel.g that works like Kernel.p on growl :)
64
- test_files: []
65
-
77
+ specification_version: 3
78
+ summary: g is like p
79
+ test_files:
80
+ - spec/g_spec.rb