kibo 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,43 @@
1
1
  module Kibo::Commands
2
- subcommand :create, "create missing targets" do
3
- opt :all, "Create all missing targets.", :short => "a"
2
+ subcommand :remotes, "create missing remotes" do
3
+ opt :all, "Create all missing remotes.", :short => "a"
4
4
  end
5
5
 
6
+ subcommand :create, "create missing apps"
7
+
8
+ subcommand :collaborate, "add collaborations"
9
+
6
10
  def create
7
11
  verify_heroku_login
8
12
 
13
+ apps = heroku("apps").split("\n").reject { |line| line =~ /===/ }
14
+ missing_apps = h.expected_remotes - apps
15
+
16
+ confirm! <<-MSG
17
+ I am going to create these instances: #{missing_apps.map(&:inspect).join(", ")} for you [#{Kibo.config.account}].
18
+ MSG
19
+
20
+ missing_apps.each do |instance|
21
+ create_instance(instance)
22
+ Kibo.config.collaborations.each do |email|
23
+ heroku "sharing:add", email
24
+ end
25
+ end
26
+ end
27
+
28
+ def collaborate
29
+ verify_heroku_login
30
+
31
+ h.expected_remotes.each do |instance|
32
+ Kibo.config.collaborations.each do |email|
33
+ heroku "sharing:add", email, "--app", instance
34
+ end
35
+ end
36
+ end
37
+
38
+ def remotes
9
39
  if Kibo.command_line.all?
10
- instances = missing_remotes
40
+ instances = h.missing_remotes
11
41
  if instances.empty?
12
42
  W "Nothing to do."
13
43
  exit 0
@@ -20,7 +50,7 @@ module Kibo::Commands
20
50
  end
21
51
 
22
52
  # only create instances that are actually missing.
23
- extra_instances = instances - missing_remotes
53
+ extra_instances = instances - h.missing_remotes
24
54
  unless extra_instances.empty?
25
55
  E <<-MSG
26
56
  kibo cannot create these instances for you: #{extra_instances.map(&:inspect).join(", ")}, because I don't not know anything about these.
@@ -28,13 +58,8 @@ MSG
28
58
  end
29
59
  end
30
60
 
31
- confirm! <<-MSG
32
- I am going to create these instances: #{instances.map(&:inspect).join(", ")}. Is this what you want? Note:
33
- You are logged in at heroku as #{config.account}.
34
- MSG
35
-
36
- instances.each do |instance|
37
- create_instance(instance)
61
+ h.missing_remotes.each do |remote|
62
+ git "remote", "add", remote, "git@heroku.com:#{remote}.git"
38
63
  end
39
64
  end
40
65
 
@@ -50,7 +75,7 @@ MSG
50
75
  if !whoami
51
76
  E "Please log in ('heroku auth:login') as #{config.account}."
52
77
  elsif whoami != Kibo.config.account
53
- E "You are currently logged in as #{whoami}; please log in ('heroku auth:login') as #{config.account}."
78
+ E "You are currently logged in as #{whoami}; please log in ('heroku auth:login') as #{Kibo.config.account}."
54
79
  end
55
80
  end
56
81
  end
@@ -10,10 +10,28 @@ module Kibo::Commands
10
10
  info.line "current account", h.whoami
11
11
  info.line "expected account", Kibo.config.account
12
12
 
13
+ info.head "processes"
14
+ Kibo.config.processes.each do |key, value|
15
+ info.line key, value
16
+ end
17
+
13
18
  info.head "remotes"
14
19
  info.line "remotes", h.expected_remotes
15
20
  info.line "configured", h.configured_remotes
16
21
  info.line "missing", h.missing_remotes
17
22
  end
18
23
  end
24
+
25
+ subcommand :logs, "Show log files for current instances"
26
+ def logs
27
+ h.configured_remotes.each do |remote|
28
+ fork do
29
+ cmd = "heroku logs --tail --app #{remote} | sed s/^/\\\\[#{remote}\\\\]\\ /"
30
+ W cmd
31
+ exec(cmd)
32
+ end
33
+ end
34
+
35
+ Process.waitall
36
+ end
19
37
  end
@@ -6,7 +6,7 @@ module Kibo::Commands
6
6
  h.check_missing_remotes :warn
7
7
 
8
8
  h.configured_remotes.each do |remote|
9
- configure_remote! remote
9
+ h.configure_remote! remote
10
10
  end
11
11
  end
12
12
  end
data/lib/kibo/config.rb CHANGED
@@ -10,6 +10,7 @@ class Kibo::Configfile < Hash
10
10
  split("\n").
11
11
  each_with_index do |line, lineno|
12
12
  next if line =~ /^\s*#/
13
+ next if line =~ /^\s*$/
13
14
  die(lineno, "Can't parse line: #{line.inspect}") unless line =~ /\s*([a-z]+):\s*(.*)$/
14
15
  key, value = $1, $2.gsub(/\s+$/, "")
15
16
 
@@ -98,6 +99,10 @@ class Kibo::Config
98
99
  self["deployment"] || {}
99
100
  end
100
101
 
102
+ def collaborations
103
+ self["collaborations"] || {}
104
+ end
105
+
101
106
  # returns source specific configuration
102
107
  def source
103
108
  self["source"] || {}
@@ -117,15 +122,13 @@ class Kibo::Config
117
122
  def remotes_by_process
118
123
  remotes = Kibo.git("remote", :quiet).split("\n")
119
124
 
120
- @remotes_by_process ||= remotes.group_by do |remote|
121
- case remote
122
- when /^#{namespace}-#{environment}-(\w+)(\d+)/
123
- $1
124
- when /^#{namespace}-#{environment}-/
125
- W "#{remote.inspect}: Ignoring target..."
126
- nil
127
- else
125
+ @remotes_by_process ||= begin
126
+ r = processes.map do |process, count|
127
+ prefix = "#{namespace}-#{environment}-#{process}"
128
+ remotes = 1.upto(count).map { |idx| "#{prefix}#{idx}" }
129
+ [ process, remotes ]
128
130
  end
129
- end.tap { |hash| hash.delete(nil) }
131
+ Hash[r]
132
+ end
130
133
  end
131
134
  end
data/lib/kibo/helpers.rb CHANGED
@@ -21,6 +21,8 @@ module Kibo::Helpers
21
21
  return
22
22
  end
23
23
 
24
+ environment = Kibo.environment
25
+
24
26
  E <<-MSG
25
27
  Missing remote(s): #{missing_remotes.map(&:inspect).join(", ")}. Run
26
28
 
@@ -33,7 +35,8 @@ Missing remote(s): #{missing_remotes.map(&:inspect).join(", ")}. Run
33
35
  # -- configure remotes ----------------------------------------------
34
36
 
35
37
  def configure_remote!(remote)
36
- sys.heroku "config:set",
38
+ environment = Kibo.environment
39
+ sys.heroku "config:set",
37
40
  "RACK_ENV=#{environment}",
38
41
  "RAILS_ENV=#{environment}",
39
42
  "INSTANCE=#{instance_for_remote(remote)}",
@@ -41,7 +44,7 @@ Missing remote(s): #{missing_remotes.map(&:inspect).join(", ")}. Run
41
44
  end
42
45
 
43
46
  def instance_for_remote(remote)
44
- remote[config.namespace.length + 1 .. -1]
47
+ remote[Kibo.config.namespace.length + 1 .. -1]
45
48
  end
46
49
 
47
50
  def configure_remote(remote)
data/lib/kibo/log.rb CHANGED
@@ -37,8 +37,8 @@ def S(*args)
37
37
  end
38
38
 
39
39
  def confirm!(msg)
40
- puts msg
41
- puts "\n\nPress ^C to abort or return to continue."
40
+ UI.warn msg
41
+ puts "Press ^C to abort or return to continue."
42
42
 
43
43
  STDIN.readline
44
44
  end
data/lib/kibo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kibo
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
data/man/kibo.1 CHANGED
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "KIBO" "1" "September 2012" "Kibo 0.3.4" "Kibo Manual"
4
+ .TH "KIBO" "1" "September 2012" "Kibo 0.3.5" "Kibo Manual"
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBkibo\fR \- manage heroku applications
data/man/kibo.1.html CHANGED
@@ -172,7 +172,7 @@ kibo -e production spindown
172
172
 
173
173
 
174
174
  <ol class='man-decor man-foot man foot'>
175
- <li class='tl'>Kibo 0.3.4</li>
175
+ <li class='tl'>Kibo 0.3.5</li>
176
176
  <li class='tc'>September 2012</li>
177
177
  <li class='tr'>kibo(1)</li>
178
178
  </ol>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kibo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-23 00:00:00.000000000 Z
12
+ date: 2012-10-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: trollop
@@ -127,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  segments:
129
129
  - 0
130
- hash: -3856345431074645108
130
+ hash: 173262939670169996
131
131
  required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  none: false
133
133
  requirements: