cpr 0.1.0-linux

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 FIXME full name
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,95 @@
1
+ = cpr
2
+
3
+ http://cpr.rubyforge.org
4
+
5
+ == DESCRIPTION:
6
+
7
+ CPR - Cross Platform R______
8
+ Fill in the blank on the R if you want.
9
+
10
+ Ruby, Rachmaninoff, Rock Star, Reaganomics...
11
+
12
+ What really matters is the CP part. The R just makes it a nice TLA.
13
+
14
+ I got tired of all these really nice gems floating around that assumed I was using
15
+ OSX. I'm not, and that really shouldn't stop me from being able to open a url from
16
+ inside a gem if I want to. CPR was born from that frustration.
17
+
18
+ == USE:
19
+
20
+ Right now CPR has two functions - notify and open.
21
+
22
+ === NOTIFY
23
+
24
+ Notify allows you to send growl-like notifications to any supported platforms.
25
+
26
+ The currently supported platforms are: Growl (obviously) on the Mac, Snarl on Windows,
27
+ and Mumbles on Linux.
28
+
29
+ To use notify, do the following:
30
+
31
+ require 'rubygems'
32
+ require 'cpr/notify'
33
+
34
+ #CPR.notify will raise an exception if no notifiers are found. notify? doesn't.
35
+ CPR.notify?("This is the title", "And here's the message!")
36
+
37
+ === OPEN
38
+
39
+ Open allows you to (surprisingly) open a file/url with the system's default
40
+ editor for that type (browser, archive manager, text editor, etc.).
41
+
42
+ On a Mac it simply uses 'open'. Windows platforms employ the 'Start' command.
43
+ Linux is slightly more complicated (as always) - first CPR checks for the 'xdg-open'
44
+ command, then 'gnome-open', and then it checks for the presence of an environmental
45
+ variable $OPEN. If any of these are present they are used in precedence of their
46
+ listed order here.
47
+
48
+ To use open, do the following:
49
+
50
+ require 'rubygems'
51
+ require 'cpr/open'
52
+
53
+ CPR.open("http://www.google.com")
54
+ CPR.open("/home/user/cool_stuff.tgz")
55
+
56
+ === THE WHOLE ENCHILADA
57
+
58
+ If you want to use everything, just require 'cpr'. It's easy.
59
+
60
+ == REQUIREMENTS:
61
+
62
+ Linux: none... yet :)
63
+
64
+ Mac: the ruby-growl gem.
65
+
66
+ Windows: the ruby-snarl gem.
67
+
68
+ == INSTALL:
69
+
70
+ (sudo) gem install cpr
71
+
72
+ == LICENSE:
73
+
74
+ (The MIT License)
75
+
76
+ Copyright (c) 2008 FIXME full name
77
+
78
+ Permission is hereby granted, free of charge, to any person obtaining
79
+ a copy of this software and associated documentation files (the
80
+ 'Software'), to deal in the Software without restriction, including
81
+ without limitation the rights to use, copy, modify, merge, publish,
82
+ distribute, sublicense, and/or sell copies of the Software, and to
83
+ permit persons to whom the Software is furnished to do so, subject to
84
+ the following conditions:
85
+
86
+ The above copyright notice and this permission notice shall be
87
+ included in all copies or substantial portions of the Software.
88
+
89
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
90
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
91
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
92
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
93
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
94
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
95
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require "rake"
2
+ require "lib/cpr"
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
data/lib/cpr.rb ADDED
@@ -0,0 +1,9 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'cpr/notify'
5
+ require 'cpr/open'
6
+
7
+ class CPR
8
+ VERSION = "0.1.0"
9
+ end
data/lib/cpr/notify.rb ADDED
@@ -0,0 +1,50 @@
1
+ class CPR
2
+
3
+ class << self
4
+
5
+ def notify(title, text)
6
+ raise "No notifier found!" unless NOTIFIER
7
+ raise "Invalid notifier!" unless NOTIFIER.respond_to?("notify")
8
+
9
+ NOTIFIER.notify(title, text)
10
+ end
11
+
12
+ ##
13
+ #notify? behaves just the same as notify, except that it won't raise any
14
+ #errors. This should be used when notify support is desired but not
15
+ #necessary (i.e. you don't need to worry about exceptions).
16
+ def notify?(title, text)
17
+ begin
18
+ notify(title, text)
19
+ rescue
20
+ #do nothing
21
+ end
22
+ end
23
+ end
24
+
25
+ end
26
+
27
+ case PLATFORM
28
+ when /linux/
29
+ if `which mumbles-send` != ""
30
+ require 'cpr/notify/mumbles-notifier'
31
+ CPR::NOTIFIER = CPR::Mumbles_Notifier.new
32
+ end
33
+ when /darwin/
34
+ if `which growl` != ""
35
+ require 'cpr/notify/growl-notifier'
36
+ CPR::NOTIFIER = CPR::Growl_Notifier.new
37
+ end
38
+ when /win32/
39
+ require 'win32/registry'
40
+ begin
41
+ Win32::Registry::HKEY_LOCAL_MACHINE.open('Software\Microsoft\Windows\CurrentVersion\App Paths\Snarl.exe')
42
+ require 'cpr/notify/snarl-notifier'
43
+ CPR::NOTIFIER = CPR::Snarl_Notifier.new
44
+ rescue
45
+ #snarl is not installed - if any other windows platforms become supported,
46
+ #they should be checked for here.
47
+ end
48
+ else
49
+ puts "Unknown operating system - CPR Notify support disabled."
50
+ end
@@ -0,0 +1,11 @@
1
+ require 'ruby-growl'
2
+ class CPR
3
+ class Growl_Notifier
4
+
5
+ def notify(title, text)
6
+ @growler ||= Growl.new "localhost", "burble", ["Burble Notification"]
7
+ @growler.notify "Burble Notification", title, text
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,8 @@
1
+ class CPR
2
+ class Mumbles_Notifier
3
+
4
+ def notify(title,text)
5
+ system("mumbles-send '#{title}' '#{text}'")
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ require 'snarl'
2
+
3
+ class CPR
4
+ class Snarl_Notifier
5
+
6
+ def notify(title, text)
7
+ Snarl.new(title, text)
8
+ end
9
+
10
+ end
11
+ end
data/lib/cpr/open.rb ADDED
@@ -0,0 +1,25 @@
1
+ class CPR
2
+ class << self
3
+
4
+ def open(path)
5
+ `#{OPEN_CMD} #{path}`
6
+ end
7
+
8
+ end
9
+
10
+ end
11
+
12
+ case PLATFORM
13
+ when /darwin/
14
+ CPR::OPEN_CMD = 'open'
15
+ when /win32/
16
+ CPR::OPEN_CMD = 'Start'
17
+ when /linux/
18
+ if `which xdg-open` != ""
19
+ CPR::OPEN_CMD = 'xdg-open'
20
+ elsif `which gnome-open` != ""
21
+ CPR::OPEN_CMD = 'gnome-open'
22
+ elsif `echo $OPEN`.chomp != ""
23
+ CPR::OPEN_CMD = '$OPEN'
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cpr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: linux
6
+ authors:
7
+ - Tommy Morgan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-06-28 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: CPR - Cross Platform Ruby library
17
+ email: tommy.morgan@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ - LICENSE
25
+ files:
26
+ - LICENSE
27
+ - README.rdoc
28
+ - Rakefile
29
+ - lib/cpr
30
+ - lib/cpr/open.rb
31
+ - lib/cpr/notify
32
+ - lib/cpr/notify/growl-notifier.rb
33
+ - lib/cpr/notify/snarl-notifier.rb
34
+ - lib/cpr/notify/mumbles-notifier.rb
35
+ - lib/cpr/notify.rb
36
+ - lib/cpr.rb
37
+ has_rdoc: true
38
+ homepage: http://github.com/duwanis/cpr
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ requirements: []
57
+
58
+ rubyforge_project:
59
+ rubygems_version: 1.1.1
60
+ signing_key:
61
+ specification_version: 2
62
+ summary: CPR - Cross Platform Ruby library
63
+ test_files: []
64
+