g 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,3 @@
1
1
  *.gem
2
2
  pkg
3
-
3
+ Gemfile.lock
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.6.0"
4
+ s.version = "1.7.0"
5
5
  s.authors = ["jugyo"]
6
6
  s.email = ["jugyo.org@gmail.com"]
7
7
  s.homepage = "http://github.com/jugyo/g"
@@ -12,5 +12,6 @@ Gem::Specification.new do |s|
12
12
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
13
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
14
14
  s.require_paths = ["lib"]
15
- s.add_runtime_dependency "ruby_gntp"
15
+ s.add_development_dependency "ruby_gntp"
16
+ s.add_development_dependency "rspec"
16
17
  end
data/lib/g.rb CHANGED
@@ -1,12 +1,11 @@
1
- require 'rubygems'
2
- require 'ruby_gntp'
3
1
  require 'pp'
4
2
 
5
- $g_host ||= "localhost"
6
- $g_priority ||= 0
7
- $g_sticky ||= true
8
-
9
3
  module Kernel
4
+ def self._g_function(&block)
5
+ @_g_function = block if block
6
+ @_g_function
7
+ end
8
+
10
9
  def g(*args)
11
10
  messages = args.dup
12
11
 
@@ -20,7 +19,11 @@ module Kernel
20
19
 
21
20
  messages.each do |i|
22
21
  text = i.is_a?(String) ? i : i.pretty_inspect
23
- GNTP.notify :app_name => $0, :title => 'g', :text => text, :sticky => $g_sticky
22
+ if Kernel._g_function
23
+ Kernel._g_function.call($0, 'g', text)
24
+ else
25
+ p text
26
+ end
24
27
  end
25
28
 
26
29
  if args.empty?
@@ -32,3 +35,15 @@ module Kernel
32
35
  end
33
36
  end
34
37
  end
38
+
39
+ catch(:break) do
40
+ %w(terminal-notifier ruby_gntp).each do |lib|
41
+ begin
42
+ require lib
43
+ require "g/#{lib}"
44
+ throw :break
45
+ rescue LoadError
46
+ end
47
+ end
48
+ warn 'Please install `terminal-notifier` or `ruby_gntp`.'
49
+ end
@@ -0,0 +1,5 @@
1
+ module Kernel
2
+ _g_function do |app_name, title, text|
3
+ GNTP.notify :app_name => app_name, :title => title, :text => text
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Kernel
2
+ _g_function do |app_name, title, text|
3
+ TerminalNotifier.notify(text, :title => title)
4
+ end
5
+ end
@@ -3,7 +3,7 @@ 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", :sticky=>true)
6
+ GNTP.should_receive(:notify).with(:app_name => $0, :title => "g", :text => "foo")
7
7
  g('foo').should == 'foo'
8
8
  end
9
9
 
@@ -14,13 +14,13 @@ describe 'g' do
14
14
 
15
15
  it 'calls for instance' do
16
16
  object = Object.new
17
- GNTP.should_receive(:notify).with(:app_name => $0, :title => "g", :text => object.pretty_inspect, :sticky=>true)
17
+ GNTP.should_receive(:notify).with(:app_name => $0, :title => "g", :text => object.pretty_inspect)
18
18
  object.g.should == object
19
19
  end
20
20
 
21
21
  it 'calls with &block' do
22
22
  object = "foo"
23
- GNTP.should_receive(:notify).with(:app_name => $0, :title => "g", :text => "FOO", :sticky=>true)
23
+ GNTP.should_receive(:notify).with(:app_name => $0, :title => "g", :text => "FOO")
24
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.6.0
4
+ version: 1.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,19 +9,40 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-13 00:00:00.000000000Z
12
+ date: 2012-08-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby_gntp
16
- requirement: &70154826525400 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
- type: :runtime
22
+ type: :development
23
23
  prerelease: false
24
- version_requirements: *70154826525400
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
25
46
  description: It works like Kernel.p with growl :)
26
47
  email:
27
48
  - jugyo.org@gmail.com
@@ -35,7 +56,8 @@ files:
35
56
  - Rakefile
36
57
  - g.gemspec
37
58
  - lib/g.rb
38
- - lib/md5.rb
59
+ - lib/g/ruby_gntp.rb
60
+ - lib/g/terminal-notifier.rb
39
61
  - spec/g_spec.rb
40
62
  homepage: http://github.com/jugyo/g
41
63
  licenses: []
@@ -57,9 +79,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
79
  version: '0'
58
80
  requirements: []
59
81
  rubyforge_project: g
60
- rubygems_version: 1.8.10
82
+ rubygems_version: 1.8.23
61
83
  signing_key:
62
84
  specification_version: 3
63
85
  summary: The Kernel.g
64
86
  test_files:
65
87
  - spec/g_spec.rb
88
+ has_rdoc:
data/lib/md5.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'digest/md5'
2
- module MD5
3
- def self.new(packet)
4
- Digest::MD5.new.update packet
5
- end
6
- end