tidy_reset 0.1.23 → 0.1.24

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: 5dfac396bf01cba613e7d43a88f111983eca7786
4
- data.tar.gz: 7bf9c15e7f6ad4bd1937eba79ebb26e358583f01
3
+ metadata.gz: 7e4be60e9fd7b99c31bd8ffff061911dcfa61f26
4
+ data.tar.gz: 1085ff55b83971aac52ff1be6719911e8b83af09
5
5
  SHA512:
6
- metadata.gz: b5d0052b3e2ccda5a0516daafec4b6b989a96d7e926b8f2cee692b4c60ab34c73708831d7e8a1da2055179b78da7f03c7b36e03e56c52c09c52752c7d3a77f8e
7
- data.tar.gz: 6b82ccbbd804e68549f06239eb1bbb97c3f35c0019c8794cfdd232bdc6ca4d0ed47ec067d9bc3d406d566abeee5d3571db0960d0de105f1abfd7776787c941b5
6
+ metadata.gz: 9d5c85c33315bb752eafa77f2ab06b09f60ac77fcaf1be9aee9f7a229ca49aee9ea751ecc4b86d0b8a689a660f5b1b53d520bb10feec6c92ef52bf7471133239
7
+ data.tar.gz: b094be0064f1f3daaac1d5eca10760d72632988d17143af2b2444182eaf145a87d654fe73055cf5e4b09bf39a21949a66df0c40080beacf96af9cda0edca37d7
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.23
1
+ 0.1.24
@@ -2,12 +2,12 @@ require 'platform-api'
2
2
 
3
3
  module TidyReset
4
4
  class ApplicationManager
5
- attr_accessor :name
5
+ attr_accessor :name, :token
6
6
 
7
7
  def initialize(options)
8
8
  @name = options.fetch(:name)
9
- token = options.fetch(:token)
10
- @heroku = PlatformAPI.connect_oauth(token)
9
+ @token = options.fetch(:token)
10
+ @heroku = PlatformAPI.connect_oauth(@token)
11
11
  end
12
12
 
13
13
  def enable_maintenance_mode
data/lib/tidy_reset.rb CHANGED
@@ -82,11 +82,19 @@ module TidyReset
82
82
  end
83
83
 
84
84
  def create_application_manager(application_name)
85
- token = configuration.token
85
+ token = if configuration.token
86
+ configuration.token
87
+ else
88
+ auth_token_cli
89
+ end
86
90
  raise NoTokenException unless token
87
91
  self::ApplicationManager.new(name: application_name, token: token)
88
92
  end
89
93
 
94
+ def auth_token_cli
95
+ Bundler.with_clean_env { `heroku auth:token`.chomp }
96
+ end
97
+
90
98
  def master_connection_from_db_config(db_config)
91
99
  # Get connection to master/maintenance database 'postgres'
92
100
  pool = ActiveRecord::Base.send(establish_connection_method, db_config.merge(
@@ -72,11 +72,20 @@ describe "TidyReset" do
72
72
  end
73
73
  TidyReset.create_application_manager('application-name').should be_a TidyReset::ApplicationManager
74
74
  end
75
- it "should require an oauth_token to be set on the configuration" do
75
+ it "should use the configuration token if it is set" do
76
76
  TidyReset.configure do |config|
77
+ config.token = 'abc'
78
+ end
79
+ app_manager = TidyReset.create_application_manager('application-name')
80
+ app_manager.token.should == 'abc'
81
+ end
82
+ it "should use the heroku command to get the current user's token if the configuraiton is not set" do
83
+ TidyReset.configure do |config|
77
84
  config.token = nil
78
85
  end
79
- expect { TidyReset.create_application_manager('application_manager') }.to raise_error(TidyReset::NoTokenException)
86
+ TidyReset.should_receive(:auth_token_cli).and_return('def')
87
+ app_manager = TidyReset.create_application_manager('application-name')
88
+ app_manager.token.should == 'def'
80
89
  end
81
90
  end
82
91
  end
data/tidy_reset.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: tidy_reset 0.1.23 ruby lib
5
+ # stub: tidy_reset 0.1.24 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "tidy_reset"
9
- s.version = "0.1.23"
9
+ s.version = "0.1.24"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tidy_reset
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.23
4
+ version: 0.1.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thinknear