Sha256: 9f610b91731accc408633aba90dafe303d709766d19f19d7862681cdb231979c

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require "thor/group"
require_relative "../../spiker"

module Spiker
  module Generators
    # Generates a single spike file, with supporting infrastructure.
    # For simpler spikes that don't need a ton of organization.
    class Simple < Thor::Group
      include Thor::Actions

      argument :name, type: :string

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

      def create_spike_directory
        empty_directory(name)
      end

      def create_spike_file
        opts = { name_as_class: Spiker.classify(name) }
        template("app.rb.erb", "#{name}/app.rb", opts)
      end

      def create_guard_file
        template("guardfile.rb", "#{name}/Guardfile")
      end

      def create_gem_file
        template("gemfile.rb", "#{name}/Gemfile")
      end

      def create_env_file
        template("../common/basic.env", "#{name}/.env")
      end

      def run_bundler
        inside(name) do
          run("bundle install")
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spiker-0.1.6 lib/spiker/generators/simple.rb
spiker-0.1.5 lib/spiker/generators/simple.rb