I wanted to create a generator that created files (and directories, etc.) based on existing files in the application (for example, views or controllers). So, if we had ideas like this
-app
-views
- layouts
- application.html.erb
- users
- index.html.erb
- show.html.erb
- etc ...
and I wanted to create files based on them that I can make (only with ruby)
directories = Dir.entries("#{Rails.root}/app/views")
directories.each do |directory|
unless directory == "." or directory == ".."
files = Dir.entries("#{Rails.root}/app/views/#{directory}")
files.each do |file|
unless file == "." or file == ".."
text = File.read("#{Rails.root}/app/views/#{directory}/#{file}")
something
something else
end
end
end
end
so this is basically what I would like to do with the generator so that I can roll my code into a plugin and use it for other applications.
, ( .) , , / ? , , ( ).
, // "initialize content" create_file - . init script?
, . , .