Class: Clash::Scaffold

Inherits:
Object
  • Object
show all
Defined in:
lib/clash/scaffold.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, options = {}) ⇒ Scaffold

Returns a new instance of Scaffold.



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/clash/scaffold.rb', line 5

def initialize(args, options = {})
  raise 'You must specify a path.' if args.empty?

  test_path = File.expand_path(args.join(" "), Dir.pwd)
  FileUtils.mkdir_p test_path
  if preserve_source_location?(test_path, options)
    abort "Conflict: #{test_path} exists and is not empty."
  end

  add_test_scaffold test_path

  puts "Clash test added to #{test_path}."
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/clash/scaffold.rb', line 3

def options
  @options
end

Instance Method Details

#add_test_scaffold(path) ⇒ Object



19
20
21
# File 'lib/clash/scaffold.rb', line 19

def add_test_scaffold(path)
  FileUtils.cp_r test_template + '/.', path
end

#test_templateObject



23
24
25
# File 'lib/clash/scaffold.rb', line 23

def test_template
  File.expand_path("../../scaffold", File.dirname(__FILE__))
end