Class: Rambo::DocumentGenerator
- Inherits:
-
Object
- Object
- Rambo::DocumentGenerator
- Defined in:
- lib/rambo/document_generator.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#options ⇒ Object
Returns the value of attribute options.
-
#raml ⇒ Object
Returns the value of attribute raml.
Class Method Summary collapse
Instance Method Summary collapse
- #generate_examples! ⇒ Object
- #generate_matcher_dir! ⇒ Object
- #generate_matchers! ⇒ Object
- #generate_rambo_helper! ⇒ Object
- #generate_spec_dir! ⇒ Object
- #generate_spec_file! ⇒ Object
-
#initialize(file, options = {}) ⇒ DocumentGenerator
constructor
A new instance of DocumentGenerator.
Constructor Details
#initialize(file, options = {}) ⇒ DocumentGenerator
23 24 25 26 27 |
# File 'lib/rambo/document_generator.rb', line 23 def initialize(file, ={}) @file = file @raml = Raml::Parser.parse_file(file) = end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
9 10 11 |
# File 'lib/rambo/document_generator.rb', line 9 def file @file end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/rambo/document_generator.rb', line 9 def end |
#raml ⇒ Object
Returns the value of attribute raml.
9 10 11 |
# File 'lib/rambo/document_generator.rb', line 9 def raml @raml end |
Class Method Details
.generate!(file, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/rambo/document_generator.rb', line 12 def generate!(file, ={}) generator = new(file, ) generator.generate_spec_dir! generator.generate_matcher_dir! generator.generate_examples! generator.generate_spec_file! generator.generate_rambo_helper! generator.generate_matchers! end |
Instance Method Details
#generate_examples! ⇒ Object
33 34 35 |
# File 'lib/rambo/document_generator.rb', line 33 def generate_examples! FileUtils.mkdir_p("spec/support/examples") end |
#generate_matcher_dir! ⇒ Object
50 51 52 |
# File 'lib/rambo/document_generator.rb', line 50 def generate_matcher_dir! FileUtils.mkdir_p("spec/support/matchers") end |
#generate_matchers! ⇒ Object
54 55 56 57 58 59 |
# File 'lib/rambo/document_generator.rb', line 54 def generate_matchers! Rambo::RSpec::HelperFile.new( template_path: File.("../rspec/templates/matcher_file_template.erb", __FILE__), file_path: "spec/support/matchers/rambo_matchers.rb" ).generate end |
#generate_rambo_helper! ⇒ Object
43 44 45 46 47 48 |
# File 'lib/rambo/document_generator.rb', line 43 def generate_rambo_helper! Rambo::RSpec::HelperFile.new( template_path: File.("../rspec/templates/rambo_helper_file_template.erb", __FILE__), file_path: "spec/rambo_helper.rb" ).generate end |
#generate_spec_dir! ⇒ Object
29 30 31 |
# File 'lib/rambo/document_generator.rb', line 29 def generate_spec_dir! FileUtils.mkdir_p("spec/contract/output") end |
#generate_spec_file! ⇒ Object
37 38 39 40 41 |
# File 'lib/rambo/document_generator.rb', line 37 def generate_spec_file! spec_file_name = file.match(/[^\/]*\.raml$/).to_s.gsub(/\.raml$/, "_spec.rb") contents = Rambo::RSpec::SpecFile.new(raml, ).render File.write("spec/contract/#{spec_file_name}", contents) end |