Class: BackRack::Generate

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Generate

Returns a new instance of Generate.



67
68
69
70
# File 'lib/backrack/generators.rb', line 67

def initialize(*args)
  raise "No Backrack app found." unless File.exists?(File.join(Pathname.new(Dir.pwd), 'scripts', 'backrack'))
  super(*args)
end

Class Method Details



63
64
65
# File 'lib/backrack/generators.rb', line 63

def self.banner(task, namespace = false, subcommand = false)
  "#{basename} generate #{task.formatted_usage(self, namespace, subcommand)}"
end

.source_rootObject



72
73
74
# File 'lib/backrack/generators.rb', line 72

def self.source_root
  File.join File.dirname(__FILE__), 'templates'
end

Instance Method Details

#collection(name) ⇒ Object



95
96
97
98
99
100
# File 'lib/backrack/generators.rb', line 95

def collection(name)
  @name   = name.camelize
  @model  = options[:model]
  @url    = options[:url]
  template "collection.js.coffee", "src/javascripts/collections/#{name}.js.coffee"
end

#model(name) ⇒ Object



87
88
89
90
# File 'lib/backrack/generators.rb', line 87

def model(name)
  @name = name.camelize
  template "model.js.coffee", "src/javascripts/models/#{name}.js.coffee"
end

#view(name) ⇒ Object



78
79
80
81
82
83
84
# File 'lib/backrack/generators.rb', line 78

def view(name)
  @name = name
  @body = options[:body]
  @camelized_name = name.camelize
  template "view.js.coffee", "src/javascripts/views/#{name}.js.coffee"
  template "view.jst.eco", "src/javascripts/templates/#{name}.jst.eco"   
end