Class: Docwright::Generators::FeatureGenerator
- Inherits:
-
Object
- Object
- Docwright::Generators::FeatureGenerator
- Defined in:
- lib/docwright/generators/feature_generator.rb
Constant Summary collapse
- CONFIG_FILE =
".docwright.yml"
Instance Method Summary collapse
Instance Method Details
#generate ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/docwright/generators/feature_generator.rb', line 10 def generate return unless File.exist?(CONFIG_FILE) config = YAML.load_file(CONFIG_FILE) features = config["features"] || [] return if features.empty? FileUtils.mkdir_p("docs/features") features.each do |feature| name = feature["name"] description = feature["description"] path = "docs/features/#{name}.md" if File.exist?(path) puts "DocWright: skipped #{path} (already exists)" else File.write(path, template(name, description)) puts "DocWright: wrote #{path}" end end end |
#generate_single(path, filename) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/docwright/generators/feature_generator.rb', line 33 def generate_single(path, filename) return if File.exist?(path) name = filename.gsub(".md", "") description = "<!-- Describe the feature -->" FileUtils.mkdir_p(File.dirname(path)) File.write(path, template(name, description)) end |