growl_windows 0.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.md ADDED
@@ -0,0 +1,34 @@
1
+ growl_windows
2
+ =============
3
+
4
+ Make gem `growl` support windows.
5
+ As you could have known, gem `growl` only support MacOS. To solve the problem on
6
+ Windows, gem `growl_windows` come out, which has same syntaxes with gem `growl`!
7
+
8
+ # Install
9
+
10
+ First, you must install software [Growl for windows](http://www.growlforwindows.com/gfw/) .
11
+
12
+ And then:
13
+
14
+ gem install growl_windows
15
+
16
+ That's all, you can enjoy it!
17
+
18
+ # Usage
19
+
20
+ require 'growl_windows'
21
+ Growl.notify("Hello Windows", title: "Growl Test")
22
+
23
+ If it print some error like this:
24
+
25
+ # Find growl path from registry failed!
26
+ # You can use e.g. Grow.register_binpath('C:\Program Files\Growl for windows\growlnotify.exe') before notifying.
27
+
28
+ You can do this with growl installation path of yourself:
29
+
30
+ require 'growl_windows'
31
+ Grow.register_binpath('C:\Program Files\Growl for windows\growlnotify.exe')
32
+ Growl.notify("Hello Windows", title: "Growl Test")
33
+
34
+ OK, other options is supported same as gem `growl`, you can find it from it's [homepage](https://github.com/visionmedia/growl).
@@ -0,0 +1,15 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "growl_windows"
3
+ s.version = "0.1.0"
4
+
5
+ s.authors = "debbbbie"
6
+ s.date = "2013-12-09"
7
+ s.description = "Make gem `growl` support windows"
8
+ s.email = "debbbbie@163.com"
9
+ s.files = ["growl_windows.gemspec", "lib/growl_windows.rb", "spec/growl_windows_spec.rb", "README.md"]
10
+ s.homepage = "https://github.com/debbbbie/growl_windows"
11
+ s.require_paths = ["lib"]
12
+ s.summary = "Make gem `growl` support windows"
13
+
14
+
15
+ end
@@ -0,0 +1,76 @@
1
+ require 'growl'
2
+
3
+ module Growl
4
+ @@path = nil
5
+
6
+ def self.version
7
+ @@path ||= self.path_from_registry
8
+ end
9
+
10
+ def self.path_from_registry
11
+ require 'win32/registry'
12
+ registry = Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Classes\growl\DefaultIcon')
13
+ registry[0].gsub('Growl.exe','growlnotify.exe')
14
+ rescue Win32::Registry::Error => e
15
+ puts "Find growl path from registry failed!\n You can use e.g. Grow.register_binpath('C:\Program Files\Growl for windows\growlnotify.exe') before notifying. "
16
+ nil
17
+ end
18
+
19
+ def self.exec *args
20
+ Kernel.system self.bin_path, *args
21
+ end
22
+
23
+ def self.bin_path= path
24
+ @@path = path
25
+ end
26
+
27
+ def self.bin_path
28
+ @@path
29
+ end
30
+
31
+ def self.register_binpath(path)
32
+ @@path = path
33
+ end
34
+
35
+ class Base
36
+
37
+ def self.switch_short switch, short
38
+ @switchers_short ||= {}
39
+ @switchers_short[switch] = short
40
+ end
41
+
42
+ def self.switches_short
43
+ @switchers_short
44
+ end
45
+
46
+ def run
47
+ raise Error, 'message required' unless message
48
+ self.class.switches.each do |switch|
49
+ if send(:"#{switch}?")
50
+ tip = !self.class.switches_short[switch].nil? ? "/#{self.class.switches_short[switch]}:" : ""
51
+ args << tip + send(switch).to_s if send(switch) && !(TrueClass === send(switch))
52
+ end
53
+ end
54
+ Growl.exec *args
55
+ end
56
+
57
+ switch_short :title, :t
58
+ switch_short :message, nil
59
+ switch_short :sticky, :s
60
+ switch_short :name, :a
61
+ switch_short :appIcon, :ai
62
+ switch_short :icon, :i
63
+ switch_short :iconpath, nil
64
+ switch_short :image, nil
65
+ switch_short :priority, :p
66
+ switch_short :identifier,:id
67
+ switch_short :host, :host
68
+ switch_short :password, :pass
69
+ switch_short :udp, nil
70
+ switch_short :port, :port
71
+ switch_short :auth, nil
72
+ switch_short :crypt, nil
73
+ switch_short :url, :cu
74
+ end
75
+
76
+ end
@@ -0,0 +1,28 @@
1
+ require File.expand_path('../../lib/growl_windows', __FILE__)
2
+ describe Growl do
3
+
4
+ describe "#installed?" do
5
+ it "should check if growlnotify is available" do
6
+ Growl.should be_installed
7
+ end
8
+ end
9
+
10
+ describe "#version" do
11
+ it "should return only the version triple" do
12
+ Growl.version.should_not eq('')
13
+ end
14
+ end
15
+
16
+ describe "#bin_path" do
17
+ it "should exist this file" do
18
+ File.exists?(Growl.bin_path).should be(true)
19
+ end
20
+ end
21
+
22
+ describe "#notify" do
23
+ it "should get a notification from Growl for windows" do
24
+ Growl.notify("test succeed").should be(true)
25
+ end
26
+
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: growl_windows
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - debbbbie
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-12-09 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Make gem `growl` support windows
15
+ email: debbbbie@163.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - growl_windows.gemspec
21
+ - lib/growl_windows.rb
22
+ - spec/growl_windows_spec.rb
23
+ - README.md
24
+ homepage: https://github.com/debbbbie/growl_windows
25
+ licenses: []
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 1.8.24
45
+ signing_key:
46
+ specification_version: 3
47
+ summary: Make gem `growl` support windows
48
+ test_files: []