class RSpec::Manumit::ProjectInitializer

Constants

FEATURE_SPEC_FILE
MANUMIT_HELPER_FILE

Attributes

destination[R]
stream[R]
template_path[R]

Public Class Methods

new() click to toggle source
# File lib/rspec/manumit/project_initializer.rb, line 10
def initialize
  @destination = Dir.getwd
  @stream = $stdout
  @template_path = File.expand_path('../project_initializer', __FILE__)
end

Public Instance Methods

run() click to toggle source
# File lib/rspec/manumit/project_initializer.rb, line 16
def run
  system('rspec --init')
  copy_template MANUMIT_HELPER_FILE
  copy_template FEATURE_SPEC_FILE
end

Private Instance Methods

copy_template(file) click to toggle source
# File lib/rspec/manumit/project_initializer.rb, line 24
def copy_template(file)
  destination_file = File.join(destination, file)
  return report_exists(file) if File.exist?(destination_file)

  report_creating(file)
  FileUtils.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) click to toggle source
# File lib/rspec/manumit/project_initializer.rb, line 39
def report_creating(file)
  stream.puts "  create   #{file}"
end
report_exists(file) click to toggle source
# File lib/rspec/manumit/project_initializer.rb, line 35
def report_exists(file)
  stream.puts "   exist   #{file}"
end