new 1.0.9 → 1.0.10
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 +8 -8
- data/lib/new.rb +4 -0
- data/lib/new/cli.rb +110 -51
- data/lib/new/source.rb +3 -1
- data/lib/new/task.rb +6 -0
- data/lib/new/validation.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDY3MTQ0YWIyYTE0NWE3NmQ5OTAxYzViYzNjNzE4ODNhNzM0YmM0ZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2FkMGUxYmM5MzM4Y2EzYzA0NDg2NGRiODZhNWZkODNkMjY1MDgzOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzcwN2E4NWIyZGMyYTVjZTIyMjBlYjk1MmJiNTgwMzMxOTA0NmE2ZGZlOTll
|
10
|
+
MmQ5MjZjMjQ2MjJkOWI1NzQ4ZDcxYzIxNmE5ZjUyMWIyNDhjYzc0MzBmZTU2
|
11
|
+
NTJhMGNkMTQyZGE2N2NjNDU2YTljNzYzNGRhMmNjYjJiYWVlM2I=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzQ4ZDU1NDFhYjg0ZDljNWU4YmY0NzQ0ZmFkYjYxMTI4YWUzNzBlNjkyOWM0
|
14
|
+
MjkwOGY0NTUzMTJhYjYxNjdkZTY3ZjE1ZjYwZmY0OTdlNTk5NDBlZTc1ZmRj
|
15
|
+
ZDI1OTNhMWQ3MDMwNTNlZTY1NzU4MDY5ZTg5YmE4ZTdhMWJiNDk=
|
data/lib/new.rb
CHANGED
data/lib/new/cli.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
#
|
2
|
+
# New::Cli is a class built on Thor for interfacing with the user on the command line
|
3
|
+
#
|
1
4
|
require 'active_support/core_ext/hash/reverse_merge'
|
2
5
|
require 'active_support/core_ext/hash/keys'
|
3
6
|
require 'cli_miami'
|
@@ -196,6 +199,7 @@ class New::Cli < Thor
|
|
196
199
|
end
|
197
200
|
|
198
201
|
desc 'tasks', 'List all available tasks'
|
202
|
+
option :task, :aliases => ['-t'], :desc => 'Get details for a single task'
|
199
203
|
option :sources, :type => :boolean, :aliases => ['-s'], :default => false, :desc => 'Show/Hide task sources'
|
200
204
|
def tasks args = {}
|
201
205
|
# merge into default options
|
@@ -207,71 +211,96 @@ class New::Cli < Thor
|
|
207
211
|
|
208
212
|
New.load_newfiles if options[:load_newfiles]
|
209
213
|
if options[:load_sources]
|
210
|
-
S.ay
|
211
214
|
S.ay 'Fetching sources...', :header
|
212
215
|
S.ay "Use the #{'green'.green} value for defining task sources in your Newfile", :indent => 2 if options[:show_source]
|
213
216
|
S.ay
|
214
217
|
New::Source.load_sources
|
215
218
|
end
|
216
219
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
+
if @options['task']
|
221
|
+
task = New::Source.find_task @options['task']
|
222
|
+
S.ay task.name.to_s.upcase, :preset => :header, :style => :underline, :padding => 30, :justify => :center
|
223
|
+
S.ay "source: #{task.source.name.to_s}", :color => :cyan, :padding => 30, :justify => :center
|
224
|
+
S.ay
|
220
225
|
|
221
|
-
|
222
|
-
|
226
|
+
max_option_length = task.class_options.keys.map(&:length).max
|
227
|
+
task.class_options.each do |name, settings|
|
228
|
+
S.ay name.to_s, :preset => :highlight_key, :padding => max_option_length, :style => :underline
|
229
|
+
S.ay settings[:description], :highlight_value
|
223
230
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
+
S.ay 'Type:', :preset => :highlight_key, :padding => max_option_length + 13
|
232
|
+
S.ay "#{settings[:type] || 'String'}", :highlight_value
|
233
|
+
|
234
|
+
if settings[:required]
|
235
|
+
S.ay 'Required:', :preset => :highlight_key, :padding => max_option_length + 13
|
236
|
+
S.ay 'true', :highlight_value
|
237
|
+
elsif settings[:default]
|
238
|
+
S.ay 'Default:', :preset => :highlight_key, :padding => max_option_length + 13
|
239
|
+
S.ay settings[:default].to_s, :highlight_value
|
231
240
|
end
|
232
|
-
|
241
|
+
|
242
|
+
if settings[:validation]
|
243
|
+
S.ay 'Validation:', :preset => :highlight_key, :padding => max_option_length + 13
|
244
|
+
S.ay settings[:validation].to_s, :highlight_value
|
245
|
+
end
|
246
|
+
|
247
|
+
S.ay
|
233
248
|
end
|
249
|
+
else
|
250
|
+
New::Source.sources.each do |source_name, source|
|
251
|
+
# determine the widest task & add some padding
|
252
|
+
longest_task_length = source.tasks.keys.map(&:length).max
|
253
|
+
|
254
|
+
S.ay source_name.to_s, :indent => 2, :newline => false, :style => :underline
|
255
|
+
S.ay source.path, :highlight_value
|
256
|
+
|
257
|
+
source.tasks.each do |task_name, task|
|
258
|
+
if options[:show_source]
|
259
|
+
padding = longest_task_length + source_name.to_s.length + 2
|
260
|
+
S.ay "#{source_name}##{task_name}", :preset => :header, :newline => false, :indent => 2, :padding => padding, :justify => :ljust
|
261
|
+
else
|
262
|
+
padding = longest_task_length + 2
|
263
|
+
S.ay task_name.to_s, :preset => :header, :newline => false, :indent => 2, :padding => padding, :justify => :ljust
|
264
|
+
end
|
265
|
+
S.ay task.description, :indent => 2
|
266
|
+
end
|
234
267
|
|
235
|
-
|
268
|
+
S.ay
|
269
|
+
end
|
236
270
|
end
|
237
271
|
end
|
238
272
|
|
239
273
|
desc 'release', 'Release a new version of your project'
|
274
|
+
option :bump, :aliases => ['-b'], :enum => ['M', 'm', 'p'], :desc => 'Version part to bump'
|
240
275
|
option :verbose, :type => :boolean, :aliases => ['-v'], :default => false, :desc => 'Verbose mode'
|
241
276
|
option :skip, :type => :array, :aliases => ['-s'], :default => [], :desc => 'Tasks to skip for this release'
|
242
277
|
def release
|
243
|
-
New.set_verbose if @options['verbose']
|
244
278
|
New.set_cli
|
279
|
+
New.set_verbose if @options['verbose']
|
245
280
|
New.load_newfiles
|
246
281
|
|
247
|
-
# request the version to bump
|
248
282
|
S.ay
|
249
|
-
S.ay 'Releasing a new version of:
|
250
|
-
S.ay New.new_object[:name], :highlight_value
|
251
|
-
|
252
|
-
S.ay "[#{'Mmp'.green}] (#{'M'.green}ajor / #{'m'.green}inor / #{'p'.green}atch)", :preset => :highlight_value, :color => :white
|
283
|
+
S.ay 'Releasing a new version of:', :highlight_key
|
284
|
+
S.ay New.new_object[:name].to_s, :highlight_value
|
285
|
+
|
253
286
|
version = Semantic::Version.new New.new_object[:version]
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
version
|
266
|
-
when 'p'
|
267
|
-
version.patch += 1
|
268
|
-
else
|
269
|
-
S.ay 'You must choose from [Mmp]', :error
|
270
|
-
nil
|
287
|
+
S.ay 'Current Version:', :highlight_key
|
288
|
+
S.ay version.to_s, :highlight_value
|
289
|
+
|
290
|
+
if @options['bump']
|
291
|
+
version = bump_version version, @options['bump']
|
292
|
+
else
|
293
|
+
S.ay 'What do you want to bump:', :highlight_key
|
294
|
+
S.ay "[#{'Mmp'.green}] (#{'M'.green}ajor / #{'m'.green}inor / #{'p'.green}atch)", :preset => :highlight_value, :color => :white
|
295
|
+
version_bump_part = nil
|
296
|
+
until version_bump_part
|
297
|
+
A.sk '', :prompt do |response|
|
298
|
+
version = version_bump_part = bump_version version, response
|
271
299
|
end
|
272
300
|
end
|
273
301
|
end
|
274
|
-
|
302
|
+
|
303
|
+
S.ay 'New Version:', :highlight_key
|
275
304
|
S.ay version.to_s, :highlight_value
|
276
305
|
S.ay
|
277
306
|
|
@@ -297,7 +326,7 @@ class New::Cli < Thor
|
|
297
326
|
desc 'version', 'Show the current version'
|
298
327
|
def version
|
299
328
|
New.load_newfiles
|
300
|
-
S.ay New.new_object[:name], :highlight_key
|
329
|
+
S.ay New.new_object[:name], :preset => :highlight_key, :padding => 0, :indent => 0
|
301
330
|
S.ay New.new_object[:version], :highlight_value
|
302
331
|
end
|
303
332
|
|
@@ -405,11 +434,7 @@ class New::Cli < Thor
|
|
405
434
|
|
406
435
|
# convert array to hash of Strings
|
407
436
|
if validation.is_a? Array
|
408
|
-
|
409
|
-
validation.each do |v|
|
410
|
-
validation_hash[v.to_sym] = String
|
411
|
-
end
|
412
|
-
validation = validation_hash
|
437
|
+
validation = array_to_hash validation
|
413
438
|
end
|
414
439
|
|
415
440
|
if validation.is_a? Hash
|
@@ -417,7 +442,7 @@ class New::Cli < Thor
|
|
417
442
|
|
418
443
|
user_response = nil
|
419
444
|
until user_response == 'n'
|
420
|
-
S.ay "#{user_array.length} objects created:
|
445
|
+
S.ay "#{user_array.length} objects created:", :indent => 2, :newline => false
|
421
446
|
S.ay user_array.join(', '), :highlight_value
|
422
447
|
A.sk 'Press ENTER to create another object. Enter `n` to stop.', :prompt do |response|
|
423
448
|
if response == 'n'
|
@@ -461,11 +486,7 @@ class New::Cli < Thor
|
|
461
486
|
|
462
487
|
# convert array to hash of Strings
|
463
488
|
if validation.is_a? Array
|
464
|
-
|
465
|
-
validation.each do |v|
|
466
|
-
validation_hash[v.to_sym] = String
|
467
|
-
end
|
468
|
-
validation = validation_hash
|
489
|
+
validation = array_to_hash validation
|
469
490
|
end
|
470
491
|
|
471
492
|
# get user values for required validation keys
|
@@ -535,6 +556,44 @@ class New::Cli < Thor
|
|
535
556
|
|
536
557
|
return user_hash
|
537
558
|
end
|
559
|
+
|
560
|
+
# convert an array to a hash
|
561
|
+
# uses the array elements as hash keys, and sets the value to String
|
562
|
+
# @param array [Array] any array
|
563
|
+
# @return [Hash]
|
564
|
+
#
|
565
|
+
def array_to_hash array
|
566
|
+
array_hash = {}
|
567
|
+
array.each do |v|
|
568
|
+
array_hash[v.to_sym] = String
|
569
|
+
end
|
570
|
+
|
571
|
+
return array_hash
|
572
|
+
end
|
573
|
+
|
574
|
+
# bump a semantic version
|
575
|
+
# @param version [Semantic::Version] a Semantic::Version object
|
576
|
+
# @param part [String] a supported part character [Mmp]
|
577
|
+
# @return [Semantic::Version] a new Semantic::Version object
|
578
|
+
#
|
579
|
+
def bump_version version, part
|
580
|
+
case part
|
581
|
+
when 'M'
|
582
|
+
version.major += 1
|
583
|
+
version.minor = 0
|
584
|
+
version.patch = 0
|
585
|
+
when 'm'
|
586
|
+
version.minor += 1
|
587
|
+
version.patch = 0
|
588
|
+
when 'p'
|
589
|
+
version.patch += 1
|
590
|
+
else
|
591
|
+
S.ay 'You must choose from [Mmp]', :error
|
592
|
+
return nil
|
593
|
+
end
|
594
|
+
|
595
|
+
return version
|
596
|
+
end
|
538
597
|
end
|
539
598
|
|
540
599
|
default_task :release
|
data/lib/new/source.rb
CHANGED
data/lib/new/task.rb
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
#
|
2
|
+
# New::Task is the base class that all custom tasks need to inherit from
|
3
|
+
#
|
1
4
|
class New::Task
|
2
5
|
extend New::Validation
|
3
6
|
|
@@ -65,6 +68,9 @@ class New::Task
|
|
65
68
|
end
|
66
69
|
|
67
70
|
# run a system command
|
71
|
+
# @param command [String] the system command to run
|
72
|
+
# @return [Boolean] true/false based on if the exit status of the command
|
73
|
+
#
|
68
74
|
def run_command command
|
69
75
|
# if verbose, dont redirect output to null
|
70
76
|
command += ' >> /dev/null 2>&1' unless New.verbose
|
data/lib/new/validation.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: new
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Brewster
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|