Class: Gem::Package::FileSource

Inherits:
Source
  • Object
show all
Defined in:
lib/rubygems/package/file_source.rb

Overview

The primary source of gems is a file on disk, including all usages internal to rubygems.

This is a private class, do not depend on it directly. Instead, pass a path object to `Gem::Package.new`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FileSource

Returns a new instance of FileSource.


12
13
14
# File 'lib/rubygems/package/file_source.rb', line 12

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

:nodoc: all


10
11
12
# File 'lib/rubygems/package/file_source.rb', line 10

def path
  @path
end

Instance Method Details

#present?Boolean

Returns:

  • (Boolean)

20
21
22
# File 'lib/rubygems/package/file_source.rb', line 20

def present?
  File.exist? path
end

#startObject


16
17
18
# File 'lib/rubygems/package/file_source.rb', line 16

def start
  @start ||= File.read path, 20
end

#with_read_io(&block) ⇒ Object


28
29
30
# File 'lib/rubygems/package/file_source.rb', line 28

def with_read_io(&block)
  File.open path, 'rb', &block
end

#with_write_io(&block) ⇒ Object


24
25
26
# File 'lib/rubygems/package/file_source.rb', line 24

def with_write_io(&block)
  File.open path, 'wb', &block
end