Class: TestServer::Actions::CreateFile
- Inherits:
-
Object
- Object
- TestServer::Actions::CreateFile
- Defined in:
- lib/test_server/actions/create_file.rb
Instance Method Summary collapse
-
#initialize(name, destination, data, options = {}, engine = ErbGenerator, repository = TemplateRepository.new) ⇒ CreateFile
constructor
A new instance of CreateFile.
- #run ⇒ Object
Constructor Details
#initialize(name, destination, data, options = {}, engine = ErbGenerator, repository = TemplateRepository.new) ⇒ CreateFile
Returns a new instance of CreateFile.
11 12 13 14 15 16 17 18 |
# File 'lib/test_server/actions/create_file.rb', line 11 def initialize(name, destination, data, = {}, engine = ErbGenerator, repository = TemplateRepository.new) @name = name @destination =::File.(destination) @data = data = @engine = engine @repository = repository end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/test_server/actions/create_file.rb', line 20 def run if need_to_run? || [:force] == true TestServer.ui_logger.warn "Creating file \"#{destination}\"." create_directories if [:create_directories] == true file = template(name, ::File.new(destination, 'w'), data) FileUtils.chmod('+x', file) if [:executable] == true else TestServer.ui_logger.warn "File \"#{destination}\" already exists. Do not create it again!." end end |