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.



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

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

Instance Method Details

#contentObject



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

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

  end
end

#save(text) ⇒ Object



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

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

end