Class: CodeigniterScaffold::Command::Scaffold

Inherits:
Object
  • Object
show all
Defined in:
lib/codeigniter_scaffold/command/scaffold.rb

Constant Summary collapse

ARGS_ARE_NEEDED =
"Some arguments are needed, please, try again."
ARGS_WRONG =
"Something goes wrong! Aborting."

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



5
6
7
# File 'lib/codeigniter_scaffold/command/scaffold.rb', line 5

def attributes
  @attributes
end

#modelObject

Returns the value of attribute model.



5
6
7
# File 'lib/codeigniter_scaffold/command/scaffold.rb', line 5

def model
  @model
end

Instance Method Details

#run(args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/codeigniter_scaffold/command/scaffold.rb', line 10

def run(args)
  begin
    return Kernel.puts(ARGS_ARE_NEEDED) unless valid?(args)
    parse(args)

    create("controller.php","application/controllers/#{@model.capitalize}.php")
    create("model.php","application/models/#{@model.capitalize}_model.php")
    create("migration.sql","application/migrations/create_#{@model.downcase}.sql")
    mkdir ("application/views/#{@model.downcase}")
    create("view_create.php","application/views/#{@model.downcase}/create.php")
    create("view_index.php","application/views/#{@model.downcase}/index.php")
  rescue
    return Kernel.puts(ARGS_WRONG)
  end
end