Class: Dslable::Generators::Workflow

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/workflow.rb

Overview

Dslable::Generators Gem Template Generator

Constant Summary collapse

TODOS_CONTENTS =

todos contents

<<-EOS
implement '<%=gem_name%>_core.rb' your main logic. pass rspec all specs.
implement bin 'bin/<%=bin_name%>'.
edit '<%=gem_name%>.gemspec'.
edit 'README.md'.
edit 'LICENSE.txt'.
git add, commit.
rake install.
check gem(test using).
gem uninstall <%=gem_name%>.
rake release.
gem install <%=gem_name%>.
after release check.
EOS
DOINGS_CONTENTS =

doings contents

<<-EOS
implement '<%=gem_name%>_core_spec.rb'.
EOS
TUDU_FILES =

tudu file definitions

{
  todos: {
    file_name: 'tudu/todos',
    contents: TODOS_CONTENTS
  },
  doings: {
    file_name: 'tudu/doings',
    contents: DOINGS_CONTENTS
  },
  dones: {
    file_name: 'tudu/dones',
    contents: ''
  },
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_dsl) ⇒ Workflow

initialize generate gem template

Params

  • _dsl: input from dsl



51
52
53
54
# File 'lib/generators/workflow.rb', line 51

def initialize(_dsl)
  fail InvalidDslError.new('dsl not allow nil') if _dsl.nil?
  @dsl = _dsl
end

Instance Attribute Details

#dslObject

Returns the value of attribute dsl.



46
47
48
# File 'lib/generators/workflow.rb', line 46

def dsl
  @dsl
end

Instance Method Details

#generateObject

generate gem template



57
58
59
60
61
62
63
64
65
66
# 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