Sha256: fb806a63395f198fbdcffd2ed6833d6246fcb061c130bb0a9603f282a6bab9c2

Contents?: true

Size: 729 Bytes

Versions: 2

Compression:

Stored size: 729 Bytes

Contents

module Doggy
  class CLI::Pull
    def initialize(options)
      @options = options
    end

    def run
      pull_resources('dashboards', Models::Dashboard) if should_pull?('dashboards')
      pull_resources('monitors',   Models::Monitor)   if should_pull?('monitors')
      pull_resources('screens',    Models::Screen)    if should_pull?('screens')
    end

  private

    def should_pull?(resource)
      @options.empty? || @options[resource]
    end

    def pull_resources(name, klass)
      Doggy.ui.say "Pulling #{ name }"
      local_resources  = klass.all_local
      remote_resources = klass.all

      klass.assign_paths(remote_resources, local_resources)
      remote_resources.each(&:save_local)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
doggy-2.0.1 lib/doggy/cli/pull.rb
doggy-2.0.0 lib/doggy/cli/pull.rb