class Dslable::Generators::Workflow

Dslable::Generators Gem Template Generator

Constants

DOINGS_CONTENTS

doings contents

TODOS_CONTENTS

todos contents

TUDU_FILES

tudu file definitions

Attributes

dsl[RW]

Public Class Methods

new(_dsl) click to toggle source
== initialize generate gem template
=== Params
  • _dsl: input from dsl

# File lib/generators/workflow.rb, line 51
def initialize(_dsl)
  fail InvalidDslError.new('dsl not allow nil') if _dsl.nil?
  @dsl = _dsl
end

Public Instance Methods

generate() click to toggle source

generate gem template

# File lib/generators/workflow.rb, line 57
def generate
  Dir.mkdir('tudu')
  gem_name = @dsl._gem_name
  bin_name = @dsl._bin_name
  TUDU_FILES.each do |key, file_definition|
    File.open("./#{file_definition[:file_name]}", 'w') do |f|
      f.print adapt_template(gem_name, bin_name, file_definition[:contents])
    end
  end
end

Private Instance Methods

adapt_template(gem_name, bin_name, template) click to toggle source
# File lib/generators/workflow.rb, line 70
def adapt_template(gem_name, bin_name, template)
  erb = ERB.new(template)
  erb.result(binding)
end