Class: FlexSDK
- Inherits:
-
Object
- Object
- FlexSDK
- Defined in:
- lib/flex_sdk/flex_sdk.rb
Instance Method Summary collapse
-
#config ⇒ Object
Create a hash of configuration objects, some from config.yml, the rest figured out.
-
#copylocale(config) ⇒ Object
Perform the copylocale step.
-
#download(config) ⇒ Object
Download the SDK zip file to the gem.
-
#sdk_dir ⇒ Object
Return the full path to the SDK dir, so other things/people can use it.
-
#unzip(config) ⇒ Object
Unzip the downloaded zip file into the target dir.
Instance Method Details
#config ⇒ Object
Create a hash of configuration objects, some from config.yml, the rest figured out
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/flex_sdk/flex_sdk.rb', line 4 def config require 'yaml' config = YAML.load_file(File.(File.join((File.dirname(__FILE__)), "..", "..", "config.yml"))) config_hash = config["flex-sdk"] # These variables are provided by config.yml sdk_ver = config_hash["sdk_ver"] vendor_path = config_hash["vendor_path"] cdn_path = config_hash["cdn_path"] # These variables are determined at runtime and combined into one hash sdk_name = "flex_sdk_" + sdk_ver config_hash["sdk_name"] = sdk_name sdk_zipfile = sdk_name + ".zip" config_hash["sdk_zipfile"] = sdk_zipfile config_hash["cdn_file"] = cdn_path + sdk_zipfile dest_dir = File.(File.join((File.dirname(__FILE__)), "..", "..", vendor_path)) config_hash["dest_dir"] = dest_dir config_hash["dest_file"] = File.join(dest_dir, sdk_zipfile) config_hash["sdk_dir"] = File.join(dest_dir, sdk_name) config_hash end |
#copylocale(config) ⇒ Object
Perform the copylocale step
72 73 74 75 76 77 78 79 80 |
# File 'lib/flex_sdk/flex_sdk.rb', line 72 def copylocale(config) sdk_name = config["sdk_dir"] `#{sdk_dir}/bin/copylocale en_US en_NZ` unless $?.to_i != 0 puts "INFO: Process copylocale completed successfully" else raise "ERROR: Process copylocale FAILED" end end |
#download(config) ⇒ Object
Download the SDK zip file to the gem
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/flex_sdk/flex_sdk.rb', line 35 def download(config) dest_dir = config["dest_dir"] dest_file = config["dest_file"] cdn_file = config["cdn_file"] puts "\n" unless File.file?(dest_file) puts "Downloading SDK\n\tFrom:\t#{cdn_file}\n\tTo:\t#{dest_file}\n\n" `curl #{cdn_file} --create-dirs -o #{dest_file} ` if $?.to_i != 0 raise "Failed to download Flex SDK\n\n" end else puts "Won't download SDK, file #{dest_file} already exists" end end |
#sdk_dir ⇒ Object
Return the full path to the SDK dir, so other things/people can use it
29 30 31 32 |
# File 'lib/flex_sdk/flex_sdk.rb', line 29 def sdk_dir config = self.config sdk_dir = config["sdk_dir"] end |
#unzip(config) ⇒ Object
Unzip the downloaded zip file into the target dir
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/flex_sdk/flex_sdk.rb', line 54 def unzip(config) sdk_dir = config["sdk_dir"] dest_file = config["dest_file"] puts "\n" unless File.directory?(sdk_dir) puts "Unzipping SDK\n\tFrom:\t#{dest_file}\n\tTo:\t#{sdk_dir}/\n\n" `unzip #{dest_file} -d #{sdk_dir}` if $?.to_i != 0 raise "Failed to unzip Flex SDK\n\n" end else puts "Won't unzip SDK, directory #{sdk_dir}/ already exists\n\n" end end |