Class: JarTools::Diff::EntryIterator::AnalyzableEntry

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/jartools/diff.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(jarfile, path, container_files) ⇒ AnalyzableEntry

Returns a new instance of AnalyzableEntry.



115
116
117
118
119
# File 'lib/jartools/diff.rb', line 115

def initialize(jarfile, path, container_files)
  @jarfile = jarfile
  @path = path
  @container_files = container_files
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



113
114
115
# File 'lib/jartools/diff.rb', line 113

def path
  @path
end

Instance Method Details

#<=>(other) ⇒ Object



140
141
142
# File 'lib/jartools/diff.rb', line 140

def <=>(other)
  path <=> other.path
end

#archive?Boolean

Returns:

  • (Boolean)


131
132
133
# File 'lib/jartools/diff.rb', line 131

def archive?
  path =~ /(zip|jar|war)$/
end

#binary?Boolean

This logic is odd, but it’s what grep does, apparently

Returns:

  • (Boolean)


136
137
138
# File 'lib/jartools/diff.rb', line 136

def binary?
  extract.contents.match("\000")
end

#display_nameObject



121
122
123
# File 'lib/jartools/diff.rb', line 121

def display_name
  (@container_files + [path]).join(" | ")
end

#extractObject



125
126
127
128
129
# File 'lib/jartools/diff.rb', line 125

def extract
  @extract ||= Zip::ZipFile.open(@jarfile.readable_filename) do |z|
    ExtractedFile.new(z.get_entry(path))
  end
end