Class: Cornichon::Writer
- Inherits:
-
Object
- Object
- Cornichon::Writer
- Defined in:
- lib/cornichon/writer.rb
Class Method Summary collapse
Class Method Details
.parse_template(template_file) ⇒ Object
35 36 37 38 |
# File 'lib/cornichon/writer.rb', line 35 def parse_template(template_file) raw_template = IO.read(template_file) Parser.parse(raw_template) end |
.templates ⇒ Object
28 29 30 31 32 33 |
# File 'lib/cornichon/writer.rb', line 28 def templates @templates ||= Proc.new { full_path = File.join(Dir.pwd, Config.relative_template_path) Dir.glob("#{full_path}/*.cornichon") }.call end |
.write!(opts = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/cornichon/writer.rb', line 8 def write!(opts = {}) $verbose = opts[:verbose] if $verbose puts "SETUP: templates at #{Config.relative_template_path}" puts "SETUP: presenters at #{Config.relative_presenter_path}" puts "SETUP: features written to #{Config.relative_feature_path}\n" end require_presenter_methods create_feature_dir templates.each { |template| template_name = File.basename(template, ".cornichon") feature_path = File.join(Dir.pwd, Config.relative_feature_path, "#{template_name}.feature") raw_feature = parse_template(template) IO.write(feature_path, raw_feature) puts "written #{feature_path}" if $verbose } end |