console_runner 0.1.20 → 0.1.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c79e1d20d6a2c13058ab7bfc7392db15f0fa18f
4
- data.tar.gz: 4c1d9bf3a7426c484acf0278241b65e61f5281b1
3
+ metadata.gz: ada21ff65dc0e2c0a9b1507be918b6f106136c18
4
+ data.tar.gz: 9296ab89bdb38ef21b3d93224c8cc940e31a0f20
5
5
  SHA512:
6
- metadata.gz: 79b5f19ec17a3948780cece0cd4498f87e20c1286acc5df491b06550b130a57fec3497d5c2708a84aec0fe05a77b70ab3480b55f533b8332fd3bd94e57700d4f
7
- data.tar.gz: 9c691933f59ff3b88dd7b953e74f77343224c6798c89eec1b52235e002c3da12c0f3617ec8527afe2d07012b02cae1ee305e33f10848cb4638b7f78b44f8b338
6
+ metadata.gz: 0899daa95e9d73083b7880314a3fa2fb144e7efc597a19aa72a376c5a388e0c8729958d2d96b904f53d8fd9d5917be2466267c9f67a0eb9e981adb56c5103602
7
+ data.tar.gz: ae4e372b0dce5c371c0ee213fb69fcd1feb587fce471790af879e3a60044edd1dc9b9ec884609a004faa6ca788d60d9cf15047d3159335ec8e09d3076b2b3dca
@@ -19,6 +19,7 @@ class CommandLineParser
19
19
  ]
20
20
  end.to_h
21
21
  @parser = Trollop::Parser.new
22
+ @parser.opt(:debug, 'Run in debug mode.', type: :flag)
22
23
  @parser.stop_on @sub_commands
23
24
  @initialize_method = nil
24
25
  end
@@ -28,7 +29,7 @@ class CommandLineParser
28
29
  end
29
30
 
30
31
  def self.debug=(value)
31
- @debug=value
32
+ @debug = value unless @debug
32
33
  end
33
34
 
34
35
  def tool_banner
@@ -66,7 +67,6 @@ class CommandLineParser
66
67
  raise_on_action_absence @sub_commands
67
68
  @initialize_method ||= MethodParser.new(@file_parser.initialize_method) if @file_parser.initialize_method
68
69
  @method = MethodParser.new action
69
- @parser.opt(:debug, 'Run in debug mode.', type: :flag)
70
70
  [@initialize_method, @method].each do |method|
71
71
  next unless method
72
72
  method.trollop_opts.each { |a| @parser.opt(*a) }
@@ -86,5 +86,4 @@ class CommandLineParser
86
86
  end
87
87
  end
88
88
 
89
- end
90
-
89
+ end
@@ -13,10 +13,12 @@ Start Time: #{start_time}".blue
13
13
 
14
14
  file_from_arg = ARGV.shift
15
15
  raise ConsoleRunnerError, 'Specify file to be executed' unless file_from_arg
16
- file_path = File.realpath file_from_arg
17
- file_parser = FileParser.new(file_path)
18
- cmd = ARGV[0]
19
- actions = file_parser.runnable_methods.select { |m| m.name.to_s == cmd }
16
+ file_path = File.realpath file_from_arg
17
+ file_parser = FileParser.new(file_path)
18
+ next_arguments = ARGV.dup
19
+ %w(-d --debug -h --help).each { |a| next_arguments.delete a }
20
+ cmd = next_arguments[0]
21
+ actions = file_parser.runnable_methods.select { |m| m.name.to_s == cmd }
20
22
  if actions.count > 1
21
23
  raise(
22
24
  ConsoleRunnerError,
@@ -28,18 +30,17 @@ Start Time: #{start_time}".blue
28
30
  c_line_parser = CommandLineParser.new(file_parser)
29
31
  c_line_parser.run(action)
30
32
 
31
- debug_message = "#{SEPARATOR}\n"
33
+ debug_message = SEPARATOR
32
34
  if c_line_parser.initialize_method
33
- debug_message += ":initialize method:\n"
35
+ debug_message += "\ninitialize method execution\n"
34
36
  debug_message += c_line_parser.initialize_method.cmd_opts.map { |k, v| " #{k} = #{v}" }.join("\n")
35
37
  end
36
- debug_message += "#{action.name} method:\n"
38
+ debug_message += "\n#{action.name} method execution\n"
37
39
  debug_message += c_line_parser.method.cmd_opts.map { |k, v| " #{k} = #{v}" }.join("\n")
38
- debug_message += "Remaining arguments: #{ARGV.inspect}" if ARGV != []
39
- debug_message += SEPARATOR
40
+ debug_message += "\nRemaining arguments: #{ARGV.inspect}" if ARGV != []
41
+ debug_message += "\n#{SEPARATOR}"
40
42
  puts debug_message if CommandLineParser.debug?
41
43
 
42
-
43
44
  require file_path
44
45
  class_full_name = file_parser.clazz.title
45
46
  raise ConsoleRunnerError, "#{class_full_name} is not defined" unless Module.const_defined?(class_full_name)
@@ -1,3 +1,3 @@
1
1
  module ConsoleRunner
2
- VERSION = '0.1.20'
2
+ VERSION = '0.1.21'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: console_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Karpovich