rebuild 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +22 -0
- data/Rakefile +2 -0
- data/bin/rebuild +4 -0
- data/lib/rebuild.rb +8 -0
- data/lib/rebuild/bootstrap.rb +7 -0
- data/lib/rebuild/cli.rb +32 -0
- data/lib/rebuild/repository.rb +60 -0
- data/lib/rebuild/runner.rb +23 -0
- data/lib/rebuild/version.rb +3 -0
- data/rebuild.gemspec +24 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5f89e6be9de86f94defed1227960a60cdfe90d48
|
4
|
+
data.tar.gz: e3f14946f04bd8799250e2dec0c0d7d66518e35c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 680b6f34e6306966fa1c79d2a13f03b29833e3dc6c01b11e0f80cbb2e8e1d3e40d98211b0ffb4e884beda3dc35c565395e575d225b4d93e7b9a2a75324a8abb3
|
7
|
+
data.tar.gz: eb4793b14ee0f3fbb742374fbebe3b1cb45be092e254175cc9b58cfc9d499a748d13564088370ca74f429c6cd3c000c36c1f091308a19e115649eadb7719b0e9
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Takashi Kokubun
|
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,22 @@
|
|
1
|
+
# Rebuild
|
2
|
+
|
3
|
+
Development environment bootstrap automator
|
4
|
+
|
5
|
+
## What's this?
|
6
|
+
|
7
|
+
In clean-installed OSX, git is unavailable but gem is available.
|
8
|
+
Thus this gem provides a way to fetch GitHub repository archive and execute scripts in it.
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
```bash
|
13
|
+
$ sudo gem install rebuild
|
14
|
+
$ rebuild k0kubun/dotfiles
|
15
|
+
```
|
16
|
+
|
17
|
+
The archive of [repository](https://github.com/k0kubun/dotfiles) is unzipped to `/tmp/dotfiles-master`.
|
18
|
+
Then executes all of `/tmp/dotfiles-master/rebuild/*.sh`.
|
19
|
+
|
20
|
+
## License
|
21
|
+
|
22
|
+
MIT License
|
data/Rakefile
ADDED
data/bin/rebuild
ADDED
data/lib/rebuild.rb
ADDED
data/lib/rebuild/cli.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rebuild'
|
2
|
+
require 'unindent'
|
3
|
+
|
4
|
+
module Rebuild
|
5
|
+
class CLI
|
6
|
+
class << self
|
7
|
+
def start
|
8
|
+
return show_usage if ARGV.length != 1
|
9
|
+
|
10
|
+
repo_path = Repository.new(ARGV.first).fetch
|
11
|
+
primary_scripts = STDIN.gets unless STDIN.isatty
|
12
|
+
|
13
|
+
runner = Runner.new(repo_path, primary_scripts)
|
14
|
+
runner.run
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def show_usage
|
20
|
+
puts <<-EOS.unindent
|
21
|
+
Commands:
|
22
|
+
rebuild # install command line tools
|
23
|
+
rebuild USER/PROJECT # execute all scripts in GitHub repo's rebuild directory
|
24
|
+
|
25
|
+
Options:
|
26
|
+
-r, [--ref=GIT_REF] # Default: master
|
27
|
+
|
28
|
+
EOS
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'rebuild'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Rebuild
|
5
|
+
class Repository
|
6
|
+
FETCH_REFERENCE = 'master'
|
7
|
+
FETCH_DIRECTORY = '/tmp'
|
8
|
+
|
9
|
+
def initialize(path)
|
10
|
+
@user, @repo = path.split('/')
|
11
|
+
@reference = FETCH_REFERENCE
|
12
|
+
|
13
|
+
abort "Invalid repository `#{path}`" if @repo.nil?
|
14
|
+
end
|
15
|
+
|
16
|
+
def fetch
|
17
|
+
FileUtils.mkdir_p(user_path)
|
18
|
+
clone_archive
|
19
|
+
|
20
|
+
repo_path
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def clone_archive
|
26
|
+
print "Cloning into #{repo_path}..."
|
27
|
+
download_archive
|
28
|
+
unzip_archive
|
29
|
+
FileUtils.rm(archive_path)
|
30
|
+
puts " done."
|
31
|
+
end
|
32
|
+
|
33
|
+
def download_archive
|
34
|
+
`curl -Ls -o #{archive_path} #{archive_url}`
|
35
|
+
end
|
36
|
+
|
37
|
+
def unzip_archive
|
38
|
+
`unzip -o #{archive_path} -d #{user_path} > /dev/null`
|
39
|
+
unzipped_path = File.join(user_path, "#{@repo}-#{@reference}")
|
40
|
+
FileUtils.rm_rf(repo_path)
|
41
|
+
FileUtils.mv(unzipped_path, repo_path)
|
42
|
+
end
|
43
|
+
|
44
|
+
def repo_path
|
45
|
+
File.join(user_path, @repo)
|
46
|
+
end
|
47
|
+
|
48
|
+
def user_path
|
49
|
+
File.join(FETCH_DIRECTORY, @user)
|
50
|
+
end
|
51
|
+
|
52
|
+
def archive_path
|
53
|
+
File.join(user_path, "#{@repo}.zip")
|
54
|
+
end
|
55
|
+
|
56
|
+
def archive_url
|
57
|
+
"https://github.com/#{@user}/#{@repo}/archive/#{@reference}.zip"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rebuild'
|
2
|
+
|
3
|
+
module Rebuild
|
4
|
+
class Runner
|
5
|
+
def initialize(repo_path, primary_scripts)
|
6
|
+
@repo_path = repo_path
|
7
|
+
@primary_scripts = primary_scripts
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
script_paths.each do |path|
|
12
|
+
puts "Running #{path}..."
|
13
|
+
`cat #{path} | bash`
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def script_paths
|
20
|
+
Dir.glob(File.join(@repo_path, '*.sh'))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/rebuild.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rebuild/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rebuild"
|
8
|
+
spec.version = Rebuild::VERSION
|
9
|
+
spec.authors = ["Takashi Kokubun"]
|
10
|
+
spec.email = ["takashikkbn@gmail.com"]
|
11
|
+
spec.summary = %q{Development environment rebuild toolkit}
|
12
|
+
spec.description = %q{Development environment rebuild toolkit}
|
13
|
+
spec.homepage = "https://github.com/k0kubun/rebuild"
|
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_runtime_dependency "unindent", "~> 1.0"
|
22
|
+
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rebuild
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Takashi Kokubun
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: unindent
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.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: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Development environment rebuild toolkit
|
56
|
+
email:
|
57
|
+
- takashikkbn@gmail.com
|
58
|
+
executables:
|
59
|
+
- rebuild
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/rebuild
|
69
|
+
- lib/rebuild.rb
|
70
|
+
- lib/rebuild/bootstrap.rb
|
71
|
+
- lib/rebuild/cli.rb
|
72
|
+
- lib/rebuild/repository.rb
|
73
|
+
- lib/rebuild/runner.rb
|
74
|
+
- lib/rebuild/version.rb
|
75
|
+
- rebuild.gemspec
|
76
|
+
homepage: https://github.com/k0kubun/rebuild
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.2.2
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Development environment rebuild toolkit
|
100
|
+
test_files: []
|