quik 0.3.0 → 1.0.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 +5 -5
- data/{HISTORY.md → CHANGELOG.md} +3 -3
- data/LICENSE.md +116 -0
- data/Manifest.txt +30 -29
- data/README.md +133 -131
- data/Rakefile +33 -34
- data/bin/qk +5 -5
- data/bin/quik +5 -5
- data/lib/quik.rb +55 -44
- data/lib/quik/builder.rb +96 -96
- data/lib/quik/catalog.rb +73 -56
- data/lib/quik/cli/main.rb +213 -179
- data/lib/quik/cli/opts.rb +33 -33
- data/lib/quik/colors.rb +148 -147
- data/lib/quik/config.rb +60 -60
- data/lib/quik/merger.rb +207 -208
- data/lib/quik/package.rb +116 -115
- data/lib/quik/version.rb +24 -24
- data/lib/quik/wizard.rb +88 -88
- data/test/data/gem-starter-template/Manifest.txt +9 -9
- data/test/data/gem-starter-template/README.md +22 -22
- data/test/data/gem-starter-template/lib/__filename__/version.rb +12 -12
- data/test/helper.rb +18 -22
- data/test/test_colors.rb +39 -39
- data/test/test_config.rb +35 -35
- data/test/test_merger.rb +35 -35
- data/test/test_package.rb +22 -22
- data/test/test_wizard.rb +50 -50
- metadata +26 -38
- data/.gemtest +0 -0
data/lib/quik/cli/main.rb
CHANGED
@@ -1,179 +1,213 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
## NOTE: gli added function are class methods (thus, wrap class Toolii in Tool for now)
|
20
|
-
|
21
|
-
class Toolii
|
22
|
-
extend GLI::App
|
23
|
-
|
24
|
-
def self.logger=(value) @@logger=value; end
|
25
|
-
def self.logger() @@logger; end
|
26
|
-
|
27
|
-
## todo: find a better name e.g. change to settings? config? safe_opts? why? why not?
|
28
|
-
def self.opts=(value) @@opts = value; end
|
29
|
-
def self.opts() @@opts; end
|
30
|
-
|
31
|
-
|
32
|
-
logger = LogUtils::Logger.root
|
33
|
-
opts = Opts.new
|
34
|
-
|
35
|
-
|
36
|
-
program_desc 'ruby quick starter template script wizard .:. the missing code generator'
|
37
|
-
version VERSION
|
38
|
-
|
39
|
-
|
40
|
-
## desc 'Use only local (offline) cached data; no (online) remote network access'
|
41
|
-
## switch [:l, :local], negatable: false
|
42
|
-
|
43
|
-
desc '(Debug) Show debug messages'
|
44
|
-
switch [:verbose], negatable: false ## todo: use -w for short form? check ruby interpreter if in use too?
|
45
|
-
|
46
|
-
desc '(Debug) Dry run; run script in simulation for testing'
|
47
|
-
switch [:test, :dry_run], negatable: false
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
##
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
catalog
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
command :
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
puts
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
end
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
1
|
+
################
|
2
|
+
## NOTE: wrap gli config into a class
|
3
|
+
## see github.com/davetron5000/gli/issues/153
|
4
|
+
|
5
|
+
module Quik
|
6
|
+
|
7
|
+
class Tool
|
8
|
+
def initialize
|
9
|
+
LogUtils::Logger.root.level = :info # set logging level to info
|
10
|
+
end
|
11
|
+
|
12
|
+
def run( args )
|
13
|
+
puts Quik.banner
|
14
|
+
Toolii.run( args )
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
## NOTE: gli added function are class methods (thus, wrap class Toolii in Tool for now)
|
20
|
+
|
21
|
+
class Toolii
|
22
|
+
extend GLI::App
|
23
|
+
|
24
|
+
def self.logger=(value) @@logger=value; end
|
25
|
+
def self.logger() @@logger; end
|
26
|
+
|
27
|
+
## todo: find a better name e.g. change to settings? config? safe_opts? why? why not?
|
28
|
+
def self.opts=(value) @@opts = value; end
|
29
|
+
def self.opts() @@opts; end
|
30
|
+
|
31
|
+
|
32
|
+
logger = LogUtils::Logger.root
|
33
|
+
opts = Opts.new
|
34
|
+
|
35
|
+
|
36
|
+
program_desc 'ruby quick starter template script wizard .:. the missing code generator'
|
37
|
+
version VERSION
|
38
|
+
|
39
|
+
|
40
|
+
## desc 'Use only local (offline) cached data; no (online) remote network access'
|
41
|
+
## switch [:l, :local], negatable: false
|
42
|
+
|
43
|
+
desc '(Debug) Show debug messages'
|
44
|
+
switch [:verbose], negatable: false ## todo: use -w for short form? check ruby interpreter if in use too?
|
45
|
+
|
46
|
+
desc '(Debug) Dry run; run script in simulation for testing'
|
47
|
+
switch [:test, :dry_run], negatable: false
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
def self.fetch_catalog
|
52
|
+
## scripts_dir = "#{Quik.root}/test/data"
|
53
|
+
## catalog = Catalog.new( "#{scripts_dir}/scripts.yml" )
|
54
|
+
|
55
|
+
url = QUIK_SCRIPTS_URL
|
56
|
+
|
57
|
+
puts "GET #{url}".bold.green ## output network access in green bold
|
58
|
+
|
59
|
+
catalog = Catalog.from_url( url )
|
60
|
+
catalog
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
def self.fetch_script( name_or_path )
|
65
|
+
|
66
|
+
## first try local version in working folder
|
67
|
+
|
68
|
+
text = ''
|
69
|
+
|
70
|
+
extname = File.extname( name_or_path )
|
71
|
+
|
72
|
+
|
73
|
+
## try local first
|
74
|
+
## todo/fix: check in ~/.quik/ dir too?
|
75
|
+
|
76
|
+
path = if extname == '.rb' && File.exist?( name_or_path )
|
77
|
+
name_or_path
|
78
|
+
elsif extname == '' && File.exist?( "#{name_or_path}.rb" )
|
79
|
+
"#{name_or_path}.rb"
|
80
|
+
elsif extname == '' && File.exist?( "~/.quik/#{name_or_path}.rb" )
|
81
|
+
"~/.quik/#{name_or_path}.rb" ## todo/check - if (~) shortcut works in windows -too?
|
82
|
+
else
|
83
|
+
nil
|
84
|
+
end
|
85
|
+
|
86
|
+
if path
|
87
|
+
text = File.open( path, 'r:utf-8' ) { |f| f.read }
|
88
|
+
else ## try fetch remote script
|
89
|
+
|
90
|
+
url = nil
|
91
|
+
|
92
|
+
if name_or_path.index( '/' ).nil? ## assume short-cut name if no (/) in name
|
93
|
+
## do a lookup from catalog!!!
|
94
|
+
catalog = fetch_catalog
|
95
|
+
rec = catalog.find( name_or_path )
|
96
|
+
url = rec['script'] if rec
|
97
|
+
|
98
|
+
if url.nil?
|
99
|
+
puts "!! ERROR - sorry no wizard script found / available for name >#{name_or_path}<"
|
100
|
+
exit 1
|
101
|
+
end
|
102
|
+
else
|
103
|
+
## assume custom github url shortcut
|
104
|
+
url = "https://github.com/#{name_or_path}/raw/master/quik.rb"
|
105
|
+
end
|
106
|
+
|
107
|
+
## assume utf8 text encoding for now
|
108
|
+
puts "GET #{url}".bold.green ## output network access in green bold
|
109
|
+
|
110
|
+
worker = Fetcher::Worker.new
|
111
|
+
text = worker.read_utf8!( url )
|
112
|
+
end
|
113
|
+
|
114
|
+
text
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
desc "List ruby quick starter scripts"
|
120
|
+
arg_name 'QUERY' # optional search query/filter
|
121
|
+
command [:list,:ls,:l] do |c|
|
122
|
+
|
123
|
+
c.action do |g,o,args|
|
124
|
+
## read in scripts diretory
|
125
|
+
catalog = fetch_catalog
|
126
|
+
catalog.list( args[0] ) ## note: pass in filter e.g. args[0]; may be nil (no filter)
|
127
|
+
puts 'Done.'
|
128
|
+
end # action
|
129
|
+
end # command list
|
130
|
+
|
131
|
+
|
132
|
+
desc "Run ruby quick starter script"
|
133
|
+
arg_name 'NAME' # required theme name
|
134
|
+
command [:new,:n] do |c|
|
135
|
+
|
136
|
+
c.action do |g,o,args|
|
137
|
+
|
138
|
+
name = args[0] || 'gem'
|
139
|
+
|
140
|
+
script = fetch_script( name )
|
141
|
+
if opts.test?
|
142
|
+
puts "dry (test) run:"
|
143
|
+
Builder.load( script, test: true )
|
144
|
+
else
|
145
|
+
Builder.load( script )
|
146
|
+
end
|
147
|
+
|
148
|
+
puts 'Done.'
|
149
|
+
end # action
|
150
|
+
end # command setup
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
desc '(Debug) Test command suite'
|
155
|
+
command :test do |c|
|
156
|
+
c.action do |g,o,args|
|
157
|
+
|
158
|
+
puts "hello from test command"
|
159
|
+
puts "args (#{args.class.name}):"
|
160
|
+
pp args
|
161
|
+
puts "o (#{o.class.name}):"
|
162
|
+
pp o
|
163
|
+
puts "g (#{g.class.name}):"
|
164
|
+
pp g
|
165
|
+
|
166
|
+
LogUtils::Logger.root.debug 'test debug msg'
|
167
|
+
LogUtils::Logger.root.info 'test info msg'
|
168
|
+
LogUtils::Logger.root.warn 'test warn msg'
|
169
|
+
|
170
|
+
puts 'Done.'
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
pre do |g,c,o,args|
|
177
|
+
opts.merge_gli_options!( g )
|
178
|
+
opts.merge_gli_options!( o )
|
179
|
+
|
180
|
+
puts Quik.banner
|
181
|
+
|
182
|
+
if opts.verbose?
|
183
|
+
LogUtils::Logger.root.level = :debug
|
184
|
+
end
|
185
|
+
|
186
|
+
logger.debug "Executing #{c.name}"
|
187
|
+
true
|
188
|
+
end
|
189
|
+
|
190
|
+
post do |global,c,o,args|
|
191
|
+
logger.debug "Executed #{c.name}"
|
192
|
+
true
|
193
|
+
end
|
194
|
+
|
195
|
+
|
196
|
+
on_error do |e|
|
197
|
+
puts
|
198
|
+
puts "*** error: #{e.message}"
|
199
|
+
|
200
|
+
if opts.verbose?
|
201
|
+
puts e.backtrace
|
202
|
+
end
|
203
|
+
|
204
|
+
false # skip default error handling
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
### exit run(ARGV) ## note: use Toolii.run( ARGV ) outside of class
|
209
|
+
|
210
|
+
end # class Toolii
|
211
|
+
|
212
|
+
end # module Quik
|
213
|
+
|
data/lib/quik/cli/opts.rb
CHANGED
@@ -1,33 +1,33 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Quik
|
4
|
-
|
5
|
-
class Opts
|
6
|
-
|
7
|
-
def merge_gli_options!( options = {} )
|
8
|
-
@test = true if options[:test] == true
|
9
|
-
@verbose = true if options[:verbose] == true
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
def verbose=(boolean) # add: alias for debug ??
|
14
|
-
@verbose = boolean
|
15
|
-
end
|
16
|
-
|
17
|
-
def verbose?
|
18
|
-
return false if @verbose.nil? # default verbose/debug flag is false
|
19
|
-
@verbose == true
|
20
|
-
end
|
21
|
-
|
22
|
-
def test=(boolean)
|
23
|
-
@test = boolean
|
24
|
-
end
|
25
|
-
|
26
|
-
def test?
|
27
|
-
return false if @test.nil? # default test/dry-run flag is false
|
28
|
-
@test == true
|
29
|
-
end
|
30
|
-
|
31
|
-
end # class Opts
|
32
|
-
|
33
|
-
end # module Quik
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Quik
|
4
|
+
|
5
|
+
class Opts
|
6
|
+
|
7
|
+
def merge_gli_options!( options = {} )
|
8
|
+
@test = true if options[:test] == true
|
9
|
+
@verbose = true if options[:verbose] == true
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def verbose=(boolean) # add: alias for debug ??
|
14
|
+
@verbose = boolean
|
15
|
+
end
|
16
|
+
|
17
|
+
def verbose?
|
18
|
+
return false if @verbose.nil? # default verbose/debug flag is false
|
19
|
+
@verbose == true
|
20
|
+
end
|
21
|
+
|
22
|
+
def test=(boolean)
|
23
|
+
@test = boolean
|
24
|
+
end
|
25
|
+
|
26
|
+
def test?
|
27
|
+
return false if @test.nil? # default test/dry-run flag is false
|
28
|
+
@test == true
|
29
|
+
end
|
30
|
+
|
31
|
+
end # class Opts
|
32
|
+
|
33
|
+
end # module Quik
|