Class: Puer::Generators::Help

Inherits:
Jam
  • Object
show all
Includes:
CLIColorize, Actions, Thor::Actions
Defined in:
lib/puer/generators/help.rb

Constant Summary collapse

RENDER_OPTIONS =
{ :fields => [:category,:command,:description] }

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Actions

#apply_component_for, #ask, #check_app_existence, #destination_root, #execute_component_setup, #fetch_app_name, #fetch_component_choice, #in_app_root?, included, #invalid_fields, #resolve_valid_choice, #retrieve_component_config, #store_component_choice, #store_component_config, #valid_choice?, #valid_constant?, #which

Methods inherited from Jam

attr_rw, #create_jam, #in_app_root?, init_generator, parseTemplate

Class Method Details



21
# File 'lib/puer/generators/help.rb', line 21

def self.banner; "puer help"; end

.source_rootObject

Define the source root



20
# File 'lib/puer/generators/help.rb', line 20

def self.source_root; File.expand_path(File.dirname(__FILE__)); end

Instance Method Details

#create_helpObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/puer/generators/help.rb', line 30

def create_help
  @developer = "eiffel"
  @created_on = Date.today.to_s
  puts colorize( "Puer Version: #{Puer::Version::STRING}", { :foreground => :red, :background => :white, :config => :underline } )
  puts
  puts "Puer is a Titanium Starter Project Generate Tool"
  puts  
  require 'yaml'
  gistfile = File.expand_path("~") + '/.puer/gist.yml'
  Gist::update_gist unless File.exist?(gistfile)          
  begin 
    g = YAML.load_file(gistfile)  
  rescue ArgumentError => e
    g = YAML.load_file(File.expand_path(File.dirname(__FILE__) + '/gist.yml'))
  end
  puts "notice: a new version '#{g['info']}' released" if g['info'] and g['info'].strip != "#{Puer::Version::STRING}"
  puts                     
  puts colorize("Generator Options")
  opt = [{ :category => "generator", :command => "puer controller controller_name", :description => "generate controller for titanium"},
         { :category => "generator", :command => "puer model model_name",   :description => "generate model for titanium"},
         { :category => "generator", :command => "puer xib",   :description => "convert xib to js"}
         ] 
  View.render(opt, RENDER_OPTIONS)
  puts                             
  g.each_pair {|key,value|
    gitopt = []   
    gname = key.downcase.gsub('_',' ')
    puts 
    if gname == 'lib'
      puts colorize("Framework Lib")   
    else
      puts colorize("Gist Category [#{gname}]") unless gname == 'info'  
    end 
    unless gname == 'info'       
      g[key].each { |k|
        k.each_pair { |k1,v1|
          if gname == 'lib'
            gitopt << {:category => "#{key.gsub('_',' ')}", :command => "puer lib #{k1}",   :description => "#{k[k1][2]['description']}" }
          else
            gitopt << {:category => "#{key.gsub('_',' ')}", :command => "puer gist #{k1}",   :description => "#{k[k1][2]['description']}" }
          end
        }
      }
    end
    View.render(gitopt, RENDER_OPTIONS) unless gname == 'info' 
  }          
  puts  
end