notifaction 0.0.8 → 0.0.9
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.
- checksums.yaml +4 -4
- data/.gitignore +9 -2
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/{LICENSE → LICENSE.txt} +4 -5
- data/README.md +3 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/notifaction.rb +12 -6
- data/lib/{notify.rb → notifaction/notify.rb} +58 -44
- data/lib/notifaction/plugin.rb +7 -0
- data/lib/{style.rb → notifaction/style.rb} +0 -0
- data/lib/notifaction/type.rb +19 -0
- data/lib/notifaction/types/linux.rb +15 -0
- data/lib/notifaction/types/osx.rb +15 -0
- data/lib/notifaction/types/terminal.rb +70 -0
- data/lib/{utils.rb → notifaction/utils.rb} +1 -1
- data/lib/notifaction/version.rb +3 -0
- data/notifaction.gemspec +24 -11
- metadata +71 -18
- data/lib/plugin.rb +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 514d8e96cf96f632d010335afd0347b2de5025e5
|
|
4
|
+
data.tar.gz: 478edc696fc6ec139e9040d2f83c404ee5e10a34
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ee30e73c53dd80cdacdeffae606899e29e8c55bd606d5847b541515c37ef48c495d61aab121e6daf90f1d4decaefff58e95758b133d7066d7eec5eeb8ab78d29
|
|
7
|
+
data.tar.gz: e4a13582cd36cae2de6cb2ba18a9a35d5bee0d87b802c2b87b7971f85bebd93b7dad3587636fa122b99f3f90505551c96d885cdcd0cc982f07431bf5885643bf
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/{LICENSE → LICENSE.txt}
RENAMED
|
@@ -9,14 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
9
9
|
copies of the Software, and to permit persons to whom the Software is
|
|
10
10
|
furnished to do so, subject to the following conditions:
|
|
11
11
|
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
copies or substantial portions of the Software.
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
16
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
17
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
SOFTWARE.
|
|
22
|
-
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require 'notifaction'
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/notifaction.rb
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
$:.unshift File.dirname(__FILE__)
|
|
2
|
-
|
|
3
1
|
require 'time'
|
|
4
2
|
require 'rbconfig'
|
|
5
3
|
require 'net/http'
|
|
6
4
|
require 'cgi'
|
|
7
|
-
|
|
8
|
-
require '
|
|
9
|
-
require '
|
|
10
|
-
require '
|
|
5
|
+
|
|
6
|
+
require 'notifaction/type'
|
|
7
|
+
require 'notifaction/types/linux'
|
|
8
|
+
require 'notifaction/types/osx'
|
|
9
|
+
require 'notifaction/types/terminal'
|
|
10
|
+
require 'notifaction/notify'
|
|
11
|
+
require 'notifaction/plugin'
|
|
12
|
+
require "notifaction/version"
|
|
13
|
+
require 'notifaction/utils'
|
|
14
|
+
|
|
15
|
+
module Notifaction
|
|
16
|
+
end
|
|
@@ -31,12 +31,15 @@ class Notify
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# Prints a pre-formatted error message to the console
|
|
34
|
-
def self.error(message)
|
|
35
|
-
message = message.split("\n").join("\n\u2716 ")
|
|
36
|
-
inline("\u2716 #{message} - #{Utils.formatted_time}", :red)
|
|
37
|
-
inline("\u2716 Exiting...", :red)
|
|
38
|
-
|
|
39
|
-
exit(1)
|
|
34
|
+
def self.error(message, config = [])
|
|
35
|
+
# message = message.split("\n").join("\n\u2716 ")
|
|
36
|
+
# inline("\u2716 #{message} - #{Utils.formatted_time}", :red)
|
|
37
|
+
# inline("\u2716 Exiting...", :red)
|
|
38
|
+
|
|
39
|
+
# exit(1)
|
|
40
|
+
handler = Notifaction::Type::Terminal.new
|
|
41
|
+
handler.error(message, config)
|
|
42
|
+
handler.quit
|
|
40
43
|
end
|
|
41
44
|
|
|
42
45
|
# Prints a pre-formatted warning message to the console
|
|
@@ -46,8 +49,10 @@ class Notify
|
|
|
46
49
|
end
|
|
47
50
|
|
|
48
51
|
# Prints a pre-formatted informational message to the console
|
|
49
|
-
def self.info(message)
|
|
50
|
-
|
|
52
|
+
def self.info(message, config = {})
|
|
53
|
+
handler = Notifaction::Type::Terminal.new
|
|
54
|
+
handler.info(message, config)
|
|
55
|
+
#inline("#{message} - #{Utils.formatted_time}", :blue)
|
|
51
56
|
end
|
|
52
57
|
|
|
53
58
|
# Prints a pre-formatted secondary informational message to the console
|
|
@@ -90,6 +95,14 @@ class Notify
|
|
|
90
95
|
yield self if block_given?
|
|
91
96
|
end
|
|
92
97
|
|
|
98
|
+
def self.print_output
|
|
99
|
+
true
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def self.print_timestamps
|
|
103
|
+
true
|
|
104
|
+
end
|
|
105
|
+
|
|
93
106
|
# register new plugins
|
|
94
107
|
def self.plugins=(plugin_config_arr)
|
|
95
108
|
plugin_config_arr.each do |hash|
|
|
@@ -103,51 +116,52 @@ class Notify
|
|
|
103
116
|
end
|
|
104
117
|
|
|
105
118
|
private
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
119
|
+
|
|
120
|
+
# Collate colour and style, build message string in format of
|
|
121
|
+
# "\e[#{style};#{colour}m#{text}\e[0m"
|
|
122
|
+
def self.inline(message, colour = nil, style = nil)
|
|
123
|
+
puts Style.format(message, colour, style)
|
|
124
|
+
end
|
|
111
125
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
126
|
+
def self.osx_notification(message, title)
|
|
127
|
+
begin
|
|
128
|
+
@response = `osascript -e 'display notification "#{message}" with title "#{title}"'`
|
|
115
129
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
end
|
|
130
|
+
$?.exitstatus == 0
|
|
131
|
+
rescue SystemExit, Interrupt
|
|
132
|
+
error("Interrupt caught, exiting")
|
|
120
133
|
end
|
|
134
|
+
end
|
|
121
135
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
# OSX system modal popup
|
|
137
|
+
def self.osx_modal(message, title, icon = :caution)
|
|
138
|
+
begin
|
|
139
|
+
@response = `osascript -e 'tell app "System Events" to display dialog "#{message}" buttons {"OK"} default button 1 with title "#{title}" with icon #{icon}'`
|
|
126
140
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
end
|
|
141
|
+
$?.exitstatus == 0
|
|
142
|
+
rescue SystemExit, Interrupt
|
|
143
|
+
error("Interrupt caught, exiting")
|
|
131
144
|
end
|
|
145
|
+
end
|
|
132
146
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
147
|
+
# Linux system notification
|
|
148
|
+
def self.notifysend(message, title)
|
|
149
|
+
begin
|
|
150
|
+
@response = `notify-send "#{title}" "#{message}"`
|
|
137
151
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
end
|
|
152
|
+
$?.exitstatus == 0
|
|
153
|
+
rescue SystemExit, Interrupt
|
|
154
|
+
error("Interrupt caught, exiting")
|
|
142
155
|
end
|
|
156
|
+
end
|
|
143
157
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
158
|
+
def self.zenity(message, title)
|
|
159
|
+
begin
|
|
160
|
+
@response = `echo "message:#{message}" | zenity --notification --listen`
|
|
147
161
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
end
|
|
162
|
+
$?.exitstatus == 0
|
|
163
|
+
rescue SystemExit, Interrupt
|
|
164
|
+
error("Interrupt caught, exiting")
|
|
152
165
|
end
|
|
153
|
-
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'notifaction/style'
|
|
2
|
+
|
|
3
|
+
module Notifaction
|
|
4
|
+
module Type
|
|
5
|
+
class Terminal < Type::Base
|
|
6
|
+
#
|
|
7
|
+
# @since 0.2.8
|
|
8
|
+
def error(message, config)
|
|
9
|
+
inline(message, config, :red)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
#
|
|
13
|
+
# @since 0.2.8
|
|
14
|
+
def warning(message, config)
|
|
15
|
+
inline(message, config, :yellow)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
#
|
|
19
|
+
# @since 0.2.8
|
|
20
|
+
def success(message, config)
|
|
21
|
+
inline(message, config, :green)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
#
|
|
25
|
+
# @since 0.2.8
|
|
26
|
+
def info(message, config)
|
|
27
|
+
inline(message, config, :blue)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
#
|
|
31
|
+
# @since 0.2.8
|
|
32
|
+
def sinfo(message, config)
|
|
33
|
+
deprecation_notice('0.2.8')
|
|
34
|
+
|
|
35
|
+
note(message, config, :cyan)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
#
|
|
39
|
+
# @since 0.2.8
|
|
40
|
+
def note(message, config)
|
|
41
|
+
inline(message, config, :cyan)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
#
|
|
45
|
+
# @since 0.2.8
|
|
46
|
+
def spit(message, config)
|
|
47
|
+
inline(message, config)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
#
|
|
51
|
+
# @since 0.2.8
|
|
52
|
+
def spacer
|
|
53
|
+
inline("\u2011 =============", {}, :magenta)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
#
|
|
59
|
+
# @since 0.2.8
|
|
60
|
+
def inline(message, config = [], colour = nil, style = nil)
|
|
61
|
+
# formatting options
|
|
62
|
+
message += " - #{Utils.formatted_time}" if config[:show_time]
|
|
63
|
+
message = "#{config[:symbol]} #{message}" if config[:fancy]
|
|
64
|
+
|
|
65
|
+
puts Style.format(message, colour, style)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
data/notifaction.gemspec
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'notifaction/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "notifaction"
|
|
8
|
+
spec.version = Notifaction::VERSION
|
|
9
|
+
spec.authors = ["Яyan Priebe"]
|
|
10
|
+
spec.email = ["rpriebe@me.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Include terminal and OS notifications in your ruby projects}
|
|
13
|
+
spec.description = %q{Include terminal and OS notifications in your ruby projects}
|
|
14
|
+
spec.homepage = "https://rubygems.org/gems/notifaction"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
17
|
+
spec.bindir = "exe"
|
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
23
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
|
24
|
+
end
|
metadata
CHANGED
|
@@ -1,32 +1,85 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: notifaction
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
7
|
+
- Яyan Priebe
|
|
8
8
|
autorequire:
|
|
9
|
-
bindir:
|
|
9
|
+
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
date: 2016-04-19 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: '1.11'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.11'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: minitest
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '5.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '5.0'
|
|
55
|
+
description: Include terminal and OS notifications in your ruby projects
|
|
56
|
+
email:
|
|
57
|
+
- rpriebe@me.com
|
|
15
58
|
executables: []
|
|
16
59
|
extensions: []
|
|
17
60
|
extra_rdoc_files: []
|
|
18
61
|
files:
|
|
19
|
-
- .gitignore
|
|
20
|
-
-
|
|
62
|
+
- ".gitignore"
|
|
63
|
+
- ".travis.yml"
|
|
64
|
+
- Gemfile
|
|
65
|
+
- LICENSE.txt
|
|
21
66
|
- README.md
|
|
67
|
+
- Rakefile
|
|
68
|
+
- bin/console
|
|
69
|
+
- bin/setup
|
|
22
70
|
- lib/notifaction.rb
|
|
23
|
-
- lib/notify.rb
|
|
24
|
-
- lib/plugin.rb
|
|
71
|
+
- lib/notifaction/notify.rb
|
|
72
|
+
- lib/notifaction/plugin.rb
|
|
73
|
+
- lib/notifaction/style.rb
|
|
74
|
+
- lib/notifaction/type.rb
|
|
75
|
+
- lib/notifaction/types/linux.rb
|
|
76
|
+
- lib/notifaction/types/osx.rb
|
|
77
|
+
- lib/notifaction/types/terminal.rb
|
|
78
|
+
- lib/notifaction/utils.rb
|
|
79
|
+
- lib/notifaction/version.rb
|
|
25
80
|
- lib/plugins/workingon.rb
|
|
26
|
-
- lib/style.rb
|
|
27
|
-
- lib/utils.rb
|
|
28
81
|
- notifaction.gemspec
|
|
29
|
-
homepage:
|
|
82
|
+
homepage: https://rubygems.org/gems/notifaction
|
|
30
83
|
licenses:
|
|
31
84
|
- MIT
|
|
32
85
|
metadata: {}
|
|
@@ -36,18 +89,18 @@ require_paths:
|
|
|
36
89
|
- lib
|
|
37
90
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
91
|
requirements:
|
|
39
|
-
- -
|
|
92
|
+
- - ">="
|
|
40
93
|
- !ruby/object:Gem::Version
|
|
41
94
|
version: '0'
|
|
42
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
43
96
|
requirements:
|
|
44
|
-
- -
|
|
97
|
+
- - ">="
|
|
45
98
|
- !ruby/object:Gem::Version
|
|
46
99
|
version: '0'
|
|
47
100
|
requirements: []
|
|
48
101
|
rubyforge_project:
|
|
49
|
-
rubygems_version: 2.0.14
|
|
102
|
+
rubygems_version: 2.0.14.1
|
|
50
103
|
signing_key:
|
|
51
104
|
specification_version: 4
|
|
52
|
-
summary:
|
|
105
|
+
summary: Include terminal and OS notifications in your ruby projects
|
|
53
106
|
test_files: []
|