Class: Transpec::CLI
- Inherits:
-
Object
- Object
- Transpec::CLI
- Defined in:
- lib/transpec/cli.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#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_spec(spec, spec_suite) ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #process(paths) ⇒ Object
- #run(args) ⇒ Object
- #run_dynamic_analysis(paths) ⇒ Object
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
16 17 18 |
# File 'lib/transpec/cli.rb', line 16 def config @config 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_spec(spec, spec_suite) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/transpec/cli.rb', line 85 def convert_spec(spec, spec_suite) puts "Converting #{spec.path}" converter = Converter.new(spec_suite, config, project.rspec_version) converter.convert_file!(spec) warn_annotations(converter.report) report << converter.report rescue Parser::SyntaxError, EncodingError => error warn_file_error(error, spec.path) report.file_errors << error end |
#process(paths) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/transpec/cli.rb', line 47 def process(paths) unless config.skip_dynamic_analysis? runtime_data = run_dynamic_analysis(paths) return false unless runtime_data end spec_suite = SpecSuite.new(paths, runtime_data) # Actually #analyze does not need to be invoked here, but doing this will avoid long freeze # while conversion of files. puts 'Gathering the spec suite data...' spec_suite.analyze puts spec_suite.specs.each do |spec| convert_spec(spec, spec_suite) end true end |
#run(args) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/transpec/cli.rb', line 28 def run(args) begin paths = OptionParser.new(config).parse(args) fail_if_should_not_continue! rescue => error warn error. return false end done = process(paths) return false unless done display_summary display_final_guide true end |
#run_dynamic_analysis(paths) ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/transpec/cli.rb', line 67 def run_dynamic_analysis(paths) runtime_data = nil puts 'Copying the project for dynamic analysis...' DynamicAnalyzer.new(rspec_command: config.rspec_command) do |analyzer| puts "Running dynamic analysis with command #{analyzer.rspec_command.inspect}..." runtime_data = analyzer.analyze(paths) end puts runtime_data rescue DynamicAnalyzer::AnalysisError => error warn "\n" + error..color(:red) return nil end |