g 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +6 -3
  2. data/lib/g.rb +16 -2
  3. data/spec/g_spec.rb +22 -11
  4. metadata +2 -2
data/Rakefile CHANGED
@@ -1,7 +1,10 @@
1
1
  $:.unshift File.dirname(__FILE__) + '/lib/'
2
2
 
3
- task :spec do
4
- system 'spec', 'spec'
3
+ require 'spec/rake/spectask'
4
+ desc 'run all specs'
5
+ Spec::Rake::SpecTask.new do |t|
6
+ t.spec_files = FileList['spec/**/*_spec.rb']
7
+ t.spec_opts = ['-c']
5
8
  end
6
9
 
7
10
  desc 'Generate gemspec'
@@ -10,7 +13,7 @@ task :gemspec do |t|
10
13
  file << <<-EOS
11
14
  Gem::Specification.new do |s|
12
15
  s.name = 'g'
13
- s.version = '1.0.0'
16
+ s.version = '1.1.0'
14
17
  s.summary = "The Kernel.g that works like Kernel.p on growl :)"
15
18
  s.description = "The Kernel.g that works like Kernel.p on growl :)"
16
19
  s.files = %w( #{Dir['lib/**/*.rb'].join(' ')}
data/lib/g.rb CHANGED
@@ -5,7 +5,21 @@ require 'pp'
5
5
  module Kernel
6
6
  GROWL = Growl.new "localhost", $0, ["Kernel.g"]
7
7
  def g(*args)
8
- args.each { |i| GROWL.notify "Kernel.g", $0, i.pretty_inspect }
9
- nil
8
+ messages =
9
+ if args.empty?
10
+ [nil.pretty_inspect]
11
+ else
12
+ args.map { |i| i.pretty_inspect }
13
+ end
14
+
15
+ messages.each { |i| GROWL.notify "Kernel.g", $0, i }
16
+
17
+ if args.empty?
18
+ nil
19
+ elsif args.size == 1
20
+ args.first
21
+ else
22
+ args
23
+ end
10
24
  end
11
25
  end
data/spec/g_spec.rb CHANGED
@@ -1,14 +1,25 @@
1
1
  $:.unshift File.dirname(__FILE__) + '/../lib'
2
2
  require 'g'
3
3
 
4
- g 'foo', 'bar'
5
- g 1
6
- g self
7
- g %w(foo bar)
8
- g ({:a=>"aaaaaaaaaaaaaaaaaa",
9
- :b=>"bbbbbbbbbbbbbbbbbbb",
10
- :c=>
11
- ["cccccccccccccccc",
12
- "CCCCCCCCCCCCCCCCC",
13
- "c c c c c ",
14
- "C C C C C C C C C "]})
4
+ describe 'g' do
5
+ it 'calls with a arg' do
6
+ Kernel::GROWL.should_receive(:notify).with("Kernel.g", $0, 'foo'.pretty_inspect)
7
+ g 'foo'
8
+ end
9
+
10
+ it 'calls with args' do
11
+ Kernel::GROWL.should_receive(:notify).twice
12
+ g 'foo', 'bar'
13
+ end
14
+
15
+ it 'calls without args' do
16
+ Kernel::GROWL.should_receive(:notify).with("Kernel.g", $0, nil.pretty_inspect)
17
+ g
18
+ end
19
+
20
+ it 'should return original args' do
21
+ g('foo').should == 'foo'
22
+ g('foo', 'bar').should == ['foo', 'bar']
23
+ g().should == nil
24
+ end
25
+ 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.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jugyo
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-21 00:00:00 +09:00
12
+ date: 2009-05-23 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency