Sha256: 713d25e498f82da3711ba1812ea15e05271a38f2345e99a63babd026be15f405

Contents?: true

Size: 748 Bytes

Versions: 9

Compression:

Stored size: 748 Bytes

Contents

# encoding: utf-8

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

9 entries across 9 versions & 1 rubygems

Version Path
doggy-2.0.10 lib/doggy/cli/pull.rb
doggy-2.0.9 lib/doggy/cli/pull.rb
doggy-2.0.8 lib/doggy/cli/pull.rb
doggy-2.0.7 lib/doggy/cli/pull.rb
doggy-2.0.6 lib/doggy/cli/pull.rb
doggy-2.0.5 lib/doggy/cli/pull.rb
doggy-2.0.4 lib/doggy/cli/pull.rb
doggy-2.0.3 lib/doggy/cli/pull.rb
doggy-2.0.2 lib/doggy/cli/pull.rb