Sha256: 87e7f2fcdf9feaf625e725275aec74416c1a87f0b37c845eead4a19baec4d666

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

class Ld::Project::Structure
  include Ld::Project::Parse
  attr_accessor :root, :name, :path

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



  def generate 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|
        @routes = parse_routes @root
        sheet.set_headings @routes[:headings]
        sheet.set_rows @routes[:rows]
      end
      excel.write_sheet 'tables' do |sheet|
        @tables = parse_schema @root
        sheet.set_headings @tables[:headings]
        sheet.set_rows @tables[:rows]
      end
      excel.write_sheet 'models' do |sheet|
        @models = parse_models @root
        sheet.set_headings @models[:headings]
        sheet.set_rows @models[:rows]
      end
    end
  end

  def find_controller model_name
    @controllers.each do |c|
      if c.name.split('_controller.rb')[0] == model_name
        return c
      end
    end
    nil
  end

  def find_view model_name
    @views.each do |v|
      if v.name == model_name
        return v
      end
    end
    nil
  end

  def camelize name
    name.camelize
  end


end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ld-0.2.3 lib/ld/project/structure.rb
ld-0.2.2 lib/ld/project/structure.rb
ld-0.2.1 lib/ld/project/structure.rb