notis 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ M2UzZGU4OTAxNWYwODdhY2Y3OGQzNWM3MTZhZTQ2MjA5MjFhYTU2Yw==
5
+ data.tar.gz: !binary |-
6
+ MTk4MDNiODFjZTdhZGUwYTFjMGVjMDEwOWY2NGFhNGMxMDMzZWZiOQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZTA2N2RhNTJmMzhiODVhMDgyMTAzMGU3YWYyZTBhYzExOWRjNWExOTJlYjYx
10
+ NTVmMzcwMThjOGY3MzA0YzdiYTJhMmQ1N2IzNmVmMzg4NWViYWU5ZjZkYWU1
11
+ ZjE4OWFmZGY4YjMwODczM2VlYWQ3MGFlOWE0ZGExNmQ4ZWM3MTU=
12
+ data.tar.gz: !binary |-
13
+ MjJiYmVkYmZlYTM2ZWJjY2FjZWM2YzljNWJkNDAwODZmMTE1NGFjYjA5YjE1
14
+ ZDY3OGY0NzUyNzA4MzkyYWQwYzdlZTQxMjlhNDNjYmMxYzA2MzVmMzVmMTRj
15
+ MDc3OTNiYTRkYjBjYzU1MWIwMTlmZDM3ODIzZjRjOWM5YzgzMTA=
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in notis.gemspec
4
+ gemspec
@@ -0,0 +1,48 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ notis (0.1.0)
5
+ methadone (~> 1.3.1)
6
+ terminal-notifier (~> 1.5.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ aruba (0.5.3)
12
+ childprocess (>= 0.3.6)
13
+ cucumber (>= 1.1.1)
14
+ rspec-expectations (>= 2.7.0)
15
+ builder (3.2.2)
16
+ childprocess (0.3.9)
17
+ ffi (~> 1.0, >= 1.0.11)
18
+ cucumber (1.3.10)
19
+ builder (>= 2.1.2)
20
+ diff-lcs (>= 1.1.3)
21
+ gherkin (~> 2.12)
22
+ multi_json (>= 1.7.5, < 2.0)
23
+ multi_test (>= 0.0.2)
24
+ diff-lcs (1.2.5)
25
+ ffi (1.9.3)
26
+ gherkin (2.12.2)
27
+ multi_json (~> 1.3)
28
+ json (1.8.1)
29
+ methadone (1.3.1)
30
+ bundler
31
+ multi_json (1.8.2)
32
+ multi_test (0.0.2)
33
+ rake (0.9.6)
34
+ rdoc (4.0.1)
35
+ json (~> 1.4)
36
+ rspec-expectations (2.14.4)
37
+ diff-lcs (>= 1.1.3, < 2.0)
38
+ terminal-notifier (1.5.1)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ aruba
45
+ bundler
46
+ notis!
47
+ rake (~> 0.9.2)
48
+ rdoc
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Chris Simpkins
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,55 @@
1
+ # Notis
2
+ ### Mac OSX Command Line Application Notifier
3
+
4
+ notis is a Mac OSX utility that allows you to display a standard OSX toast message notification at the completion of a long-running command with the option to emit an audio signal.
5
+
6
+ ## Installation
7
+
8
+ Install the Ruby gem with the following command:
9
+
10
+ ``` bash
11
+ gem install notis
12
+ ```
13
+
14
+ ## Usage
15
+ You can run the command that is to be tracked as an argument to notis or you can pipe the standard output from the command to notis. The way that you run it influences the level of detail that you receive in the notification text.
16
+
17
+ ### Run Command as an Argument to notis
18
+ Use the command to be tracked as an argument to notis and enclose it in quotes if it includes spaces or special shell characters. For example, if you are running the command `longrunner bigfile.baf`:
19
+
20
+ ```
21
+ notis "longrunner bigfile.baf"
22
+ ```
23
+ When you run notis with this syntax, you will receive a notification that identifies the completed command with up to 20 characters of the original command string.
24
+
25
+ ### Pipe Standard Output from Command to notis
26
+ You can also use notis by piping the standard output stream of another command to the notis standard input stream. Assuming that you are running the command `longrunner bigfile.baf`:
27
+
28
+ ```
29
+ longrunner bigfile.baf | notis
30
+ ```
31
+
32
+ ## Options
33
+
34
+ This utility provides the option to mute the standard output from the original command and to emit an audio signal that the command completed along with the notification toast message. These options can combined.
35
+
36
+ ### Mute Standard Output from the Tracked Command (`-m, --mute`)
37
+
38
+ ```
39
+ notis -m "longrunner bigfile.baf"
40
+ ```
41
+ or
42
+ ```
43
+ longrunner bigfile.baf | notis -m
44
+ ```
45
+
46
+ ### Emit Audio Signal as Part of the Notification (`-b, --bell`)
47
+
48
+ ```
49
+ notis -b "longrunner bigfile.baf"
50
+ ```
51
+ or
52
+ ```
53
+ longrunner bigfile.baf | notis -b
54
+ ```
55
+
@@ -0,0 +1,23 @@
1
+ = notis - a Mac OSX toast message notification utility for command line applications
2
+
3
+ Author:: Christopher Simpkins (git.simpkins@gmail.com)
4
+ Copyright:: Copyright (c) 2013 Christopher Simpkins
5
+
6
+
7
+ notis is a Mac OSX utility that allows you to display a standard OSX toast message notification at the completion of a long-running command with the option to emit an audio signal.
8
+
9
+ == Links
10
+
11
+ * {Source on Github}[https://github.com/chrissimpkins/notis]
12
+
13
+ == Install
14
+
15
+ $ gem install notis
16
+
17
+ == Examples
18
+
19
+ notis "longrunner bigfile.baf"
20
+
21
+ longrunner bigfile.baf | notis
22
+
23
+
@@ -0,0 +1,61 @@
1
+ def dump_load_path
2
+ puts $LOAD_PATH.join("\n")
3
+ found = nil
4
+ $LOAD_PATH.each do |path|
5
+ if File.exists?(File.join(path,"rspec"))
6
+ puts "Found rspec in #{path}"
7
+ if File.exists?(File.join(path,"rspec","core"))
8
+ puts "Found core"
9
+ if File.exists?(File.join(path,"rspec","core","rake_task"))
10
+ puts "Found rake_task"
11
+ found = path
12
+ else
13
+ puts "!! no rake_task"
14
+ end
15
+ else
16
+ puts "!!! no core"
17
+ end
18
+ end
19
+ end
20
+ if found.nil?
21
+ puts "Didn't find rspec/core/rake_task anywhere"
22
+ else
23
+ puts "Found in #{path}"
24
+ end
25
+ end
26
+ require 'bundler'
27
+ require 'rake/clean'
28
+
29
+ require 'rake/testtask'
30
+
31
+ require 'cucumber'
32
+ require 'cucumber/rake/task'
33
+ gem 'rdoc' # we need the installed RDoc gem, not the system one
34
+ require 'rdoc/task'
35
+
36
+ include Rake::DSL
37
+
38
+ Bundler::GemHelper.install_tasks
39
+
40
+
41
+ Rake::TestTask.new do |t|
42
+ t.pattern = 'test/tc_*.rb'
43
+ end
44
+
45
+
46
+ CUKE_RESULTS = 'results.html'
47
+ CLEAN << CUKE_RESULTS
48
+ Cucumber::Rake::Task.new(:features) do |t|
49
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
50
+ t.fork = false
51
+ end
52
+
53
+ Rake::RDocTask.new do |rd|
54
+
55
+ rd.main = "README.rdoc"
56
+
57
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
58
+ end
59
+
60
+ task :default => [:test,:features]
61
+
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'methadone'
5
+ require 'open3'
6
+ require 'terminal-notifier'
7
+ require 'notis.rb'
8
+
9
+ class App
10
+ include Methadone::Main
11
+
12
+ main do | user_command |
13
+ begin
14
+ # STD IN BLOCK
15
+ unless user_command # if user pipes a command to the Notis standard input stream (instead of using Notis as primary command)
16
+ unless options["m"] # mute original command std out switch
17
+ #print the original command's std out stream
18
+ puts ARGF.read
19
+ end
20
+ if options["b"] # ring bell switch
21
+ Notis.runit("terminal-notifier -sound default -title Notis -message 'The piped process is complete.'")
22
+ exit 0
23
+ end
24
+ Notis.runit("terminal-notifier -title Notis -message 'The piped process is complete.'")
25
+ exit 0
26
+ end
27
+ # END STD IN BLOCK
28
+
29
+ # MAIN COMMAND BLOCK
30
+ thecommand = Notis.runit("#{user_command}")
31
+ # If command returned exit code 0, then echo the std output from the command unless mute switch
32
+ unless options["m"]
33
+ puts("#{thecommand}")
34
+ end
35
+ # decrease length of the string for display if > 20 char
36
+ if user_command.length > 20
37
+ user_command = user_command[0..19] + "... "
38
+ end
39
+ # and then launch the Mac OSX notification that the process completed
40
+ if options["b"] # ring bell switch
41
+ Notis.runit("terminal-notifier -title Notis -sound default -message '#{user_command} completed successfully.'")
42
+ exit 0
43
+ end
44
+ Notis.runit("terminal-notifier -title Notis -message '#{user_command} completed successfully.'")
45
+ exit 0
46
+ # END MAIN COMMAND BLOCK
47
+ # TODO: handle exit status 1 in original command with appropriate message to user
48
+ end
49
+
50
+ end #end main
51
+
52
+ description "Launch a Mac OSX notification at the completion of another command. Include the command to be run as the argument to notis, or pipe the command's standard output to the notis standard input stream. This utility provides the option to mute the standard output from the original command and to emit an audio signal that the command completed along with the notification toast message.\n\nExamples:\n\n Run command as argument to notis:\n\tnotis 'curl -L http://bigsite.com'\n\n Pipe Standard Output to notis:\n\tcurl -L http://bigsite.com | notis"
53
+
54
+ # Switches:
55
+ on("--bell","-b","Provide an audio alert with notification")
56
+ on("--mute","-m","Mute standard output from running process")
57
+
58
+ # Optional argument
59
+ arg :user_command, :optional
60
+
61
+ version Notis::VERSION
62
+
63
+ begin
64
+ go!
65
+ rescue => e
66
+ STDERR.puts("There was an error with Notis.")
67
+ STDERR.puts e.message
68
+ exit 1
69
+ end
70
+ end
@@ -0,0 +1,13 @@
1
+ Feature: My bootstrapped app kinda works
2
+ In order to get going on coding my awesome app
3
+ I want to have aruba and cucumber setup
4
+ So I don't have to do it myself
5
+
6
+ Scenario: App just runs
7
+ When I get help for "notis"
8
+ Then the exit status should be 0
9
+ And the banner should be present
10
+ And the banner should document that this app takes options
11
+ And the following options should be documented:
12
+ |--version|
13
+ And the banner should document that this app takes no arguments
@@ -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,41 @@
1
+ #!/bin/sh
2
+ # Scriptacular - gemify.sh
3
+ # Create a Ruby gem and push it to rubygems.org
4
+ # Copyright 2013 Christopher Simpkins
5
+ # MIT License
6
+
7
+ # Enter your gem name below (do not enter version number)
8
+ # or pass it as the first argument to the shell script
9
+ GEM_NAME="notis"
10
+
11
+ # Don't touch these
12
+ GEMSPEC_SUFFIX=".gemspec"
13
+ GEM_BUILD_CMD="gem build"
14
+ GEM_PUSH_CMD="gem push"
15
+
16
+ # if there is an argument to the script, define the gem name with it
17
+ if [ $# -eq 1 ]; then
18
+ GEM_NAME=$1
19
+ elif [ $# -gt 1 ]; then
20
+ echo "You entered too many arguments. Please specify the name of your gem as the argument to the script." >&2
21
+ exit 1
22
+ fi
23
+
24
+ # if the gem name has not been defined, print error message and exit
25
+ if [ -z "$GEM_NAME" ]; then
26
+ echo "You did not enter a gem name. Please include it as an argument to the script or hard code it as a variable in the script." >&2
27
+ exit 1
28
+ fi
29
+
30
+ # run the gem build and parse for the gem release filename
31
+ GEM_BUILD_NAME=$(gem build "$GEM_NAME$GEMSPEC_SUFFIX" | awk '/File/ {print $2}' -)
32
+
33
+ # if the build failed (i.e. no file name obtained above), print error message and exit
34
+ if [ -z "$GEM_BUILD_NAME" ]; then
35
+ echo "The gem build failed. Please confirm the gem name and try again." >&2
36
+ exit 1
37
+ fi
38
+
39
+ # if above succeeded, then push to rubygems.org using the gem that was compiled
40
+ gem push $GEM_BUILD_NAME
41
+ exit 0
@@ -0,0 +1,19 @@
1
+ require "notis/version"
2
+ require 'open3'
3
+
4
+ module Notis
5
+ def Notis.runit(command)
6
+ begin
7
+ stdout_str, stderr_str, status = Open3.capture3(command)
8
+ if status.exitstatus == 0
9
+ return "#{stdout_str}"
10
+ else
11
+ STDERR.puts stderr_str #if the primary application fails, pass the error message to the user
12
+ exit 1
13
+ end
14
+ rescue => e
15
+ STDERR.puts e.message
16
+ exit 1
17
+ end #end begin/rescue blocks
18
+ end #end runit
19
+ end #end Notis module
@@ -0,0 +1,3 @@
1
+ module Notis
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'notis/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "notis"
8
+ spec.version = Notis::VERSION
9
+ spec.authors = ["Chris Simpkins"]
10
+ spec.email = ["git.simpkins@gmail.com"]
11
+ spec.description = %q{notis is a Mac OSX utility that allows you to display a standard OSX toast message notification at the completion of a long-running command with the option to emit an audio signal.}
12
+ spec.summary = %q{notis}
13
+ spec.homepage = "https://github.com/chrissimpkins/notis"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency('bundler')
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency('rdoc')
24
+ spec.add_development_dependency('aruba')
25
+ spec.add_development_dependency('rake', '~> 0.9.2')
26
+ spec.add_dependency('methadone', '~> 1.3.1')
27
+ spec.add_dependency('terminal-notifier', '~> 1.5.1')
28
+ 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,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: notis
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Simpkins
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: aruba
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.9.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.9.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: methadone
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 1.3.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 1.3.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: terminal-notifier
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 1.5.1
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 1.5.1
111
+ description: notis is a Mac OSX utility that allows you to display a standard OSX
112
+ toast message notification at the completion of a long-running command with the
113
+ option to emit an audio signal.
114
+ email:
115
+ - git.simpkins@gmail.com
116
+ executables:
117
+ - notis
118
+ extensions: []
119
+ extra_rdoc_files: []
120
+ files:
121
+ - Gemfile
122
+ - Gemfile.lock
123
+ - LICENSE.txt
124
+ - README.md
125
+ - README.rdoc
126
+ - Rakefile
127
+ - bin/notis
128
+ - features/notis.feature
129
+ - features/step_definitions/notis_steps.rb
130
+ - features/support/env.rb
131
+ - gemify.sh
132
+ - lib/notis.rb
133
+ - lib/notis/version.rb
134
+ - notis.gemspec
135
+ - test/tc_something.rb
136
+ homepage: https://github.com/chrissimpkins/notis
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ! '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.1.10
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: notis
160
+ test_files:
161
+ - features/notis.feature
162
+ - features/step_definitions/notis_steps.rb
163
+ - features/support/env.rb
164
+ - test/tc_something.rb