Sha256: 70071362e89d503bd957a1146461ce6cae73a9a7d1cdbc0a5f9d1c124f27981f

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 GivenOption < Thor::Group
      include Thor::Actions

      argument :name, type: :string

      def self.source_root
        "#{File.dirname(__FILE__)}/templates/given"
      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/given.rb
spiker-0.1.5 lib/spiker/generators/given.rb