Class: Rambo::CLI
- Inherits:
-
Object
- Object
- Rambo::CLI
- Defined in:
- lib/cli.rb
Instance Method Summary collapse
-
#initialize(raml_file = nil, opts = {}, stdout = STDOUT, stderr = STDERR) ⇒ CLI
constructor
A new instance of CLI.
- #run! ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(raml_file = nil, opts = {}, stdout = STDOUT, stderr = STDERR) ⇒ CLI
Returns a new instance of CLI.
6 7 8 9 10 11 12 13 |
# File 'lib/cli.rb', line 6 def initialize(raml_file=nil, opts={}, stdout=STDOUT, stderr=STDERR) @stdout = stdout @stderr = stderr @file = raml_file = opts validate! end |
Instance Method Details
#run! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cli.rb', line 15 def run! print_logo begin Rambo.generate_contract_tests!(file, ) stdout.puts("Generating contract tests...") sleep 0.4 stdout.puts("Done!".green) rescue NoMethodError => e stderr.puts("Error: #{e.message}".red) stderr.puts "\t#{e.backtrace.join("\n\t")}" end end |
#validate! ⇒ Object
31 32 33 34 |
# File 'lib/cli.rb', line 31 def validate! exit_for_missing_file unless file exit_for_invalid_file_format unless file.match(/\.raml$/) end |