travis-blink1 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5597610c7dbd758ba31f5350504f3441724b4ae8
4
+ data.tar.gz: 76401717af549ac7865e72b13612f3bfff029ea5
5
+ SHA512:
6
+ metadata.gz: 19fc5028dbfe5c263c77126a9db711325c59ef37a2973d43f869274bb2123454ebf0b8f5817335830f9ad802bc1a469a4e3f3b97fe05b70c52b1e935c033d648
7
+ data.tar.gz: cc6936dc430e56f8204b2734de8a2003b5289ddbf8ada8f146fdea10e4f69c662ab8ce5436c8605117c083a506411d3a2668fa63022d05769cdde469eda20647
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
4
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in travis-blink1.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard 'rspec', cmd: 'bundle exec rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 ryo katsuma
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,47 @@
1
+ # Travis::Blink1
2
+
3
+ `travis-blink1` is a simple sign by blink(1).
4
+
5
+ When you specify a repository travis-blink1 checks your pull request and it shows signal by Travis CI is passed or not.
6
+ Of course gree sign is passed and red is not.
7
+
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'travis-blink1'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install travis-blink1
24
+
25
+ ## Usage
26
+
27
+ When you specify `git remote` address on github.com at your repository root,
28
+ try simply like this.
29
+
30
+ ```sh
31
+ travis-blink1
32
+ ```
33
+
34
+ You can also specify repository name.
35
+
36
+ ```sh
37
+ travis-blink1 your_name/your_repository
38
+ ```
39
+
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it ( https://github.com/katsuma/travis-blink1/fork )
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
data/bin/travis-blink1 ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'travis/blink1'
3
+ include Travis::Blink1
4
+
5
+ Travis::Blink1.run
@@ -0,0 +1,75 @@
1
+ require "travis/blink1/version"
2
+ require "open3"
3
+ require 'blink1'
4
+ require 'travis'
5
+
6
+ module Travis
7
+ module Blink1
8
+ BLINK_TIMES = 7
9
+
10
+ GREEN = [0, 255, 0].freeze
11
+ RED = [255, 0, 0].freeze
12
+ YELLOW = [255, 255, 0].freeze
13
+
14
+ def run
15
+ blink1 = ::Blink1.new
16
+ blink1.open
17
+
18
+ Signal.trap(:INT) do
19
+ dispose_blink1(blink1)
20
+ exit
21
+ end
22
+
23
+ repository_name = fetch_repository_name
24
+ repository = Travis::Repository.find(repository_name)
25
+ banner(repository_name)
26
+
27
+ begin
28
+ state = repository.reload.last_build.state
29
+ notify_by(state, blink1: blink1)
30
+
31
+ sleep(3)
32
+ end while loop?
33
+ end
34
+
35
+ def fetch_repository_name
36
+ unless repository_name = ARGV.first
37
+ results = *Open3.capture2("git remote -v | grep push | awk '{ print $2 }'")
38
+ repository_name_regexp = /github\.com\/(.+)/
39
+
40
+ matched_name = results.first.match(repository_name_regexp)
41
+ raise unless matched_name
42
+ repository_name = matched_name[1]
43
+ end
44
+ repository_name
45
+ rescue
46
+ messages = "Specify repository name. Try \"travis-blink1 user/repo\" or set remote address by \"git remote add origin https://github.com/user/repo.git\""
47
+ raise ArgumentError.new(messages)
48
+ end
49
+
50
+ def notify_by(state, blink1: nil)
51
+ case state
52
+ when "passed"
53
+ blink1.set_rgb(*GREEN)
54
+ when "errored", "failed"
55
+ blink1.blink(*RED, BLINK_TIMES)
56
+ when "started"
57
+ blink1.blink(*YELLOW, BLINK_TIMES)
58
+ end
59
+ end
60
+
61
+ def banner(repository_name)
62
+ puts "Watching repository: #{repository_name}"
63
+ end
64
+
65
+ def loop?
66
+ true
67
+ end
68
+
69
+ def dispose_blink1(blink1)
70
+ blink1.off
71
+ blink1.close
72
+ rescue
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,5 @@
1
+ module Travis
2
+ module Blink1
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'travis/blink1'
4
+ require 'simplecov'
5
+ require 'coveralls'
6
+
7
+ include Travis::Blink1
8
+
9
+ RSpec.configure do |config|
10
+ config.color = true
11
+ config.tty = true
12
+ end
13
+
14
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
15
+ SimpleCov::Formatter::HTMLFormatter,
16
+ Coveralls::SimpleCov::Formatter
17
+ ]
18
+
19
+ SimpleCov.start do
20
+ add_filter '/spec/'
21
+ end
@@ -0,0 +1,176 @@
1
+ require 'spec_helper'
2
+
3
+ describe Travis::Blink1 do
4
+ describe "version" do
5
+ it "has a version number" do
6
+ expect(Travis::Blink1::VERSION).not_to be nil
7
+ end
8
+ end
9
+
10
+ describe "#fetch_repositry_name" do
11
+ subject do
12
+ Travis::Blink1.fetch_repository_name
13
+ end
14
+
15
+ context "when argument is given" do
16
+ before do
17
+ allow(ARGV).to receive(:first).and_return(repository_name)
18
+ end
19
+
20
+ let(:repository_name) do
21
+ 'katsuma/travis-blink1'
22
+ end
23
+
24
+ it "returns repository name" do
25
+ expect(subject).to eq(repository_name)
26
+ end
27
+ end
28
+
29
+ context "when argument is not given" do
30
+ before do
31
+ allow(ARGV).to receive(:first).and_return(nil)
32
+ allow(Open3).to receive(:capture2).and_return([repository_url, nil])
33
+ end
34
+
35
+ context "and when git is set" do
36
+ let(:repository_url) do
37
+ "https://github.com/katsuma/travis-blink1"
38
+ end
39
+
40
+ let(:repository_name) do
41
+ "katsuma/travis-blink1"
42
+ end
43
+
44
+ it "returns repository name" do
45
+ expect(subject).to eq(repository_name)
46
+ end
47
+ end
48
+
49
+ context "and when git is not set" do
50
+ let(:repository_url) do
51
+ ""
52
+ end
53
+
54
+ it "raises an ArgumentError" do
55
+ expect { subject }.to raise_error(ArgumentError)
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ describe "#notify_by" do
62
+ subject do
63
+ Travis::Blink1.notify_by(state, blink1: blink1)
64
+ end
65
+
66
+
67
+ context "when state is passed" do
68
+ let(:state) do
69
+ "passed"
70
+ end
71
+
72
+ let(:blink1) do
73
+ double(:blink1, set_rgb: nil)
74
+ end
75
+
76
+ it "sets green color" do
77
+ expect(blink1).to receive(:set_rgb).with(*Travis::Blink1::GREEN)
78
+ subject
79
+ end
80
+ end
81
+
82
+ context "when state is errored" do
83
+ let(:state) do
84
+ "errored"
85
+ end
86
+
87
+ let(:blink1) do
88
+ double(:blink1, blink: nil)
89
+ end
90
+
91
+ it "blinks with red color" do
92
+ expect(blink1).to receive(:blink).with(*Travis::Blink1::RED, anything)
93
+ subject
94
+ end
95
+ end
96
+ end
97
+
98
+
99
+ describe "#run" do
100
+ subject do
101
+ Travis::Blink1.run
102
+ end
103
+
104
+ before do
105
+ stub_blink1
106
+
107
+ allow(Travis::Blink1).to receive(:fetch_repository_name).and_return(repository_name)
108
+ allow(Travis::Blink1).to receive(:loop?).and_return(false)
109
+ allow(Travis::Blink1).to receive(:sleep).and_return(true)
110
+ allow(Travis::Blink1).to receive(:banner).and_return("")
111
+ end
112
+
113
+ let(:repository_name) do
114
+ "katsuma/travis-blink1"
115
+ end
116
+
117
+ let(:repository) do
118
+ double(reload: double(last_build: double(state: state)))
119
+ end
120
+
121
+ context "when Travis CI is passed" do
122
+ let(:state) do
123
+ "passed"
124
+ end
125
+
126
+ before do
127
+ allow(Travis::Repository).to receive(:find).and_return(repository)
128
+ end
129
+
130
+ it "notifies by 'passed'" do
131
+ expect(Travis::Blink1).to receive(:notify_by).with('passed', anything)
132
+ subject
133
+ end
134
+ end
135
+
136
+ context "when Travis CI is errored" do
137
+ let(:state) do
138
+ "errored"
139
+ end
140
+
141
+ before do
142
+ allow(Travis::Repository).to receive(:find).and_return(repository)
143
+ end
144
+
145
+ it "notifies by 'errored'" do
146
+ expect(Travis::Blink1).to receive(:notify_by).with('errored', anything)
147
+ subject
148
+ end
149
+ end
150
+
151
+ context "When Travis CI is started" do
152
+ let(:state) do
153
+ "started"
154
+ end
155
+
156
+ before do
157
+ allow(Travis::Repository).to receive(:find).and_return(repository)
158
+ end
159
+
160
+ it "notifies by 'errored'" do
161
+ expect(Travis::Blink1).to receive(:notify_by).with('started', anything)
162
+ subject
163
+ end
164
+ end
165
+
166
+ def stub_blink1
167
+ allow_any_instance_of(Blink1).to receive_messages(
168
+ on: true,
169
+ off: true,
170
+ open: true,
171
+ close: true,
172
+ blink: true,
173
+ )
174
+ end
175
+ end
176
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'travis/blink1/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "travis-blink1"
8
+ spec.version = Travis::Blink1::VERSION
9
+ spec.authors = ["ryo katsuma"]
10
+ spec.email = ["katsuma@gmail.com"]
11
+ spec.summary = %q{Simple sign by blink(1) if Travis CI is passed or not.}
12
+ spec.description = %q{travis-blink1 is a simple sign by blink(1). When you specify a repository travis-blink1 checks your pull request and it shows signal by Travis CI is passed or not. Of course gree sign is passed and red is not.}
13
+ spec.homepage = "https://github.com/katsuima/travis-blink1"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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 "rake", "~> 10.3.2"
22
+ spec.add_development_dependency "rspec", "~> 3.0.0"
23
+ spec.add_development_dependency "guard", "~> 2.6.1"
24
+ spec.add_development_dependency "guard-rspec", "~> 4.3.1"
25
+ spec.add_development_dependency "growl", "~> 1.0.3"
26
+ spec.add_development_dependency "simplecov", "~> 0.9.0"
27
+ spec.add_development_dependency "coveralls", "~> 0.7.1"
28
+ spec.add_dependency "rb-blink1", "~> 0.0.7"
29
+ spec.add_dependency "travis", "~> 1.7.1"
30
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: travis-blink1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - ryo katsuma
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 10.3.2
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 10.3.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.0.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.0.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.6.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.6.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 4.3.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 4.3.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: growl
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.0.3
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.0.3
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.9.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.9.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.7.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.7.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: rb-blink1
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.0.7
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.0.7
125
+ - !ruby/object:Gem::Dependency
126
+ name: travis
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 1.7.1
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 1.7.1
139
+ description: travis-blink1 is a simple sign by blink(1). When you specify a repository
140
+ travis-blink1 checks your pull request and it shows signal by Travis CI is passed
141
+ or not. Of course gree sign is passed and red is not.
142
+ email:
143
+ - katsuma@gmail.com
144
+ executables:
145
+ - travis-blink1
146
+ extensions: []
147
+ extra_rdoc_files: []
148
+ files:
149
+ - ".gitignore"
150
+ - ".rspec"
151
+ - ".travis.yml"
152
+ - Gemfile
153
+ - Guardfile
154
+ - LICENSE.txt
155
+ - README.md
156
+ - Rakefile
157
+ - bin/travis-blink1
158
+ - lib/travis/blink1.rb
159
+ - lib/travis/blink1/version.rb
160
+ - spec/spec_helper.rb
161
+ - spec/travis/blink1_spec.rb
162
+ - travis-blink1.gemspec
163
+ homepage: https://github.com/katsuima/travis-blink1
164
+ licenses:
165
+ - MIT
166
+ metadata: {}
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubyforge_project:
183
+ rubygems_version: 2.2.2
184
+ signing_key:
185
+ specification_version: 4
186
+ summary: Simple sign by blink(1) if Travis CI is passed or not.
187
+ test_files:
188
+ - spec/spec_helper.rb
189
+ - spec/travis/blink1_spec.rb