class Savvy::Application
Constants
- SAVVYFILE_TEMPLATE
Attributes
config[R]
savvyfile[R]
Public Class Methods
new()
click to toggle source
# File lib/savvy/application.rb, line 13 def initialize @config = Savvy.config @savvyfile = Savvy.config.root.join('Savvyfile') @config.setup! end
Public Instance Methods
run()
click to toggle source
# File lib/savvy/application.rb, line 20 def run program :name, 'savvy' program :version, Savvy::VERSION program :description, 'Savvy file generator' command :init do |c| c.syntax = 'savvy init' c.description = 'Initialize a Savvyfile' c.action do if savvyfile.exist? puts "! #{savvyfile} exists" unless agree("Do you want to overwrite? ") puts "Not overwriting" exit end end contents = savvyfile_contents puts "Writing to #{savvyfile}" savvyfile.open('w+') do |f| f.write contents end end end run! end
savvyfile_contents()
click to toggle source
# File lib/savvy/application.rb, line 52 def savvyfile_contents app_name = config.app_name = ask 'What is the name of your app? ' do |q| q.default = config.app_name end ERB.new(File.read(SAVVYFILE_TEMPLATE)).result(binding) end