Class: Slideshow::Fetch
- Inherits:
-
Object
- Object
- Slideshow::Fetch
- Includes:
- LogUtils::Logging
- Defined in:
- lib/slideshow/cli/commands/fetch.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
- #fetch(src) ⇒ Object
- #fetch_all ⇒ Object
-
#initialize(opts, config) ⇒ Fetch
constructor
A new instance of Fetch.
Constructor Details
#initialize(opts, config) ⇒ Fetch
Returns a new instance of Fetch.
9 10 11 12 |
# File 'lib/slideshow/cli/commands/fetch.rb', line 9 def initialize( opts, config ) @opts = opts @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
14 15 16 |
# File 'lib/slideshow/cli/commands/fetch.rb', line 14 def config @config end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
14 15 16 |
# File 'lib/slideshow/cli/commands/fetch.rb', line 14 def opts @opts end |
Instance Method Details
#fetch(src) ⇒ Object
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 71 72 73 74 75 76 77 |
# File 'lib/slideshow/cli/commands/fetch.rb', line 23 def fetch( src ) logger.debug "src=>#{src}<" ## check for builtin shortcut (assume no / or \) if src.index( '/' ).nil? && src.index( '\\' ).nil? shortcut = src.clone src = config.map_fetch_shortcut( src ) if src.nil? puts "** Error: No mapping found for fetch shortcut '#{shortcut}'." return end puts " Mapping fetch shortcut '#{shortcut}' to: #{src}" else shortcut = nil end # 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 "packname >#{pakname}<" logger.debug "pakpath >#{pakpath}<" Pakman::Fetcher.new( logger ).fetch_pak( src, pakpath ) ################################### ## step 2) if shortcut exists (auto include quickstarter manifest w/ same name/key) if shortcut.present? src = config.map_quick_shortcut( shortcut ) return if src.nil? # no shortcut found; sorry; returning (nothing more to do) puts " Mapping quick shortcut '#{shortcut}' to: #{src}" uri = URI.parse( src ) logger.debug "scheme: #{uri.scheme}, host: #{uri.host}, port: #{uri.port}, path: #{uri.path}" # downcase basename w/ extension (remove .txt) 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 end |
#fetch_all ⇒ Object
17 18 19 20 21 |
# File 'lib/slideshow/cli/commands/fetch.rb', line 17 def fetch_all config.default_fetch_shortcuts.keys.each do |shortcut| fetch( shortcut ) end end |