Class: Jazz::Generators::Scaffold

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



6
7
8
# File 'lib/jazz/generators/scaffold/scaffold.rb', line 6

def attributes
  @attributes
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/jazz/generators/scaffold/scaffold.rb', line 6

def name
  @name
end

Class Method Details

.source_rootObject



8
9
10
# File 'lib/jazz/generators/scaffold/scaffold.rb', line 8

def self.source_root
  File.join(File.dirname(__FILE__))
end

Instance Method Details

#convert_attributesObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/jazz/generators/scaffold/scaffold.rb', line 44

def convert_attributes
  @attribute_hash = Hash.new
  
  attributes.each do |attribute|
    val = attribute.split(':')
    if val[0] && val[1]
      @attribute_hash[val[0]] = val[1]
    end
    
  end
  
  self.attributes = {}
  self.attributes = @attribute_hash
end

#createObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/jazz/generators/scaffold/scaffold.rb', line 12

def create
  convert_attributes        
  create_model
  create_database
  create_fixture
  create_controller
  create_helper
  create_scenario
  create_views
end

#create_controllerObject



59
60
61
# File 'lib/jazz/generators/scaffold/scaffold.rb', line 59

def create_controller
  template  "templates/controller.js", "app/controllers/#{name.downcase.pluralize}_controller.js"
end

#create_databaseObject



28
29
30
# File 'lib/jazz/generators/scaffold/scaffold.rb', line 28

def create_database
  template  "templates/database.js", "db/create/create_#{name.pluralize.downcase}.js"
end

#create_fixtureObject



32
33
34
# File 'lib/jazz/generators/scaffold/scaffold.rb', line 32

def create_fixture
  template  "templates/fixture.js", "db/fixtures/#{name.pluralize.downcase}.js"
end

#create_helperObject



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

def create_helper
  template  "templates/helper.js", "app/helpers/#{name.downcase.pluralize}_helper.js"
end

#create_modelObject



24
25
26
# File 'lib/jazz/generators/scaffold/scaffold.rb', line 24

def create_model
  template  "templates/model.js", "app/models/#{name.singularize.downcase}.js"
end

#create_scenarioObject



67
68
69
# File 'lib/jazz/generators/scaffold/scaffold.rb', line 67

def create_scenario
  template  "templates/scenario.js", "app/scenarios/#{name.downcase.pluralize}_scenario.js"
end

#create_viewsObject



36
37
38
39
40
41
42
# File 'lib/jazz/generators/scaffold/scaffold.rb', line 36

def create_views
  template  "templates/view_form.handlebars", "app/views/#{name.pluralize.downcase}/_form.handlebars"
  template  "templates/view_edit.handlebars", "app/views/#{name.pluralize.downcase}/edit.handlebars"
  template  "templates/view_index.handlebars", "app/views/#{name.pluralize.downcase}/index.handlebars"
  template  "templates/view_new.handlebars", "app/views/#{name.pluralize.downcase}/new.handlebars"
  template  "templates/view_show.handlebars", "app/views/#{name.pluralize.downcase}/show.handlebars"
end