Class: Idb::HostFileWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/lib/host_file_wrapper.rb

Instance Method Summary collapse

Constructor Details

#initializeHostFileWrapper

Returns a new instance of HostFileWrapper.



3
4
5
# File 'lib/lib/host_file_wrapper.rb', line 3

def initialize
  @cache_path = "#{$tmp_path}/device/hosts"
end

Instance Method Details

#contentObject



7
8
9
10
11
12
13
14
15
# File 'lib/lib/host_file_wrapper.rb', line 7

def content
  FileUtils.mkpath "#{$tmp_path}/device" unless File.directory? "#{$tmp_path}/device"
  $device.ops.download "/etc/hosts", @cache_path
  begin
    File.open(@cache_path, "r").read
  rescue
    $log.error "Could not open #{@cache_path}"
  end
end

#save(text) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/lib/host_file_wrapper.rb', line 17

def save(text)
  # upload
  File.open(@cache_path, "w") do |f|
    f.puts text
  end
  $device.ops.upload(@cache_path, "/etc/hosts")
end