Class: Slideshow::Quick
- Inherits:
-
Object
- Object
- Slideshow::Quick
- Includes:
- ManifestHelper
- Defined in:
- lib/slideshow/cli/commands/quick.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#fetch_pak(shortcut) ⇒ Object
todo rename to fetch_quick_pak?? share/use same code in fetch too??.
-
#initialize(logger, opts, config) ⇒ Quick
constructor
fix: remove opts, use config (wrapped!!).
- #run ⇒ Object
Methods included from ManifestHelper
#installed_quick_manifest_patterns, #installed_quick_manifests, #installed_template_manifest_patterns, #installed_template_manifests
Constructor Details
#initialize(logger, opts, config) ⇒ Quick
fix: remove opts, use config (wrapped!!)
9 10 11 12 13 |
# File 'lib/slideshow/cli/commands/quick.rb', line 9 def initialize( logger, opts, config ) @logger = logger @opts = opts @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
15 16 17 |
# File 'lib/slideshow/cli/commands/quick.rb', line 15 def config @config end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
15 16 17 |
# File 'lib/slideshow/cli/commands/quick.rb', line 15 def logger @logger end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
15 16 17 |
# File 'lib/slideshow/cli/commands/quick.rb', line 15 def opts @opts end |
Instance Method Details
#fetch_pak(shortcut) ⇒ Object
todo rename to fetch_quick_pak??
share/use same code in fetch too??
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 |
# File 'lib/slideshow/cli/commands/quick.rb', line 49 def fetch_pak( shortcut ) src = config.map_quick_shortcut( shortcut ) if src.nil? puts "*** error: no mapping found for quick shortcut '#{shortcut}'." exit 2 end puts " Mapping quick shortcut '#{shortcut}' to: #{src}" # src = 'http://github.com/geraldb/slideshow/raw/d98e5b02b87ee66485431b1bee8fb6378297bfe4/code/templates/fullerscreen.txt' # src = 'http://github.com/geraldb/sandbox/raw/13d4fec0908fbfcc456b74dfe2f88621614b5244/s5blank/s5blank.txt' uri = URI.parse( src ) logger.debug "scheme: #{uri.scheme}, host: #{uri.host}, port: #{uri.port}, path: #{uri.path}" pakname = File.basename( uri.path ).downcase.gsub('.txt','') pakpath = File.( "#{config.config_dir}/templates/#{pakname}" ) logger.debug "pakname >#{pakname}<" logger.debug "pakpath >#{pakpath}<" Pakman::Fetcher.new( logger ).fetch_pak( src, pakpath ) end |
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/slideshow/cli/commands/quick.rb', line 17 def run manifest_name = opts.quick_manifest.gsub('.txt','').gsub('.quick','') # make sure we get name w/o .quick and .txt extension ### todo:fix: always download quickstart templates (except welcome?) # how to make sure the won't go stale in the cache after the download? manifests = installed_quick_manifests matches = manifests.select { |m| (m[0] == manifest_name+'.txt.quick') || (m[0] == manifest_name+'.quick.txt') } if matches.empty? fetch_pak( manifest_name ) # retry manifests = installed_quick_manifests matches = manifests.select { |m| (m[0] == manifest_name+'.txt.quick') || (m[0] == manifest_name+'.quick.txt') } if matches.empty? puts "*** error: quickstart template #{manifest_name} not found" exit 2 end end manifestsrc = matches[0][1] pakpath = opts.output_path logger.debug( "manifestsrc=>#{manifestsrc}<, pakpath=>#{pakpath}<" ) Pakman::Copier.new( logger ).copy_pak( manifestsrc, pakpath ) end |