Sha256: d63baacf8ea0deccc43f16e9df228db549712c006224ca16bd1c9f3a5f501e3f

Contents?: true

Size: 1010 Bytes

Versions: 41

Compression:

Stored size: 1010 Bytes

Contents

# frozen_string_literal: true

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.exist?(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

41 entries across 41 versions & 4 rubygems

Version Path
cucumber-9.2.1 lib/cucumber/project_initializer.rb
cucumber-9.2.0 lib/cucumber/project_initializer.rb
cucumber-9.1.2 lib/cucumber/project_initializer.rb
cucumber-9.1.1 lib/cucumber/project_initializer.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/cucumber-9.1.0/lib/cucumber/project_initializer.rb
cucumber-9.1.0 lib/cucumber/project_initializer.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/cucumber-9.0.2/lib/cucumber/project_initializer.rb
cucumber-9.0.2 lib/cucumber/project_initializer.rb
cucumber-9.0.1 lib/cucumber/project_initializer.rb
cucumber-9.0.0 lib/cucumber/project_initializer.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/project_initializer.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/project_initializer.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/project_initializer.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-8.0.0/lib/cucumber/project_initializer.rb
cucumber-8.0.0 lib/cucumber/project_initializer.rb
cucumber-8.0.0.rc.1 lib/cucumber/project_initializer.rb
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/cucumber-7.1.0/lib/cucumber/project_initializer.rb
cucumber-7.1.0 lib/cucumber/project_initializer.rb
cucumber-7.0.0 lib/cucumber/project_initializer.rb
cucumber-6.1.0 lib/cucumber/project_initializer.rb