post-it 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ results.html
3
+ pkg
4
+ html
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in post-it.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ post-it (1.0.1)
5
+ methadone (~> 1.2.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ aruba (0.5.0)
11
+ childprocess (= 0.2.3)
12
+ cucumber (>= 1.1.1)
13
+ ffi (>= 1.0.11)
14
+ rspec-expectations (>= 2.7.0)
15
+ builder (3.1.3)
16
+ childprocess (0.2.3)
17
+ ffi (~> 1.0.6)
18
+ cucumber (1.2.1)
19
+ builder (>= 2.1.2)
20
+ diff-lcs (>= 1.1.3)
21
+ gherkin (~> 2.11.0)
22
+ json (>= 1.4.6)
23
+ diff-lcs (1.1.3)
24
+ ffi (1.0.11)
25
+ gherkin (2.11.4)
26
+ json (>= 1.4.6)
27
+ json (1.7.5)
28
+ methadone (1.2.1)
29
+ bundler
30
+ rake (0.9.2.2)
31
+ rdoc (3.12)
32
+ json (~> 1.4)
33
+ rspec-expectations (2.11.3)
34
+ diff-lcs (~> 1.1.3)
35
+
36
+ PLATFORMS
37
+ ruby
38
+
39
+ DEPENDENCIES
40
+ aruba
41
+ post-it!
42
+ rake (~> 0.9.2)
43
+ rdoc
data/LICENSE.txt ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2012 Joe Workman
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # Post-It
2
+
3
+ [Sticky Notificiations][sn-mas] is a Mac Application developed by the brilliant [Matt Gemmell](http://mattgemmell.com). It allows you to create post-it note style reminders into Notification Center (Mountain Lion or later) or Growl.
4
+
5
+ Post-It is a simple utlity that uses [Sticky Notificiations][sn-mas] to post messages to Notification Center on Mac OS X. You can now easily send yourself notifications from command-line or your own scripts and applications.
6
+
7
+ **Important**: This utility will only function if you have Sticky Notificiations.app v1.0.4+ installed.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'post-it'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install post-it
22
+
23
+ ## Usage
24
+
25
+ ### Shell or Terminal
26
+
27
+ <pre>
28
+ Usage: post-it [options] message
29
+
30
+ Options:
31
+ --version Show help/version info
32
+ --prepare Prepare the post-it and open it
33
+ inside Sticky Notifications.app
34
+ -t, --title TITLE The title of the notification
35
+ (default: Post It)
36
+ -s, --subtitle SUBTITLE The subtitle of the notification
37
+
38
+ Arguments:
39
+
40
+ message
41
+ The notification message that will be displayed in Notification Center.
42
+ </pre>
43
+
44
+
45
+ Post a simple message:
46
+
47
+ $ post-it "My Message"
48
+
49
+ Post with custom titles:
50
+
51
+ $ post-it -t "My Title" -s "My Subtitle" "My Message"
52
+
53
+ Prepare a message in SN:
54
+
55
+ $ post-it --prepare -t "My Title" -s "My Subtitle" "My Message"
56
+
57
+ ### Ruby Class
58
+
59
+ The `post-it` terminal command simply uses the PostIt::Notification class in order to send messages to Sticky Notifications. You can do the same thing form your ruby scripts.
60
+
61
+ Quick and dirty notifications:
62
+
63
+ post_it = PostIt::Notification.new()
64
+ post_it.send("My Message")
65
+
66
+ You can define default values for both the `title` and the `subtitle` when you create the post-it object. These options are passed as a hash.
67
+
68
+ post_it = PostIt::Notification.new({:title => "My Title", :subtitle => "My Subtitle"})
69
+
70
+ You can override the default titles and also pass the `prepare` option when you are sending the notification:
71
+
72
+ post_it.send(message,{:prepare => true,:title => "My Title"})
73
+
74
+ Its probably a good idea to check for errors when you are using Post-It. Exceptions will be raised in two scenarios:
75
+
76
+ 1. If the Sticky Notifications.app is not found in the `/Applications` folder.
77
+ 2. If an error occurs while sending the notifications via the SN URL scheme.
78
+
79
+ Example:
80
+
81
+ begin
82
+ post_it = PostIt::Notification.new()
83
+ post_it.send(message)
84
+ rescue Exception => e
85
+ # There was an error
86
+ puts e.message
87
+ end
88
+
89
+
90
+ ## Contributing
91
+
92
+ 1. Fork it
93
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
94
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
95
+ 4. Push to the branch (`git push origin my-new-feature`)
96
+ 5. Create new Pull Request
97
+
98
+
99
+
100
+ [sn-mas]: http://click.linksynergy.com/fs-bin/stat?id=oqL0KdXmKTI&offerid=146261&type=3&subid=0&tmpid=1826&RD_PARM1=https%253A%252F%252Fitunes.apple.com%252Fus%252Fapp%252Fsticky-notifications%252Fid552377168%253Fmt%253D12%2526uo%253D4%2526partnerId%253D30
data/README.rdoc ADDED
@@ -0,0 +1,49 @@
1
+ = post-it - Send post-it notes Notification Center on Mac OS X.
2
+
3
+ Author:: Joe Workman (joe at workmanmail.com)
4
+ Copyright:: Copyright (c) 2012 Joe Workman
5
+
6
+ License:: Distributes under the MIT license,
7
+ see LICENSE.txt in the source distro
8
+
9
+
10
+ [Sticky Notificiations][sn-mas] is a Mac Application developed by the brilliant [Matt Gemmell](http://mattgemmell.com). It allows you to create post-it note style reminders into Notification Center (Mountain Lion or later) or Growl.
11
+
12
+ Post-It is a simple utlity that uses [Sticky Notificiations][sn-mas] to post messages to Notification Center on Mac OS X. You can now easily send yourself notifications from command-line or your own scripts and applications.
13
+
14
+ **Important**: This utility will only function if you have Sticky Notificiations.app v1.0.4+ installed.
15
+
16
+
17
+ == Links
18
+
19
+ * {Source on Github}[GITHUB]
20
+ * RDoc[LINK TO RDOC.INFO]
21
+
22
+ == Install
23
+
24
+ Install:
25
+ gem install post-it
26
+
27
+ == Shell Examples
28
+
29
+ Post a simple message:
30
+ post-it "My Message"
31
+
32
+ Post with custom titles:
33
+ post-it -t "My Title" -s "My Subtitle" "My Message"
34
+
35
+ Prepare a message in SN:
36
+ post-it --prepare -t "My Title" -s "My Subtitle" "My Message"
37
+
38
+
39
+ == Ruby Examples
40
+
41
+ Quick and dirty notifications:
42
+ post_it = PostIt::Notification.new()
43
+ post_it.send("My Message")
44
+
45
+ You can define default values:
46
+ post_it = PostIt::Notification.new({:title => "My Title", :subtitle => "My Subtitle"})
47
+
48
+ Pass options to send method:
49
+ post_it.send(message,{:prepare => true,:title => "My Title"})
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ require 'bundler'
2
+ require 'rake/clean'
3
+
4
+ require 'rake/testtask'
5
+
6
+ require 'cucumber'
7
+ require 'cucumber/rake/task'
8
+ gem 'rdoc' # we need the installed RDoc gem, not the system one
9
+ require 'rdoc/task'
10
+
11
+ include Rake::DSL
12
+
13
+ Bundler::GemHelper.install_tasks
14
+
15
+
16
+ Rake::TestTask.new do |t|
17
+ t.pattern = 'test/tc_*.rb'
18
+ end
19
+
20
+
21
+ CUKE_RESULTS = 'results.html'
22
+ CLEAN << CUKE_RESULTS
23
+ Cucumber::Rake::Task.new(:features) do |t|
24
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
25
+ t.fork = false
26
+ end
27
+
28
+ Rake::RDocTask.new do |rd|
29
+
30
+ rd.main = "README.rdoc"
31
+
32
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
33
+ end
34
+
35
+ task :default => [:test,:features]
data/bin/post-it ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'methadone'
5
+ require 'post-it'
6
+
7
+ class App
8
+ include Methadone::Main
9
+ include Methadone::CLILogging
10
+ include Methadone::SH
11
+
12
+ main do |message|
13
+ begin
14
+ post_it = PostIt::Notification.new({:title => options[:title], :subtitle => options[:subtitle]})
15
+ post_it.send(message,{:prepare => options[:prepare]})
16
+ rescue Exception => e
17
+ exit_now!(e.message)
18
+ end
19
+ end
20
+
21
+ # Declare command-line interface here
22
+ version PostIt::VERSION
23
+
24
+ description 'A simple utlity that uses `Sticky Notificiations.app` to post messages to Notification Center on Mac OS X.
25
+ This utility will only function if you have Sticky Notificiations.app installed.'
26
+
27
+ options['title'] = 'Post It'
28
+
29
+ on("--prepare","Prepare the post-it and open it inside Sticky Notifications.app")
30
+ on("-t TITLE","--title","The title of the notification")
31
+ on("-s SUBTITLE","--subtitle","The subtitle of the notification")
32
+
33
+ arg :message, 'The notification message that will be displayed in Notification Center.
34
+
35
+ '
36
+ go!
37
+ end
@@ -0,0 +1,18 @@
1
+ Feature: Send notifications to Notification Center via Sticky Notifications.app
2
+ So that I have a nice way of getting feedback from my script
3
+ I want send notifications to Notification Center via Sticky Notifications.app
4
+
5
+ Scenario: Basic UI
6
+ When I get help for "post-it"
7
+ Then the exit status should be 0
8
+ And the banner should be present
9
+ And the banner should include the version
10
+ And the banner should document that this app takes options
11
+ And the banner should document that this app's arguments are:
12
+ |message| which is required |
13
+ And the following options should be documented:
14
+ |--version|
15
+ |--title|
16
+ |--subtitle|
17
+ |--prepare|
18
+
@@ -0,0 +1 @@
1
+ # Put your step definitions here
@@ -0,0 +1,16 @@
1
+ require 'aruba/cucumber'
2
+ require 'methadone/cucumber'
3
+
4
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
5
+ LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
6
+
7
+ Before do
8
+ # Using "announce" causes massive warnings on 1.9.2
9
+ @puts = true
10
+ @original_rubylib = ENV['RUBYLIB']
11
+ ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
12
+ end
13
+
14
+ After do
15
+ ENV['RUBYLIB'] = @original_rubylib
16
+ end
@@ -0,0 +1,3 @@
1
+ module PostIt
2
+ VERSION = "1.0.1"
3
+ end
data/lib/post-it.rb ADDED
@@ -0,0 +1,44 @@
1
+ require "post-it/version"
2
+ require 'optparse'
3
+ require 'methadone'
4
+
5
+ module PostIt
6
+ class Notification
7
+ include Methadone::Main
8
+ include Methadone::CLILogging
9
+ include Methadone::SH
10
+
11
+ attr_accessor :title
12
+ attr_accessor :subtitle
13
+
14
+ def initialize(options={})
15
+ @title = options[:title] ? options[:title] : 'Post It'
16
+ @subtitle = options[:subtitle] ? options[:subtitle] : nil
17
+
18
+ # Raise an exception if the Sticky Notifications app was not found
19
+ unless File.exists?('/Applications/Sticky Notifications.app')
20
+ raise "Sticky Notifications.app does not seem to be installed"
21
+ end
22
+ end
23
+
24
+ public
25
+
26
+ def send(message,options={})
27
+ # Setup the default arguments for the SN url
28
+ title = options[:title] ? options[:title] : self.title
29
+ subtitle = options[:subtitle] ? options[:subtitle] : self.subtitle
30
+ method = options[:prepare] ? 'prepare' : 'note'
31
+
32
+ # Build the URL scheme for sticky-notifications
33
+ notifyurl = "sticky-notifications://#{method}?message=#{message}&title=#{title}"
34
+ notifyurl += "&subtitle=#{subtitle}" if subtitle
35
+
36
+ # Via Methadone::SH (shell) run the open command to open the url. Raise an exception if there were errors
37
+ begin
38
+ sh "open '#{notifyurl}'"
39
+ rescue Exception => e
40
+ raise e.message
41
+ end
42
+ end
43
+ end
44
+ end
data/post-it.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'post-it/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "post-it"
8
+ gem.version = PostIt::VERSION
9
+ gem.authors = ["Joe Workman"]
10
+ gem.email = ["joe at workmanmail.com"]
11
+ gem.description = %q{A simple utlity that uses `Sticky Notificiations.app` to post messages to Notification Center on Mac OS X.}
12
+ gem.summary = %q{A simple utlity that uses `Sticky Notificiations.app` to post messages to Notification Center on Mac OS X.}
13
+ gem.homepage = "https://github.com/joeworkman/post-it"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ gem.add_development_dependency('rdoc')
20
+ gem.add_development_dependency('aruba')
21
+ gem.add_development_dependency('rake','~> 0.9.2')
22
+ gem.add_dependency('methadone', '~>1.2.1')
23
+ end
@@ -0,0 +1,7 @@
1
+ require 'test/unit'
2
+
3
+ class TestSomething < Test::Unit::TestCase
4
+ def test_truth
5
+ assert true
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: post-it
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Joe Workman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rdoc
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
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: aruba
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'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.2
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.9.2
62
+ - !ruby/object:Gem::Dependency
63
+ name: methadone
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.2.1
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.2.1
78
+ description: A simple utlity that uses `Sticky Notificiations.app` to post messages
79
+ to Notification Center on Mac OS X.
80
+ email:
81
+ - joe at workmanmail.com
82
+ executables:
83
+ - post-it
84
+ extensions: []
85
+ extra_rdoc_files: []
86
+ files:
87
+ - .gitignore
88
+ - Gemfile
89
+ - Gemfile.lock
90
+ - LICENSE.txt
91
+ - README.md
92
+ - README.rdoc
93
+ - Rakefile
94
+ - bin/post-it
95
+ - features/post-it.feature
96
+ - features/step_definitions/post-it_steps.rb
97
+ - features/support/env.rb
98
+ - lib/post-it.rb
99
+ - lib/post-it/version.rb
100
+ - post-it.gemspec
101
+ - test/tc_something.rb
102
+ homepage: https://github.com/joeworkman/post-it
103
+ licenses: []
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ segments:
115
+ - 0
116
+ hash: 1805713952822864554
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ segments:
124
+ - 0
125
+ hash: 1805713952822864554
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 1.8.24
129
+ signing_key:
130
+ specification_version: 3
131
+ summary: A simple utlity that uses `Sticky Notificiations.app` to post messages to
132
+ Notification Center on Mac OS X.
133
+ test_files:
134
+ - features/post-it.feature
135
+ - features/step_definitions/post-it_steps.rb
136
+ - features/support/env.rb
137
+ - test/tc_something.rb