hoodoo 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/hoodoo +1 -1
- data/lib/hoodoo/generator.rb +69 -17
- data/lib/hoodoo/version.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27c91b7d6239a85430ddf6e2cb47e0461775375e6f4b1969c6bbbf9017a41243
|
4
|
+
data.tar.gz: 3808aceb6a8474d1c456d25b38aa5a280df7c6da547747f1a54cce3b57bbe1ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35bea308563fef3c91d9f5f015942b3a03a198a299a18f754079d8ed1319cfc7da10165deee81d356064bcf1f479e5d20958807b9a7f90a998a3d288291d25b0
|
7
|
+
data.tar.gz: 072047f7dc3c8deccb4a034de3bd793149909e99107455125313ae92f4ce85b059cf90b11ad3587af4b85a86c2199f235180f592b54bded4891ebc97a0802f4e
|
data/bin/hoodoo
CHANGED
data/lib/hoodoo/generator.rb
CHANGED
@@ -11,6 +11,7 @@
|
|
11
11
|
require 'singleton'
|
12
12
|
require 'fileutils'
|
13
13
|
require 'pathname'
|
14
|
+
require 'getoptlong'
|
14
15
|
|
15
16
|
module Hoodoo
|
16
17
|
|
@@ -36,26 +37,58 @@ module Hoodoo
|
|
36
37
|
#
|
37
38
|
NAME_REGEX = /^[a-zA-Z01-9_-]{2,30}$/
|
38
39
|
|
39
|
-
# Run the +hoodoo+ command implementation.
|
40
|
+
# Run the +hoodoo+ command implementation. Command line options are
|
41
|
+
# taken from the Ruby ARGV constant.
|
40
42
|
#
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
return show_usage if
|
43
|
+
def run!
|
44
|
+
git = nil
|
45
|
+
path = nil
|
46
|
+
|
47
|
+
return show_usage() if ARGV.length < 1
|
48
|
+
name = ARGV.shift() if ARGV.first[ 0 ] != '-'
|
49
|
+
|
50
|
+
opts = GetoptLong.new(
|
51
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
52
|
+
[ '--version', '-v', '-V', GetoptLong::NO_ARGUMENT ],
|
53
|
+
[ '--path', '-p', GetoptLong::REQUIRED_ARGUMENT ],
|
54
|
+
[ '--from', '-f', GetoptLong::REQUIRED_ARGUMENT ],
|
55
|
+
[ '--git', '-g', GetoptLong::REQUIRED_ARGUMENT ],
|
56
|
+
)
|
57
|
+
|
58
|
+
silence_stream( $stderr ) do
|
59
|
+
begin
|
60
|
+
opts.each do | opt, arg |
|
61
|
+
case opt
|
62
|
+
when '--help'
|
63
|
+
return show_usage()
|
64
|
+
when '--version'
|
65
|
+
return show_version()
|
66
|
+
when '--path'
|
67
|
+
path = arg
|
68
|
+
when '--from', '--git'
|
69
|
+
git = arg
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument => e
|
74
|
+
return usage_and_warning( e.message )
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
unless path.nil? || git.nil?
|
80
|
+
return usage_and_warning( 'Use the --path OR --from arguments, but not both' )
|
81
|
+
end
|
46
82
|
|
47
|
-
|
83
|
+
git ||= 'git@github.com:LoyaltyNZ/service_shell.git'
|
48
84
|
|
49
|
-
|
50
|
-
return
|
85
|
+
name = ARGV.shift() if name.nil?
|
86
|
+
return show_usage() if name.nil?
|
51
87
|
|
88
|
+
return usage_and_warning( "Unexpected extra arguments were given" ) if ARGV.count > 0
|
52
89
|
return usage_and_warning( "SERVICE_NAME must match #{ NAME_REGEX.inspect }" ) if naughty_name?( name )
|
53
90
|
return usage_and_warning( "'#{ name }' already exists" ) if File.exist?( "./#{ name }" )
|
54
91
|
|
55
|
-
path = args[ 2 ] if args[ 1 ] == '--path'
|
56
|
-
git = args[ 2 ] if args[ 1 ] == '--from'
|
57
|
-
git ||= 'git@github.com:LoyaltyNZ/service_shell.git'
|
58
|
-
|
59
92
|
return create_service( name, git, path )
|
60
93
|
end
|
61
94
|
|
@@ -143,7 +176,7 @@ module Hoodoo
|
|
143
176
|
puts
|
144
177
|
puts "Creates a service shell at the PWD, customised with the given service name."
|
145
178
|
puts
|
146
|
-
puts " hoodoo <service-name> [--from <git-repository>
|
179
|
+
puts " hoodoo <service-name> [--from <git-repository> OR --path <full-pathname>]"
|
147
180
|
puts
|
148
181
|
puts "For example:"
|
149
182
|
puts
|
@@ -151,7 +184,8 @@ module Hoodoo
|
|
151
184
|
puts " hoodoo service_person --from git@github.com:YOURNAME/service_shell_fork.git"
|
152
185
|
puts " hoodoo service_product --path /path/to/local/service/shell/container"
|
153
186
|
puts
|
154
|
-
puts "
|
187
|
+
puts "The '--from' option is aliased as '--git'. All options have single letter"
|
188
|
+
puts "equivalents. See also:"
|
155
189
|
puts
|
156
190
|
puts " hoodoo --help shows this help"
|
157
191
|
puts " hoodoo --version shows the require-able gem version"
|
@@ -171,9 +205,27 @@ module Hoodoo
|
|
171
205
|
end
|
172
206
|
|
173
207
|
def usage_and_warning( warning )
|
174
|
-
puts "WARNING: #{warning}"
|
175
208
|
puts
|
176
|
-
|
209
|
+
puts "-" * 80
|
210
|
+
puts "WARNING: #{warning}"
|
211
|
+
puts "-" * 80
|
212
|
+
|
213
|
+
return show_usage()
|
214
|
+
end
|
215
|
+
|
216
|
+
def silence_stream( stream, &block )
|
217
|
+
begin
|
218
|
+
old_stream = stream.dup
|
219
|
+
stream.reopen( File::NULL )
|
220
|
+
stream.sync = true
|
221
|
+
|
222
|
+
yield
|
223
|
+
|
224
|
+
ensure
|
225
|
+
stream.reopen( old_stream )
|
226
|
+
old_stream.close
|
227
|
+
|
228
|
+
end
|
177
229
|
end
|
178
230
|
end
|
179
231
|
end
|
data/lib/hoodoo/version.rb
CHANGED
@@ -12,11 +12,11 @@ module Hoodoo
|
|
12
12
|
# The Hoodoo gem version. If this changes, be sure to re-run
|
13
13
|
# <tt>bundle install</tt> or <tt>bundle update</tt>.
|
14
14
|
#
|
15
|
-
VERSION = '2.1.
|
15
|
+
VERSION = '2.1.2'
|
16
16
|
|
17
17
|
# The Hoodoo gem date. If this changes, be sure to re-run
|
18
18
|
# <tt>bundle install</tt> or <tt>bundle update</tt>.
|
19
19
|
#
|
20
|
-
DATE = '2017-11-
|
20
|
+
DATE = '2017-11-07'
|
21
21
|
|
22
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hoodoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loyalty New Zealand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dalli
|
@@ -526,7 +526,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
526
526
|
version: '0'
|
527
527
|
requirements: []
|
528
528
|
rubyforge_project:
|
529
|
-
rubygems_version: 2.7.
|
529
|
+
rubygems_version: 2.7.1
|
530
530
|
signing_key:
|
531
531
|
specification_version: 4
|
532
532
|
summary: Opinionated APIs
|