Class: Transpec::CLI
- Inherits:
-
Object
- Object
- Transpec::CLI
- Defined in:
- lib/transpec/cli.rb,
lib/transpec/cli/option_parser.rb
Defined Under Namespace
Classes: OptionParser
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
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/transpec/cli.rb', line 83 def convert_spec(spec, spec_suite) puts "Converting #{spec.path}" converter = Converter.new(spec_suite, config) 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
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/transpec/cli.rb', line 51 def process(paths) unless config.skip_dynamic_analysis? runtime_data = run_dynamic_analysis(paths) end spec_suite = SpecSuite.new(project, 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 end |
#run(args) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/transpec/cli.rb', line 28 def run(args) begin paths = OptionParser.new(config).parse(args) validate_project! rescue => error warn error. return false end begin process(paths) rescue DynamicAnalyzer::AnalysisError => error warn "\n" + error..color(:red) return false end display_summary display_final_guide true end |
#run_dynamic_analysis(paths) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/transpec/cli.rb', line 68 def run_dynamic_analysis(paths) runtime_data = nil puts 'Copying the project for dynamic analysis...' DynamicAnalyzer.new(project: project, 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 end |