Class: Xmvc::Generator::View

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/xmvc/generators/view.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



6
7
8
# File 'lib/xmvc/generators/view.rb', line 6

def self.source_root 
  File.join(Xmvc::TEMPLATE_PATH)
end

Instance Method Details

#generate(package, name) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/xmvc/generators/view.rb', line 11

def generate(package, name)        
  @namespace  = Extlib::Inflection.underscore(package)
  @name       = Extlib::Inflection.underscore(name)
  @filename = "app/views/#{@namespace}/#{@name}.js"
  
  unless File.exists? @filename
    Xmvc::Config.add(:views, {
      :package => @package,
      :filename  => @name
    })
  end
  template("View.js", @filename)
end