idler 0.1.0
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 +7 -0
- data/.drone.yml +10 -0
- data/.gitignore +9 -0
- data/.idler.rb +7 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +79 -0
- data/Rakefile +1 -0
- data/bin/idler +6 -0
- data/circle.yml +9 -0
- data/idler.gemspec +28 -0
- data/lib/idler.rb +38 -0
- data/lib/idler/branch.rb +37 -0
- data/lib/idler/descriptions.rb +42 -0
- data/lib/idler/dsl.rb +12 -0
- data/lib/idler/errors.rb +7 -0
- data/lib/idler/git_branch.rb +11 -0
- data/lib/idler/install.rb +11 -0
- data/lib/idler/version.rb +3 -0
- data/lib/idler/workers.rb +26 -0
- data/lib/templates/idler.rb +7 -0
- data/spec/idler/branch_spec.rb +120 -0
- data/spec/idler/descriptions_spec.rb +133 -0
- data/spec/idler/dsl_spec.rb +32 -0
- data/spec/idler/git_branch_spec.rb +25 -0
- data/spec/idler/install_spec.rb +21 -0
- data/spec/idler/workers_spec.rb +105 -0
- data/spec/idler_spec.rb +90 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/supports/.idler.rb +17 -0
- data/spec/supports/development +1 -0
- data/spec/supports/git/COMMIT_EDITMSG +1 -0
- data/spec/supports/git/HEAD +1 -0
- data/spec/supports/git/config +7 -0
- data/spec/supports/git/description +1 -0
- data/spec/supports/git/hooks/applypatch-msg.sample +15 -0
- data/spec/supports/git/hooks/commit-msg.sample +24 -0
- data/spec/supports/git/hooks/post-update.sample +8 -0
- data/spec/supports/git/hooks/pre-applypatch.sample +14 -0
- data/spec/supports/git/hooks/pre-commit.sample +49 -0
- data/spec/supports/git/hooks/pre-push.sample +53 -0
- data/spec/supports/git/hooks/pre-rebase.sample +169 -0
- data/spec/supports/git/hooks/prepare-commit-msg.sample +36 -0
- data/spec/supports/git/hooks/update.sample +128 -0
- data/spec/supports/git/index +0 -0
- data/spec/supports/git/info/exclude +6 -0
- data/spec/supports/git/logs/HEAD +3 -0
- data/spec/supports/git/logs/refs/heads/development +2 -0
- data/spec/supports/git/logs/refs/heads/master +1 -0
- data/spec/supports/git/objects/26/7415b535950497a6fe509c590aae53b8aa8371 +0 -0
- data/spec/supports/git/objects/3e/6bfeeb8e007bfdaea40081872e8d6148e571ea +2 -0
- data/spec/supports/git/objects/4b/825dc642cb6eb9a060e54bf8d69288fbee4904 +0 -0
- data/spec/supports/git/objects/97/ead751ee1b140cf8f560247f934987dcb88ee1 +0 -0
- data/spec/supports/git/objects/b2/ced74c2ca4e1f4bb69a2a937b71f411606cade +0 -0
- data/spec/supports/git/objects/ba/1959001cdfe38905402ad8dbfdd43e8da6d7ea +0 -0
- data/spec/supports/git/objects/ce/37909c3bed60d7e414d5904e54af0ae3b774f7 +0 -0
- data/spec/supports/git/objects/e7/4160f0955857b33155e6366b08abb2e17938dc +2 -0
- data/spec/supports/git/refs/heads/development +1 -0
- data/spec/supports/git/refs/heads/master +1 -0
- data/spec/supports/master +1 -0
- metadata +229 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bf5485974905d8648da83f3158aaf7887e4c1716
|
4
|
+
data.tar.gz: a191fb836bd89e3176e4e237f569ad3efc7907a3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a2ccd4caf7a9e487d5c5743a3b020f7275713566c5d43f5c031fc31d8c9b65e2d823ab47bc125123bdd81a98d6ef61433e736da138e6b5b75af8b8c1f05aa987
|
7
|
+
data.tar.gz: c6f92977c1185bd0a6c2bf9f8fa2e5fd9bfe2e96ff41179cb69100b6d89edba4ac5bce5c172a3288ccf47b40b40acaf931a7e8e993b9154b92a3c82efb8b3c22
|
data/.drone.yml
ADDED
data/.gitignore
ADDED
data/.idler.rb
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 toihrk
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
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
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Idler
|
2
|
+
|
3
|
+
[](https://circleci.com/gh/toihrk/idler)
|
4
|
+
|
5
|
+
ブランチ毎に異なるスクリプトを実行するコマンド`idler`を提供します。
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'idler'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install idler
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
### Initialize
|
26
|
+
|
27
|
+
$ bundle exec idler init
|
28
|
+
|
29
|
+
カレントディレクトリに`.idler.rb`を配置します。
|
30
|
+
|
31
|
+
### Edit `.idler.rb`
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
branch 'master' do
|
35
|
+
desc 'master branch description here'
|
36
|
+
detail 'master branch detail here'
|
37
|
+
worker do
|
38
|
+
# Something script here
|
39
|
+
end
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
**`branch(branch_name, &block)`**
|
44
|
+
|
45
|
+
`branch_name` ブランチ名の文字列を与える
|
46
|
+
|
47
|
+
ブロック内では以下のメソッドでブランチ毎の動作を定義する
|
48
|
+
|
49
|
+
- **`desc(description)`** ブランチの説明を`description`で与える
|
50
|
+
- **`detail(note)`** ブランチの詳細を`note`で与える
|
51
|
+
- **`worker(&block)`** ブランチでの動作を定義
|
52
|
+
|
53
|
+
### Commands
|
54
|
+
|
55
|
+
|
56
|
+
$ idler
|
57
|
+
|
58
|
+
現在のブランチで定義済みの動作を行う
|
59
|
+
|
60
|
+
$ idler develop
|
61
|
+
|
62
|
+
`develop`ブランチで定義済みの動作を行う
|
63
|
+
|
64
|
+
|
65
|
+
$ idler info
|
66
|
+
|
67
|
+
定義済みのブランチの情報を表示
|
68
|
+
|
69
|
+
## Contributing
|
70
|
+
|
71
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/toihrk/idler. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
72
|
+
|
73
|
+
|
74
|
+
## License
|
75
|
+
|
76
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
77
|
+
|
78
|
+
|
79
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/idler
ADDED
data/circle.yml
ADDED
data/idler.gemspec
ADDED
@@ -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 'idler/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "idler"
|
8
|
+
spec.version = Idler::VERSION
|
9
|
+
spec.authors = ["toihrk"]
|
10
|
+
spec.email = ["toihrk@me.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Idler - Let's lazy the deploy!!}
|
13
|
+
spec.description = %q{Idler is a utility for automatically the deploy or other.}
|
14
|
+
spec.homepage = "https://github.com/toihrk/idler"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = ['idler']
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "git"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "pry"
|
27
|
+
spec.add_development_dependency "pry-doc"
|
28
|
+
end
|
data/lib/idler.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'idler/version'
|
2
|
+
require 'idler/errors'
|
3
|
+
require 'idler/install'
|
4
|
+
require 'idler/git_branch'
|
5
|
+
require 'idler/branch'
|
6
|
+
require 'idler/descriptions'
|
7
|
+
require 'idler/workers'
|
8
|
+
|
9
|
+
module Idler
|
10
|
+
class << self
|
11
|
+
|
12
|
+
include GitBranch
|
13
|
+
|
14
|
+
def descriptions
|
15
|
+
@descriptions ||= Descriptions.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def workers
|
19
|
+
@workers ||= Workers.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def run(argv = [])
|
23
|
+
argvs = []
|
24
|
+
argvs.push *ARGV.dup
|
25
|
+
argvs.push *argv
|
26
|
+
|
27
|
+
Install.copy if argvs.include?('init')
|
28
|
+
descriptions.info if argvs.include?('info')
|
29
|
+
|
30
|
+
if argvs.empty?
|
31
|
+
workers.run(current_branch)
|
32
|
+
else
|
33
|
+
workers.run(argvs.first) unless ['init', 'info'].include? argvs.first
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
data/lib/idler/branch.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
module Idler
|
2
|
+
class Branch
|
3
|
+
|
4
|
+
def initialize(branch_name = nil, block = nil)
|
5
|
+
raise Idler::NotDetectBranchError if branch_name.nil?
|
6
|
+
@branch = branch_name
|
7
|
+
|
8
|
+
descriptions.add_branch branch_name
|
9
|
+
workers.add_branch branch_name
|
10
|
+
|
11
|
+
self.instance_eval &block unless block.nil?
|
12
|
+
end
|
13
|
+
|
14
|
+
def desc(description)
|
15
|
+
descriptions.add_desc @branch, description
|
16
|
+
end
|
17
|
+
|
18
|
+
def detail(note)
|
19
|
+
descriptions.add_detail @branch, note
|
20
|
+
end
|
21
|
+
|
22
|
+
def worker(&block)
|
23
|
+
workers.add_worker @branch, block
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def descriptions
|
29
|
+
Idler.descriptions
|
30
|
+
end
|
31
|
+
|
32
|
+
def workers
|
33
|
+
Idler.workers
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Idler
|
2
|
+
class Descriptions
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@descriptions = {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def add_branch(branch_name = nil)
|
9
|
+
raise NothingBranchNameError if branch_name.nil?
|
10
|
+
@descriptions[branch_name] = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_desc(branch_name = nil, desc = "")
|
14
|
+
raise NothingBranchNameError if branch_name.nil?
|
15
|
+
raise NotYetAddBranchError unless @descriptions.key?(branch_name)
|
16
|
+
@descriptions[branch_name][:description] = desc
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_detail(branch_name = nil, detail = "")
|
20
|
+
raise NothingBranchNameError if branch_name.nil?
|
21
|
+
raise NotYetAddBranchError unless @descriptions.key?(branch_name)
|
22
|
+
@descriptions[branch_name][:detail] = detail
|
23
|
+
end
|
24
|
+
|
25
|
+
def info
|
26
|
+
puts "--- Branches Info ---"
|
27
|
+
|
28
|
+
@descriptions.each do |branch, info|
|
29
|
+
print "* \e[1m#{branch}\e[0m"
|
30
|
+
|
31
|
+
if info[:description]
|
32
|
+
puts " - #{info[:description]}"
|
33
|
+
else
|
34
|
+
print "\n"
|
35
|
+
end
|
36
|
+
|
37
|
+
puts "#{info[:detail]}\n" if info[:detail]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
data/lib/idler/dsl.rb
ADDED
data/lib/idler/errors.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Idler
|
2
|
+
class Workers
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@workers = {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def add_branch(branch_name = nil)
|
9
|
+
raise NothingBranchNameError if branch_name.nil?
|
10
|
+
@workers[branch_name] = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_worker(branch_name = nil, block = nil)
|
14
|
+
raise NothingBranchNameError if branch_name.nil?
|
15
|
+
raise NotYetAddBranchError unless @workers.key?(branch_name)
|
16
|
+
raise NotProcError unless block.class == Proc
|
17
|
+
@workers[branch_name] = block
|
18
|
+
end
|
19
|
+
|
20
|
+
def run(branch_name = nil)
|
21
|
+
raise NothingBranchNameError if branch_name.nil?
|
22
|
+
@workers[branch_name].call if @workers.key?(branch_name)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Idler::Branch do
|
4
|
+
|
5
|
+
describe '.new' do
|
6
|
+
let(:branch) { nil }
|
7
|
+
let(:block) { Proc.new { nil } }
|
8
|
+
subject { described_class.new(branch, block) }
|
9
|
+
|
10
|
+
context 'with nil block' do
|
11
|
+
let(:branch) { 'test' }
|
12
|
+
let(:block) { Proc.new { nil } }
|
13
|
+
|
14
|
+
it { expect { subject }.to_not raise_error }
|
15
|
+
it { is_expected.to be_a Idler::Branch }
|
16
|
+
|
17
|
+
it 'instance variable @branch should be set "test"' do
|
18
|
+
expect(subject.instance_variable_get(:@branch)).to eq('test')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'Descriptions should be set branches' do
|
22
|
+
expect(Idler.descriptions.instance_variable_get(:@descriptions)).to eq({ "test" => {}})
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'Workers should be set branches' do
|
26
|
+
expect(Idler.workers.instance_variable_get(:@workers)).to eq({ "test" => nil })
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'with block' do
|
31
|
+
let(:branch) { 'test' }
|
32
|
+
|
33
|
+
let(:block) do
|
34
|
+
Proc.new do
|
35
|
+
desc "test description"
|
36
|
+
detail "test detail"
|
37
|
+
worker do
|
38
|
+
nil
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it { expect { subject }.to_not raise_error }
|
44
|
+
it { is_expected.to be_a Idler::Branch }
|
45
|
+
|
46
|
+
it 'instance variable @branch should be set "test"' do
|
47
|
+
expect(subject.instance_variable_get(:@branch)).to eq('test')
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'Descriptions should be set branches' do
|
51
|
+
expected_hash = {
|
52
|
+
"test" => {
|
53
|
+
description: 'test description',
|
54
|
+
detail: 'test detail'
|
55
|
+
}
|
56
|
+
}
|
57
|
+
expect(Idler.descriptions.instance_variable_get(:@descriptions)).to match(expected_hash)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'Workers should be set branches' do
|
61
|
+
expect(Idler.workers.instance_variable_get(:@workers)).to_not be_nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'without block' do
|
66
|
+
let(:branch) { 'test' }
|
67
|
+
let(:block) { nil }
|
68
|
+
|
69
|
+
it { expect { subject }.to_not raise_error }
|
70
|
+
it { is_expected.to be_a Idler::Branch }
|
71
|
+
|
72
|
+
it 'instance variable @branch should be set "test"' do
|
73
|
+
expect(subject.instance_variable_get(:@branch)).to eq('test')
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'Descriptions should be set branches' do
|
77
|
+
expect(Idler.descriptions.instance_variable_get(:@descriptions)).to eq({ "test" => {}})
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'Workers should be set branches' do
|
81
|
+
expect(Idler.workers.instance_variable_get(:@workers)).to eq({ "test" => nil })
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'without branch' do
|
86
|
+
let(:branch) { nil }
|
87
|
+
let(:block) { nil }
|
88
|
+
|
89
|
+
it { expect { subject }.to raise_error(Idler::NotDetectBranchError) }
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#desc' do
|
95
|
+
let(:instance) { described_class.new('test') }
|
96
|
+
let(:desc) { 'test description' }
|
97
|
+
subject { instance.desc(desc) }
|
98
|
+
|
99
|
+
it { is_expected.to eq(desc) }
|
100
|
+
end
|
101
|
+
|
102
|
+
describe '#detail' do
|
103
|
+
let(:instance) { described_class.new('test') }
|
104
|
+
let(:detail) { 'test detail' }
|
105
|
+
subject { instance.detail(detail) }
|
106
|
+
|
107
|
+
it { is_expected.to eq(detail) }
|
108
|
+
end
|
109
|
+
|
110
|
+
describe '#worker' do
|
111
|
+
let(:instance) { described_class.new('test') }
|
112
|
+
let(:worker) { Proc.new { nil } }
|
113
|
+
subject { instance.worker(&worker) }
|
114
|
+
|
115
|
+
it 'should eq given block' do
|
116
|
+
is_expected.to eq(worker)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|