Sha256: 19ed00c964ddff2bb1af40b93ff9af84445c2a5ba5ca93da8fa2490b1602537a

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

module Slideshow

class GenTemplates


### fix: remove opts, use config (wrapped!!)

  def initialize( logger, opts, config )
    @logger  = logger
    @opts    = opts
    @config  = config
  end

  attr_reader :logger, :opts, :config

  def run
    manifest_name = opts.manifest.gsub( '.txt', '' )  # remove (optional) .txt ending
    logger.debug "manifest=#{manifest_name}"
    
    manifests = installed_generator_manifests
    
    # check for builtin generator manifests
    matches = manifests.select { |m| m[0] == manifest_name+'.txt.gen' }
    
    if matches.empty?
      puts "*** error: unknown template manifest '#{manifest_name}'"
      # todo: list installed manifests
      exit 2
    end
        
    manifestsrc = matches[0][1]
    pakpath     = opts.output_path

    logger.debug( "manifestsrc=>#{manifestsrc}<, pakpath=>#{pakpath}<" )
    
    Pakman::Copier.new( logger ).copy_pak( manifestsrc, pakpath )
  end

private

  def installed_generator_manifests
    # 1) search gem/templates 

    patterns = [
      "#{Slideshow.root}/templates/*.txt.gen"
    ]

    Pakman::Finder.new( logger ).find_manifests( patterns )
  end

end # class GenTemplates
end # module Slideshow

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slideshow-1.2.0.beta4 lib/slideshow/cli/commands/gen_templates.rb