Sha256: d7a67e1c9b42f65dcf158203f26a105b8057242f492a5967e0b9b37866009c44

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

module Skellington
  class Generator
    attr_reader :path, :filename, :camelname, :files, :gems
    attr_accessor :licensor

    def initialize path
      @full_path = path
      @path = File.dirname @full_path
      @filename = File.basename(@full_path)
      @camelname = Skellington.camelise(wormname)
      @gems = config['gems']
      @files = config['files']
    end

    def config
      @config ||= YAML.load File.read File.join File.dirname(__FILE__), '..', '..', 'config/config.yaml'
    end

    def run
      if File.exist? @full_path
        $stderr.puts "Path '#{@full_path}' already exists. Quitting"
        exit 1
      end

      generate
      git_init
      post_run
    end

    def generate
      @files.each do |k, v|
        t = Template.new k, self
        t.write
      end
    end

    def wormname
      @filename.gsub('-', '_')
    end

    def renamed
      @filename != wormname
    end

    def git_init
      Git.init wormname
    end

    def post_run
      t = Template.new 'post-run', self
      puts t.to_s
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
skellington-0.7.5 lib/skellington/generator.rb
skellington-0.7.4 lib/skellington/generator.rb