Sha256: 67d8448d16b292ec1d3db0bb534560ec5279c89418310ce6e68cd6365cd8206a

Contents?: true

Size: 689 Bytes

Versions: 5

Compression:

Stored size: 689 Bytes

Contents

class Ld::Views
  attr_accessor :headings, :rows

  def initialize root, models
    @root = root
    @models = models
    parse
  end

  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

  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

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ld-0.4.5 lib/ld/project/views.rb
ld-0.4.4 lib/ld/project/views.rb
ld-0.4.3 lib/ld/project/views.rb
ld-0.4.2 lib/ld/project/views.rb
ld-0.4.1 lib/ld/project/views.rb