Method: Slideshow::ManifestFinder#find_manifestsrc

Defined in:
lib/slideshow/commands/manifest_finder.rb

#find_manifestsrc(manifest_arg) ⇒ Object

rename - just use find_manifest ??



21
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
# File 'lib/slideshow/commands/manifest_finder.rb', line 21

def find_manifestsrc( manifest_arg )    ## rename - just use find_manifest ??


  manifest_path_or_name = manifest_arg.dup   ## make a copy


  # add .txt file extension if missing (for convenience)

  if manifest_path_or_name.downcase.ends_with?( '.txt' ) == false
    manifest_path_or_name << '.txt'
  end

  logger.debug "manifest=#{manifest_path_or_name}"

  # check if file exists (if yes use custom template package!) - allows you to override builtin package with same name

  if File.exists?( manifest_path_or_name )
    manifestsrc = manifest_path_or_name
  else
    # check for builtin manifests

    manifests = installed_template_manifests
    matches = manifests.select { |m| m[0] == manifest_path_or_name }

    if matches.empty?
      puts "*** error: unknown template manifest '#{manifest_path_or_name}'"
      puts
      puts "Use"
      puts "  slideshow list      # or"
      puts "  slideshow ls"
      puts "to see what template packs you have installed."
      puts
      puts "Use"
      puts "  slideshow install #{manifest_path_or_name.sub('.txt','')}      # or"
      puts "  slideshow i #{manifest_path_or_name.sub('.txt','')}"
      puts "to (try to) install the missing template pack."
      puts
      puts "See github.com/slideshow-templates for some ready-to-use/download template packs"
      puts "or use your very own."
      puts

      # todo: list installed manifests - why? why not?

      exit 2
    end

    manifestsrc = matches[0][1]
  end

  ### todo: use File.expand_path( xx, relative_to ) always with second arg

  ##   do NOT default to cwd (because cwd will change!)


  # Reference src with absolute path, because this can be used with different pwd

  manifestsrc = File.expand_path( manifestsrc, usrdir )
  manifestsrc
end