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
Constructor Details
#initialize ⇒ CLI
22 23 24 25 26 |
# File 'lib/transpec/cli.rb', line 22 def initialize @project = Project.new @config = Config.new @report = Report.new end |
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
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/transpec/cli.rb', line 70 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 => error report.syntax_errors << error warn_syntax_error(error) end |
#process(paths) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/transpec/cli.rb', line 51 def process(paths) runtime_data = nil unless config.skip_dynamic_analysis? runtime_data = run_dynamic_analysis(paths) 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 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) fail_if_should_not_continue! rescue => error warn error. return false end begin process(paths) rescue DynamicAnalyzer::AnalysisError warn_dynamic_analysis_error return false end display_summary display_final_guide true end |