Class: Ld::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/ld/project/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = Rails.root.to_s) ⇒ Project

Returns a new instance of Project.



5
6
7
8
# File 'lib/ld/project/project.rb', line 5

def initialize path = Rails.root.to_s
  @root = Ld::File.new path
  parse_project
end

Instance Attribute Details

#controllersObject

Returns the value of attribute controllers.



3
4
5
# File 'lib/ld/project/project.rb', line 3

def controllers
  @controllers
end

#modelsObject

Returns the value of attribute models.



3
4
5
# File 'lib/ld/project/project.rb', line 3

def models
  @models
end

#rootObject

Returns the value of attribute root.



3
4
5
# File 'lib/ld/project/project.rb', line 3

def root
  @root
end

#routesObject

Returns the value of attribute routes.



3
4
5
# File 'lib/ld/project/project.rb', line 3

def routes
  @routes
end

#tablesObject

Returns the value of attribute tables.



3
4
5
# File 'lib/ld/project/project.rb', line 3

def tables
  @tables
end

#viewsObject

Returns the value of attribute views.



3
4
5
# File 'lib/ld/project/project.rb', line 3

def views
  @views
end

Instance Method Details

#add_bugObject



45
46
47
# File 'lib/ld/project/project.rb', line 45

def add_bug

end

#parse_projectObject



10
11
12
13
14
15
16
17
# File 'lib/ld/project/project.rb', line 10

def parse_project
  @tables = Ld::Tables.new @root, nil
  @models = Ld::Models.new @root, @tables
  @routes = Ld::Routes.new @root, @models
  @tables = Ld::Tables.new @root, @models
  @views = Ld::Views.new @root, @models
  @controllers = Ld::Controllers.new @root, @models
end

#to_xls(path = "#{@root.path}/project.xls") ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ld/project/project.rb', line 19

def to_xls path = "#{@root.path}/project.xls"
  Ld::Excel.create path do |excel|
    # sheet.set_format({color: :black, font_size: 14, font: '微软雅黑'})
    excel.write_sheet 'routes' do |sheet|
      sheet.set_headings @routes.headings
      sheet.set_rows @routes.rows
    end
    excel.write_sheet 'tables' do |sheet|
      sheet.set_headings @tables.headings
      sheet.set_rows @tables.rows
    end
    excel.write_sheet 'models' do |sheet|
      sheet.set_headings @models.headings
      sheet.set_rows @models.rows
    end
    excel.write_sheet 'views' do |sheet|
      sheet.set_headings @views.headings
      sheet.set_rows @views.rows
    end
    excel.write_sheet 'controllers' do |sheet|
      sheet.set_headings @controllers.headings
      sheet.set_rows @controllers.rows
    end
  end
end