Class: Train::Transports::Mock::Connection::File

Inherits:
File
  • Object
show all
Defined in:
lib/train/transports/mock.rb

Constant Summary

Constants inherited from File

File::DATA_FIELDS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from File

#block_device?, #character_device?, #directory?, #file?, #file_version, #md5sum, #mounted?, #owned_by?, #path, #pipe?, #product_version, #sanitize_filename, #sha256sum, #socket?, #source, #source_path, #symlink?, #to_json, #version?

Constructor Details

#initialize(backend, path, follow_symlink = true) ⇒ File

Returns a new instance of File.



172
173
174
175
176
# File 'lib/train/transports/mock.rb', line 172

def initialize(backend, path, follow_symlink = true)
  super(backend, path, follow_symlink)
  @type = :unknown
  @exist = false
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



170
171
172
# File 'lib/train/transports/mock.rb', line 170

def type
  @type
end

Class Method Details

.from_json(json) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
# File 'lib/train/transports/mock.rb', line 150

def self.from_json(json)
  res = new(json["backend"],
    json["path"],
    json["follow_symlink"])
  res.type = json["type"]
  Train::File::DATA_FIELDS.each do |f|
    m = (f.tr("?", "") + "=").to_sym
    res.method(m).call(json[f])
  end
  res
end

Instance Method Details

#mountedObject



178
179
180
181
# File 'lib/train/transports/mock.rb', line 178

def mounted
  @mounted ||=
    @backend.run_command("mount | grep -- ' on #{@path}'")
end