notifaction 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2708ebdc002e1ebc5439db8e406d31c382a5d773
4
- data.tar.gz: e2fb135d2714fdb38fe7a5835ccdac4ea8859adc
3
+ metadata.gz: 514d8e96cf96f632d010335afd0347b2de5025e5
4
+ data.tar.gz: 478edc696fc6ec139e9040d2f83c404ee5e10a34
5
5
  SHA512:
6
- metadata.gz: d9a72caffe85037783019b88d4feb7884b66c299c12c6be36488e6c340a841feb5eb2a767fc4dab181c894b96e50d12bf62685f3727b19be84f711012f304a3a
7
- data.tar.gz: a17299060126728f7f56783e9a059cf4afa6d0ac33214992009b9b15b4cbd0550e657335d2c47f1eed9fc3c439f3fe595778fde64a6e66ea2ffcbfeef2f93020
6
+ metadata.gz: ee30e73c53dd80cdacdeffae606899e29e8c55bd606d5847b541515c37ef48c495d61aab121e6daf90f1d4decaefff58e95758b133d7066d7eec5eeb8ab78d29
7
+ data.tar.gz: e4a13582cd36cae2de6cb2ba18a9a35d5bee0d87b802c2b87b7971f85bebd93b7dad3587636fa122b99f3f90505551c96d885cdcd0cc982f07431bf5885643bf
data/.gitignore CHANGED
@@ -1,2 +1,9 @@
1
- *.gem
2
- test.rb
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in notifaction.gemspec
4
+ gemspec
@@ -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 all
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 THE
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
@@ -5,6 +5,9 @@ Include terminal and OS notifications in your project.
5
5
  ## Usage
6
6
 
7
7
  ```ruby
8
+ gem install notifaction
9
+
10
+ # ...
8
11
  require 'notifaction'
9
12
 
10
13
  # Print an angry red terminal message
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :spec
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
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
- require 'utils.rb'
8
- require 'style.rb'
9
- require 'plugin.rb'
10
- require 'notify.rb'
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
- inline("#{message} - #{Utils.formatted_time}", :blue)
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
- # Collate colour and style, build message string in format of
107
- # "\e[#{style};#{colour}m#{text}\e[0m"
108
- def self.inline(message, colour = nil, style = nil)
109
- puts Style.format(message, colour, style)
110
- end
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
- def self.osx_notification(message, title)
113
- begin
114
- @response = `osascript -e 'display notification "#{message}" with title "#{title}"'`
126
+ def self.osx_notification(message, title)
127
+ begin
128
+ @response = `osascript -e 'display notification "#{message}" with title "#{title}"'`
115
129
 
116
- $?.exitstatus == 0
117
- rescue SystemExit, Interrupt
118
- error("Interrupt caught, exiting")
119
- end
130
+ $?.exitstatus == 0
131
+ rescue SystemExit, Interrupt
132
+ error("Interrupt caught, exiting")
120
133
  end
134
+ end
121
135
 
122
- # OSX system modal popup
123
- def self.osx_modal(message, title, icon = :caution)
124
- begin
125
- @response = `osascript -e 'tell app "System Events" to display dialog "#{message}" buttons {"OK"} default button 1 with title "#{title}" with icon #{icon}'`
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
- $?.exitstatus == 0
128
- rescue SystemExit, Interrupt
129
- error("Interrupt caught, exiting")
130
- end
141
+ $?.exitstatus == 0
142
+ rescue SystemExit, Interrupt
143
+ error("Interrupt caught, exiting")
131
144
  end
145
+ end
132
146
 
133
- # Linux system notification
134
- def self.notifysend(message, title)
135
- begin
136
- @response = `notify-send "#{title}" "#{message}"`
147
+ # Linux system notification
148
+ def self.notifysend(message, title)
149
+ begin
150
+ @response = `notify-send "#{title}" "#{message}"`
137
151
 
138
- $?.exitstatus == 0
139
- rescue SystemExit, Interrupt
140
- error("Interrupt caught, exiting")
141
- end
152
+ $?.exitstatus == 0
153
+ rescue SystemExit, Interrupt
154
+ error("Interrupt caught, exiting")
142
155
  end
156
+ end
143
157
 
144
- def self.zenity(message, title)
145
- begin
146
- @response = `echo "message:#{message}" | zenity --notification --listen`
158
+ def self.zenity(message, title)
159
+ begin
160
+ @response = `echo "message:#{message}" | zenity --notification --listen`
147
161
 
148
- $?.exitstatus == 0
149
- rescue SystemExit, Interrupt
150
- error("Interrupt caught, exiting")
151
- end
162
+ $?.exitstatus == 0
163
+ rescue SystemExit, Interrupt
164
+ error("Interrupt caught, exiting")
152
165
  end
153
- end
166
+ end
167
+ end
@@ -0,0 +1,7 @@
1
+ module Notifaction
2
+ module Plugin
3
+ def self.num_lines(file)
4
+ File.foreach(file).inject(0) {|c, line| c+1}
5
+ end
6
+ end
7
+ end
File without changes
@@ -0,0 +1,19 @@
1
+ module Notifaction
2
+ module Type
3
+ class Base
4
+
5
+ #
6
+ # @since 0.2.8
7
+ def deprecation_notice(version)
8
+ puts "Deprecated as of #{version}"
9
+ end
10
+
11
+ #
12
+ # @since 0.2.8
13
+ def quit
14
+ exit
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ module Notifaction
2
+ module Type
3
+ class Linux < Type::Base
4
+
5
+ def bubble(message, title)
6
+
7
+ end
8
+
9
+ def modal(message, title)
10
+
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module Notifaction
2
+ module Type
3
+ class OSX < Type::Base
4
+
5
+ def bubble(message, title)
6
+
7
+ end
8
+
9
+ def modal(message, title)
10
+
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -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
@@ -24,4 +24,4 @@ class Utils
24
24
  end
25
25
  )
26
26
  end
27
- end
27
+ end
@@ -0,0 +1,3 @@
1
+ module Notifaction
2
+ VERSION = "0.0.9"
3
+ end
data/notifaction.gemspec CHANGED
@@ -1,11 +1,24 @@
1
- Gem::Specification.new do |s|
2
- s.name = 'notifaction'
3
- s.version = '0.0.8'
4
- s.summary = "Notification Satisfaction"
5
- s.description = "Include terminal and OS notifications in your project"
6
- s.authors = ["Ryan Priebe"]
7
- s.email = 'hello@ryanpriebe.com'
8
- s.files = `git ls-files`.split($\)
9
- s.homepage = 'http://rubygems.org/gems/notifaction'
10
- s.license = 'MIT'
11
- end
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.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
- - Ryan Priebe
7
+ - Яyan Priebe
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-05 00:00:00.000000000 Z
12
- dependencies: []
13
- description: Include terminal and OS notifications in your project
14
- email: hello@ryanpriebe.com
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
- - LICENSE
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: http://rubygems.org/gems/notifaction
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: Notification Satisfaction
105
+ summary: Include terminal and OS notifications in your ruby projects
53
106
  test_files: []
data/lib/plugin.rb DELETED
@@ -1,5 +0,0 @@
1
- module Plugin
2
- def self.num_lines(file)
3
- File.foreach(file).inject(0) {|c, line| c+1}
4
- end
5
- end