capfig 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest ADDED
@@ -0,0 +1,5 @@
1
+ README.markdown
2
+ Rakefile
3
+ lib/capfig.rb
4
+ test/capfig_test.rb
5
+ Manifest
data/README.markdown ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('capfig', '0.1.0') do |p|
6
+ p.description = "Easily configure cap deployments"
7
+ p.url = "http://github.com/elitheeli/capfig"
8
+ p.author = "Eli Fox-Epstein"
9
+ p.email = "eli@elilies.com"
10
+ p.ignore_pattern = ['tmp/*', 'script/*']
11
+ p.development_dependencies = ['capistrano >=2.0.0']
12
+ end
data/capfig.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{capfig}
5
+ s.version = "0.1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Eli Fox-Epstein"]
9
+ s.date = %q{2010-03-20}
10
+ s.description = %q{Easily configure cap deployments}
11
+ s.email = %q{eli@elilies.com}
12
+ s.extra_rdoc_files = ["README.markdown", "lib/capfig.rb"]
13
+ s.files = ["README.markdown", "Rakefile", "lib/capfig.rb", "test/capfig_test.rb", "Manifest", "capfig.gemspec"]
14
+ s.homepage = %q{http://github.com/elitheeli/capfig}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Capfig", "--main", "README.markdown"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{capfig}
18
+ s.rubygems_version = %q{1.3.6}
19
+ s.summary = %q{Easily configure cap deployments}
20
+ s.test_files = ["test/capfig_test.rb"]
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 3
25
+
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ s.add_development_dependency(%q<capistrano>, [">= 2.0.0"])
28
+ else
29
+ s.add_dependency(%q<capistrano>, [">= 2.0.0"])
30
+ end
31
+ else
32
+ s.add_dependency(%q<capistrano>, [">= 2.0.0"])
33
+ end
34
+ end
data/lib/capfig.rb ADDED
@@ -0,0 +1,46 @@
1
+ abort "Requires Capistrano 2!" unless Capistrano::Configuration.respond_to?(:instance)
2
+
3
+ module CapFig
4
+ def configuration_for(name, settings = {})
5
+ settings[:path], settings[:filename] = File.split(settings[:filepath]) if settings[:filepath]
6
+ settings[:path] ||= 'config'
7
+ settings[:chmod] ||= 775
8
+
9
+ after 'deploy:update_code', "#{name}:symlink"
10
+ before 'deploy:setup', name.to_sym
11
+ namespace(name.to_sym) do
12
+ desc "Configuration for #{name}"
13
+ task(:default) do
14
+ set(:shared_dir) { File.join(fetch(:shared_path), settings[:path]) }
15
+ set(:shared_file) { File.join(fetch(:shared_dir), settings[:filename]) } if settings[:filename]
16
+ run "mkdir -p #{shared_dir}"
17
+ run "chmod #{settings[:chmod]} #{shared_dir}" if settings[:chmod]
18
+ if settings[:filename]
19
+ settings[:text] = yield if block_given?
20
+ puts settings[:text], shared_file
21
+ run "chmod #{settings[:chmod]} #{shared_file}"
22
+ elsif block_given?
23
+ yield
24
+ end
25
+ end
26
+ sym_path = File.join(File.split("#{settings[:path]}/#{settings[:filename]}"))
27
+ symlink_task name, sym_path, :chmod => settings[:chmod]
28
+ end
29
+ end
30
+
31
+ def symlink_task(nspace, path, settings = {})
32
+ settings[:chmod] ||= 775
33
+ desc "Create the symlink for #{File.basename(path)}"
34
+ namespace(nspace.to_sym) do
35
+ task(:symlink) do
36
+ from = File.join(fetch(:shared_path), path)
37
+ to = File.join(fetch(:release_path), path)
38
+ run "mkdir -p #{File.dirname(to)}"
39
+ run "chmod #{settings[:chmod]} #{File.dirname(to)}" if settings[:chmod]
40
+ run "ln -nfs #{from} #{to}"
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ Capistrano::Configuration.send(:include, CapFig)
@@ -0,0 +1,24 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'capistrano'
4
+ require File.dirname(__FILE__) + "/../lib/capfig"
5
+
6
+ module Capistrano
7
+ class Configuration
8
+ include CapFig
9
+ end
10
+ end
11
+
12
+ class CapfigTest < Test::Unit::TestCase
13
+
14
+ def setup
15
+ @cap = Capistrano::Configuration.new
16
+ end
17
+
18
+ def test_basic_configuration
19
+ @cap.configuration_for(:foo)
20
+ tasks = @cap.task_list(true).map {|t| [t.name, t.namespace.name]}
21
+ assert tasks.include? [:default, :foo]
22
+ assert tasks.include? [:symlink, :foo]
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capfig
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Eli Fox-Epstein
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-03-20 00:00:00 -04:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: capistrano
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 0
30
+ - 0
31
+ version: 2.0.0
32
+ type: :development
33
+ version_requirements: *id001
34
+ description: Easily configure cap deployments
35
+ email: eli@elilies.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files:
41
+ - README.markdown
42
+ - lib/capfig.rb
43
+ files:
44
+ - README.markdown
45
+ - Rakefile
46
+ - lib/capfig.rb
47
+ - test/capfig_test.rb
48
+ - Manifest
49
+ - capfig.gemspec
50
+ has_rdoc: true
51
+ homepage: http://github.com/elitheeli/capfig
52
+ licenses: []
53
+
54
+ post_install_message:
55
+ rdoc_options:
56
+ - --line-numbers
57
+ - --inline-source
58
+ - --title
59
+ - Capfig
60
+ - --main
61
+ - README.markdown
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ segments:
76
+ - 1
77
+ - 2
78
+ version: "1.2"
79
+ requirements: []
80
+
81
+ rubyforge_project: capfig
82
+ rubygems_version: 1.3.6
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: Easily configure cap deployments
86
+ test_files:
87
+ - test/capfig_test.rb