root/app_generators/vintage_application/vintage_application_generator.rb

Revision 1, 2.0 kB (checked in by jeremymcanal..@gmail.com, 9 months ago)

--

Line 
1 class VintageApplicationGenerator < RubiGen::Base
2  
3   DEFAULT_SHEBANG = File.join(Config::CONFIG['bindir'],
4                               Config::CONFIG['ruby_install_name'])
5  
6   default_options :author => nil
7  
8   attr_reader :name
9  
10   def initialize(runtime_args, runtime_options = {})
11     super
12     usage if args.empty?
13     @destination_root = File.expand_path(args.shift)
14     @name = base_name
15     extract_options
16   end
17
18   def manifest
19     record do |m|
20       # Ensure appropriate folder(s) exists
21       m.directory ''
22       BASEDIRS.each { |path| m.directory path }
23
24       m.file "configuration.yml", "configuration.yml"
25       m.file "README", "README"
26       m.file "index.erb", "app/index.erb"
27       m.file "vintage.png", "static/vintage.png"
28       m.file "style.css", "static/style.css"
29      
30       # m.dependency "install_rubigen_scripts", [destination_root, 'vintage_application'],
31       #   :shebang => options[:shebang], :collision => :force
32     end
33   end
34
35   protected
36     def banner
37       <<-EOS
38 Creates a ...
39
40 USAGE: #{spec.name} name"
41 EOS
42     end
43
44     def add_options!(opts)
45       opts.separator ''
46       opts.separator 'Options:'
47       # For each option below, place the default
48       # at the top of the file next to "default_options"
49       # opts.on("-a", "--author=\"Your Name\"", String,
50       #         "Some comment about this option",
51       #         "Default: none") { |options[:author]| }
52       opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
53     end
54    
55     def extract_options
56       # for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
57       # Templates can access these value via the attr_reader-generated methods, but not the
58       # raw instance variable value.
59       # @author = options[:author]
60     end
61
62     # Installation skeleton.  Intermediate directories are automatically
63     # created so don't sweat their absence here.
64     BASEDIRS = %w(
65       app
66       static
67       helpers
68       test
69       tmp
70     )
71 end
Note: See TracBrowser for help on using the browser.