Class: Clash::Scaffold
- Inherits:
-
Object
- Object
- Clash::Scaffold
- Defined in:
- lib/clash/scaffold.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #add_test ⇒ Object
-
#initialize(options = {}) ⇒ Scaffold
constructor
A new instance of Scaffold.
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 = { path: 'test', title: 'Test Build', dir: 'test-site', force: false }.merge() @options[:path] = File.(@options[:path], Dir.pwd) end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/clash/scaffold.rb', line 3 def @options end |
Instance Method Details
#add_test ⇒ Object
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 |