regen 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 +7 -0
- data/bin/regen +3 -0
- data/lib/regen.rb +74 -0
- metadata +46 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 82f8de6ff1b3ce834280eedc44866e6f6da6c2b0
|
4
|
+
data.tar.gz: a4699e2ee9c45a7e0f0f77519dc02dbcda98f1cc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 74032ecc23dd62fbdcc82b12524d422a2d9c5a69408cf7ad08d43e5ae7179778cabe157bf75353757cbfdafff5b576e941f1af42a98eab8d55a1447d2a2c4bec
|
7
|
+
data.tar.gz: 7ce2e872c1112f70cdf3a6e94f00c89c71ca4b137682fba821aa84e349cd3baa6f496d7775c3d55e9c2b32a1916565a7d8849e0d7f75539d2e39a7e7006c243a
|
data/bin/regen
ADDED
data/lib/regen.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'optparse'
|
3
|
+
require 'pry-byebug'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
OptionParser.new do |opts|
|
8
|
+
opts.banner = "Usage: rgen.rb [options]"
|
9
|
+
|
10
|
+
opts.on("-c", "--config CONFIGFILE", "Specify Config file") do |c|
|
11
|
+
options[:config_file] = c
|
12
|
+
end
|
13
|
+
|
14
|
+
opts.on("-d", "--dest DESTINATIONDIR", "Specify Destination Directory") do |d|
|
15
|
+
options[:destination] = d
|
16
|
+
end
|
17
|
+
end.parse!
|
18
|
+
|
19
|
+
options[:config_file] ||= "sample.json"
|
20
|
+
|
21
|
+
# Create the destination directory if it doesn't exist
|
22
|
+
raise 'A destination directory must be specified' unless options[:destination]
|
23
|
+
Dir.mkdir options[:destination] unless File.exists? options[:destination]
|
24
|
+
|
25
|
+
file = File.read(options[:config_file])
|
26
|
+
data = JSON.parse(file)
|
27
|
+
|
28
|
+
# Run any pre-commands before copying over template files
|
29
|
+
# These are run from the destination directory
|
30
|
+
data["pre-commands"] ||= []
|
31
|
+
start_dir = Dir.pwd
|
32
|
+
Dir.chdir(options[:destination])
|
33
|
+
data["pre-commands"].each do |command|
|
34
|
+
`#{command}`
|
35
|
+
end
|
36
|
+
Dir.chdir(start_dir)
|
37
|
+
|
38
|
+
# Templates can point to a git repo
|
39
|
+
# or a local directory
|
40
|
+
#
|
41
|
+
# They will be applied in the order specified
|
42
|
+
# in the config files; if there is a file conflict
|
43
|
+
# the last one in wins.
|
44
|
+
Dir.mkdir "./rgen_tmp"
|
45
|
+
data["ignore"] ||= []
|
46
|
+
data["templates"] ||= []
|
47
|
+
data["templates"].each do |command|
|
48
|
+
if command.match(/http|https/)
|
49
|
+
`git clone #{command} rgen_clone_tmp`
|
50
|
+
Dir.foreach("rgen_clone_tmp") do |x|
|
51
|
+
unless [".", ".."].include?(x)
|
52
|
+
FileUtils.mv("rgen_clone_tmp/#{x}", "rgen_tmp/") unless data["ignore"].include?(x)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
FileUtils.remove_dir "rgen_clone_tmp"
|
56
|
+
else
|
57
|
+
`cp -R #{command} ./rgen_tmp/`
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
#binding.pry
|
62
|
+
`cp -R ./rgen_tmp/ #{options[:destination]}`
|
63
|
+
|
64
|
+
# Running any post commands that should come after the
|
65
|
+
# templates are copied
|
66
|
+
data["post-commands"] ||= []
|
67
|
+
start_dir = Dir.pwd
|
68
|
+
Dir.chdir(options[:destination])
|
69
|
+
data["post-commands"].each do |command|
|
70
|
+
`#{command}`
|
71
|
+
end
|
72
|
+
Dir.chdir(start_dir)
|
73
|
+
|
74
|
+
`rm -rdf ./rgen_tmp`
|
metadata
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: regen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joiey Seeley
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-30 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Quickly generate project boilerplate so you can get to work.
|
14
|
+
email: joiey.seeley@gmail.com
|
15
|
+
executables:
|
16
|
+
- regen
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/regen
|
21
|
+
- lib/regen.rb
|
22
|
+
homepage: https://github.com/bigtunacan/regen.git
|
23
|
+
licenses:
|
24
|
+
- MIT
|
25
|
+
metadata: {}
|
26
|
+
post_install_message:
|
27
|
+
rdoc_options: []
|
28
|
+
require_paths:
|
29
|
+
- lib
|
30
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirements: []
|
41
|
+
rubyforge_project:
|
42
|
+
rubygems_version: 2.4.8
|
43
|
+
signing_key:
|
44
|
+
specification_version: 4
|
45
|
+
summary: Regen
|
46
|
+
test_files: []
|