Class: Slideshow::Update

Inherits:
Object
  • Object
show all
Includes:
LogUtils::Logging
Defined in:
lib/slideshow/commands/update.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Update

Returns a new instance of Update.



22
23
24
# File 'lib/slideshow/commands/update.rb', line 22

def initialize( config )
  @config  = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



26
27
28
# File 'lib/slideshow/commands/update.rb', line 26

def config
  @config
end

Instance Method Details

#updateObject

update shortcut index



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/slideshow/commands/update.rb', line 29

def update   # update shortcut index
  dest =  config.shortcut_index_file
  
  destfull = File.expand_path( dest )
  destpath = File.dirname( destfull )
  FileUtils.makedirs( destpath ) unless File.directory?( destpath )

  logger.debug "destfull=>#{destfull}<"
  logger.debug "destpath=>#{destpath}<"

  ## todo/fix: use a config setting for index url (do NOT hard core)
  src = 'https://raw.github.com/slideshow-s9/registry/master/slideshow.index.yml'

  puts "Updating shortcut index - downloading '#{src}'..."
  ::Fetcher::Worker.new.copy( src, destfull )
end