Class: Hive::FileSystem
- Inherits:
-
Object
- Object
- Hive::FileSystem
- Defined in:
- lib/hive/file_system.rb
Instance Method Summary collapse
- #check_build_integrity(destination_path) ⇒ Object
- #executed_script_path ⇒ Object
- #fetch_build(build_url, destination_path) ⇒ Object
-
#finalise_results_directory ⇒ Object
Copy useful stuff into the results directory.
- #home_path ⇒ Object
-
#initialize(job_id, home_directory, log) ⇒ FileSystem
constructor
A new instance of FileSystem.
- #logs_path ⇒ Object
- #results_path ⇒ Object
- #testbed_path ⇒ Object
Constructor Details
#initialize(job_id, home_directory, log) ⇒ FileSystem
Returns a new instance of FileSystem.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/hive/file_system.rb', line 5 def initialize(job_id, home_directory, log) @job_id = job_id @home_directory = home_directory @log = log @log.debug "Creating job paths with id=#{@job_id} and home=#{@home_directory}" make_directory(home_path) make_directory(results_path) make_directory(logs_path) make_directory(testbed_path) end |
Instance Method Details
#check_build_integrity(destination_path) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/hive/file_system.rb', line 57 def check_build_integrity( destination_path ) output = `file #{destination_path}` if output =~ /zip/ result = `zip -T #{destination_path}` @log.info(result) $? == 0 else true end end |
#executed_script_path ⇒ Object
32 33 34 |
# File 'lib/hive/file_system.rb', line 32 def executed_script_path @bash_script_path ||= "#{testbed_path}/executed_script.sh" end |
#fetch_build(build_url, destination_path) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/hive/file_system.rb', line 41 def fetch_build(build_url, destination_path) base_url = Hive.config.network['scheduler'] apk_url = base_url + '/' + build_url job = Hive::Messages::Job.new response = job.fetch(apk_url) tempfile = Tempfile.new('build.apk') File.open(tempfile.path,'w') do |f| f.write response.body end copy_file(tempfile.path, destination_path) check_build_integrity( destination_path ) end |
#finalise_results_directory ⇒ Object
Copy useful stuff into the results directory
37 38 39 |
# File 'lib/hive/file_system.rb', line 37 def finalise_results_directory copy_file(executed_script_path, "#{results_path}/executed_script.sh") end |
#home_path ⇒ Object
16 17 18 |
# File 'lib/hive/file_system.rb', line 16 def home_path @home_path ||= "#{@home_directory}/#{@job_id.to_s}" end |
#logs_path ⇒ Object
24 25 26 |
# File 'lib/hive/file_system.rb', line 24 def logs_path @logs_path ||= "#{home_path}/logs" end |
#results_path ⇒ Object
20 21 22 |
# File 'lib/hive/file_system.rb', line 20 def results_path @results_path ||= "#{home_path}/results" end |
#testbed_path ⇒ Object
28 29 30 |
# File 'lib/hive/file_system.rb', line 28 def testbed_path @testbed_path ||= "#{home_path}/test_code" end |