tddium-preview 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tddium-preview (0.1.5)
4
+ tddium-preview (0.5.0)
5
5
  bundler
6
6
  highline
7
7
  json
data/lib/tddium.rb CHANGED
@@ -33,12 +33,13 @@ class Tddium < Thor
33
33
  method_option :email, :type => :string, :default => nil
34
34
  method_option :password, :type => :string, :default => nil
35
35
  method_option :ssh_key_file, :type => :string, :default => nil
36
+ method_option :app, :type => :string, :default => nil
36
37
  def account
37
38
  set_default_environment(options[:environment])
38
39
  if user_details = user_logged_in?
39
40
  # User is already logged in, so just display the info
40
41
  show_user_details(user_details)
41
- elsif heroku_config = HerokuConfig.read_config
42
+ elsif heroku_config = HerokuConfig.read_config(options[:app])
42
43
  # User has logged in to heroku, and TDDIUM environment variables are
43
44
  # present
44
45
  handle_heroku_user(options, heroku_config)
@@ -429,7 +430,7 @@ class Tddium < Thor
429
430
  if user && user["user"]["heroku_needs_activation"] != true
430
431
  say Text::Status::HEROKU_CONFIG
431
432
  elsif user
432
- say Text::Process::HEROKU_WELCOME
433
+ say Text::Process::HEROKU_WELCOME % heroku_config['TDDIUM_USER_NAME']
433
434
  params = get_user_credentials(:email => heroku_config['TDDIUM_USER_NAME'])
434
435
  params.delete(:email)
435
436
  params[:password_confirmation] = HighLine.ask(Text::Prompt::PASSWORD_CONFIRMATION) { |q| q.echo = "*" }
@@ -94,6 +94,8 @@ tddium spec
94
94
  HEROKU_WELCOME = "
95
95
  Thanks for installing the Tddium Heroku Add-On!
96
96
 
97
+ Your tddium username is: %s
98
+
97
99
  Next, set a password and provide an SSH key to authenticate your communication
98
100
  with Tddium.
99
101
 
data/lib/tddium/heroku.rb CHANGED
@@ -3,11 +3,14 @@ Copyright (c) 2011 Solano Labs All Rights Reserved
3
3
  =end
4
4
 
5
5
  class HerokuConfig
6
- def self.read_config
6
+ REQUIRED_KEYS = %w{TDDIUM_API_KEY TDDIUM_USER_NAME}
7
+ def self.read_config(app=nil)
7
8
  result = nil
8
9
  begin
9
10
  config = {}
10
- output = `heroku config -s`
11
+ command = "heroku config -s"
12
+ command += " --app #{app}" if app
13
+ output = `#{command}`
11
14
  output.lines.each do |line|
12
15
  line.chomp!
13
16
  k, v = line.split('=')
@@ -15,6 +18,7 @@ class HerokuConfig
15
18
  config[k] = v
16
19
  end
17
20
  end
21
+ return nil if REQUIRED_KEYS.inject(false) {|missing, x| !config[x]}
18
22
  result = config if config.keys.length > 0
19
23
  rescue Errno::ENOENT
20
24
  rescue Errno::EPERM
@@ -3,5 +3,5 @@ Copyright (c) 2011 Solano Labs All Rights Reserved
3
3
  =end
4
4
 
5
5
  module TddiumVersion
6
- VERSION = "0.5.0"
6
+ VERSION = "0.5.1"
7
7
  end
data/spec/heroku_spec.rb CHANGED
@@ -7,9 +7,13 @@ require "rspec"
7
7
  require "tddium/heroku"
8
8
 
9
9
  describe HerokuConfig do
10
+ SAMPLE_APP = "testapp"
10
11
  SAMPLE_HEROKU_CONFIG_TDDIUM = "
11
12
  TDDIUM_API_KEY=abcdefg
12
13
  TDDIUM_USER_NAME=app1234@heroku.com
14
+ "
15
+ SAMPLE_HEROKU_CONFIG_PARTIAL = "
16
+ TDDIUM_API_KEY=abcdefg
13
17
  "
14
18
  SAMPLE_HEROKU_CONFIG_NO_TDDIUM = "
15
19
  DB_URL=postgres://foo/bar
@@ -32,6 +36,28 @@ DB_URL=postgres://foo/bar
32
36
  end
33
37
  end
34
38
 
39
+ context "with app specified" do
40
+ before do
41
+ HerokuConfig.stub(:`).with("heroku config -s --app #{SAMPLE_APP}").and_return(SAMPLE_HEROKU_CONFIG_TDDIUM)
42
+ HerokuConfig.should_receive(:`).with("heroku config -s --app #{SAMPLE_APP}")
43
+ end
44
+
45
+ it "should pass the app to heroku config" do
46
+ result = HerokuConfig.read_config(SAMPLE_APP)
47
+ result.should_not be_nil
48
+ end
49
+ end
50
+
51
+ context "missing config" do
52
+ before do
53
+ HerokuConfig.stub(:`).with("heroku config -s").and_return(SAMPLE_HEROKU_CONFIG_PARTIAL)
54
+ end
55
+
56
+ it "should return nil" do
57
+ HerokuConfig.read_config.should be_nil
58
+ end
59
+ end
60
+
35
61
  context "addon not installed" do
36
62
  before do
37
63
  HerokuConfig.stub(:`).with("heroku config -s").and_return(SAMPLE_HEROKU_CONFIG_NO_TDDIUM)
data/spec/tddium_spec.rb CHANGED
@@ -536,7 +536,7 @@ describe Tddium do
536
536
  it_behaves_like "prompt for ssh key"
537
537
 
538
538
  it "should display the heroku welcome" do
539
- tddium.should_receive(:say).with(Tddium::Text::Process::HEROKU_WELCOME)
539
+ tddium.should_receive(:say).with(Tddium::Text::Process::HEROKU_WELCOME % SAMPLE_EMAIL)
540
540
  run_account(tddium)
541
541
  end
542
542
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: tddium-preview
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.0
5
+ version: 0.5.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Solano Labs
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-27 00:00:00 -07:00
13
+ date: 2011-05-28 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency