Class: Device::ParamsDat
- Inherits:
-
Object
- Object
- Device::ParamsDat
- Includes:
- DaFunk::Helper
- Defined in:
- lib/device/params_dat.rb
Constant Summary collapse
- FILE_NAME =
"./main/params.dat"
Class Attribute Summary collapse
-
.apps ⇒ Object
Returns the value of attribute apps.
-
.file ⇒ Object
Returns the value of attribute file.
-
.status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
- .application_menu ⇒ Object
- .download ⇒ Object
- .executable_app ⇒ Object
- .executable_apps ⇒ Object
- .format! ⇒ Object
-
.parse_apps ⇒ Object
TODO Scalone: Change after @bmsatierf change the format For each apps on apps_list We’ll have: Today: <label>,<arquivo>,<pages>,<crc>; After: <label>,<arquivo>,<type>,<crc>; Today: “1 - App,pc2_app.posxml,1,E0A0;” After: “1 - App,pc2_app.posxml,posxml,E0A0;” After: “1 - App,pc2_app.zip,ruby,E0A0;”.
- .setup ⇒ Object
- .update_app(application) ⇒ Object
- .update_apps(force = false) ⇒ Object
Class Attribute Details
.apps ⇒ Object
Returns the value of attribute apps.
8 9 10 |
# File 'lib/device/params_dat.rb', line 8 def apps @apps end |
.file ⇒ Object
Returns the value of attribute file.
8 9 10 |
# File 'lib/device/params_dat.rb', line 8 def file @file end |
.status ⇒ Object
Returns the value of attribute status.
8 9 10 |
# File 'lib/device/params_dat.rb', line 8 def status @status end |
Class Method Details
.application_menu ⇒ Object
108 109 110 111 112 |
# File 'lib/device/params_dat.rb', line 108 def self. = Hash.new executable_apps.each { |app| [app.label] = app } ("Application Menu", , {:number => true}) end |
.download ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/device/params_dat.rb', line 47 def self.download if attach Device::Display.clear puts "Downloading Params" ret = Device::Transaction::Download.request_param_file(FILE_NAME) if value = check_download_error(ret) puts "Downloaded Successfully" parse_apps end value end end |
.executable_app ⇒ Object
97 98 99 100 101 102 |
# File 'lib/device/params_dat.rb', line 97 def self.executable_app selected = self.executable_apps if selected.size == 1 selected.first end end |
.executable_apps ⇒ Object
104 105 106 |
# File 'lib/device/params_dat.rb', line 104 def self.executable_apps self.apps.select{|app| app.label != "X"} end |
.format! ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'lib/device/params_dat.rb', line 71 def self.format! self.apps.each do |app| File.delete(app.zip) if File.exists?(app.zip) Dir.delete(app.file_no_ext) if File.exists?(app.file_no_ext) && File.exists?(app.file_no_ext) end File.delete(FILE_NAME) if File.exists?(FILE_NAME) Device::System.restart end |
.parse_apps ⇒ Object
TODO Scalone: Change after @bmsatierf change the format For each apps on apps_list We’ll have: Today: <label>,<arquivo>,<pages>,<crc>; After: <label>,<arquivo>,<type>,<crc>; Today: “1 - App,pc2_app.posxml,1,E0A0;” After: “1 - App,pc2_app.posxml,posxml,E0A0;” After: “1 - App,pc2_app.zip,ruby,E0A0;”
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/device/params_dat.rb', line 32 def self.parse_apps @apps = [] return unless self.setup self.file["apps_list"].to_s.gsub("\"", "").split(";").each do |app| @apps << Device::Application.new(*app.split(",")) end if (@apps.size >= 1) self.status = true else self.status = false end end |
.setup ⇒ Object
21 22 23 |
# File 'lib/device/params_dat.rb', line 21 def self.setup @file = FileDb.new(FILE_NAME) end |
.update_app(application) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/device/params_dat.rb', line 80 def self.update_app(application) if attach && application Device::Display.clear puts "Downloading #{application.file}..." ret = Device::Transaction::Download.request_file(application.file, application.zip) unless check_download_error ret sleep 2 end end end |
.update_apps(force = false) ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/device/params_dat.rb', line 60 def self.update_apps(force = false) if force || ! self.status self.download end if self.status @apps.each do |app| self.update_app(app) end end end |