Class: Transpec::CLI
- Inherits:
-
Object
- Object
- Transpec::CLI
- Defined in:
- lib/transpec/cli.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Class Method Summary collapse
Instance Method Summary collapse
- #convert_file(file_path, runtime_data = nil) ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #process(paths) ⇒ Object
- #run(args) ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
20 21 22 23 |
# File 'lib/transpec/cli.rb', line 20 def initialize @configuration = Configuration.new @report = Report.new end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
14 15 16 |
# File 'lib/transpec/cli.rb', line 14 def configuration @configuration end |
Class Method Details
.run(args = ARGV) ⇒ Object
16 17 18 |
# File 'lib/transpec/cli.rb', line 16 def self.run(args = ARGV) new.run(args) end |
Instance Method Details
#convert_file(file_path, runtime_data = nil) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/transpec/cli.rb', line 60 def convert_file(file_path, runtime_data = nil) puts "Converting #{file_path}" converter = Converter.new(@configuration, runtime_data, @report) converter.convert_file!(file_path) @report.invalid_context_errors.concat(converter.invalid_context_errors) converter.invalid_context_errors.each do |error| warn_invalid_context_error(error) end rescue Parser::SyntaxError => error @report.syntax_errors << error warn_syntax_error(error) end |
#process(paths) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/transpec/cli.rb', line 43 def process(paths) runtime_data = nil unless @configuration.skip_dynamic_analysis? puts 'Copying project for dynamic analysis...' DynamicAnalyzer.new(rspec_command: @configuration.rspec_command) do |analyzer| puts "Running dynamic analysis with command \"#{analyzer.rspec_command}\"..." runtime_data = analyzer.analyze(paths) end puts end FileFinder.find(paths).each do |file_path| convert_file(file_path, runtime_data) end end |
#run(args) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/transpec/cli.rb', line 25 def run(args) begin paths = OptionParser.new(@configuration).parse(args) fail_if_should_not_continue! rescue => error warn error. return false end process(paths) display_summary if @configuration. display_final_guide true end |