Sha256: 97b023c50a5f699b6a90fed0dacedda4a6d1acff33b926cc11d21741c4cf1e56

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 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
    manifest_name = manifest_name.downcase.gsub( '.txt', '' )  # remove (optional) .txt ending
    logger.debug "manifest=#{manifest_name}"
    
    # check for builtin generator manifests
    manifests = installed_generator_manifests.select { |m| m[0] == manifest_name+'.txt.gen' }
    
    if manifests.empty?
      puts "*** error: unknown generator template pack '#{manifest_name}'"
      # todo: list installed manifests
      exit 2
    end
        
    manifestsrc = manifests[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

6 entries across 6 versions & 1 rubygems

Version Path
slideshow-1.2.4 lib/slideshow/cli/commands/gen_templates.rb
slideshow-1.2.3 lib/slideshow/cli/commands/gen_templates.rb
slideshow-1.2.2 lib/slideshow/cli/commands/gen_templates.rb
slideshow-1.2.1 lib/slideshow/cli/commands/gen_templates.rb
slideshow-1.2.0 lib/slideshow/cli/commands/gen_templates.rb
slideshow-1.2.0.beta5 lib/slideshow/cli/commands/gen_templates.rb