Class: Bookfile::BookPackage
- Inherits:
-
Object
- Object
- Bookfile::BookPackage
- Defined in:
- lib/bookfile/package/package.rb
Overview
change to BookTemplates/BookTheme/BookPack/BookClass/BookStyle ???
Instance Method Summary collapse
- #download ⇒ Object
-
#initialize(name, opts = {}) ⇒ BookPackage
constructor
A new instance of BookPackage.
- #local_zip_dir ⇒ Object
- #local_zip_name ⇒ Object
-
#local_zip_path ⇒ Object
local zip path.
-
#prepare(unzip_dir) ⇒ Object
change to require - why, why not??.
-
#remote_zip_url ⇒ Object
remote zip url.
- #unzip(unzip_dir) ⇒ Object
Constructor Details
#initialize(name, opts = {}) ⇒ BookPackage
Returns a new instance of BookPackage.
7 8 9 10 |
# File 'lib/bookfile/package/package.rb', line 7 def initialize( name, opts={} ) @name = name @opts = opts end |
Instance Method Details
#download ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/bookfile/package/package.rb', line 44 def download ## logger.info( "download book package '#{@name}'" ) ## logger.info( " from '#{remote_zip_url}'" ) ## logger.info( " to '#{local_zip_path}'..." ) ## note: lets use http:// instead of https:// for now - lets us use person proxy (NOT working w/ https for now) 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_book_templates( src, dest_zip ) end |
#local_zip_dir ⇒ Object
25 26 27 |
# File 'lib/bookfile/package/package.rb', line 25 def local_zip_dir "./tmp" end |
#local_zip_name ⇒ Object
19 20 21 22 23 |
# File 'lib/bookfile/package/package.rb', line 19 def local_zip_name ### note: replace / in name w/ --I-- ## e.g. flatten the filename, that is, do NOT include any folders @name.gsub('/', '--I--') # note: will NOT include/return .zip extension end |
#local_zip_path ⇒ Object
local zip path
29 30 31 |
# File 'lib/bookfile/package/package.rb', line 29 def local_zip_path # local zip path "#{local_zip_dir}/#{local_zip_name}.zip" end |
#prepare(unzip_dir) ⇒ Object
change to require - why, why not??
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/bookfile/package/package.rb', line 71 def prepare( unzip_dir ) ## change to require - why, why not?? puts "auto-require/include book scripts in '#{unzip_dir}/_scripts'" files = Dir["#{unzip_dir}/_scripts/**/*.rb"] pp files files.each_with_index do |file,idx| ## todo/check: check for exceptions??? puts " [#{idx+1}/#{files.count}] try auto-require '#{file}'..." require file end ## include Hytext::Helper or use HytextHelper ?? ## include Bookfile::Helper or use BookfileHelper ?? ## check Rails example names for helper modules ## get Helper module name from book template name ??? =begin res = require 'worlddb/models' if res puts " include WorldDb::Models" Builder.send :include, WorldDb::Models ## PageCtx.send :include, WorldDb::Models ## BookCtx.send :include, WorldDb::Models ## also add to xxxx ??? ## (possible to include as globals ???? how - Object.send :include ???) or ## Module.send :include ?? else ## find a better check - check for constants defined??? if not define??? ## or use constant_missing handler??? puts " assume WorldDb::Models already included ??" end =end end |
#remote_zip_url ⇒ Object
remote zip url
13 14 15 16 17 |
# File 'lib/bookfile/package/package.rb', line 13 def remote_zip_url # remote zip url ### note: use http:// for now - lets us use (personal proxy NOT working w/ https) for now ## "https://github.com/#{@name}/archive/gh-pages.zip" "http://github.com/#{@name}/archive/gh-pages.zip" end |
#unzip(unzip_dir) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/bookfile/package/package.rb', line 60 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_book_templates( src, dest_unzip ) end |