kibo 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/bin/kibo CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ $:.unshift File.join(File.dirname(__FILE__), "../lib")
2
3
 
3
- require_relative "../lib/kibo"
4
+ require "kibo"
4
5
  Kibo.run
@@ -1,5 +1,4 @@
1
1
  require "trollop"
2
- require "kibo/version"
3
2
 
4
3
  module Kibo::CommandLine
5
4
  extend self
@@ -10,47 +10,74 @@ module Kibo::Commands
10
10
  h.check_missing_remotes(:error)
11
11
  end
12
12
 
13
- run_commands Kibo.config.deployment["first"]
14
- W "first commands done"
15
-
13
+ ENV["ENVIRONMENT"] = Kibo.environment
14
+
16
15
  #
17
- # create a deployment branch, if there is none yet.
18
- checkout_branch Kibo.environment
19
-
20
- git "merge", "master"
21
- run_commands Kibo.config.deployment["pre"]
22
- W "pre commands done"
23
-
24
- h.configured_remotes.each do |remote|
25
- deploy_remote! remote
16
+ # Run source commands
17
+ with_commands :source do
18
+
19
+ # create a deployment branch, if there is none yet.
20
+ in_branch "kibo.#{Kibo.environment}" do
21
+ git "merge", "master"
22
+
23
+ with_commands :deployment do
24
+ h.configured_remotes.each do |remote|
25
+ deploy_remote! remote
26
+ end
27
+ end
28
+ end
26
29
  end
27
-
28
- W "Deployment succeeded."
29
- run_commands Kibo.config.deployment["post"]
30
30
  rescue StandardError
31
31
  W $!
32
32
  raise
33
- ensure
34
- unless current_branch == "master"
35
- git "reset", "--hard"
36
- git "checkout", "master"
37
- end
38
33
  end
39
34
 
40
35
  private
36
+
37
+ def with_commands(sym, &block)
38
+ commands_hash = Kibo.config.send(sym) || {}
39
+
40
+ run = lambda { |key|
41
+ next unless commands = commands_hash[key]
42
+
43
+ W "Running #{sym}.#{key} commands"
44
+ [ *commands ].each do |command|
45
+ Kibo::System.sh! command
46
+ end
47
+ }
48
+
49
+ run.call("pre")
50
+
51
+ yield
52
+
53
+ run.call("success")
54
+ ensure
55
+ run.call("final")
56
+ end
41
57
 
42
- def checkout_branch(name)
43
- unless branches.include?(name)
44
- Kibo::System.git "branch", name
58
+ #
59
+ # checkout the branch +name+, create it if necessary.
60
+ def in_branch(name, &block)
61
+ previous_branch = current_branch
62
+
63
+ if name != previous_branch
64
+ git "branch", name unless branches.include?(name)
65
+ git "checkout", name
45
66
  end
46
67
 
47
- git "checkout", name
68
+ yield
69
+ rescue StandardError
70
+ STDERR.puts $!
71
+ raise
72
+ ensure
73
+ unless current_branch == previous_branch
74
+ git "reset", "--hard"
75
+ git "checkout", previous_branch
76
+ end
48
77
  end
49
-
78
+
50
79
  def current_branch
51
- `git branch`.split(/\n/).detect do |line|
52
- line =~ /^* /
53
- end.sub(/^\* /, "")
80
+ `git rev-parse --abbrev-ref HEAD`.chomp
54
81
  end
55
82
 
56
83
  def branches
@@ -59,15 +86,6 @@ module Kibo::Commands
59
86
  end
60
87
 
61
88
  def deploy_remote!(remote)
62
- git "push", remote, "HEAD:master"
63
- end
64
-
65
- def run_commands(commands)
66
- return unless commands
67
- commands = [ commands ] if commands.is_a?(String)
68
-
69
- commands.each do |command|
70
- Kibo::System.sh! command
71
- end
89
+ git "push", "--force", remote, "HEAD:master"
72
90
  end
73
91
  end
data/lib/kibo/config.rb CHANGED
@@ -55,6 +55,8 @@ class Kibo::Config
55
55
  W "No such file", path
56
56
  end
57
57
 
58
+ verify_version!
59
+
58
60
  @procfile = Kibo::Configfile.new(self["procfile"])
59
61
  end
60
62
 
@@ -66,6 +68,23 @@ class Kibo::Config
66
68
  end
67
69
  end
68
70
 
71
+ def verify_version!
72
+ return unless self["version"]
73
+
74
+ files_version = self["version"].split(".").map(&:to_i)
75
+ kibos_version = Kibo::VERSION.split(".").map(&:to_i)
76
+
77
+ files_version.zip(kibos_version).each do |files, kibos|
78
+ next if kibos == files
79
+ if kibos > files
80
+ W "The Kibofile requires kibo version #{self["version"]}. You have #{Kibo::VERSION}... this might work."
81
+ return
82
+ end
83
+
84
+ E "The Kibofile requires kibo version #{self["version"]}. You have #{Kibo::VERSION}."
85
+ end
86
+ end
87
+
69
88
  #
70
89
  # we need namespace-ENVIRONMENT-process<1>
71
90
 
@@ -78,6 +97,11 @@ class Kibo::Config
78
97
  def deployment
79
98
  self["deployment"] || {}
80
99
  end
100
+
101
+ # returns source specific configuration
102
+ def source
103
+ self["source"] || {}
104
+ end
81
105
 
82
106
  # returns the heroku namespace
83
107
  def namespace
data/lib/kibo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kibo
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
data/lib/kibo.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module Kibo
2
2
  end
3
3
 
4
+ require_relative "kibo/version"
4
5
  require_relative "kibo/log"
5
6
  require_relative "kibo/system"
6
7
  require_relative "kibo/config"
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.3" "Kibo Manual"
4
+ .TH "KIBO" "1" "September 2012" "Kibo 0.3.4" "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.3</li>
175
+ <li class='tl'>Kibo 0.3.4</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.3
4
+ version: 0.3.4
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-21 00:00:00.000000000 Z
12
+ date: 2012-09-23 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: 3660277376767937513
130
+ hash: -3856345431074645108
131
131
  required_rubygems_version: !ruby/object:Gem::Requirement
132
132
  none: false
133
133
  requirements: