Sha256: 8711a22868bc10610f233fa66637a1a614ff130f1485912f9bbbca3a3dab7ab1

Contents?: true

Size: 948 Bytes

Versions: 1

Compression:

Stored size: 948 Bytes

Contents

require 'photo_party_sync/version'
require 'photo_party_sync/card'
require 'photo_party_sync/logger'

module PhotoPartySync
  # Calls all cards
  class Watcher
    include PhotoPartySync::Logging

    def initialize(options)
      if options[:cards].empty?
        STDERR.puts 'You need to supply a card name.'
        exit 1
      end

      @options = options

      @options[:cards].each { |card| card.target_base_path = @options[:dir] } unless @options[:dir].empty?
    end

    def watch
      loop do
        check_all
        sleep 1
      end
    end

    def check_all
      @options[:cards].each do |cardname|
        check_card cardname
      end
    end

    def check_card(card)
      if card.ready?
        logger.info "Found #{card.name}, getting file list..." unless @options[:quiet]
        card.download_all
      else
        logger.warn "Cannot reach #{card.name}. Skipping." unless @options[:quiet]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
photo_party_sync-0.1.0 lib/photo_party_sync.rb