class Template
Class for template and boilerplate files
Constants
- PROJECT_TEMPLATE
Attributes
name[RW]
test_type[R]
Public Class Methods
new(name, type)
click to toggle source
# File lib/opening_act/template.rb, line 8 def initialize(name, type) @name = name @test_type = type[1..-1] end
Public Instance Methods
create()
click to toggle source
# File lib/opening_act/template.rb, line 13 def create FileUtils.copy_entry PROJECT_TEMPLATE, name end
initiate_project()
click to toggle source
# File lib/opening_act/template.rb, line 17 def initiate_project Dir.chdir name do `git init` `gem install bundler` `bundle install` end end
remove_extra_files()
click to toggle source
# File lib/opening_act/template.rb, line 38 def remove_extra_files other_test_type = test_type == 'rspec' ? 'test' : 'spec' FileUtils.rm_rf("#{name}/#{other_test_type}") FileUtils.rm Dir.glob("#{name}/*_#{other_test_type}") end
rename_files()
click to toggle source
# File lib/opening_act/template.rb, line 25 def rename_files File.rename("#{name}/new_app.rb", "#{name}/#{name}.rb") case test_type when 'minitest' File.rename("#{name}/test/new_app_test.rb", "#{name}/test/#{name}_test.rb") when 'rspec' File.rename("#{name}/spec/new_app_spec.rb", "#{name}/spec/#{name}_spec.rb") end remove_test_suffix end
Private Instance Methods
remove_test_suffix()
click to toggle source
# File lib/opening_act/template.rb, line 47 def remove_test_suffix Dir.glob("#{name}/*_*").each do |file| File.rename(file, file[0..-6]) end end