markdown_exec 0.0.6 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c89f954d1fc114cb22e9222ebc2c7d0575848d597899e1385edbf7b5963f08b
4
- data.tar.gz: f14d0e24a3c348c303e96014b68a477d560ed1c3c707ac486173ffe19513df1d
3
+ metadata.gz: 4a4e558c22601546757b3fdd28f0c438ca1419badd2416e8beac4bc35692d6fe
4
+ data.tar.gz: fdb68f22046be5c9c00b9044330a2891ac047505644defdb493b2795c0852943
5
5
  SHA512:
6
- metadata.gz: b78cd2cfbef3c47acd318c173fa953891f83c29ea2ac59b062dafc2e2ce8573c4f862f2e681cacb6ebd827dc77b10b984dd8a33a1349849357e9c64ab564932d
7
- data.tar.gz: 8f8282f7a5a171dee4c83f9fce9974f48b7ee55b43d25651bfebaec0f46b97028c1ed58bd23ea85a796f949cd1eeae923d6899a5efb448879de96aa37287915d
6
+ metadata.gz: b0d32562440fc40f82dd00d189a51f55e0d7f5ca4dcc2f80d3c915622222a3234bafd162abb6931f78ab1d32fc067eba97c0788a6dca0bfaa87ce653001c62e6
7
+ data.tar.gz: 44de2ffe388333c536512bef6cd6981424ed68f84a157d0b60397ae598a4cf60dae49b413c91d2683da9d544bd6d5c5790bd7f278c6ed5873e1d3f74f30f6f67
data/README.md CHANGED
@@ -62,3 +62,5 @@ gem list | grep exec
62
62
  gem uninstall markdown_exec
63
63
  ```
64
64
  pusher api key: rubygems_8c4b38ef685484719858c53c3161a124c15d7a9bec6cb65a
65
+
66
+ gem push markdown_exec-0.0.1.gem
data/Rakefile CHANGED
@@ -13,27 +13,26 @@ require 'rubocop/rake_task'
13
13
 
14
14
  RuboCop::RakeTask.new
15
15
 
16
- task default: %i[test rubocop]
16
+ require_relative 'lib/markdown_exec/version'
17
17
 
18
- GEM_NAME = 'markdown_exec'
19
- GEM_VERSION = '0.0.6'
18
+ task default: %i[test rubocop]
20
19
 
21
20
  # task :default => :build
22
21
 
23
22
  task :build do
24
- system "gem build #{GEM_NAME}.gemspec"
23
+ system "gem build #{MarkdownExec::GEM_NAME}.gemspec"
25
24
  end
26
25
 
27
26
  task install: :build do
28
- system "gem install #{GEM_NAME}-#{GEM_VERSION}.gem"
27
+ system "gem install #{MarkdownExec::GEM_NAME}-#{MarkdownExec::VERSION}.gem"
29
28
  end
30
29
 
31
30
  task publish: :build do
32
- system "gem push #{GEM_NAME}-#{GEM_VERSION}.gem"
31
+ system "gem push #{MarkdownExec::GEM_NAME}-#{MarkdownExec::VERSION}.gem"
33
32
  end
34
33
 
35
34
  task uninstall: :build do
36
- system "gem uninstall #{GEM_NAME}"
35
+ system "gem uninstall #{MarkdownExec::GEM_NAME}"
37
36
  end
38
37
 
39
38
  task :clean do
data/bin/mde CHANGED
@@ -3,8 +3,6 @@
3
3
 
4
4
  # encoding=utf-8
5
5
 
6
- require 'markdown_exec'
6
+ require_relative '../lib/markdown_exec'
7
7
 
8
- mp = MarkdownExec::MarkParse.new
9
- mp.fout Time.now
10
- # mp.run
8
+ MarkdownExec::MarkParse.new.run
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MarkdownExec
4
- VERSION = '0.0.6'
4
+ APP_NAME = 'MDE'
5
+ APP_DESC = 'Markdown block executor'
6
+ GEM_NAME = 'markdown_exec'
7
+ VERSION = '0.1.0'
5
8
  end
data/lib/markdown_exec.rb CHANGED
@@ -1,38 +1,17 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'markdown_exec/version'
4
-
5
1
  #!/usr/bin/env ruby
6
2
  # frozen_string_literal: true
7
3
 
8
4
  # encoding=utf-8
9
- # rubocop:disable Style/GlobalVars
10
-
11
- env_debug = ENV['MARKDOWN_EXEC_DEBUG']
12
- $pdebug = !(env_debug || '').empty?
13
5
 
14
- # APP_NAME = 'MDExec'
15
- # APP_DESC = 'Markdown block executor'
16
- # VERSION = '0.0.6'
17
-
18
- # require 'markdown_exec'
19
- # # puts MarkdownExec::MarkParse.echo(ARGV[0])
6
+ # rubocop:disable Style/GlobalVars
7
+ $pdebug = !(ENV['MARKDOWN_EXEC_DEBUG'] || '').empty?
20
8
 
9
+ require 'open3'
21
10
  require 'optparse'
22
11
  require 'pathname'
23
12
  require 'tty-prompt'
24
13
  require 'yaml'
25
-
26
- # require_relative 'mdlib'
27
- # #!/usr/bin/env ruby
28
- # # frozen_string_literal: true
29
- # # encoding=utf-8
30
-
31
- # env_debug = ENV['MARKDOWN_EXEC_DEBUG']
32
- # $pdebug = !(env_debug || '').empty?
33
-
34
- require 'open3'
35
- # require 'tty-prompt'
14
+ require_relative 'markdown_exec/version'
36
15
 
37
16
  BLOCK_SIZE = 1024
38
17
  SELECT_PAGE_HEIGHT = 12
@@ -40,12 +19,6 @@ SELECT_PAGE_HEIGHT = 12
40
19
  module MarkdownExec
41
20
  class Error < StandardError; end
42
21
 
43
- # Markdown Exec
44
- # class MarkParse
45
- # def self.echo(str = '')
46
- # "#{str}#{str}"
47
- # end
48
- # end
49
22
  ##
50
23
  #
51
24
  class MarkParse
@@ -183,7 +156,7 @@ module MarkdownExec
183
156
  end
184
157
  end
185
158
  blocks.tap { |ret| puts "get_blocks() ret: #{ret.inspect}" if $pdebug }
186
- end
159
+ end # get_blocks
187
160
 
188
161
  def make_block_label(block, call_options = {})
189
162
  opts = options.merge(call_options)
@@ -303,7 +276,7 @@ module MarkdownExec
303
276
  end
304
277
 
305
278
  selected[:name]
306
- end
279
+ end # select_block
307
280
 
308
281
  def select_md_file
309
282
  opts = options
@@ -387,150 +360,160 @@ module MarkdownExec
387
360
  end
388
361
  all.tap { |ret| puts "unroll() ret: #{ret.inspect}" if $pdebug }
389
362
  end
390
- end
391
363
 
392
- # $stderr.sync = true
393
- # $stdout.sync = true
364
+ # $stderr.sync = true
365
+ # $stdout.sync = true
394
366
 
395
- def fout(str)
396
- puts str # to stdout
397
- end
398
-
399
- ## configuration file
400
- #
401
- def read_configuration!(options, configuration_path)
402
- if Pathname.new(configuration_path).exist?
403
- # rubocop:disable Security/YAMLLoad
404
- options.merge!((YAML.load(File.open(configuration_path)) || {})
405
- .transform_keys(&:to_sym))
406
- # rubocop:enable Security/YAMLLoad
367
+ ## configuration file
368
+ #
369
+ def read_configuration!(options, configuration_path)
370
+ if Pathname.new(configuration_path).exist?
371
+ # rubocop:disable Security/YAMLLoad
372
+ options.merge!((YAML.load(File.open(configuration_path)) || {})
373
+ .transform_keys(&:to_sym))
374
+ # rubocop:enable Security/YAMLLoad
375
+ end
376
+ options
407
377
  end
408
- options
409
- end
410
378
 
411
- def run
412
- ## default configuration
413
- #
414
- options = {
415
- mdheadings: true,
416
- list_blocks: false,
417
- list_docs: false,
418
- mdfilename: 'README.md',
419
- mdfolder: '.'
420
- }
379
+ def run
380
+ ## default configuration
381
+ #
382
+ options = {
383
+ mdheadings: true,
384
+ list_blocks: false,
385
+ list_docs: false,
386
+ mdfilename: 'README.md',
387
+ mdfolder: '.'
388
+ }
421
389
 
422
- def options_finalize!(options); end
390
+ def options_finalize!(options); end
423
391
 
424
- # read local configuration file
425
- #
426
- read_configuration! options, ".#{APP_NAME.downcase}.yml"
392
+ # puts "MDE run() ARGV: #{ARGV.inspect}"
427
393
 
428
- ## read current details for aws resources from app_data_file
429
- #
430
- # load_resources! options
431
- # puts "q31 options: #{options.to_yaml}" if $pdebug
432
-
433
- # rubocop:disable Metrics/BlockLength
434
- option_parser = OptionParser.new do |opts|
435
- executable_name = File.basename($PROGRAM_NAME)
436
- opts.banner = [
437
- "#{APP_NAME} - #{APP_DESC} (#{VERSION})".freeze,
438
- "Usage: #{executable_name} [options]"
439
- ].join("\n")
440
-
441
- ## menu top: on_head appear in reverse order added
394
+ # read local configuration file
442
395
  #
443
- opts.on('--config PATH', 'Read configuration file') do |value|
444
- read_configuration! options, value
445
- end
396
+ read_configuration! options, ".#{MarkdownExec::APP_NAME.downcase}.yml"
446
397
 
447
- ## menu body: items appear in order added
398
+ ## read current details for aws resources from app_data_file
448
399
  #
449
- opts.on('-f RELATIVE', '--mdfilename', 'Name of document') do |value|
450
- options[:mdfilename] = value
451
- end
452
-
453
- opts.on('-p PATH', '--mdfolder', 'Path to documents') do |value|
454
- options[:mdfolder] = value
455
- end
400
+ # load_resources! options
401
+ # puts "q31 options: #{options.to_yaml}" if $pdebug
402
+
403
+ # rubocop:disable Metrics/BlockLength
404
+ option_parser = OptionParser.new do |opts|
405
+ executable_name = File.basename($PROGRAM_NAME)
406
+ opts.banner = [
407
+ "#{MarkdownExec::APP_NAME} - #{MarkdownExec::APP_DESC} (#{MarkdownExec::VERSION})",
408
+ "Usage: #{executable_name} [options]"
409
+ ].join("\n")
410
+
411
+ ## menu top: on_head appear in reverse order added
412
+ #
413
+ opts.on('--config PATH', 'Read configuration file') do |value|
414
+ read_configuration! options, value
415
+ end
456
416
 
457
- opts.on('--list-blocks', 'List blocks') do |_value|
458
- options[:list_blocks] = true
459
- end
417
+ ## menu body: items appear in order added
418
+ #
419
+ opts.on('-f RELATIVE', '--mdfilename', 'Name of document') do |value|
420
+ options[:mdfilename] = value
421
+ end
460
422
 
461
- opts.on('--list-docs', 'List docs in current folder') do |_value|
462
- options[:list_docs] = true
463
- end
423
+ opts.on('-p PATH', '--mdfolder', 'Path to documents') do |value|
424
+ options[:mdfolder] = value
425
+ end
464
426
 
465
- ## menu bottom: items appear in order added
466
- #
467
- opts.on_tail('-h', '--help', 'App help') do |_value|
468
- puts option_parser.help
469
- exit
470
- end
427
+ opts.on('--list-blocks', 'List blocks') do |_value|
428
+ options[:list_blocks] = true
429
+ end
471
430
 
472
- opts.on_tail('-v', '--version', 'App version') do |_value|
473
- puts VERSION
474
- exit
475
- end
431
+ opts.on('--list-docs', 'List docs in current folder') do |_value|
432
+ options[:list_docs] = true
433
+ end
476
434
 
477
- opts.on_tail('-x', '--exit', 'Exit app') do |_value|
478
- exit
479
- end
435
+ ## menu bottom: items appear in order added
436
+ #
437
+ opts.on_tail('-h', '--help', 'App help') do |_value|
438
+ puts option_parser.help
439
+ exit
440
+ end
480
441
 
481
- opts.on_tail('-0', 'Show configuration') do |_v|
482
- options_finalize! options
483
- puts options.to_yaml
484
- end
485
- end
486
- # rubocop:enable Metrics/BlockLength
442
+ opts.on_tail('-v', '--version', 'App version') do |_value|
443
+ puts MarkdownExec::VERSION
444
+ exit
445
+ end
487
446
 
488
- option_parser.load # filename defaults to basename of the program without suffix in a directory ~/.options
489
- option_parser.environment # env defaults to the basename of the program.
490
- option_parser.parse! # (into: options)
491
- options_finalize! options
447
+ opts.on_tail('-x', '--exit', 'Exit app') do |_value|
448
+ exit
449
+ end
492
450
 
493
- ## process
494
- #
495
- # rubocop:disable Metrics/BlockLength
496
- loop do # once
497
- mp = MarkParse.new options
498
- options.merge!(
499
- {
500
- approve: true,
501
- bash: true,
502
- display: true,
503
- exclude_expect_blocks: true,
504
- execute: true,
505
- prompt: 'Execute',
506
- struct: true
507
- }
508
- )
509
-
510
- ## show
511
- #
512
- if options[:list_docs]
513
- fout mp.find_files
514
- break
515
- end
451
+ opts.on_tail('-0', 'Show configuration') do |_v|
452
+ options_finalize! options
453
+ puts options.to_yaml
454
+ end
455
+ end # OptionParser
456
+ # rubocop:enable Metrics/BlockLength
516
457
 
517
- if options[:list_blocks]
518
- fout (mp.find_files.map do |file|
519
- mp.make_block_labels(mdfilename: file, struct: true)
520
- end).flatten(1).to_yaml
521
- break
522
- end
458
+ option_parser.load # filename defaults to basename of the program without suffix in a directory ~/.options
459
+ option_parser.environment # env defaults to the basename of the program.
460
+ option_parser.parse! # (into: options)
461
+ options_finalize! options
523
462
 
524
463
  ## process
525
464
  #
526
- mp.select_block(bash: true, struct: true) if options[:mdfilename]
465
+ # rubocop:disable Metrics/BlockLength
466
+ loop do # once
467
+ mp = MarkParse.new options
468
+ options.merge!(
469
+ {
470
+ approve: true,
471
+ bash: true,
472
+ display: true,
473
+ exclude_expect_blocks: true,
474
+ execute: true,
475
+ prompt: 'Execute',
476
+ struct: true
477
+ }
478
+ )
479
+
480
+ ## show
481
+ #
482
+ if options[:list_docs]
483
+ fout mp.find_files
484
+ break
485
+ end
527
486
 
528
- # rubocop:disable Style/BlockComments
529
- # rubocop:enable Style/BlockComments
487
+ if options[:list_blocks]
488
+ fout (mp.find_files.map do |file|
489
+ mp.make_block_labels(mdfilename: file, struct: true)
490
+ end).flatten(1).to_yaml
491
+ break
492
+ end
493
+
494
+ ## process
495
+ #
496
+ mp.select_block(bash: true, struct: true) if options[:mdfilename]
497
+
498
+ # rubocop:disable Style/BlockComments
499
+ =begin
500
+ # rescue ArgumentError => e
501
+ # puts "User abort: #{e}"
502
+
503
+ # rescue StandardError => e
504
+ # puts "ERROR: #{e}"
505
+ # raise StandardError, e
506
+
507
+ # ensure
508
+ # exit
509
+ =end
510
+ # rubocop:enable Style/BlockComments
511
+
512
+ break unless false # rubocop:disable Lint/LiteralAsCondition
513
+ end # loop
514
+ end # run
515
+ end # class MarkParse
530
516
 
531
- break unless false # rubocop:disable Lint/LiteralAsCondition
532
- end
533
- end
534
517
  # rubocop:enable Metrics/BlockLength
535
518
  # rubocop:enable Style/GlobalVars
536
- end
519
+ end # module MarkdownExec
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdown_exec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fareed Stevenson