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.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#report ⇒ Object
readonly
Returns the value of attribute report.
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
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
16 17 18 |
# File 'lib/transpec/cli.rb', line 16 def configuration @configuration end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
16 17 18 |
# File 'lib/transpec/cli.rb', line 16 def project @project end |
#report ⇒ Object (readonly)
Returns the value of attribute report.
16 17 18 |
# File 'lib/transpec/cli.rb', line 16 def report @report end |
Class Method Details
.run(args = ARGV) ⇒ Object
18 19 20 |
# File 'lib/transpec/cli.rb', line 18 def self.run(args = ARGV) new.run(args) end |
Instance Method Details
#convert_file(file_path, runtime_data = nil) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/transpec/cli.rb', line 63 def convert_file(file_path, runtime_data = nil) puts "Converting #{file_path}" converter = Converter.new(@configuration, @project.rspec_version, runtime_data, @report) converter.convert_file!(file_path) @report.context_errors.concat(converter.context_errors) converter.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
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/transpec/cli.rb', line 46 def process(paths) runtime_data = nil unless @configuration.skip_dynamic_analysis? puts 'Copying the project for dynamic analysis...' DynamicAnalyzer.new(rspec_command: @configuration.rspec_command) do |analyzer| puts "Running dynamic analysis with command #{analyzer.rspec_command.inspect}..." 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
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/transpec/cli.rb', line 28 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 display_final_guide true end |