Class: Keydown::Tasks
- Inherits:
-
Thor
- Object
- Thor
- Keydown::Tasks
- Includes:
- Thor::Actions
- Defined in:
- lib/keydown/tasks/base.rb,
lib/keydown/tasks/slides.rb,
lib/keydown/tasks/generate.rb
Constant Summary collapse
- @@source_root =
File.join(File.dirname(__FILE__), '..', '..', '..')
Instance Attribute Summary collapse
-
#presentation_name ⇒ Object
readonly
Returns the value of attribute presentation_name.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#presentation_name ⇒ Object (readonly)
Returns the value of attribute presentation_name.
3 4 5 |
# File 'lib/keydown/tasks/generate.rb', line 3 def presentation_name @presentation_name end |
Class Method Details
.source_root ⇒ Object
7 8 9 |
# File 'lib/keydown/tasks/base.rb', line 7 def self.source_root @@source_root end |
.template_dir ⇒ Object
11 12 13 |
# File 'lib/keydown/tasks/base.rb', line 11 def self.template_dir @@template_dir end |
Instance Method Details
#generate(name) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/keydown/tasks/generate.rb', line 7 def generate(name) @presentation_name = name # instance variable used when the directory is copied directory "templates/generate", name copy_file "templates/generate/deck.js/themes/transition/horizontal-slide.css", "#{name}/css/horizontal-slide.css" copy_file "templates/generate/deck.js/themes/style/swiss.css", "#{name}/css/swiss.css" copy_file "templates/generate/deck.js/extensions/codemirror/themes/default.css", "#{name}/css/default.css" end |
#slides(file) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/keydown/tasks/slides.rb', line 9 def (file) file += '.md' unless file.match(/\.md$/) unless File.exist?(file) say "#{file} not found. Please call with a KeyDown Markdown file: keydown slides my_file.md", :red return end @@template_dir = File.join(Keydown::Tasks.source_root, 'templates', 'deck.js') say "Creating Keydown presentation from #{file}", :yellow = SlideDeck.new(File.new(file).read) backgrounds = ..collect do || .background_image unless .background_image.empty? end.compact context = OpenStruct.new({ :backgrounds => backgrounds }) scss_template = Tilt.new(File.join(Tasks.template_dir, '..', 'keydown.scss.erb')) scss = scss_template.render(context) compass_path = File.join(Gem.loaded_specs['compass'].full_gem_path, 'frameworks', 'compass', 'stylesheets') create_file 'css/keydown.css', :force => true do Sass::Engine.new(scss, :syntax => :scss, :load_paths => [compass_path]).render end presentation = file.gsub('md', 'html') create_file presentation, :force => true do .to_html end end |