Sha256: b8fd4dfeb0f77882c34dc68da425c6b7d5d44447eec8172e7363ebf40d22c931

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

require 'thor'

module Shuhari
  module ProjectGeneration
    include Thor::Actions
    include PlatformGems

    protected

    def create_project
      template 'Gemfile.tt'
      copy_file 'Guardfile'
      setup_code
      template 'shuhari.yml.tt'
      template '.rvmrc.tt' if gemset
    end

    def setup_code
      inside('lib') { template 'kata.rb.tt', "#{snake_name}.rb" }
      inside(test_directory) { send :"setup_#{framework}" }
    end

    def setup_rspec
      template 'spec_helper.rb.tt'
      template 'kata_spec.rb.tt', "#{snake_name}_spec.rb"
    end

    def setup_minitest
      template 'test_helper.rb.tt'
      template 'test_kata.rb.tt', "test_#{snake_name}.rb"
    end

    alias_method :setup_minitest_spec, :setup_rspec

    def setup_testunit
      template 'test_helper.rb.tt'
      template 'kata_test.rb.tt', "#{snake_name}_test.rb"
    end

    def setup_cucumber
      inside('support') { template 'env.rb.tt' }
      directory 'step_definitions'
      template 'kata.feature.tt', "#{snake_name}.feature"
    end

    def clean_project
      ['lib', test_directory].each { |dir| remove_dir dir }
    end

    def test_directory
      case framework
      when 'rspec', 'minitest_spec' then 'spec'
      when 'cucumber' then 'features'
      else 'test'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shuhari-0.1.1 lib/shuhari/project_generation.rb
shuhari-0.1.0 lib/shuhari/project_generation.rb