Sha256: 19eee86a6a735e1dbd7b60cb9c2525a09b9039e9b6ee7565dcd7a48ef47afc8d

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

require 'thor'

module Begin
  class Generator < Thor::Group
    include Thor::Actions

    argument :package_name
    class_option :github_user, default: nil

    def self.source_root
      "#{File.dirname(__FILE__)}/../"
    end

    def create_package_directory
      if File.exists?(package_name) || File.directory?(package_name)
        say  'The directory #{package_name} already exists, aborting.', :red
        exit 1
      else
        empty_directory package_name
      end
    end

    def create_lib_structure
      empty_directory "#{package_name}/lib/#{package_name}"
    end

    def create_rspec_structure
      empty_directory "#{package_name}/spec/unit/lib/#{package_name}"
      empty_directory "#{package_name}/spec/integration/lib/#{package_name}"
      create_file_from_template 'spec', 'spec_helper.rb'
      create_file_from_template '.rspec'
    end

    def create_rvm_files
      create_file_from_template '.ruby-version'
      create_file_from_template '.ruby-gemset'
    end

    def create_support_files
      @ruby_version = '2.0.0'
      %w(.gitignore .rubocop.yml Gemfile Rakefile README.md .travis.yml Guardfile .blam).each do |file|
        create_file_from_template file
      end
    end

    private

    def create_file_from_template(*args)
      path = args.reduce {|base, arg| File.join(base, arg) }
      tt = File.join('templates', path) + '.tt'
      file = File.join(package_name, path)
      template tt, file, get_options
    end

    def get_options


      {ruby_version: '2.0.0'}
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
begin-1.0.1 lib/begin/generator.rb