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.



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

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.



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

def type
  @type
end

Class Method Details

.from_json(json) ⇒ Object



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

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



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

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