puddle 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 540bfda5cceaaa2418e6ec4056082575068b9c60
4
+ data.tar.gz: b59625b98b959bfb98b44c278b39d51afcb8885b
5
+ SHA512:
6
+ metadata.gz: e4d713bebd45a77f38c8de9af1f579cd11b09284af9288d9c8fc6b20726e960650aafdfc39b4be61110a10c75873865acd9bb3f7f9ffa6562139c8c70b08020b
7
+ data.tar.gz: ff67bd52dd4ae253548ba731ac661120a79c3fb34a6d522d85e09368955a2ab7061251c8541ca5b6a802b23c978ecca9ba96db63026a6d86380ebfd14a5106db
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,5 @@
1
+ --color
2
+ --warnings
3
+ --require webmock/rspec
4
+ --require spec_helper
5
+ --require puddle
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.4
5
+ sudo: false
6
+ addons:
7
+ code_climate:
8
+ repo_token: 06a46ea5905e034f5b40db072d078c2208b89a15463f663842ba7019af7ae5cc
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in puddle.gemspec
4
+ gemspec
5
+
6
+ gem "codeclimate-test-reporter", "~> 0.4", group: :test, require: nil
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ [![Code Climate](https://codeclimate.com/github/rsb/puddle/badges/gpa.svg)](https://codeclimate.com/github/rsb/puddle)
2
+ [![Build Status](https://travis-ci.org/rsb/puddle.svg?branch=master)](https://travis-ci.org/rsb/puddle)
3
+ # Puddle
4
+ Puddle can be used in two different ways. Firstly, it is a command line utility
5
+ that simplifies creating, destroying or modifying digital ocean droplets, ssh
6
+ keys or domains. Secondly, it can be used as a library that can do the same
7
+ thing as the command line interface accept programmatically. I decided to write
8
+ puddle because I am working with continuous deployment pipelines and I wanted a
9
+ gem I had control over so that the pipelines could manage digital ocean objects.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'puddle'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install puddle
26
+
27
+ ## Usage
28
+
29
+ TODO: Write usage instructions here
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
36
+
37
+ ## Contributing
38
+
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/puddle. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
40
+
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "puddle"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ require "pry"
11
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/exe/puddle ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bundler/setup'
3
+ require 'puddle'
4
+
5
+ Puddle::Cli::Main.start(ARGV)
@@ -0,0 +1,17 @@
1
+ require 'thor'
2
+
3
+ module Puddle
4
+ module Cli
5
+ class BaseCli < Thor
6
+ class_option :token
7
+ class_option :json, type: :boolean
8
+
9
+ map %w[--version -v] => :__display_version
10
+
11
+ desc "--version", "prints the current version"
12
+ def __display_version
13
+ $stdout.puts Puddle::VERSION
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,36 @@
1
+ module Puddle
2
+ module Cli
3
+ class Main < BaseCli
4
+ desc 'account', 'show account details'
5
+ def account
6
+ token = options.token || ENV['DO_API_TOKEN']
7
+ Puddle.api_token = token
8
+
9
+ begin
10
+ result = Puddle.account
11
+ rescue RestClient::Unauthorized => e
12
+ $stderr.puts "#{e.message} invalid token"
13
+ exit 1
14
+ end
15
+
16
+ unless result.has_key?('account')
17
+ $stderr.puts 'no account found'
18
+ exit 1
19
+ end
20
+
21
+ result = result['account']
22
+ if options.json?
23
+ puts result.to_json
24
+ return
25
+ end
26
+
27
+ data = ""
28
+ data << sprintf("droplet limit: %-s\n", result['droplet_limit'])
29
+ data << sprintf("email: %-s\n", result['email'])
30
+ data << sprintf("uuid: %-s\n", result['uuid'])
31
+ data << sprintf("email verified: %-s\n", result['email_verified'])
32
+ puts data
33
+ end
34
+ end
35
+ end
36
+ end
data/lib/puddle/cli.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'puddle/cli/base_cli'
2
+ require 'puddle/cli/main'
@@ -0,0 +1,3 @@
1
+ module Puddle
2
+ VERSION = "0.1.0"
3
+ end
data/lib/puddle.rb ADDED
@@ -0,0 +1,66 @@
1
+ require 'json'
2
+ require 'puddle/version'
3
+ require 'rest-client'
4
+
5
+ module Puddle
6
+ DO_API_BASE = 'https://api.digitalocean.com'
7
+ DO_API_VERSION = 'v2'
8
+
9
+ class << self
10
+ attr_accessor :api_token
11
+ def digital_ocean_api_url
12
+ "#{DO_API_BASE}/#{DO_API_VERSION}"
13
+ end
14
+
15
+ def content_type_header
16
+ 'application/json'
17
+ end
18
+
19
+ def accept_header
20
+ '*/*; q=0.5, application/json'
21
+ end
22
+
23
+ def authorization_header
24
+ "Bearer #{api_token}"
25
+ end
26
+
27
+ def user_agent_header
28
+ 'Puddle'
29
+ end
30
+
31
+ def accept_encoding_header
32
+ 'gzip, deflate'
33
+ end
34
+
35
+ def build_headers(headers = {})
36
+ defaults = {
37
+ 'Accept' => accept_header,
38
+ 'Accept-Encoding' => accept_encoding_header,
39
+ 'Authorization' => authorization_header,
40
+ 'Content-Type' => content_type_header,
41
+ 'User-Agent' => user_agent_header,
42
+ }
43
+
44
+ defaults.merge(headers)
45
+ end
46
+
47
+ def account
48
+ result = digital_ocean(:get, 'account')
49
+ JSON.parse(result)
50
+ end
51
+
52
+ def digital_ocean(method, endpoint, options = {})
53
+ headers = build_headers(options[:headers] || {})
54
+ timeout = options[:timeout] || 10
55
+ url = "#{digital_ocean_api_url}/#{endpoint}"
56
+ RestClient::Request.execute(
57
+ method: method,
58
+ url: url,
59
+ headers: headers,
60
+ timeout: timeout
61
+ )
62
+ end
63
+ end
64
+
65
+ require "puddle/cli"
66
+ end
data/puddle.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'puddle/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "puddle"
8
+ spec.version = Puddle::VERSION
9
+ spec.authors = ["Robert Scott-Buccleuch"]
10
+ spec.email = ["rsb.code@gmail.com"]
11
+
12
+ spec.summary = %q{api wrapper to simplify managing droplets, ssh keys, domains etc...}
13
+ spec.homepage = "https://github.com/rsb/puddle"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/})}
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "thor", "~> 0.19.1"
21
+ spec.add_dependency "rest-client", "~> 1.8.0"
22
+
23
+ spec.add_development_dependency "pry", "~> 0.10.1"
24
+ spec.add_development_dependency "webmock", "~> 1.21.0"
25
+ spec.add_development_dependency "bundler", "~> 1.10"
26
+ spec.add_development_dependency "rspec", "~> 3.3"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: puddle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Robert Scott-Buccleuch
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.19.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.19.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.8.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.8.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.10.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.10.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.21.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.21.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.10'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '10.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '10.0'
111
+ description:
112
+ email:
113
+ - rsb.code@gmail.com
114
+ executables:
115
+ - puddle
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".travis.yml"
122
+ - CODE_OF_CONDUCT.md
123
+ - Gemfile
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - exe/puddle
129
+ - lib/puddle.rb
130
+ - lib/puddle/cli.rb
131
+ - lib/puddle/cli/base_cli.rb
132
+ - lib/puddle/cli/main.rb
133
+ - lib/puddle/version.rb
134
+ - puddle.gemspec
135
+ homepage: https://github.com/rsb/puddle
136
+ licenses: []
137
+ metadata: {}
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubyforge_project:
154
+ rubygems_version: 2.4.7
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: api wrapper to simplify managing droplets, ssh keys, domains etc...
158
+ test_files: []