capo 0.0.3 → 0.9.0

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/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Capo
2
2
 
3
- Command line utility to fetch and manage recipes
3
+ ![Capo.io](http://capo.io/assets/logo.png)
4
+
5
+ Command line utility to fetch and manage recipes with [Capo.io](http://capo.io).
4
6
 
5
7
  ## Installation
6
8
 
@@ -18,7 +20,21 @@ Or install it yourself as:
18
20
 
19
21
  ## Usage
20
22
 
21
- TODO: Write usage instructions here
23
+ Run `capo begin` to set up capistrano in your project. It will create a `Capfile` and `config/deploy.rb` in the folder where you run the command.
24
+
25
+ Run `capo list` to get a list of aailable recipes. Install recipes with `capo install a_recipe`.
26
+
27
+ You can get a list of installed recipes with `capo added`.
28
+
29
+ ## About
30
+
31
+ The [Capo.io](http://capo.io) website and this gem were build in 48 hours for the [2012 Rails Rumble](http://railsrumble.com/).
32
+
33
+ Both were built by
34
+ * [Jeroen Jacobs](https://github.com/jeroenj)
35
+ * [Joren De Groof](https://github.com/joren)
36
+ * [Steven De Coeyer](https://github.com/zhann)
37
+ * [Hannes Fostie](https://github.com/hannesfostie)
22
38
 
23
39
  ## Contributing
24
40
 
data/bin/capo CHANGED
@@ -33,12 +33,16 @@ case ARGV[0]
33
33
  when 'init'
34
34
  Capo::Init.fetch_repository
35
35
  when 'begin'
36
+ Capo::Init.fetch_repository
36
37
  Capo::Capfile.generate
37
38
  when 'list'
39
+ Capo::Init.fetch_repository
38
40
  Capo::Recipes.list
39
41
  when 'add'
42
+ Capo::Init.fetch_repository
40
43
  Capo::Recipes.add ARGV[1]
41
44
  when 'added'
45
+ Capo::Init.fetch_repository
42
46
  Capo::Recipes.added
43
47
  else
44
48
  puts option_parser unless @usage_shown
data/lib/capo/init.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'git'
2
+ require 'timeout'
2
3
 
3
4
  module Capo
4
5
  module Init
@@ -8,15 +9,26 @@ module Capo
8
9
 
9
10
  puts "Pulling changes from remote repository"
10
11
  begin
11
- repo = Git.open Capo.repository_path
12
- puts repo.lib.send :command, 'pull' # repo.pull is broken in git-1.2.5, see: https://github.com/schacon/ruby-git/issues/32
12
+ repo = with_timeout{Git.open Capo.repository_path}
13
+ puts with_timeout{repo.lib.send :command, 'pull'} # repo.pull is broken in git-1.2.5, see: https://github.com/schacon/ruby-git/issues/32
13
14
  rescue
14
15
  puts "Repository doesn't seem to exist yet..."
15
16
  puts "Cloning repository from #{repository_url} to #{Capo.repository_path}"
16
- Git.clone repository_url, Capo.repository_path
17
+ with_timeout{Git.clone repository_url, Capo.repository_path}
17
18
  retry
18
19
  end
19
20
  end
21
+
22
+ private
23
+ def with_timeout
24
+ begin
25
+ Timeout::timeout 2 do
26
+ yield
27
+ end
28
+ rescue Timeout::Error
29
+ puts 'Git timeout. Skipping repository update.'
30
+ end
31
+ end
20
32
  end
21
33
  end
22
34
  end
data/lib/capo/recipes.rb CHANGED
@@ -10,20 +10,29 @@ module Capo
10
10
  end
11
11
 
12
12
  def add name
13
- raise "Recipe '#{name}' not found" unless recipes.map{|recipe| recipe[:name]}.include? name
13
+ recipe = recipes.select{|r| r[:name] == name}.first
14
+ raise "Recipe '#{name}' not found" unless recipe
15
+
16
+ if (dependencies = recipe[:dependencies]).any?
17
+ puts "[#{name}] Installing dependencies first:"
18
+ dependencies.each do |dependency|
19
+ puts "[#{dependency}] Installing depdendency"
20
+ add dependency
21
+ end
22
+ end
14
23
 
15
24
  app_recipe_path = File.join app_deploy_path, "#{name}.rb"
16
25
 
17
26
  Dir.mkdir(app_deploy_path) unless Dir.exists?(app_deploy_path)
18
27
 
19
- puts "Copying recipe '#{name}' to #{app_recipe_path}"
28
+ puts "[#{name}] Copying recipe to #{app_recipe_path}"
20
29
  FileUtils.copy File.join(Capo.repository_path, 'recipes', name, "#{name}.rb"), app_recipe_path
21
30
 
22
- puts "Adding line to Capfile"
31
+ puts "[#{name}] Adding line to Capfile"
23
32
  capfile = File.join Capo.app_path, 'Capfile'
24
33
  File.open(capfile, 'a+'){|f| f.puts "load 'config/deploy/#{name}'"}
25
34
 
26
- puts "Recipe #{name} added"
35
+ puts "[#{name}] Recipe added"
27
36
  end
28
37
 
29
38
  def added
data/lib/capo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Capo
2
- VERSION = '0.0.3'
2
+ VERSION = '0.9.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: