Sha256: 52f63e25e0645a8a1bd094eae2714838cb17d43a9d4b0b7cf0814d9c58aad689

Contents?: true

Size: 980 Bytes

Versions: 12

Compression:

Stored size: 980 Bytes

Contents

module Cucumber

  # Generates generic file structure for a cucumber project
  class ProjectInitializer
    def run
      create_directory('features')
      create_directory('features/step_definitions')
      create_directory('features/support')
      create_file('features/support/env.rb')
    end

    private

    def create_directory(dir_name)
      create_directory_or_file dir_name, true
    end

    def create_file(file_name)
      create_directory_or_file file_name, false
    end

    def create_directory_or_file(file_name, directory)
      file_type = if directory
                    :mkdir_p
                  else
                    :touch
                  end

      report_exists(file_name) || return if File.exists?(file_name)

      report_creating(file_name)
      FileUtils.send file_type, file_name
    end

    def report_exists(file)
      puts "   exist   #{file}"
    end

    def report_creating(file)
      puts "  create   #{file}"
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
cucumber-2.99.0 lib/cucumber/project_initializer.rb
cucumber-2.4.0 lib/cucumber/project_initializer.rb
cucumber-2.3.3 lib/cucumber/project_initializer.rb
cucumber-2.3.2 lib/cucumber/project_initializer.rb
cucumber-2.3.1 lib/cucumber/project_initializer.rb
cucumber-2.3.0 lib/cucumber/project_initializer.rb
cucumber-2.2.0 lib/cucumber/project_initializer.rb
cucumber-2.1.0 lib/cucumber/project_initializer.rb
cucumber-2.0.2 lib/cucumber/project_initializer.rb
cucumber-2.0.1 lib/cucumber/project_initializer.rb
cucumber-2.0.0 lib/cucumber/project_initializer.rb
cucumber-2.0.0.rc.5 lib/cucumber/project_initializer.rb