Class: DroidProj::Android::App
- Inherits:
-
Object
- Object
- DroidProj::Android::App
- Defined in:
- lib/droidproj/app.rb
Instance Attribute Summary collapse
-
#res(&block) ⇒ Object
Public: DSL for setting the app’s resources.
-
#res_path ⇒ Object
Returns the value of attribute res_path.
-
#root_dir ⇒ Object
Returns the value of attribute root_dir.
Instance Method Summary collapse
-
#create_filesystem! ⇒ Object
Public: Creates the necessary filesystem considering all options.
-
#initialize(root_dir) ⇒ App
constructor
A new instance of App.
Constructor Details
#initialize(root_dir) ⇒ App
Returns a new instance of App.
9 10 11 |
# File 'lib/droidproj/app.rb', line 9 def initialize(root_dir) @root_dir = root_dir end |
Instance Attribute Details
#res(&block) ⇒ Object
Public: DSL for setting the app’s resources
&block - (optional) Block which is called to create a new Android::Resources
object, which is then set to self.res
Returns either the existing Android::Resources object or the newly
created one.
24 25 26 |
# File 'lib/droidproj/app.rb', line 24 def res @res end |
#res_path ⇒ Object
Returns the value of attribute res_path.
7 8 9 |
# File 'lib/droidproj/app.rb', line 7 def res_path @res_path end |
#root_dir ⇒ Object
Returns the value of attribute root_dir.
7 8 9 |
# File 'lib/droidproj/app.rb', line 7 def root_dir @root_dir end |
Instance Method Details
#create_filesystem! ⇒ Object
Public: Creates the necessary filesystem considering all options
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/droidproj/app.rb', line 41 def create_filesystem! return if !self.res res_filesystem = self.res.filesystem_hash DroidProj::Logger.log "Creating #{res_path}..." FileUtils.mkdir_p res_path res_filesystem.each do |folder, files| folder = folder.to_s folder_path = File.join(res_path, folder) DroidProj::Logger.log "Creating #{folder_path}...".green FileUtils.mkdir_p folder_path files.each do |file_op| case file_op when Android::Resources::MoveOp to = File.join(res_path, folder, file_op.to) DroidProj::Logger.log "Copying #{file_op.from} to #{to}...".green FileUtils.cp file_op.from, to when Android::Resources::WriteOp at = File.join(res_path, folder, file_op.at) DroidProj::Logger.log "Writing #{at}...".green FileUtils.rm_f at File.open(at, 'w') { |f| f.write(file_op.content) } end end end end |