capstrap 0.3.2 → 0.3.3

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/CHANGELOG.markdown CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.3.3
2
+
3
+ * Add call to apt-get update pre-package install
4
+ * Set ruby as rvm default by default (of course)
5
+ * Record the elapsed time on a capstrap execution.
6
+
1
7
  # 0.3.2
2
8
 
3
9
  * Install chef gem to rvm default gemset rather than @global
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capstrap (0.3.0)
4
+ capstrap (0.3.2)
5
5
  capistrano (~> 2.5.19)
6
6
  thor (~> 0.14.3)
7
7
 
@@ -15,6 +15,14 @@ module Capstrap
15
15
  end
16
16
 
17
17
  namespace :apt do
18
+ desc "Resynchronizes the package index files."
19
+ task :update do
20
+ unless @updated
21
+ apt_update
22
+ @updated = true
23
+ end
24
+ end
25
+
18
26
  namespace :install do
19
27
  desc "Installs packages for running RVM"
20
28
  task :rvm_depends do
@@ -33,6 +41,9 @@ module Capstrap
33
41
  end
34
42
  end
35
43
  end
44
+
45
+ before "apt:install:rvm_depends", "apt:update"
46
+ before "apt:install:mri_depends", "apt:update"
36
47
  end
37
48
  end
38
49
  end
@@ -46,6 +46,12 @@ def apt_install(pkg, check=false)
46
46
  end
47
47
  end
48
48
 
49
+ ##
50
+ # Updates package repository via apt-get.
51
+ def apt_update
52
+ run %{apt-get update -y}
53
+ end
54
+
49
55
  def rvm_env
50
56
  %{[[ -s "/usr/local/lib/rvm" ]] && source /usr/local/lib/rvm; }
51
57
  end
data/lib/capstrap/cli.rb CHANGED
@@ -13,42 +13,50 @@ module Capstrap
13
13
  end
14
14
 
15
15
  desc "ruby HOST", "Install an RVM ruby on remote SSH host HOST"
16
- method_option "default", :type => :boolean, :desc =>
17
- "Set this ruby to be RVM default."
18
16
  def ruby(ssh_host)
19
- @ssh_host = ssh_host
20
- setup_config options
21
- exec_ruby
17
+ track_time do
18
+ @ssh_host = ssh_host
19
+ setup_config options
20
+ exec_ruby
21
+ end
22
22
  end
23
23
 
24
24
  desc "chef HOST", "Install chef gem on remote SSH host HOST"
25
25
  def chef(ssh_host)
26
- @ssh_host = ssh_host
27
- setup_config options
28
- exec_chef
26
+ track_time do
27
+ @ssh_host = ssh_host
28
+ setup_config options
29
+ exec_chef
30
+ end
29
31
  end
30
32
 
31
33
  desc "solo HOST", "Install chef cookbooks & config on remote SSH host HOST"
32
34
  def solo(ssh_host)
33
- @ssh_host = ssh_host
34
- setup_config options
35
- assert_repos_set
36
- exec_solo
35
+ track_time do
36
+ @ssh_host = ssh_host
37
+ setup_config options
38
+ assert_repos_set
39
+ exec_solo
40
+ end
37
41
  end
38
42
 
39
43
  desc "execute HOST", "Executes chef solo config on remote SSH host HOST"
40
44
  def execute(ssh_host)
41
- @ssh_host = ssh_host
42
- setup_config options
43
- assert_repos_set
44
- exec_execute
45
+ track_time do
46
+ @ssh_host = ssh_host
47
+ setup_config options
48
+ assert_repos_set
49
+ exec_execute
50
+ end
45
51
  end
46
52
 
47
53
  desc "update HOST", "Updates and executes chef solo on remote SSH host HOST"
48
54
  def update(ssh_host)
49
- @ssh_host = ssh_host
50
- setup_config options
51
- exec_update
55
+ track_time do
56
+ @ssh_host = ssh_host
57
+ setup_config options
58
+ exec_update
59
+ end
52
60
  end
53
61
 
54
62
  [:ruby, :chef, :solo, :execute, :update].each do |task|
@@ -107,9 +115,7 @@ module Capstrap
107
115
 
108
116
  def exec_ruby
109
117
  config.find_and_execute_task "rvm:install:#{config.fetch(:ruby)}"
110
- if options[:default]
111
- config.find_and_execute_task "rvm:default:#{config.fetch(:ruby)}"
112
- end
118
+ config.find_and_execute_task "rvm:default:#{config.fetch(:ruby)}"
113
119
  end
114
120
 
115
121
  def exec_chef
@@ -176,5 +182,16 @@ module Capstrap
176
182
  config.set(var[:sym], options[var[:opt]])
177
183
  end
178
184
  end
185
+
186
+ def track_time(&block)
187
+ start = Time.now
188
+ yield
189
+ elapsed = Time.now - start
190
+ if elapsed < 60.0
191
+ puts "\n\n * Elapsed time: #{(Time.now - start)} seconds.\n"
192
+ else
193
+ puts "\n\n * Elapsed time: #{(Time.now - start) / 60.0} minutes.\n"
194
+ end
195
+ end
179
196
  end
180
197
  end
@@ -1,3 +1,3 @@
1
1
  module Capstrap
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capstrap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Fletcher Nichol
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-28 00:00:00 -07:00
18
+ date: 2010-12-10 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency