Method: Thor::Actions#create_file
- Defined in:
- lib/thor/actions/create_file.rb
#create_file(destination, *args, &block) ⇒ Object Also known as: add_file
Create a new file relative to the destination root with the given data, which is the return value of a block or a data string.
Parameters
- destination<String>
-
the relative path to the destination root.
- data<String|NilClass>
-
the data to append to the file.
- config<Hash>
-
give :verbose => false to not log the status.
Examples
create_file "lib/fun_party.rb" do
hostname = ask("What is the virtual hostname I should use?")
"vhost.name = #{hostname}"
end
create_file "config/apache.conf", "your apache config"
22 23 24 25 26 |
# File 'lib/thor/actions/create_file.rb', line 22 def create_file(destination, *args, &block) config = args.last.is_a?(Hash) ? args.pop : {} data = args.first action CreateFile.new(self, destination, block || data.to_s, config) end |