g 1.5.0 → 1.6.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/g.gemspec +1 -1
  2. data/lib/g.rb +12 -11
  3. data/spec/g_spec.rb +12 -12
  4. metadata +5 -5
data/g.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "g"
4
- s.version = "1.5.0"
4
+ s.version = "1.6.0"
5
5
  s.authors = ["jugyo"]
6
6
  s.email = ["jugyo.org@gmail.com"]
7
7
  s.homepage = "http://github.com/jugyo/g"
data/lib/g.rb CHANGED
@@ -7,23 +7,24 @@ $g_priority ||= 0
7
7
  $g_sticky ||= true
8
8
 
9
9
  module Kernel
10
- def g(*args, &block)
11
- # growl = Growl.new $g_host, 'g', [$0]
10
+ def g(*args)
11
+ messages = args.dup
12
12
 
13
- args.push(block) if block
14
-
15
- messages =
16
- if args.empty?
17
- ['g!']
13
+ if messages.empty?
14
+ if block_given?
15
+ messages << yield(self)
18
16
  else
19
- args.map { |i| i.pretty_inspect }
17
+ messages << self
20
18
  end
19
+ end
21
20
 
22
- # messages.each { |i| growl.notify $0, 'g', i, $g_priority, $g_sticky }
23
- messages.each { |i| GNTP.notify :app_name => $0, :title => 'g', :text => i, :sticky => $g_sticky }
21
+ messages.each do |i|
22
+ text = i.is_a?(String) ? i : i.pretty_inspect
23
+ GNTP.notify :app_name => $0, :title => 'g', :text => text, :sticky => $g_sticky
24
+ end
24
25
 
25
26
  if args.empty?
26
- nil
27
+ self
27
28
  elsif args.size == 1
28
29
  args.first
29
30
  else
@@ -3,24 +3,24 @@ require 'g'
3
3
 
4
4
  describe 'g' do
5
5
  it 'calls with a arg' do
6
- GNTP.should_receive(:notify).with(:app_name => $0, :title => "g", :text => "foo".pretty_inspect, :sticky=>true)
6
+ GNTP.should_receive(:notify).with(:app_name => $0, :title => "g", :text => "foo", :sticky=>true)
7
7
  g('foo').should == 'foo'
8
8
  end
9
9
 
10
- it 'calls with block' do
11
- block = Proc.new {}
12
- GNTP.should_receive(:notify).with(:app_name => $0, :title => "g", :text => block.pretty_inspect, :sticky=>true)
13
- g(&block).should == block
10
+ it 'calls with args' do
11
+ GNTP.should_receive(:notify).exactly(2).times
12
+ g('foo', 1).should == ['foo', 1]
14
13
  end
15
14
 
16
- it 'calls with args' do
17
- block = Proc.new {}
18
- GNTP.should_receive(:notify).exactly(3).times
19
- g('foo', 1, &block).should == ['foo', 1, block]
15
+ it 'calls for instance' do
16
+ object = Object.new
17
+ GNTP.should_receive(:notify).with(:app_name => $0, :title => "g", :text => object.pretty_inspect, :sticky=>true)
18
+ object.g.should == object
20
19
  end
21
20
 
22
- it 'calls without args' do
23
- GNTP.should_receive(:notify).with(:app_name => $0, :title => "g", :text => "g!", :sticky=>true)
24
- g.should == nil
21
+ it 'calls with &block' do
22
+ object = "foo"
23
+ GNTP.should_receive(:notify).with(:app_name => $0, :title => "g", :text => "FOO", :sticky=>true)
24
+ object.g {|i| i.upcase}.should == object
25
25
  end
26
26
  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.5.0
4
+ version: 1.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-14 00:00:00.000000000Z
12
+ date: 2012-01-13 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby_gntp
16
- requirement: &2169115360 !ruby/object:Gem::Requirement
16
+ requirement: &70154826525400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2169115360
24
+ version_requirements: *70154826525400
25
25
  description: It works like Kernel.p with growl :)
26
26
  email:
27
27
  - jugyo.org@gmail.com
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
57
  version: '0'
58
58
  requirements: []
59
59
  rubyforge_project: g
60
- rubygems_version: 1.8.11
60
+ rubygems_version: 1.8.10
61
61
  signing_key:
62
62
  specification_version: 3
63
63
  summary: The Kernel.g