Class: Slideshow::Merge
- Inherits:
-
Object
- Object
- Slideshow::Merge
- Includes:
- LogUtils::Logging
- Defined in:
- lib/slideshow/commands/merge.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#usrdir ⇒ Object
readonly
original working dir (user called slideshow from).
Instance Method Summary collapse
-
#initialize(config) ⇒ Merge
constructor
A new instance of Merge.
- #merge(deck, ctx, headers, content_for) ⇒ Object
Constructor Details
#initialize(config) ⇒ Merge
Returns a new instance of Merge.
11 12 13 14 15 16 |
# File 'lib/slideshow/commands/merge.rb', line 11 def initialize( config ) @config = config ## todo: check if we need to use expand_path - Dir.pwd always absolute (check ~/user etc.) @usrdir = File.( Dir.pwd ) # save original (current) working directory end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config
18 19 20 |
# File 'lib/slideshow/commands/merge.rb', line 18 def config @config end |
#usrdir ⇒ Object (readonly)
original working dir (user called slideshow from)
19 20 21 |
# File 'lib/slideshow/commands/merge.rb', line 19 def usrdir @usrdir end |
Instance Method Details
#merge(deck, ctx, headers, content_for) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/slideshow/commands/merge.rb', line 22 def merge( deck, ctx, headers, content_for ) manifestsrc = ctx[:manifestsrc] name = ctx[:name] outdir = ctx[:outdir] ## note: ## assumes name == basename (e.g. name without extension and directory) ## rename name to basename - why? why not?? ## note: assumes working directory is (default) work directory ## e.g. original working dir (user called slideshow from) puts "Merging slideshow '#{name}'..." #### pak merge # nb: change cwd to template pak root @pakdir = File.dirname( manifestsrc ) # template pak root - make availabe too in erb via binding logger.debug " setting pakdir to >#{@pakdir}<" # todo/fix: change current work dir (cwd) in pakman gem itself # for now lets do it here logger.debug "changing cwd to pak - new >#{@pakdir}<, old >#{Dir.pwd}<" Dir.chdir( @pakdir ) logger.debug( "manifestsrc >#{manifestsrc}<, outdir >#{outdir}<" ) ########################################### ## setup hash for binding assigns = { 'name' => name, 'headers' => HeadersDrop.new( headers ), 'content' => deck.content, 'slides' => deck..map { || SlideDrop.new() }, # strutured content - use LiquidDrop - why? why not? } ## add content_for entries e.g. ## content_for :js => more_content_for_js or content_for_js or extra_js etc. ## for now allow all three aliases puts "content_for:" pp content_for content_for.each do |k,v| puts " (auto-)add content_for >#{k.to_s}< to ctx:" puts v assigns[ "more_content_for_#{k}"] = v assigns[ "content_for_#{k}" ] = v assigns[ "extra_#{k}" ] = v end puts "assigns:" pp assigns Pakman::LiquidTemplater.new.merge_pak( manifestsrc, outdir, assigns, name ) ## pop/restore org (original) working folder/dir unless usrdir == @pakdir logger.debug "restoring cwd to usr - new >#{usrdir}<, old >#{Dir.pwd}<" Dir.chdir( usrdir ) end end |