heroku_hatchet 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1dd72d84205630c9902d1034ed9b2f358f9bcac7
4
- data.tar.gz: 39699160e782ab507187f9d0d0e366d8d4498bb2
3
+ metadata.gz: f7c988335800a9dca89f7a076e3ce6cfdac19d83
4
+ data.tar.gz: d60e3963f8d0fdb5e9093de065fb0febb76e18c5
5
5
  SHA512:
6
- metadata.gz: 47a512d1cdb769b32fda37d815f3f4c21efca697987f2edff92f1a1d103ce5e70a8c2a8d80bd68a5c6dc2d7501e8aa977753649afd0dd26932baa0498197c369
7
- data.tar.gz: b31f80b92e7471ac1f40a690735187787dfead74e41846a93f4644d4a7bfb36fc12581ce770db5d25ff4c4a262ad7e4212547d64d770532c68928e94c9bc6342
6
+ metadata.gz: 329323e1be9617e21c2a23ca6ac0755a7bbf31645bfe0081a8d27ba9936eb328f3a2444b6a650efcd39e0924cfbf7fd5de62fe82eb213764582edf2cb33ab084
7
+ data.tar.gz: 8bef99fdd2e069e5d81f401a0dc20b790da68fff8ee269568ec1dc05e4e25bfc5d6165fe8114bf4821bc45b48fcd123f680d45c7010e49ca31e1c4d0060cca9b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## HEAD
2
2
 
3
+ ## 1.3.5
4
+
5
+ - Ensure travis box has an SSH key
6
+
3
7
  ## 1.3.4
4
8
 
5
9
  - Ignore when we try to delete an app that does not exist
data/bin/hatchet CHANGED
@@ -13,6 +13,7 @@ $: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
13
13
  require 'hatchet'
14
14
  require 'thor'
15
15
  require 'threaded'
16
+ require 'date'
16
17
 
17
18
  class HatchetCLI < Thor
18
19
  desc "install", "installs repos defined in 'hatchet.json'"
@@ -40,6 +41,22 @@ class HatchetCLI < Thor
40
41
  end
41
42
  end
42
43
 
44
+ desc "destroy [NAME]", "Deletes applications"
45
+ option :all, :type => :boolean
46
+ def destroy(name=nil)
47
+ api_key = ENV['HEROKU_API_KEY'] || bundle_exec {`heroku auth:token`.chomp }
48
+ heroku = Heroku::API.new(api_key: api_key)
49
+ reaper = Hatchet::Reaper.new(heroku)
50
+
51
+ if options[:all]
52
+ reaper.destroy_all
53
+ elsif !name.nil?
54
+ reaper.destroy_by_name(name)
55
+ else
56
+ raise "Must provide an app name or --all"
57
+ end
58
+ end
59
+
43
60
  private
44
61
 
45
62
  def warn_dot_ignore!
@@ -72,6 +89,16 @@ class HatchetCLI < Thor
72
89
  FileUtils.mkdir_p(path)
73
90
  puts `cd #{path} && git clone #{git_repo} --quiet`
74
91
  end
92
+
93
+ def bundle_exec
94
+ if defined?(Bundler)
95
+ Bundler.with_clean_env do
96
+ yield
97
+ end
98
+ else
99
+ yield
100
+ end
101
+ end
75
102
  end
76
103
 
77
104
  HatchetCLI.start(ARGV)
@@ -34,12 +34,23 @@ module Hatchet
34
34
 
35
35
  def destroy_oldest
36
36
  oldest_name = @hatchet_apps.pop["name"]
37
- puts "Destroying #{oldest_name.inspect}. Hatchet app limit: #{HATCHET_APP_LIMT}"
38
- @heroku.delete_app(oldest_name)
37
+ destroy_by_name(oldest_name, "Hatchet app limit: #{HATCHET_APP_LIMT}")
39
38
  rescue Heroku::API::Errors::NotFound
40
39
  # app already deleted, cycle will catch if there's still too many
41
40
  end
42
41
 
42
+ def destroy_all
43
+ get_apps
44
+ @hatchet_apps.each do |app|
45
+ destroy_by_name(app["name"])
46
+ end
47
+ end
48
+
49
+ def destroy_by_name(name, details="")
50
+ puts "Destroying #{name.inspect}. #{details}"
51
+ @heroku.delete_app(name)
52
+ end
53
+
43
54
  private
44
55
 
45
56
  def over_limit?
@@ -47,4 +58,3 @@ module Hatchet
47
58
  end
48
59
  end
49
60
  end
50
-
@@ -1,3 +1,3 @@
1
1
  module Hatchet
2
- VERSION = "1.3.4"
2
+ VERSION = "1.3.5"
3
3
  end
@@ -0,0 +1,31 @@
1
+ require 'test_helper'
2
+
3
+ class ReaperTest < Test::Unit::TestCase
4
+
5
+ def test_destroy_by_name
6
+ heroku = mock('heroku')
7
+ reaper = Hatchet::Reaper.new(heroku)
8
+ heroku.expects(:delete_app).with("my-app-name")
9
+ reaper.destroy_by_name("my-app-name")
10
+ end
11
+
12
+ def test_destroy_all
13
+ heroku = stub(:get_apps =>
14
+ stub(:body => [{
15
+ 'name' => 'hatchet-t-123',
16
+ 'created_at' => DateTime.new.to_s
17
+ },{
18
+ 'name' => 'hatchet-t-abc',
19
+ 'created_at' => DateTime.new.to_s
20
+ },{
21
+ 'name' => 'my-app-name',
22
+ 'created_at' => DateTime.new.to_s
23
+ }
24
+ ])
25
+ )
26
+ reaper = Hatchet::Reaper.new(heroku)
27
+ heroku.expects(:delete_app).with('hatchet-t-123')
28
+ heroku.expects(:delete_app).with('hatchet-t-abc')
29
+ reaper.destroy_all
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_hatchet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Schneeman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-25 00:00:00.000000000 Z
11
+ date: 2014-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: heroku-api
@@ -249,6 +249,7 @@ files:
249
249
  - test/hatchet/heroku_api_test.rb
250
250
  - test/hatchet/labs_test.rb
251
251
  - test/hatchet/multi_cmd_runner_test.rb
252
+ - test/hatchet/reaper_test.rb
252
253
  - test/hatchet/runner_test.rb
253
254
  - test/test_helper.rb
254
255
  homepage: https://github.com/heroku/hatchet
@@ -321,5 +322,7 @@ test_files:
321
322
  - test/hatchet/heroku_api_test.rb
322
323
  - test/hatchet/labs_test.rb
323
324
  - test/hatchet/multi_cmd_runner_test.rb
325
+ - test/hatchet/reaper_test.rb
324
326
  - test/hatchet/runner_test.rb
325
327
  - test/test_helper.rb
328
+ has_rdoc: