Sha256: 21a7462f2e3000799fedd48b07e75b9c1faabbf47cb0bda4766e6aa7fdd87d02

Contents?: true

Size: 1.27 KB

Versions: 7395

Compression:

Stored size: 1.27 KB

Contents

RSpec::Support.require_rspec_support "directory_maker"

module RSpec
  module Core
    # @private
    # Generates conventional files for an RSpec project.
    class ProjectInitializer
      attr_reader :destination, :stream, :template_path

      DOT_RSPEC_FILE = '.rspec'
      SPEC_HELPER_FILE =  'spec/spec_helper.rb'

      def initialize(opts={})
        @destination = opts.fetch(:destination, Dir.getwd)
        @stream = opts.fetch(:report_stream, $stdout)
        @template_path = opts.fetch(:template_path) do
          File.expand_path("../project_initializer", __FILE__)
        end
      end

      def run
        copy_template DOT_RSPEC_FILE
        copy_template SPEC_HELPER_FILE
      end

    private

      def copy_template(file)
        destination_file = File.join(destination, file)
        return report_exists(file) if File.exist?(destination_file)

        report_creating(file)
        RSpec::Support::DirectoryMaker.mkdir_p(File.dirname(destination_file))
        File.open(destination_file, 'w') do |f|
          f.write File.read(File.join(template_path, file))
        end
      end

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

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

Version data entries

7,395 entries across 7,312 versions & 129 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_organization_ruby-0.123.162 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_id_ruby-0.123.162 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_id_ruby-0.123.161 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_organization_ruby-0.123.161 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_organization_ruby-0.123.160 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_id_ruby-0.123.160 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_organization_ruby-0.123.159 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_id_ruby-0.123.159 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_id_ruby-0.123.158 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_organization_ruby-0.123.158 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_id_ruby-0.123.157 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_organization_ruby-0.123.157 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_organization_ruby-0.123.156 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_id_ruby-0.123.156 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
messente_api-2.3.0 vendor/bundle/ruby/3.4.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_bank_ruby-0.123.153 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_id_ruby-0.123.153 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb
cybrid_api_organization_ruby-0.123.153 vendor/bundle/ruby/3.3.0/gems/rspec-core-3.13.2/lib/rspec/core/project_initializer.rb