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.



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

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

:nodoc: all



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

def path
  @path
end

Instance Method Details

#present?Boolean

Returns:

  • (Boolean)


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

def present?
  File.exist? path
end

#startObject



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

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

#with_read_io(&block) ⇒ Object



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

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

#with_write_io(&block) ⇒ Object



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

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