Sha256: 15e271bd334de793ab3859fe81d8f3d2a7634ba09779eb75af305bdf8baaedcd

Contents?: true

Size: 1.57 KB

Versions: 8

Compression:

Stored size: 1.57 KB

Contents

module MakeItSo
  class GosuAppGenerator < Thor::Group
    include Thor::Actions

    desc "Creates a new Gosu game"
    argument :name,
      type: :string,
      desc: "The name of the new application"

    class_option :rspec,
      type: :boolean,
      default: true,
      desc: 'install rspec'

    def directories
      [
        'lib',
        'spec',
        'img'
      ].each do |dir|
        empty_directory File.join(app_path, dir)
      end
    end

    def app_file
      file_path = 'app.rb'
      template(file_path, File.join(app_path, file_path))
    end

    def readme
      inside app_path do
        create_file "README.md", "# README\n\n"
      end
    end

    def lib
      [
        'lib/keys.rb',
        'lib/bounding_box.rb'
      ].each do |file_path|
        template(file_path, File.join(app_path, file_path))
      end
    end

    def gemfile
      file_path = 'Gemfile'
      template(file_path, File.join(app_path, file_path))
    end

    def gitignore
      file_path = '.gitignore'
      template(file_path, File.join(app_path, file_path))
    end

    def rspec
      if options.rspec?
        spec_helper = 'spec/spec_helper.rb'
        template(spec_helper, File.join(app_path, spec_helper))

        dot_rspec = '.rspec'
        template(dot_rspec, File.join(app_path, dot_rspec))
      end
    end

    def self.source_root
      template_path = File.join(
        File.dirname(__FILE__),
        "..",
        "..",
        "templates",
        "gosu")

      File.expand_path(template_path)
    end

    protected
    def app_path
      name
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
make_it_so-0.6.0 lib/generators/gosu_app_generator.rb
make_it_so-0.5.1 lib/generators/gosu_app_generator.rb
make_it_so-0.5.0 lib/generators/gosu_app_generator.rb
make_it_so-0.4.5 lib/generators/gosu_app_generator.rb
make_it_so-0.4.3 lib/generators/gosu_app_generator.rb
make_it_so-0.4.2 lib/generators/gosu_app_generator.rb
make_it_so-0.4.1 lib/generators/gosu_app_generator.rb
make_it_so-0.4.0 lib/generators/gosu_app_generator.rb