Class: Ld::Views
- Inherits:
-
Object
- Object
- Ld::Views
- Defined in:
- lib/ld/project/views.rb
Instance Attribute Summary collapse
-
#headings ⇒ Object
Returns the value of attribute headings.
-
#rows ⇒ Object
Returns the value of attribute rows.
Instance Method Summary collapse
- #find(model_name) ⇒ Object
-
#initialize(root, models) ⇒ Views
constructor
A new instance of Views.
- #parse ⇒ Object
Constructor Details
#initialize(root, models) ⇒ Views
4 5 6 7 8 |
# File 'lib/ld/project/views.rb', line 4 def initialize root, models @root = root @models = models parse end |
Instance Attribute Details
#headings ⇒ Object
Returns the value of attribute headings.
2 3 4 |
# File 'lib/ld/project/views.rb', line 2 def headings @headings end |
#rows ⇒ Object
Returns the value of attribute rows.
2 3 4 |
# File 'lib/ld/project/views.rb', line 2 def rows @rows end |
Instance Method Details
#find(model_name) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/ld/project/views.rb', line 19 def find model_name @view_dirs.each do |view_dir| if view_dir.name == model_name.pluralize return Ld::View.new view_dir end end nil end |
#parse ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/ld/project/views.rb', line 10 def parse @rows = @root.find('app/views').search_regexp(/.html/).map{|v| dir_name = v.parent.name model_name = @models.models.include?(dir_name.singularize) ? dir_name.singularize : nil [model_name,v.lines.size,dir_name,v.name,v.path] }.sort{|a,b| b[1] <=> a[1]} @headings = ['所属模型名','行数','文件夹名','文件名','path'] end |