heroku_hatchet 1.1.5 → 1.1.6

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: 4ee0b38854a5f1cb30cfc0d7e9fd24852f1e6b1b
4
- data.tar.gz: e4590d04c6c89c2aa7c13aa43188876e626d74af
3
+ metadata.gz: 5858aba476c6665c554f78f1e59ff86620441b05
4
+ data.tar.gz: b720257ac9ec4fef2df697eb48c36f519cdec43d
5
5
  SHA512:
6
- metadata.gz: f91146008e35f431a642779c6cc4026f8e537dc7800262d561bf4d3750a6f955a0e78b16b5501c90a780f0a39716765bfefeba6e129628359609a207832c3073
7
- data.tar.gz: 0ef2a05da46150f37a1cf93f33fa3b314f25073ec8d8b253324c58d7f7797444be3648090cd779e72e3185b615f0ed1d34c7ca2a311ef9137beeb1086e3d8ba0
6
+ metadata.gz: dc750c15ad6d24155300b83d7015b6b4c906ce5222ac730e9bd4d9ec3fac3cfb2ee2c7108becf53658e823e66491feed7c99fa08eb29146ae658fc41a1ecad01
7
+ data.tar.gz: 4b67d67bc28e56613d9495f448a69447cff1fd58569b3ec1be4869eba55abc0f18513ea1bce3ad5db8a21679774bbcd114fb8e663913ae751d2c8c53f6b2bf3f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## HEAD
2
2
 
3
+ ## 1.1.6
4
+ - `App#setup!` is now idempotent
5
+ - Added `App#get_config`
6
+ - Added `App#set_config`
7
+
3
8
  ## 1.1.5
4
9
  - Add `App#in_directory` to public API
5
10
 
data/Rakefile CHANGED
@@ -12,4 +12,4 @@ test_task = Rake::TestTask.new(:test) do |t|
12
12
  t.libs << 'test'
13
13
  t.pattern = 'test/hatchet/**/*_test.rb'
14
14
  t.verbose = false
15
- end
15
+ end
data/lib/hatchet/app.rb CHANGED
@@ -27,14 +27,23 @@ module Hatchet
27
27
  self.class.config
28
28
  end
29
29
 
30
+ def set_config(options = {})
31
+ options.each do |key, value|
32
+ heroku.put_config_vars(name, key => value)
33
+ end
34
+ end
30
35
 
31
- def add_database(db_name = 'heroku-postgresql:dev', match_val = "HEROKU_POSTGRESQL_[A-Z]+_URL")
32
- Hatchet::RETRIES.times.retry do
33
- heroku.post_addon(name, db_name)
34
- _, value = heroku.get_config_vars(name).body.detect {|k, v| k.match(/#{match_val}/) }
35
- heroku.put_config_vars(name, 'DATABASE_URL' => value)
36
+ def get_config
37
+ heroku.get_config_vars(name).body
38
+ end
39
+
40
+ def add_database(db_name = 'heroku-postgresql:dev', match_val = "HEROKU_POSTGRESQL_[A-Z]+_URL")
41
+ Hatchet::RETRIES.times.retry do
42
+ heroku.post_addon(name, db_name)
43
+ _, value = get_config.detect {|k, v| k.match(/#{match_val}/) }
44
+ set_config('DATABASE_URL' => value)
45
+ end
36
46
  end
37
- end
38
47
 
39
48
  # runs a command on heroku similar to `$ heroku run #foo`
40
49
  # but programatically and with more control
@@ -68,8 +77,10 @@ module Hatchet
68
77
 
69
78
  # creates a new heroku app via the API
70
79
  def setup!
80
+ return self if @app_is_setup
71
81
  heroku.post_app(name: name)
72
82
  @app_is_setup = true
83
+ self
73
84
  end
74
85
 
75
86
  def push!
@@ -1,3 +1,3 @@
1
1
  module Hatchet
2
- VERSION = "1.1.5"
2
+ VERSION = "1.1.6"
3
3
  end
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+
3
+ class HerokuApiTest < Test::Unit::TestCase
4
+
5
+ def test_config_vars
6
+ runner = Hatchet::Runner.new("no_lockfile").setup!
7
+ expected = {}
8
+ assert_equal expected, runner.get_config
9
+ runner.set_config("foo" => "bar")
10
+ expected = {"foo" => "bar"}
11
+ assert_equal expected, runner.get_config
12
+ ensure
13
+ runner.teardown!
14
+ end
15
+ 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.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Schneeman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-26 00:00:00.000000000 Z
11
+ date: 2013-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: heroku-api
@@ -216,6 +216,7 @@ files:
216
216
  - test/hatchet/anvil_test.rb
217
217
  - test/hatchet/config_test.rb
218
218
  - test/hatchet/git_test.rb
219
+ - test/hatchet/heroku_api_test.rb
219
220
  - test/hatchet/multi_cmd_runner_test.rb
220
221
  - test/hatchet/runner_test.rb
221
222
  - test/test_helper.rb
@@ -285,6 +286,7 @@ test_files:
285
286
  - test/hatchet/anvil_test.rb
286
287
  - test/hatchet/config_test.rb
287
288
  - test/hatchet/git_test.rb
289
+ - test/hatchet/heroku_api_test.rb
288
290
  - test/hatchet/multi_cmd_runner_test.rb
289
291
  - test/hatchet/runner_test.rb
290
292
  - test/test_helper.rb