123456789_123456789_123456789_123456789_123456789_

Class: RSpec::Core::ProjectInitializer Private

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: rspec-core/lib/rspec/core/project_initializer.rb

Overview

Generates conventional files for an ::RSpec project.

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#destination (readonly)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/project_initializer.rb', line 8

attr_reader :destination, :stream, :template_path

#stream (readonly)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/project_initializer.rb', line 8

attr_reader :destination, :stream, :template_path

#template_path (readonly)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/project_initializer.rb', line 8

attr_reader :destination, :stream, :template_path

Instance Method Details

#copy_template(file) (private)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/project_initializer.rb', line 28

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

#report_creating(file) (private)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/project_initializer.rb', line 43

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

#report_exists(file) (private)

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/project_initializer.rb', line 39

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

#run

[ GitHub ]

  
# File 'rspec-core/lib/rspec/core/project_initializer.rb', line 21

def run
  copy_template DOT_RSPEC_FILE
  copy_template SPEC_HELPER_FILE
end