Module: Kitabu::Templates
Constant Summary collapse
- TEMPLATES_ROOT =
File.join(Kitabu::Base::GEM_ROOT, 'templates')
- DIRECTORIES =
%w(text templates output)
Instance Method Summary collapse
- #bundle_css!(options) ⇒ Object
- #config!(options) ⇒ Object
- #directories!(options) ⇒ Object
- #files!(options) ⇒ Object
- #process!(options) ⇒ Object
Instance Method Details
#bundle_css!(options) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/kitabu/templates.rb', line 38 def bundle_css!() contents = Dir["#{TEMPLATES_ROOT}/themes/*.css"].collect do |file| File.read(file) end File.open("#{options[:path]}/templates/syntax.css", "w+") << contents.join("\n\n") end |
#config!(options) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/kitabu/templates.rb', line 30 def config!() template = File.new(File.join(TEMPLATES_ROOT, 'config.yml')).read env = OpenStruct.new() contents = ERB.new(template).result env.instance_eval{binding} File.open(File.join([:path], 'config.yml'), 'w+') << contents end |
#directories!(options) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/kitabu/templates.rb', line 15 def directories!() FileUtils.mkdir([:path]) DIRECTORIES.each do |d| FileUtils.mkdir File.join([:path], d) end end |
#files!(options) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/kitabu/templates.rb', line 23 def files!() copy_file "Rakefile", "#{options[:path]}/Rakefile" copy_file "layouts/#{options[:layout]}/layout.css", "#{options[:path]}/templates/layout.css" copy_file "layouts/#{options[:layout]}/layout.html", "#{options[:path]}/templates/layout.html" copy_file "user.css", "#{options[:path]}/templates/user.css" end |
#process!(options) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/kitabu/templates.rb', line 8 def process!() directories!() bundle_css!() files!() config!() end |