Class: Cloudwalk::Ruby::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
ManagerHelper, Rake::DSL
Defined in:
lib/cloudwalk/ruby/rake_task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ManagerHelper

#host, included, #posxml2xml, #token, #xml2posxml, #xml2rb

Constructor Details

#initialize {|_self| ... } ⇒ RakeTask

Returns a new instance of RakeTask.

Yields:

  • (_self)

Yield Parameters:



22
23
24
25
26
27
28
29
# File 'lib/cloudwalk/ruby/rake_task.rb', line 22

def initialize
  yield self if block_given?

  @debug    ||= false
  @debug_flag = @debug ? '-g' : ''

  define
end

Instance Attribute Details

#debugObject

Returns the value of attribute debug.



20
21
22
# File 'lib/cloudwalk/ruby/rake_task.rb', line 20

def debug
  @debug
end

#debug_flagObject

Returns the value of attribute debug_flag.



20
21
22
# File 'lib/cloudwalk/ruby/rake_task.rb', line 20

def debug_flag
  @debug_flag
end

Instance Method Details

#defineObject



31
32
33
34
35
36
37
38
39
40
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
# File 'lib/cloudwalk/ruby/rake_task.rb', line 31

def define
  namespace :cloudwalk do
    desc "Compile ruby application"
    task :build do
      Rake::Task[:build].invoke
    end

    desc "Package Build"
    task :package do
      Rake::Task[:package].invoke
    end

    desc "Deploy all compiled applications based in Cwfile.json"
    task :deploy => "cloudwalk:package" do
      if Cloudwalk::CwFileJson.setup
        Cloudwalk::Deploy.new(Cloudwalk::CwFileJson.cwfile,
                              Cloudwalk::CwFileJson.lock).ruby
      end
    end

    desc "Update CwFile.json.lock"
    task :update do
      Cloudwalk::CwFileJson.delete_lock!
      Cloudwalk::CwFileJson.setup(true)
      Cloudwalk::CwFileJson.persist_lock!
    end

    desc "Compile each .rb to .mrb"
    task :single_build do
      FileUtils.mkdir_p "./out/shared"

      files = FileList["./lib/*"].zip(FileList["./lib/*"].pathmap("./out/shared/%n.mrb"))
      files.each do |file,out|
        next if file == "./lib/main.rb"
        if File.file?(file)
          sh "cloudwalk compile #{self.debug_flag} -o #{out} #{file}"
        end
      end
    end

    desc "Create zipfile from all .mrb"
    task :single_package do
      require "archive/zip"
      FileUtils.rm_f "./out/mrb.zip"
      Archive::Zip.archive "./out/mrb.zip", FileList["./out/shared/*.mrb"].to_a
    end
  end

  task :default => "cloudwalk:build"
end