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(options = {}) ⇒ Scaffold

Returns a new instance of Scaffold.



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

def initialize(options = {})
  @options = {
    path: 'test',
    title: 'Test Build',
    dir: 'test-site',
    force: false
  }.merge(options)

  @options[:path] = File.expand_path(@options[:path], Dir.pwd)
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_testObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/clash/scaffold.rb', line 16

def add_test
  config = File.join(@options[:path], '_clash.yml')

  prevent_dir_name_collisions
  content = test_content

  if !File.exist?(config)
    content.lstrip!
  end

  path = File.join(@options[:path], @options[:dir])

  FileUtils.mkdir_p path
  FileUtils.cp_r test_template + '/.', path


  File.open(config, 'a') do |f|
    f.write content
  end
  
  puts "New Clash test added to " + @options[:path].yellow
  print_test_files(path)
  puts "Tests:"
end