Class: Bookery::Project
- Inherits:
-
Object
- Object
- Bookery::Project
- Defined in:
- lib/bookery/project.rb
Constant Summary collapse
- DEFAULTS =
{ book_dir: 'book', assets_dir: 'assets', config_file: 'config.yml' }
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Instance Method Summary collapse
- #assets ⇒ Object
- #book_config ⇒ Object
- #books ⇒ Object
- #generator_config ⇒ Object
-
#initialize(project_dir, config = {}) ⇒ Project
constructor
A new instance of Project.
- #publish(publishers) ⇒ Object
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
3 4 5 |
# File 'lib/bookery/project.rb', line 3 def config @config end |
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
3 4 5 |
# File 'lib/bookery/project.rb', line 3 def dir @dir end |
Instance Method Details
#assets ⇒ Object
34 35 36 37 38 |
# File 'lib/bookery/project.rb', line 34 def assets Dir.glob(File.join(dir, config[:assets_dir], '**/*')).reject do |file| File.directory?(file) or file =~ /\/(includes|templates)\// end.sort end |
#book_config ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/bookery/project.rb', line 16 def book_config @book_config ||= Proc.new do conf = config[:book] conf[:template] = File.join(dir, conf[:template]) conf end.call end |
#books ⇒ Object
30 31 32 |
# File 'lib/bookery/project.rb', line 30 def books @books ||= load_books end |
#generator_config ⇒ Object
24 25 26 27 28 |
# File 'lib/bookery/project.rb', line 24 def generator_config conf = config[:generator] conf[:project_dir] = dir conf end |
#publish(publishers) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/bookery/project.rb', line 40 def publish(publishers) books.each do |book| prepare_output_dir(book) publishers.each { |publisher| publisher.publish(book) } end end |