Class: Buildr::AS3::Alchemy::AlchemyToolkit

Inherits:
Object
  • Object
show all
Defined in:
lib/buildr/as3/alchemy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(flex_sdk) ⇒ AlchemyToolkit

Returns a new instance of AlchemyToolkit.



29
30
31
32
33
34
35
36
37
38
# File 'lib/buildr/as3/alchemy.rb', line 29

def initialize(flex_sdk)
  @version = "1.0-PR1"
  @system = Buildr::Util.win_os? ? "win" : "unix"
  @spec = "com.adobe.alchemy:toolkit:zip:#{@system}:#{@version}"
  @flex_sdk = flex_sdk
  @alchemy_zip = Buildr.artifact(@spec)
  @alchemy_dir = File.join(File.dirname(@alchemy_zip.to_s), "alchemy-#{@system}-#{@version}", get_alchemy_toolkit_subfolder(@system) )
  generate_paths @alchemy_dir
  self
end

Instance Attribute Details

#achacksObject (readonly)

Returns the value of attribute achacks.



27
28
29
# File 'lib/buildr/as3/alchemy.rb', line 27

def achacks
  @achacks
end

#alchemy_setupObject (readonly)

Returns the value of attribute alchemy_setup.



27
28
29
# File 'lib/buildr/as3/alchemy.rb', line 27

def alchemy_setup
  @alchemy_setup
end

#binObject (readonly)

Returns the value of attribute bin.



27
28
29
# File 'lib/buildr/as3/alchemy.rb', line 27

def bin
  @bin
end

#flex_sdkObject (readonly)

Returns the value of attribute flex_sdk.



27
28
29
# File 'lib/buildr/as3/alchemy.rb', line 27

def flex_sdk
  @flex_sdk
end

#gccObject (readonly)

Returns the value of attribute gcc.



27
28
29
# File 'lib/buildr/as3/alchemy.rb', line 27

def gcc
  @gcc
end

#homeObject (readonly)

Returns the value of attribute home.



27
28
29
# File 'lib/buildr/as3/alchemy.rb', line 27

def home
  @home
end

#swfbridgeObject (readonly)

Returns the value of attribute swfbridge.



27
28
29
# File 'lib/buildr/as3/alchemy.rb', line 27

def swfbridge
  @swfbridge
end

Instance Method Details

#from(url) ⇒ Object



74
75
76
77
# File 'lib/buildr/as3/alchemy.rb', line 74

def from(url)
  @url = url
  self
end

#invokeObject



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
# File 'lib/buildr/as3/alchemy.rb', line 40

def invoke
  @url ||= get_alchemy_toolkit_url(@system)

  if Buildr::Util.win_os?
    unless File.exists? @alchemy_zip.to_s
      FileUtils.mkdir_p File.dirname(@alchemy_zip.to_s) unless File.directory? File.dirname(@alchemy_zip.to_s)
      File.open @alchemy_zip.to_s, 'w' do |file|
        file.binmode()
        URI.read(@url, {:progress=>true}) { |chunk| file.write chunk }
      end
    end
  else
    Buildr.artifact(@spec).from(Buildr.download(@url)).invoke unless File.exists? @alchemy_zip.to_s
  end

  unless File.exists? @alchemy_dir
    puts "Unzipping Alchemy, this might take a while."
    unzip_dir = File.dirname @alchemy_dir
    if Buildr::Util.win_os?
      puts "Please make sure unzip is installed and in your PATH variable!"
      unzip @alchemy_zip, unzip_dir
    else
      begin
        Buildr.unzip(unzip_dir.to_s=>@alchemy_zip.to_s).target.invoke
      rescue TypeError
        puts "RubyZip extract failed, trying system unzip now."
        unzip @alchemy_zip, unzip_dir
      end
    end
  end
  setup unless File.exists? @alchemy_setup
  self
end