manageheroku 0.0.1

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: c2d02b1fdc27479ab5f8ead9f8c101edab42bb43
4
+ data.tar.gz: 7dff69b335c0cf9513dd03535b7f047d323a3b5c
5
+ SHA512:
6
+ metadata.gz: df9ca8c44525386e0d7dc7d08b33691fe866bd12c17660d8d6d89608b59604c1c19763dad007cdd3edac853511fa11084b6762963da7cf3ffc29d81af5eefe59
7
+ data.tar.gz: 727ecfb5925da2b619992731a75b65cda0bb6e6ee3a9ab49a419aa6f1ea7ff3868764b100dd5724a6cc82246d5f5472d01dfd86b681480580c56c249aff023e5
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in manageheroku.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Josh Cronemeyer
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Manageheroku
2
+
3
+ Manage Heroku App Formations
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'manageheroku'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install manageheroku
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/manageheroku/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.test_files = FileList['test/*_test.rb']
6
+ end
@@ -0,0 +1,8 @@
1
+ require 'platform-api'
2
+ require "manageheroku/version"
3
+ require "manageheroku/formation"
4
+ require "manageheroku/conf"
5
+ require "manageheroku/heroku"
6
+
7
+ module Manageheroku
8
+ end
@@ -0,0 +1,18 @@
1
+ require 'yaml'
2
+ module Manageheroku
3
+ class Conf
4
+ def initialize(conf_file)
5
+ @conf_data = {}
6
+ @conf_data = YAML.load_file(conf_file)
7
+ end
8
+
9
+ def oauth_token
10
+ @conf_data['oauth-token']
11
+ end
12
+
13
+ def formations
14
+ formation_objects = @conf_data["formations"]
15
+ formation_objects.map{|formation_object| Manageheroku::Formation.new(formation_object["name"], formation_object["procs"]) }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ module Manageheroku
2
+ class Formation
3
+ attr_reader :name
4
+ def initialize(name, procs)
5
+ @name = name
6
+ @procs = procs
7
+ end
8
+
9
+ def update_params
10
+ [@name, {updates: @procs}]
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ module Manageheroku
2
+ class Heroku
3
+ def initialize(conf_file)
4
+ @conf = Manageheroku::Conf.new(conf_file)
5
+ @formations = @conf.formations
6
+ @heroku = PlatformAPI.connect_oauth(@conf.oauth_token)
7
+ end
8
+
9
+ def update!
10
+ @formations.each do |formation|
11
+ @heroku.formation.batch_update(*formation.update_params)
12
+ end
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module Manageheroku
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'manageheroku/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "manageheroku"
8
+ spec.version = Manageheroku::VERSION
9
+ spec.authors = ["Josh Cronemeyer"]
10
+ spec.email = ["joshuacronemeyer@gmail.com"]
11
+ spec.summary = %q{Manage Heroku Apps from config files}
12
+ spec.description = %q{Manage Heroku Apps from config files}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency 'platform-api', '~> 0.5.0'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ end
data/test/conf_test.rb ADDED
@@ -0,0 +1,17 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ class ConfTest < MiniTest::Test
4
+ describe "configuration" do
5
+ it "must load the oauth token" do
6
+ conf = Manageheroku::Conf.new(File.join(File.dirname(__FILE__), 'sample_conf.yml'))
7
+ conf.oauth_token.must_equal "the-magic-oauth-token"
8
+ end
9
+
10
+ it "must update all the formations" do
11
+ conf = Manageheroku::Conf.new(File.join(File.dirname(__FILE__), 'sample_conf.yml'))
12
+ conf.formations.first.name.must_equal "myapp-development"
13
+ conf.formations.last.name.must_equal "myapp-performance"
14
+ end
15
+ end
16
+ end
17
+
@@ -0,0 +1,12 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ class HerokuTest < MiniTest::Test
4
+ describe "heroku" do
5
+ # it "really works" do
6
+ # conf_file_path = File.join(File.dirname(__FILE__), 'analysis_conf.yml')
7
+ # heroku = Manageheroku::Heroku.new(conf_file_path)
8
+ # heroku.update!
9
+ # end
10
+ end
11
+ end
12
+
@@ -0,0 +1,20 @@
1
+ oauth-token: "the-magic-oauth-token"
2
+ formations:
3
+ - name: "myapp-development"
4
+ procs:
5
+ - process: "web"
6
+ quantity: 0
7
+ - process: "resque-low"
8
+ quantity: 0
9
+ - name: "myapp-staging"
10
+ procs:
11
+ - process: "web"
12
+ quantity: 0
13
+ - process: "resque-low"
14
+ quantity: 0
15
+ - name: "myapp-performance"
16
+ procs:
17
+ - process: "web"
18
+ quantity: 0
19
+ - process: "resque-low"
20
+ quantity: 0
@@ -0,0 +1,3 @@
1
+ require 'minitest/autorun'
2
+ require 'manageheroku'
3
+
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: manageheroku
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Josh Cronemeyer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: platform-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.5.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.5.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Manage Heroku Apps from config files
56
+ email:
57
+ - joshuacronemeyer@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/manageheroku.rb
68
+ - lib/manageheroku/conf.rb
69
+ - lib/manageheroku/formation.rb
70
+ - lib/manageheroku/heroku.rb
71
+ - lib/manageheroku/version.rb
72
+ - manageheroku.gemspec
73
+ - test/conf_test.rb
74
+ - test/heroku_test.rb
75
+ - test/sample_conf.yml
76
+ - test/test_helper.rb
77
+ homepage: ''
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.2.2
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: Manage Heroku Apps from config files
101
+ test_files:
102
+ - test/conf_test.rb
103
+ - test/heroku_test.rb
104
+ - test/sample_conf.yml
105
+ - test/test_helper.rb