Class: DrJekyll::Package
- Inherits:
-
Object
- Object
- DrJekyll::Package
- Defined in:
- lib/drjekyll/package.rb
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(key, hash) ⇒ Package
constructor
note: for now pass in key as its own arg (not part/included in hash).
- #local_zip_dir ⇒ Object
- #local_zip_name ⇒ Object
-
#local_zip_path ⇒ Object
local zip path.
-
#remote_zip_url ⇒ Object
remote zip url.
- #unzip(unzip_dir) ⇒ Object
Constructor Details
#initialize(key, hash) ⇒ Package
note: for now pass in key as its own arg (not part/included in hash)
7 8 9 10 11 12 |
# File 'lib/drjekyll/package.rb', line 7 def initialize( key, hash ) ## note: for now pass in key as its own arg (not part/included in hash) @key = key @hash = hash @download_url = @hash['download_url'] # as string end |
Instance Method Details
#download ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/drjekyll/package.rb', line 32 def download src = remote_zip_url dest_zip = local_zip_path ## make sure dest folder exists FileUtils.mkdir_p( local_zip_dir ) unless Dir.exists?( local_zip_dir ) fetch_theme( src, dest_zip ) end |
#local_zip_dir ⇒ Object
22 23 24 |
# File 'lib/drjekyll/package.rb', line 22 def local_zip_dir "." ## use ./tmp or ./dl or ~/.drjekyll/cache ?? end |
#local_zip_name ⇒ Object
18 19 20 |
# File 'lib/drjekyll/package.rb', line 18 def local_zip_name @key # note: will NOT include/return .zip extension end |
#local_zip_path ⇒ Object
local zip path
26 27 28 |
# File 'lib/drjekyll/package.rb', line 26 def local_zip_path # local zip path "#{local_zip_dir}/#{local_zip_name}.zip" end |
#remote_zip_url ⇒ Object
remote zip url
14 15 16 |
# File 'lib/drjekyll/package.rb', line 14 def remote_zip_url # remote zip url @download_url # as string end |
#unzip(unzip_dir) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/drjekyll/package.rb', line 41 def unzip( unzip_dir ) src = local_zip_path dest_unzip = unzip_dir ## local_unzip_dir ## check if folders exists? if not create folder in path FileUtils.mkdir_p( dest_unzip ) unless Dir.exists?( dest_unzip ) unzip_theme( src, dest_unzip ) end |