Class: TerrapopExtractInformation
- Inherits:
-
Object
- Object
- TerrapopExtractInformation
- Includes:
- ExtractEngine::FileManagement
- Defined in:
- app/models/terrapop_extract_information.rb
Instance Method Summary collapse
- #build_information_file ⇒ Object
- #filename ⇒ Object
-
#initialize(request) ⇒ TerrapopExtractInformation
constructor
A new instance of TerrapopExtractInformation.
- #request ⇒ Object
Constructor Details
#initialize(request) ⇒ TerrapopExtractInformation
Returns a new instance of TerrapopExtractInformation.
4 5 6 |
# File 'app/models/terrapop_extract_information.rb', line 4 def initialize(request) @request = request end |
Instance Method Details
#build_information_file ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/models/terrapop_extract_information.rb', line 8 def build_information_file create_directories(request) File.open(filename, "w") {|f| f.puts "User: " + request.user.firstname_lastname + " (" + request.user.email + ")" begin f.puts "TP Build: " + Rails.configuration.build_number rescue Exception => e $stderr.puts "*** Unable to determine build number for deployment" end f.puts "Extract Date: " + request.updated_at.strftime("%B %e, %Y - %H:%M:%S %Z") t = request.total_time.to_i ss, ms = t.divmod(1000) #=> [270921, 0] mm, ss = ss.divmod(60) #=> [4515, 21] hh, mm = mm.divmod(60) #=> [75, 15] dd, hh = hh.divmod(24) #=> [3, 3] #puts "%d days, %d hours, %d minutes and %d seconds" % [dd, hh, mm, ss] total_time = "" times = ActiveSupport::OrderedHash.new #times = {"day" => dd, "hour" => hh, "min" => mm, "sec" => ss, "ms" => ms} times[:day] = dd times[:hour] = hh times[:min] = mm times[:sec] = ss #times[:ms] = ms time_str = times.map{|key,amt| if amt > 0 "#{amt} #{key.to_s}" end }.reject{|f| f.nil? }.join(", ") f.puts "Extract Time: " + time_str } filename end |
#filename ⇒ Object
56 57 58 |
# File 'app/models/terrapop_extract_information.rb', line 56 def filename File.join(request.location, request.name + "_info.txt") end |
#request ⇒ Object
60 61 62 |
# File 'app/models/terrapop_extract_information.rb', line 60 def request @request end |