Class: Bookfile::Bookfile

Inherits:
Object
  • Object
show all
Defined in:
lib/bookfile/bookfile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBookfile



13
14
15
16
17
# File 'lib/bookfile/bookfile.rb', line 13

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

#booksObject (readonly)

Returns the value of attribute books.



11
12
13
# File 'lib/bookfile/bookfile.rb', line 11

def books
  @books
end

#databasesObject (readonly)

Returns the value of attribute databases.



10
11
12
# File 'lib/bookfile/bookfile.rb', line 10

def databases
  @databases
end

#packagesObject (readonly)

include LogUtils::Logging



9
10
11
# File 'lib/bookfile/bookfile.rb', line 9

def packages
  @packages
end

Instance Method Details

#build(unzip_dir) ⇒ Object



68
69
70
71
72
73
# File 'lib/bookfile/bookfile.rb', line 68

def build( unzip_dir )
  puts "[bookfile] build books"
  @books.each do |book|
    book.build( unzip_dir )
  end
end

#connectObject

def setup

  puts "[bookfile] setup database connections n models"
  @databases.each do |database|
    database.setup
  end
end


50
51
52
53
54
55
# File 'lib/bookfile/bookfile.rb', line 50

def connect
  puts "[bookfile] connect to database(s)"
  @databases.each do |database|
    database.connect
  end
end

#downloadObject



20
21
22
23
24
25
# File 'lib/bookfile/bookfile.rb', line 20

def download
  puts "[bookfile] dowload book packages"
  @packages.each do |package|
    package.download
  end
end

#dumpObject



77
78
79
80
81
82
83
# File 'lib/bookfile/bookfile.rb', line 77

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



58
59
60
61
62
63
64
65
# File 'lib/bookfile/bookfile.rb', line 58

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 ???


31
32
33
34
35
36
37
38
# File 'lib/bookfile/bookfile.rb', line 31

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