kete-capistrano-configuration 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ == 0.1.0 (January 6, 2009)
2
+
3
+ * Initial Release
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Kieran Pilkington
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest ADDED
@@ -0,0 +1,8 @@
1
+ capistrano-configuration.gemspec
2
+ CHANGELOG.rdoc
3
+ install.rb
4
+ lib/capistrano-configuration.rb
5
+ Manifest
6
+ MIT-LICENSE
7
+ Rakefile
8
+ README.rdoc
data/README.rdoc ADDED
@@ -0,0 +1,63 @@
1
+ = Capistrano Configuration
2
+
3
+ Capistrano Configuration allows you to create configurations on deployment,
4
+ so you don't have to worry about copy different yml files to the right place
5
+ (especially when you have multiple deploy stages in one repository)
6
+
7
+
8
+ == Installation
9
+
10
+ sudo gem install kete-capistrano-configuration
11
+
12
+
13
+ == Usage
14
+
15
+ Simply add the following to your deploy.rb file:
16
+
17
+ require 'capistrano-configuration'
18
+
19
+ and then write your configurations in ruby like so:
20
+
21
+ configure :database do
22
+ environment 'development' do
23
+ config 'username', 'app'
24
+ config 'password', 'secret'
25
+ end
26
+ environment 'production' do
27
+ config 'username', 'app_production'
28
+ config 'password', 'secret_production'
29
+ end
30
+ end
31
+
32
+ configure :google_map_key do
33
+ config 'map_key', 'u232398b208x9830x30xb383'
34
+ end
35
+
36
+ The gem will take care of the rest. It stores your configurations,
37
+ and after the code is updated, it'll write the configurations needed
38
+ for things like migrations.
39
+
40
+ Note: The method name environment doesn't suit all configurations, so
41
+ that method has an alias called 'context' which you can use to do the
42
+ same thing.
43
+
44
+
45
+ == Issues
46
+
47
+ The gem currently only supports one environment level, that is, code
48
+ like this won't work:
49
+
50
+ configure :database do
51
+ environment :test do
52
+ environment :remote do
53
+ config 'username', 'app'
54
+ end
55
+ end
56
+ end
57
+
58
+ This feature (nested environments) is planned for a future version.
59
+
60
+
61
+ == Credits
62
+
63
+ Gem created and maintained by Kieran Pilkington <kieran@katipo.co.nz>
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ namespace :gem do
2
+
3
+ task :default => :build
4
+
5
+ desc 'Build the Capistrano Configuration Gem'
6
+ task :build do
7
+ Dir['*.gem'].each do |gem_filename|
8
+ sh "rm -rf #{gem_filename}"
9
+ end
10
+ sh "gem build capistrano-configuration.gemspec"
11
+ end
12
+
13
+ desc 'Install the Capistrano Configuration Gem'
14
+ task :install do
15
+ gem_filename = Dir['*.gem'].first
16
+ sh "sudo gem install --local #{gem_filename}"
17
+ end
18
+
19
+ end
20
+
21
+ task :default => ['gem:build', 'gem:install']
@@ -0,0 +1,34 @@
1
+ # Gem::Specification for capistrano-configuration
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "capistrano-configuration"
5
+ s.version = "0.1.0"
6
+ s.date = "2009-01-06"
7
+ s.author = "Kieran Pilkington"
8
+ s.email = "kieran@katipo.co.nz"
9
+ s.homepage = "http://github.com/kete/capistrano-configuration"
10
+ s.summary = "Configure your application on deployment"
11
+ s.description = "Write application configuration files on deployment with Ruby"
12
+ s.require_path = "lib"
13
+ s.files = %w{ capistrano-configuration.gemspec
14
+ CHANGELOG.rdoc
15
+ install.rb
16
+ lib/capistrano-configuration.rb
17
+ Manifest
18
+ MIT-LICENSE
19
+ Rakefile
20
+ README.rdoc }
21
+ s.has_rdoc = true
22
+ s.extra_rdoc_files = %w{ CHANGELOG.rdoc
23
+ MIT-LICENSE
24
+ README.rdoc }
25
+ s.rdoc_options = ["--line-numbers",
26
+ "--inline-source",
27
+ "--title",
28
+ "capistrano-configuration",
29
+ "--main",
30
+ "README.rdoc"]
31
+ s.rubygems_version = "1.1.1"
32
+ s.add_dependency "capistrano", ">= 1.1.0"
33
+ s.rubyforge_project = "capistrano-conf"
34
+ end
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ puts IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
@@ -0,0 +1,60 @@
1
+ unless Capistrano::Configuration.respond_to?(:instance)
2
+ abort "capistrano-configuration requires Capistrano 2"
3
+ end
4
+
5
+ module CapistranoConfiguration
6
+ unless included_modules.include? CapistranoConfiguration
7
+
8
+ @@configurations = Hash.new
9
+ @@current_config = String.new
10
+ @@current_env = String.new
11
+
12
+ def configure(config)
13
+ @@current_config = config
14
+ @@configurations[@@current_config] ||= Hash.new
15
+ yield
16
+ end
17
+
18
+ def environment(env)
19
+ @@current_env = env
20
+ @@configurations[@@current_config][@@current_env] ||= Hash.new
21
+ yield
22
+ @@current_env = nil
23
+ end
24
+ alias :context :environment
25
+
26
+ def config(setting, value)
27
+ if @@current_env.nil?
28
+ @@configurations[@@current_config][setting] = value
29
+ else
30
+ @@configurations[@@current_config][@@current_env][setting] = value
31
+ end
32
+ end
33
+
34
+ Capistrano::Configuration.instance.load do
35
+
36
+ namespace :deploy do
37
+
38
+ namespace :configuration do
39
+
40
+ desc 'Write the configuration files based on whats in @@configurations'
41
+ task :write, :role => :app do
42
+ abort "@@configurations is empty. Did you forget to define some configurations?" if @@configurations.empty?
43
+ @@configurations.each do |file, value|
44
+ run "cd #{current_path} && rm -rf config/#{file}.yml"
45
+ run "cd #{current_path} && echo '#{value.to_yaml.gsub("'", "\\'")}' >> config/#{file}.yml"
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+
53
+ after "deploy:update_code", "deploy:configuration:write"
54
+
55
+ end
56
+
57
+ end
58
+ end
59
+
60
+ Capistrano::Configuration.send(:include, CapistranoConfiguration)
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kete-capistrano-configuration
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kieran Pilkington
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-06 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: capistrano
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.1.0
23
+ version:
24
+ description: Write application configuration files on deployment with Ruby
25
+ email: kieran@katipo.co.nz
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - CHANGELOG.rdoc
32
+ - MIT-LICENSE
33
+ - README.rdoc
34
+ files:
35
+ - capistrano-configuration.gemspec
36
+ - CHANGELOG.rdoc
37
+ - install.rb
38
+ - lib/capistrano-configuration.rb
39
+ - Manifest
40
+ - MIT-LICENSE
41
+ - Rakefile
42
+ - README.rdoc
43
+ has_rdoc: true
44
+ homepage: http://github.com/kete/capistrano-configuration
45
+ post_install_message:
46
+ rdoc_options:
47
+ - --line-numbers
48
+ - --inline-source
49
+ - --title
50
+ - capistrano-configuration
51
+ - --main
52
+ - README.rdoc
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ version:
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ version:
67
+ requirements: []
68
+
69
+ rubyforge_project: capistrano-conf
70
+ rubygems_version: 1.2.0
71
+ signing_key:
72
+ specification_version: 2
73
+ summary: Configure your application on deployment
74
+ test_files: []
75
+