Class: Cloudwalk::Posxml::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Cloudwalk::Posxml::RakeTask
- Includes:
- ManagerHelper, Rake::DSL
- Defined in:
- lib/cloudwalk/posxml/rake_task.rb
Instance Attribute Summary collapse
-
#libs ⇒ Object
Returns the value of attribute libs.
-
#main_out ⇒ Object
Returns the value of attribute main_out.
-
#out_path ⇒ Object
Returns the value of attribute out_path.
-
#outs ⇒ Object
Returns the value of attribute outs.
-
#root_path ⇒ Object
Returns the value of attribute root_path.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize {|_self| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
- #platform_call(command) ⇒ Object
Methods included from ManagerHelper
#host, included, #posxml2xml, #token, #xml2posxml, #xml2rb
Constructor Details
#initialize {|_self| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cloudwalk/posxml/rake_task.rb', line 22 def initialize yield self if block_given? @libs ||= FileList['lib/*.xml'] @root_path ||= "./" @out_path ||= File.join(root_path, "out", "shared") @outs ||= @libs.pathmap("%{lib,#{@out_path}}p") define end |
Instance Attribute Details
#libs ⇒ Object
Returns the value of attribute libs.
20 21 22 |
# File 'lib/cloudwalk/posxml/rake_task.rb', line 20 def libs @libs end |
#main_out ⇒ Object
Returns the value of attribute main_out.
20 21 22 |
# File 'lib/cloudwalk/posxml/rake_task.rb', line 20 def main_out @main_out end |
#out_path ⇒ Object
Returns the value of attribute out_path.
20 21 22 |
# File 'lib/cloudwalk/posxml/rake_task.rb', line 20 def out_path @out_path end |
#outs ⇒ Object
Returns the value of attribute outs.
20 21 22 |
# File 'lib/cloudwalk/posxml/rake_task.rb', line 20 def outs @outs end |
#root_path ⇒ Object
Returns the value of attribute root_path.
20 21 22 |
# File 'lib/cloudwalk/posxml/rake_task.rb', line 20 def root_path @root_path end |
Instance Method Details
#define ⇒ Object
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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/cloudwalk/posxml/rake_task.rb', line 41 def define namespace :cloudwalk do desc "Compile posxml" task :build do |t, args| arguments = ARGV[1..-1] if arguments && path = arguments.first FileUtils.mkdir_p self.out_path xml, out = self.libs.zip(self.outs).find { |file, out| file == path } posxml = xml2posxml(out) platform_call "cloudwalk compile -xml -o #{posxml} #{xml}" puts "=> #{File.size(posxml)} " else FileUtils.rm_rf self.out_path FileUtils.mkdir_p self.out_path self.libs.zip(self.outs).each do |file, out| posxml = xml2posxml(out) platform_call "cloudwalk compile -xml -o #{posxml} #{file}" puts "=> #{File.size(posxml)} " end end end desc "Deploy all compiled applications based in Cwfile.json" task :deploy => :build do if Cloudwalk::CwFileJson.setup if path = ARGV[1..-1].first xml, out = self.libs.zip(self.outs).find { |file, out| file == path } posxmls = [xml2posxml(out)] else posxmls = self.outs.collect { |xml| xml2posxml(xml) } end Cloudwalk::Deploy.new(Cloudwalk::CwFileJson.cwfile, Cloudwalk::CwFileJson.lock).posxml(posxmls) end end desc "Update CwFile.json.lock" task :update do Cloudwalk::CwFileJson.delete_lock! Cloudwalk::CwFileJson.setup(true) Cloudwalk::CwFileJson.persist_lock! end desc "Translate from .xml to .rb, OUT_PATH expected" task :translate do raise "OUT_PATH not send" unless out = ENV["OUT_PATH"] if path = ARGV[1..-1].first xmls = [self.libs.find { |file| file == path }] xmls.zip([File.join(out, File.basename(xml2rb(path)))]) else xmls = self.libs.inject([]) do |array, lib| array << [lib, File.join(out, File.basename(xml2rb(lib)))] end end xmls.each do |xml, out| sh "cloudwalk compile -txml -o #{out} #{xml}" end end end task :default => "cloudwalk:build" end |
#platform_call(command) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/cloudwalk/posxml/rake_task.rb', line 33 def platform_call(command) if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) sh("bash -c \"#{command}\"") else sh command end end |