Sha256: 1aef79a2f6770b7647e15beb9a6e0bcdb0359c7e5ce118bcea991b91bf75dcb2

Contents?: true

Size: 983 Bytes

Versions: 53

Compression:

Stored size: 983 Bytes

Contents

module Burp
  class FileModel
  
    attr_accessor :public_path
  
    def initialize(public_path)
      self.public_path = public_path
    end
  
    def self.all
      @file_paths = Dir.glob("#{Burp.content_directory}uploads/*").select{|path| File.file?(path) }
      @file_paths = @file_paths.map {|path| path.gsub("#{Burp.content_directory}uploads/","/burp/files/") }
      @file_paths.map {|path| FileModel.new(path)}.sort.reverse
    end
  
    def to_param
      public_path
    end
    
    def on_disk_path
      public_path.gsub("/burp/files/","#{Burp.content_directory}uploads/")
    end
    
    def mtime
      @mtime_cache ||= File.mtime(on_disk_path)
    end
    
    def size
      @size_cache ||= File.size(on_disk_path)
    end
  
    def <=>(other)
      other.is_a?(FileModel) ? self.mtime <=> other.mtime : 0
    end

    def eql?(other)
      self.class == other.class && self.hash == other.hash
    end

    def hash
      public_path.hash
    end
  
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
burp_cms-1.7.1 app/models/burp/file_model.rb
burp_cms-1.7.0 app/models/burp/file_model.rb
burp_cms-1.6.0 app/models/burp/file_model.rb
burp_cms-1.5.13 app/models/burp/file_model.rb
burp_cms-1.5.12 app/models/burp/file_model.rb
burp_cms-1.5.11 app/models/burp/file_model.rb
burp_cms-1.5.10 app/models/burp/file_model.rb
burp_cms-1.5.9 app/models/burp/file_model.rb
burp_cms-1.5.8 app/models/burp/file_model.rb
burp_cms-1.5.7 app/models/burp/file_model.rb
burp_cms-1.5.6 app/models/burp/file_model.rb
burp_cms-1.5.5 app/models/burp/file_model.rb
burp_cms-1.5.4 app/models/burp/file_model.rb
burp_cms-1.5.3 app/models/burp/file_model.rb
burp_cms-1.5.2 app/models/burp/file_model.rb
burp_cms-1.5.1 app/models/burp/file_model.rb
burp_cms-1.5.0 app/models/burp/file_model.rb
burp_cms-1.4.1 app/models/burp/file_model.rb
burp_cms-1.4.0 app/models/burp/file_model.rb
burp_cms-1.3.33 app/models/burp/file_model.rb