Class: FlexPMD
- Inherits:
-
Object
- Object
- FlexPMD
- Defined in:
- lib/flex_pmd/flex_pmd.rb
Instance Method Summary collapse
-
#cdn_file ⇒ Object
Return the full web URL of the PMD to download.
-
#config ⇒ Object
Return a hash of configuration objects from config.yml.
-
#dest_dir ⇒ Object
Return the destination (think: vendor) directory to put the PMD into.
-
#dest_file ⇒ Object
Return the full path of target zip file.
-
#download ⇒ Object
Download the PMD zip file into the gem’s directory.
-
#pmd_dir ⇒ Object
Return the full path to the PMD dir, so other things/people can use it.
-
#pmd_name ⇒ Object
Return the human readable name of the PMD.
-
#pmd_ver ⇒ Object
Return the version PMD.
-
#pmd_zipfile ⇒ Object
Return just the file name of the target zip file.
-
#unzip ⇒ Object
Unzip the downloaded zip file into the target dir.
Instance Method Details
#cdn_file ⇒ Object
Return the full web URL of the PMD to download
41 42 43 |
# File 'lib/flex_pmd/flex_pmd.rb', line 41 def cdn_file cdn_file = config["cdn_path"] end |
#config ⇒ Object
Return a hash of configuration objects from config.yml
4 5 6 7 8 |
# File 'lib/flex_pmd/flex_pmd.rb', line 4 def config require 'yaml' config = YAML.load_file(File.(File.join((File.dirname(__FILE__)), "..", "..", "config.yml"))) config_hash = config["flex-pmd"] end |
#dest_dir ⇒ Object
Return the destination (think: vendor) directory to put the PMD into
11 12 13 |
# File 'lib/flex_pmd/flex_pmd.rb', line 11 def dest_dir dest_dir = File.(File.join((File.dirname(__FILE__)), "..", "..", config["vendor_path"])) end |
#dest_file ⇒ Object
Return the full path of target zip file
31 32 33 |
# File 'lib/flex_pmd/flex_pmd.rb', line 31 def dest_file dest_file = File.join(dest_dir, pmd_zipfile) end |
#download ⇒ Object
Download the PMD zip file into the gem’s directory
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/flex_pmd/flex_pmd.rb', line 46 def download puts "\n" unless File.file?(dest_file) puts "Downloading PMD\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 PMD\n\n" end else puts "Won't download PMD, file #{dest_file} already exists" end end |
#pmd_dir ⇒ Object
Return the full path to the PMD dir, so other things/people can use it
36 37 38 |
# File 'lib/flex_pmd/flex_pmd.rb', line 36 def pmd_dir pmd_dir = File.join(dest_dir, pmd_name) end |
#pmd_name ⇒ Object
Return the human readable name of the PMD
21 22 23 |
# File 'lib/flex_pmd/flex_pmd.rb', line 21 def pmd_name pmd_name = "flex_pmd_" + pmd_ver end |
#pmd_ver ⇒ Object
Return the version PMD
16 17 18 |
# File 'lib/flex_pmd/flex_pmd.rb', line 16 def pmd_ver pmd_ver = config["pmd_ver"] end |
#pmd_zipfile ⇒ Object
Return just the file name of the target zip file
26 27 28 |
# File 'lib/flex_pmd/flex_pmd.rb', line 26 def pmd_zipfile pmd_zipfile = pmd_name + ".zip" end |
#unzip ⇒ Object
Unzip the downloaded zip file into the target dir
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/flex_pmd/flex_pmd.rb', line 60 def unzip puts "\n" unless File.directory?(pmd_dir) puts "Unzipping PMD\n\tFrom:\t#{dest_file}\n\tTo:\t#{pmd_dir}/\n\n" `unzip #{dest_file} -d #{pmd_dir}` if $?.to_i != 0 raise "Failed to unzip Flex PMD\n\n" end else puts "Won't unzip PMD, directory #{pmd_dir}/ already exists\n\n" end end |