Class: Idb::HostFileWrapper
- Inherits:
-
Object
- Object
- Idb::HostFileWrapper
- Defined in:
- lib/lib/host_file_wrapper.rb
Instance Method Summary collapse
- #content ⇒ Object
-
#initialize ⇒ HostFileWrapper
constructor
A new instance of HostFileWrapper.
- #save(text) ⇒ Object
Constructor Details
#initialize ⇒ HostFileWrapper
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
#content ⇒ Object
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 |