rigit 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +49 -0
- data/bin/rig +6 -3
- data/lib/rigit/command_line.rb +2 -1
- data/lib/rigit/commands/build.rb +58 -62
- data/lib/rigit/commands/install.rb +58 -0
- data/lib/rigit/config.rb +1 -1
- data/lib/rigit/docopt.txt +19 -1
- data/lib/rigit/extensions/file_extension.rb +3 -0
- data/lib/rigit/git.rb +19 -0
- data/lib/rigit/rig.rb +56 -0
- data/lib/rigit/version.rb +1 -1
- data/lib/rigit.rb +10 -5
- metadata +19 -2
- data/lib/rigit/rigger.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55f146cc6a111bbb185a681203d87a7cf5092ce5f461e3e1aac4aec11bd121aa
|
4
|
+
data.tar.gz: 46990712e2b86bd1b1c8785084d6e1b02e18f05de2248030a41e21ec8b7049b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f33dbd202c77428e16e05bf42441b6359b49132ef78a977608d13029414327441c163e44e390957fb5182fc7554948e86ef359b4598daa4d794d8726280c5e2
|
7
|
+
data.tar.gz: 84f92225b7b0edeba9a5a4583a097ccac9047dc5e2b1fe837bd19be45ecf4f08c5be5d96e93530d3bf21be282613eb97d8117e49d01ba7552eed537a1ab670db
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
Rigit
|
2
|
+
==================================================
|
3
|
+
|
4
|
+
[](https://rubygems.org/gems/rigit)
|
5
|
+
[](https://travis-ci.org/DannyBen/rigit)
|
6
|
+
[](https://codeclimate.com/github/DannyBen/rigit)
|
7
|
+
[](https://codeclimate.com/github/DannyBen/rigit)
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+

|
12
|
+
|
13
|
+
---
|
14
|
+
|
15
|
+
Table of Contents
|
16
|
+
--------------------------------------------------
|
17
|
+
|
18
|
+
* [Installation](#installation)
|
19
|
+
* [Quick Start](#quick-start)
|
20
|
+
* [Installing Rigs](#installing-rigs)
|
21
|
+
* [Using Rigs (Scaffolding)](#using-rigs-scaffolding)
|
22
|
+
* [Creating Rigs](#creating-rigs)
|
23
|
+
* [Directory Structure](#directory-structure)
|
24
|
+
* [Config File](#config-file)
|
25
|
+
|
26
|
+
|
27
|
+
Installation
|
28
|
+
--------------------------------------------------
|
29
|
+
|
30
|
+
|
31
|
+
Quick Start
|
32
|
+
--------------------------------------------------
|
33
|
+
|
34
|
+
|
35
|
+
Installing Rigs
|
36
|
+
--------------------------------------------------
|
37
|
+
|
38
|
+
|
39
|
+
Using Rigs (Scaffolding)
|
40
|
+
--------------------------------------------------
|
41
|
+
|
42
|
+
|
43
|
+
Creating Rigs
|
44
|
+
--------------------------------------------------
|
45
|
+
|
46
|
+
### Directory Structure
|
47
|
+
|
48
|
+
### Config File
|
49
|
+
|
data/bin/rig
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'rigit'
|
3
|
+
require 'colsole'
|
4
|
+
include Colsole
|
3
5
|
|
4
6
|
begin
|
5
7
|
Rigit::CommandLine.execute ARGV
|
6
8
|
rescue Rigit::Exit => e
|
7
|
-
|
9
|
+
message = e.message
|
10
|
+
say message unless message == 'Rigit::Exit'
|
8
11
|
exit 1
|
9
12
|
rescue Rigit::ConfigError => e
|
10
|
-
|
13
|
+
say "#{e.class} - #{e.message}"
|
11
14
|
exit 1
|
12
15
|
rescue TTY::Reader::InputInterrupt
|
13
|
-
|
16
|
+
say "\nGoodbye"
|
14
17
|
exit 1
|
15
18
|
end
|
data/lib/rigit/command_line.rb
CHANGED
data/lib/rigit/commands/build.rb
CHANGED
@@ -1,81 +1,77 @@
|
|
1
|
-
require '
|
1
|
+
require 'colsole'
|
2
2
|
|
3
|
-
module Rigit
|
4
|
-
module
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
class Builder
|
11
|
-
attr_reader :args
|
3
|
+
module Rigit::Commands
|
4
|
+
module Build
|
5
|
+
def build
|
6
|
+
Builder.new(args).execute
|
7
|
+
end
|
12
8
|
|
13
|
-
|
14
|
-
|
15
|
-
end
|
9
|
+
class Builder
|
10
|
+
attr_reader :args, :rig_name, :target_dir
|
16
11
|
|
17
|
-
|
18
|
-
puts "#{config.intro}\n\n" if config.intro
|
19
|
-
verify_folders
|
20
|
-
arguments = prompt.get_input params
|
21
|
-
rigger = Rigit::Rigger.new source, arguments
|
22
|
-
rigger.scaffold
|
23
|
-
end
|
12
|
+
include Colsole
|
24
13
|
|
25
|
-
|
14
|
+
def initialize(args)
|
15
|
+
@args = args
|
16
|
+
@rig_name = args['RIG']
|
17
|
+
@target_dir = '.'
|
18
|
+
end
|
26
19
|
|
27
|
-
|
28
|
-
|
29
|
-
|
20
|
+
def execute
|
21
|
+
say "Building !txtgrn!#{rig_name}"
|
22
|
+
say "!txtblu!#{config.intro}" if config.has_key? :intro
|
23
|
+
verify_dirs
|
24
|
+
arguments = prompt.get_input params
|
25
|
+
rig.scaffold arguments:arguments, target_dir: target_dir
|
26
|
+
say "Done"
|
27
|
+
end
|
30
28
|
|
31
|
-
|
32
|
-
args['RIG']
|
33
|
-
end
|
29
|
+
private
|
34
30
|
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
def rig
|
32
|
+
@rig ||= Rigit::Rig.new rig_name
|
33
|
+
end
|
38
34
|
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
def config
|
36
|
+
@config ||= rig.config
|
37
|
+
end
|
42
38
|
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
def params
|
40
|
+
@params ||= params!
|
41
|
+
end
|
46
42
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
output
|
43
|
+
def params!
|
44
|
+
output = {}
|
45
|
+
input = args['PARAMS']
|
46
|
+
input.each do |param|
|
47
|
+
key, value = param.split '='
|
48
|
+
output[key.to_sym] = value
|
55
49
|
end
|
50
|
+
output
|
51
|
+
end
|
56
52
|
|
57
|
-
|
58
|
-
|
59
|
-
|
53
|
+
def prompt
|
54
|
+
@prompt ||= Rigit::Prompt.new config.params
|
55
|
+
end
|
60
56
|
|
61
|
-
|
62
|
-
|
63
|
-
|
57
|
+
def tty_prompt
|
58
|
+
@tty_prompt ||= TTY::Prompt.new
|
59
|
+
end
|
64
60
|
|
65
|
-
|
66
|
-
|
67
|
-
|
61
|
+
def verify_dirs
|
62
|
+
verify_source_dir
|
63
|
+
verify_target_dir
|
64
|
+
end
|
68
65
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
66
|
+
def verify_source_dir
|
67
|
+
raise Rigit::Exit, "No such rig: #{rig_name}" unless rig.exist?
|
68
|
+
end
|
73
69
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
70
|
+
def verify_target_dir
|
71
|
+
if !Dir.empty? target_dir
|
72
|
+
dirstring = target_dir == '.' ? 'Current directory' : "Directory '#{target_dir}'"
|
73
|
+
continue = tty_prompt.yes? "#{dirstring} is not empty. Continue anyway?", default: false
|
74
|
+
raise Rigit::Exit, "Goodbye" unless continue
|
79
75
|
end
|
80
76
|
end
|
81
77
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'colsole'
|
3
|
+
|
4
|
+
module Rigit::Commands
|
5
|
+
module Install
|
6
|
+
def install
|
7
|
+
Installer.new(args).execute
|
8
|
+
end
|
9
|
+
|
10
|
+
class Installer
|
11
|
+
include Colsole
|
12
|
+
|
13
|
+
attr_reader :args, :rig_name, :repo
|
14
|
+
|
15
|
+
def initialize(args)
|
16
|
+
@args = args
|
17
|
+
@rig_name = args['RIG']
|
18
|
+
@repo = args['REPO']
|
19
|
+
end
|
20
|
+
|
21
|
+
def execute
|
22
|
+
verify_dirs
|
23
|
+
install
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def install
|
29
|
+
say "Installing !txtgrn!#{repo}\n"
|
30
|
+
FileUtils.mkdir_p target_path unless Dir.exist? target_path
|
31
|
+
success = Git.clone repo, target_path
|
32
|
+
|
33
|
+
if success
|
34
|
+
say "\nRig installed !txtgrn!successfully!txtrst! in !txtgrn!#{target_path}"
|
35
|
+
say "To build a new project with this rig, run this in any empty directory:\n"
|
36
|
+
say " !txtpur!rig build #{rig_name}\n"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def rig
|
41
|
+
@rig ||= Rigit::Rig.new rig_name
|
42
|
+
end
|
43
|
+
|
44
|
+
def target_path
|
45
|
+
@target_path ||= rig.path
|
46
|
+
end
|
47
|
+
|
48
|
+
def verify_dirs
|
49
|
+
if Dir.exist? target_path
|
50
|
+
say "Rig !txtgrn!#{rig_name}!txtrst! is already installed."
|
51
|
+
say "In order to update it from the source repository, run:\n"
|
52
|
+
say " !txtpur!rig update #{rig_name}\n"
|
53
|
+
raise Rigit::Exit
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/rigit/config.rb
CHANGED
data/lib/rigit/docopt.txt
CHANGED
@@ -2,10 +2,28 @@ Rigit
|
|
2
2
|
|
3
3
|
Usage:
|
4
4
|
rig build RIG [PARAMS...]
|
5
|
+
rig install RIG REPO
|
6
|
+
|
7
|
+
Commands:
|
8
|
+
build
|
9
|
+
Create a new project based on one of the installed rig templates.
|
10
|
+
This command should be executed in an empty directory.
|
11
|
+
In case the rig has arguments, you will be prompted to input them.
|
12
|
+
If you wish to execute this command without interactivity, you may
|
13
|
+
use specify all parameters in the PARAMS parameter (see below).
|
5
14
|
|
6
15
|
Parameters:
|
7
16
|
RIG
|
8
17
|
The name of the source folder (installed rig).
|
9
18
|
|
19
|
+
REPO
|
20
|
+
A git repository containing rig configuration.
|
21
|
+
Use the 'clone URL' for the repository.
|
22
|
+
|
23
|
+
PARAMS
|
24
|
+
Specify any of the rig's parameters in the format 'param=value'.
|
25
|
+
For boolean parameters, use 'param=y' or 'param=n'.
|
26
|
+
|
10
27
|
Examples:
|
11
|
-
rig build gem name=mygem
|
28
|
+
rig build gem name=mygem spec=y
|
29
|
+
rig install example https://github.com/DannyBen/example-rig.git
|
@@ -2,9 +2,12 @@ require 'fileutils'
|
|
2
2
|
|
3
3
|
class File
|
4
4
|
def self.deep_write(filename, content)
|
5
|
+
# :nocov: only due to the fact that the rspec_fixtures gem brings
|
6
|
+
# this method as well
|
5
7
|
dirname = File.dirname filename
|
6
8
|
FileUtils.mkdir_p dirname unless File.directory? dirname
|
7
9
|
File.write filename, content
|
10
|
+
# :nocov:
|
8
11
|
end
|
9
12
|
end
|
10
13
|
|
data/lib/rigit/git.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Rigit
|
2
|
+
class Git
|
3
|
+
def self.clone(repo, target_path)
|
4
|
+
execute %Q[git clone #{repo} "#{target_path}"]
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def self.execute(command)
|
10
|
+
if ENV['SIMULATE_GIT']
|
11
|
+
puts "Simulated Execute: #{command}"
|
12
|
+
true
|
13
|
+
else
|
14
|
+
system command
|
15
|
+
$?&.exitstatus == 0
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/rigit/rig.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
module Rigit
|
2
|
+
class Rig
|
3
|
+
attr_reader :name
|
4
|
+
|
5
|
+
def self.home
|
6
|
+
ENV['RIG_HOME'] ||= File.expand_path('.rigs', Dir.home)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.home=(path)
|
10
|
+
ENV['RIG_HOME'] = path
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(name)
|
14
|
+
@name = name
|
15
|
+
end
|
16
|
+
|
17
|
+
def scaffold(arguments: {}, target_dir:'.')
|
18
|
+
scaffold_dir "#{path}/base", arguments, target_dir
|
19
|
+
|
20
|
+
arguments.each do |key, value|
|
21
|
+
additive_dir = "#{path}/#{key}=#{value}"
|
22
|
+
if Dir.exist? additive_dir
|
23
|
+
scaffold_dir additive_dir, arguments, target_dir
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def path
|
29
|
+
"#{Rig.home}/#{name}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def exist?
|
33
|
+
Dir.exist? path
|
34
|
+
end
|
35
|
+
|
36
|
+
def config_file
|
37
|
+
"#{path}/config.yml"
|
38
|
+
end
|
39
|
+
|
40
|
+
def config
|
41
|
+
@config ||= Config.load(config_file)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def scaffold_dir(dir, arguments, target_dir)
|
47
|
+
files = Dir["#{dir}/**/*"].reject { |file| File.directory? file }
|
48
|
+
|
49
|
+
files.each do |file|
|
50
|
+
target_file = (file % arguments).sub dir, target_dir
|
51
|
+
content = File.read(file) % arguments
|
52
|
+
File.deep_write target_file, content
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/rigit/version.rb
CHANGED
data/lib/rigit.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
require 'rigit/extensions/file_extension.rb'
|
2
2
|
|
3
|
-
require 'rigit/commands/build'
|
4
|
-
|
5
|
-
require 'rigit/command_line'
|
6
3
|
require 'rigit/config'
|
7
4
|
require 'rigit/errors'
|
8
5
|
require 'rigit/prompt'
|
9
|
-
require 'rigit/
|
6
|
+
require 'rigit/rig'
|
7
|
+
require 'rigit/git'
|
8
|
+
|
9
|
+
require 'rigit/commands/build'
|
10
|
+
require 'rigit/commands/install'
|
11
|
+
require 'rigit/command_line'
|
10
12
|
|
11
|
-
|
13
|
+
module Rigit
|
14
|
+
module Commands
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rigit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.15'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: colsole
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.5'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.5'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: byebug
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,16 +185,19 @@ executables:
|
|
171
185
|
extensions: []
|
172
186
|
extra_rdoc_files: []
|
173
187
|
files:
|
188
|
+
- README.md
|
174
189
|
- bin/rig
|
175
190
|
- lib/rigit.rb
|
176
191
|
- lib/rigit/command_line.rb
|
177
192
|
- lib/rigit/commands/build.rb
|
193
|
+
- lib/rigit/commands/install.rb
|
178
194
|
- lib/rigit/config.rb
|
179
195
|
- lib/rigit/docopt.txt
|
180
196
|
- lib/rigit/errors.rb
|
181
197
|
- lib/rigit/extensions/file_extension.rb
|
198
|
+
- lib/rigit/git.rb
|
182
199
|
- lib/rigit/prompt.rb
|
183
|
-
- lib/rigit/
|
200
|
+
- lib/rigit/rig.rb
|
184
201
|
- lib/rigit/version.rb
|
185
202
|
homepage: https://github.com/DannyBen/rigit
|
186
203
|
licenses:
|
data/lib/rigit/rigger.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
module Rigit
|
2
|
-
class Rigger
|
3
|
-
attr_reader :rig, :arguments, :target_dir
|
4
|
-
|
5
|
-
def initialize(rig, arguments={}, target_dir='.')
|
6
|
-
@rig = rig
|
7
|
-
@target_dir = target_dir
|
8
|
-
@arguments = arguments
|
9
|
-
end
|
10
|
-
|
11
|
-
def scaffold
|
12
|
-
scaffold_dir "#{source_dir}/base"
|
13
|
-
|
14
|
-
arguments.each do |key, value|
|
15
|
-
additive_dir = "#{source_dir}/#{key}=#{value}"
|
16
|
-
if Dir.exist? additive_dir
|
17
|
-
scaffold_dir additive_dir
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def source_dir
|
25
|
-
"#{ENV['RIG_HOME']}/#{rig}"
|
26
|
-
end
|
27
|
-
|
28
|
-
def scaffold_dir(dir)
|
29
|
-
files = Dir["#{dir}/**/*"].reject { |file| File.directory? file }
|
30
|
-
|
31
|
-
files.each do |file|
|
32
|
-
target_file = (file % arguments).sub dir, target_dir
|
33
|
-
content = File.read(file) % arguments
|
34
|
-
File.deep_write target_file, content
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|