rake_notification 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c6a3378a9677b2056d89ebd7c7901b8612e82e67
4
+ data.tar.gz: 7e36ff689aa4d62697e3e6a2b9b2f8044d09e154
5
+ SHA512:
6
+ metadata.gz: 38e812351b33202687047f77557370ffdbd3ec24fc2fe526c1761f86b483db0857777049e3ec23061b1ae2f23d634303b21ef869f0b729cc7299b6a942f67382
7
+ data.tar.gz: 780d0d7119135c8d1408670ef8a843866bffed2bd76472798ae9a0cdbe11e4bdc237d935bbe2072ed40d1401c7154cfb0b3bc844fcf73c0ba14b7bbded8aa0a1
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rake_notification.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 mizokami
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.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # RakeNotification
2
+
3
+ Notification of status for rake
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rake_notification'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ ### Execution
16
+
17
+ $ bundle exec rake_notify your_task
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it ( https://github.com/mizoR/rake_notification/fork )
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/rake_notify ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require 'rubygems'
5
+ gem 'rake'
6
+ rescue LoadError
7
+ end
8
+
9
+ require 'rake'
10
+ require 'rake_notification'
11
+
12
+ using RakeNotification
13
+
14
+ if File.exist?(RakeNotification.config_path)
15
+ require RakeNotification.config_path
16
+ end
17
+
18
+ Rake.application.run
@@ -0,0 +1,57 @@
1
+ require 'rake'
2
+
3
+ module RakeNotification
4
+ def self.config_path
5
+ './config/rake_notification.rb'
6
+ end
7
+
8
+ refine Rake::Application do
9
+ def init(app_name='rake')
10
+ super
11
+ end
12
+
13
+ def reconstructed_command_line
14
+ @reconstructed_command_line ||= "#{File.basename($0)} #{ARGV.join(' ')}"
15
+ end
16
+
17
+ def register_observer(observer)
18
+ notification_observers << observer
19
+ end
20
+
21
+ def register_interceptor(interceptor)
22
+ notification_interceptors << interceptor
23
+ end
24
+
25
+ def run
26
+ inform_interceptors
27
+ super
28
+ rescue SystemExit => e
29
+ inform_observers(e)
30
+ raise e
31
+ else
32
+ inform_observers
33
+ end
34
+
35
+ private
36
+
37
+ def inform_interceptors
38
+ notification_interceptors.each do |interceptor|
39
+ interceptor.started_task(self)
40
+ end
41
+ end
42
+
43
+ def inform_observers(system_exit=SystemExit.new(0))
44
+ notification_observers.each do |observer|
45
+ observer.completed_task(self, system_exit)
46
+ end
47
+ end
48
+
49
+ def notification_interceptors
50
+ @notification_interceptors ||= []
51
+ end
52
+
53
+ def notification_observers
54
+ @notification_observers ||= []
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,3 @@
1
+ module RakeNotification
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1 @@
1
+ job_type :rake_notify, "cd :path && :environment_variable=:environment :bundle_command rake_notify :task --silent :output"
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rake_notification/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rake_notification"
8
+ spec.version = RakeNotification::VERSION
9
+ spec.authors = ["mizokami"]
10
+ spec.email = ["suzunatsu@yahoo.com"]
11
+ spec.summary = %q{Rake notification}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "activesupport"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "pry"
25
+ spec.add_development_dependency "rspec"
26
+ end
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ describe RakeNotification do
4
+ using RakeNotification
5
+
6
+ subject { app }
7
+
8
+ let(:app) { Rake::Application.new }
9
+
10
+ let(:notifier) { double('notifier') }
11
+
12
+ before {
13
+ allow(app).to receive(:invoke_task).and_return(true)
14
+ }
15
+
16
+ it { expect(described_class.config_path).to be_a String }
17
+
18
+ it { should be_respond_to :run }
19
+
20
+ describe "#reconstruct_command_line" do
21
+ subject { app.reconstruct_command_line }
22
+ it {
23
+ app.init
24
+ expect(app.reconstructed_command_line).to be_a String
25
+ }
26
+ end
27
+
28
+ describe '#register_interceptor' do
29
+ before { app.register_interceptor notifier }
30
+
31
+ it '#started_task が実行されること' do
32
+ expect(notifier).to receive(:started_task).with(app)
33
+ expect(notifier).not_to receive(:completed_task)
34
+
35
+ app.run
36
+ end
37
+ end
38
+
39
+ describe '#register_observer' do
40
+ before { app.register_observer notifier }
41
+
42
+ it '#completed_task が実行されること' do
43
+ expect(notifier).not_to receive(:started_task)
44
+ expect(notifier).to receive(:completed_task)
45
+
46
+ app.run
47
+ end
48
+
49
+ context 'タスクの実行中に例外が発生' do
50
+ before { app.stub(:invoke_task).and_raise(StandardError.new('Rake Error')) }
51
+
52
+ it '#completed_task が実行されること' do
53
+ expect(notifier).not_to receive(:started_task)
54
+ expect(notifier).to receive(:completed_task).with(app, kind_of(SystemExit))
55
+ begin
56
+ $stderr.reopen('/dev/null', 'w')
57
+ app.run
58
+ rescue SystemExit => e
59
+ expect(e).not_to be_success
60
+ rescue => e
61
+ raise e
62
+ else
63
+ raise "Rake::Application#run should raise SystemExit, but did not."
64
+ ensure
65
+ $stderr = STDERR
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,3 @@
1
+ require 'rspec'
2
+ require 'rake'
3
+ require 'rake_notification'
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rake_notification
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - mizokami
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
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: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
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: pry
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: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - suzunatsu@yahoo.com
86
+ executables:
87
+ - rake_notify
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - bin/rake_notify
97
+ - lib/rake_notification.rb
98
+ - lib/rake_notification/version.rb
99
+ - lib/rake_notification/whenever.rb
100
+ - rake_notification.gemspec
101
+ - spec/lib/rake_notification_spec.rb
102
+ - spec/spec_helper.rb
103
+ homepage: ''
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.2.2
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Rake notification
127
+ test_files:
128
+ - spec/lib/rake_notification_spec.rb
129
+ - spec/spec_helper.rb