Sha256: 7e53d82ab9851580d3bf794f34e511079a1da623531dcee71e9f82b4c397acda
Contents?: true
Size: 1.81 KB
Versions: 4
Compression:
Stored size: 1.81 KB
Contents
# encoding: utf-8 require 'generators/generators' require 'fileutils' require 'dslable_dsl' require 'erb' module Dslable::Generators # =Dslable::Generators Gem Template Generator class Workflow # ==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 file definitions TUDU_FILES = { todos: { file_name: 'tudu/todos', contents: TODOS_CONTENTS }, doings: { file_name: 'tudu/doings', contents: DOINGS_CONTENTS }, dones: { file_name: 'tudu/dones', contents: '' }, } attr_accessor :dsl # == initialize generate gem template # === Params #- _dsl: input from dsl def initialize(_dsl) fail InvalidDslError.new('dsl not allow nil') if _dsl.nil? @dsl = _dsl end # == generate gem template 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 def adapt_template(gem_name, bin_name, template) erb = ERB.new(template) erb.result(binding) end end class InvalidDslError < StandardError; end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
dslable-0.0.6 | lib/generators/workflow.rb |
dslable-0.0.5 | lib/generators/workflow.rb |
dslable-0.0.4 | lib/generators/workflow.rb |
dslable-0.0.3 | lib/generators/workflow.rb |