Sha256: 68756900049231366e3f4d4b23285485412a96fc5704dee3bec30f01565e34f3

Contents?: true

Size: 760 Bytes

Versions: 9

Compression:

Stored size: 760 Bytes

Contents

require 'droplet_kit'
require 'yaml'

module DigitalOcean
  CONFIG_FILE = "#{Ops::PROVIDERS_DIR}/digitalocean.yml"

  def self.client
    begin
      config = YAML.load_file CONFIG_FILE
    rescue
      raise "Please, create '#{CONFIG_FILE}' file with token value"
    end
    DropletKit::Client.new(access_token: config["token"])
  end

  def self.build_droplet(host_name)
    begin
      params = YAML.load_file "#{Ops::DIR}/hosts/#{host_name}.yml"
      params["name"]= host_name
    rescue
      raise "Please, create '#{CONFIG_FILE}' file with token value"
    end
    DropletKit::Droplet.new params
  end
end

module DropletKit
  class Client
    def find_droplet_by_name(host_name)
      self.droplets.all.find{|d| d.name == host_name}
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
open-dock-0.0.10 lib/open-dock/digitalocean.rb
prun-ops-0.0.9 lib/prun-ops/digitalocean.rb
prun-ops-0.0.8 lib/prun-ops/digitalocean.rb
prun-ops-0.0.7 lib/prun-ops/digitalocean.rb
prun-ops-0.0.6 lib/prun-ops/digitalocean.rb
prun-ops-0.0.5 lib/prun-ops/digitalocean.rb
prun-ops-0.0.4 lib/prun-ops/digitalocean.rb
prun-ops-0.0.3 lib/prun-ops/digitalocean.rb
prun-ops-0.0.2 lib/prun-ops/digitalocean.rb