jugyo-g 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +7 -0
- data/Rakefile +6 -3
- data/lib/g.rb +16 -2
- data/spec/g_spec.rb +22 -11
- metadata +1 -1
data/README.markdown
CHANGED
|
@@ -11,11 +11,18 @@ The Kernel.g that works like Kernel.p on growl :)
|
|
|
11
11
|
Install
|
|
12
12
|
--------
|
|
13
13
|
|
|
14
|
+
sudo gem install g
|
|
15
|
+
|
|
16
|
+
or
|
|
17
|
+
|
|
14
18
|
sudo gem install jugyo-g --source http://gems.github.com
|
|
15
19
|
|
|
16
20
|
Synopsis
|
|
17
21
|
--------
|
|
18
22
|
|
|
23
|
+
require 'rubygems'
|
|
24
|
+
require 'g'
|
|
25
|
+
|
|
19
26
|
g 'foo'
|
|
20
27
|
g 1
|
|
21
28
|
g self
|
data/Rakefile
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
$:.unshift File.dirname(__FILE__) + '/lib/'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
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.
|
|
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
|
-
|
|
9
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
g
|
|
7
|
-
g
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|