Class: TriadCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/scaffolding/commands/triad.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ TriadCommand

Returns a new instance of TriadCommand.



4
5
6
7
8
# File 'lib/scaffolding/commands/triad.rb', line 4

def initialize(*args)
  raise "name parameter must be specified" if args.length < 1
  @name = args[0]
  @path  = Dir.pwd
end

Instance Method Details

#checkObject



10
11
12
13
14
15
16
17
18
# File 'lib/scaffolding/commands/triad.rb', line 10

def check
  raise "not a freightrain application" unless File.exist?(File.join(@path, "views"))
  raise "not a freightrain application" unless File.exist?(File.join(@path, "viewmodels"))
  raise "#{@name} view already exists"  if File.exist?(File.join(@path, "views", "#{@name}_view.rb"))
  raise "#{@name} view definition already exists" if File.exist?(File.join(@path, "views", "#{@name}_view.glade"))
  raise "#{@name} view binding file already exists" if File.exist?(File.join(@path, "views", "#{@name}_view.bnd.yml"))
  raise "#{@name} viewmodel already exists" if File.exist?(File.join(@path, "viewmodels", "#{@name}_view_model.rb"))

end

#executeObject



20
21
22
23
24
25
# File 'lib/scaffolding/commands/triad.rb', line 20

def execute
  Generator.create_stub(File.join(@path, "views", "#{@name}_view.rb"), "view", :name => @name.capitalize)
  Generator.create_stub(File.join(@path, "views", "#{@name}_view.glade"), "view_control_glade",:name => @name)
  Generator.create_stub(File.join(@path, "viewmodels", "#{@name}_view_model.rb"), "view_model", :name => @name.capitalize)
  print "#{@name} triad created\n"
end