class Cubic::Generator::View
View
fulfils the V in the MVC pattern. The html documents generated by the View
generator will sit in your app/views directory, waiting to be served by your application.
Public Instance Methods
design(dir, action)
click to toggle source
Creates a hash that will be used for file generation purposes
# File lib/cubic/generators/view.rb, line 12 def design(dir, action) @files << { directory: "#{Config[:root_path]}/app/views/#{dir}", path: "/app/views/#{dir}/#{action}.#{Config[:html_type]}", content: "%p Coming to you from in #{dir}/#{action}" } end
generate()
click to toggle source
# File lib/cubic/generators/view.rb, line 18 def generate @files.each do |info| mkdir_p(info[:directory]) unless Dir.exist?(info[:directory]) path = File.join(Config[:root_path], info[:path]) File.open(path, 'w') { |f| f.write(info[:content]) } end end