Class: Bookfile::Bookfile
- Inherits:
-
Object
- Object
- Bookfile::Bookfile
- Includes:
- LogUtils::Logging
- Defined in:
- lib/bookfile/bookfile.rb
Instance Attribute Summary collapse
-
#books ⇒ Object
readonly
Returns the value of attribute books.
-
#databases ⇒ Object
readonly
Returns the value of attribute databases.
-
#packages ⇒ Object
readonly
Returns the value of attribute packages.
Class Method Summary collapse
-
.load(code) ⇒ Object
another convenience method - use like Bookfile.load().
-
.load_file(path = './Bookfile') ⇒ Object
convenience method - use like Bookfile.load_file().
Instance Method Summary collapse
- #build(unzip_dir) ⇒ Object
-
#connect ⇒ Object
def setup puts “[bookfile] setup database connections n models” @databases.each do |database| database.setup end end.
- #download ⇒ Object
- #dump ⇒ Object
-
#initialize ⇒ Bookfile
constructor
A new instance of Bookfile.
- #prepare(unzip_dir) ⇒ Object
-
#unzip(unzip_dir) ⇒ Object
todo/fix - add unzip_dir as an option/config to constructor - why, why not?? location needs to get (re)used in prepare too for now pass along unzip_dir again ???.
Constructor Details
#initialize ⇒ Bookfile
Returns a new instance of Bookfile.
31 32 33 34 35 |
# File 'lib/bookfile/bookfile.rb', line 31 def initialize @packages = [] # only allow single package - why, why not?? @databases = [] # only allow single database - why, why not?? @books = [] # only allow single book - why, why not?? end |
Instance Attribute Details
#books ⇒ Object (readonly)
Returns the value of attribute books.
29 30 31 |
# File 'lib/bookfile/bookfile.rb', line 29 def books @books end |
#databases ⇒ Object (readonly)
Returns the value of attribute databases.
28 29 30 |
# File 'lib/bookfile/bookfile.rb', line 28 def databases @databases end |
#packages ⇒ Object (readonly)
Returns the value of attribute packages.
27 28 29 |
# File 'lib/bookfile/bookfile.rb', line 27 def packages @packages end |
Class Method Details
.load(code) ⇒ Object
another convenience method - use like Bookfile.load()
18 19 20 21 22 23 |
# File 'lib/bookfile/bookfile.rb', line 18 def self.load( code ) # Note: return datafile (of course, NOT the builder) # if you want a builder use Bookfile::Builder ;-) builder = Builder.load( code ) builder.bookfile end |
.load_file(path = './Bookfile') ⇒ Object
convenience method - use like Bookfile.load_file()
10 11 12 13 14 15 |
# File 'lib/bookfile/bookfile.rb', line 10 def self.load_file( path='./Bookfile' ) # Note: return datafile (of course, NOT the builder) # if you want a builder use Bookfile::Builder ;-) builder = Builder.load_file( path ) builder.bookfile end |
Instance Method Details
#build(unzip_dir) ⇒ Object
86 87 88 89 90 91 |
# File 'lib/bookfile/bookfile.rb', line 86 def build( unzip_dir ) puts "[bookfile] build books" @books.each do |book| book.build( unzip_dir ) end end |
#connect ⇒ Object
def setup
puts "[bookfile] setup database connections n models"
@databases.each do |database|
database.setup
end
end
68 69 70 71 72 73 |
# File 'lib/bookfile/bookfile.rb', line 68 def connect puts "[bookfile] connect to database(s)" @databases.each do |database| database.connect end end |
#download ⇒ Object
38 39 40 41 42 43 |
# File 'lib/bookfile/bookfile.rb', line 38 def download puts "[bookfile] dowload book packages" @packages.each do |package| package.download end end |
#dump ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/bookfile/bookfile.rb', line 95 def dump ## ## for debugging dump datasets (note: will/might also check if zip exits) ## logger.info( "[datafile] dump datasets (for debugging)" ) ## @datasets.each do |dataset| ## dataset.dump() ## end end |
#prepare(unzip_dir) ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/bookfile/bookfile.rb', line 76 def prepare( unzip_dir ) @databases.each do |database| database.prepare ## require models and include in builder/page ctx end @packages.each do |package| package.prepare( unzip_dir ) ## require helpers and include in builder/page ctx end end |
#unzip(unzip_dir) ⇒ Object
todo/fix - add unzip_dir as an option/config to constructor - why, why not??
location needs to get (re)used in prepare too
for now pass along unzip_dir again ???
49 50 51 52 53 54 55 56 |
# File 'lib/bookfile/bookfile.rb', line 49 def unzip( unzip_dir ) puts "[bookfile] unzip book packages" ### fix: for multiple packages use a number?? - how to make path unique ## for now is ./book @packages.each do |package| package.unzip( unzip_dir ) end end |