sunedison-cap 0.3.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.
@@ -0,0 +1,8 @@
1
+ == 0.2.2 2011-08-26
2
+ * update syntax for chown: user : instead of . in specifying user:group
3
+ * update gemspec in order to build gem with including all required files (was broken for previous versions)
4
+
5
+ == 0.0.1 2009-02-05
6
+
7
+ * 1 major enhancement:
8
+ * Initial release
data/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ Copyright (c) 2009 SunEdison, LLC
2
+
3
+ ---
4
+ ---
5
+
6
+ Some portions of this code are copies of software licensed under the
7
+ MIT license. That license is included below:
8
+ Copyright (c) 2008 Engine Yard
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining
11
+ a copy of this software and associated documentation files (the
12
+ "Software"), to deal in the Software without restriction, including
13
+ without limitation the rights to use, copy, modify, merge, publish,
14
+ distribute, sublicense, and/or sell copies of the Software, and to
15
+ permit persons to whom the Software is furnished to do so, subject to
16
+ the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be
19
+ included in all copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ History.txt
2
+ LICENSE
3
+ Manifest.txt
4
+ PostInstall.txt
5
+ README.rdoc
6
+ Rakefile
7
+ lib/sunedison-cap.rb
8
+ lib/sunedison-cap/recipes.rb
9
+ lib/sunedison-cap/recipes/apache.rb
10
+ lib/sunedison-cap/recipes/configure.rb
11
+ lib/sunedison-cap/recipes/db.rb
12
+ lib/sunedison-cap/recipes/deploy.rb
13
+ lib/sunedison-cap/recipes/passenger.rb
14
+ lib/sunedison-cap/utils.rb
15
+ script/console
16
+ script/destroy
17
+ script/generate
18
+ spec/spec.opts
19
+ spec/spec_helper.rb
20
+ spec/sunedison-cap_spec.rb
21
+ sunedison-cap.gemspec
22
+ tasks/rspec.rake
@@ -0,0 +1,7 @@
1
+
2
+ For more information on sunedison-cap, see http://sunedison-cap.rubyforge.org
3
+
4
+ NOTE: Change this information in PostInstall.txt
5
+ You can also delete it if you don't want it.
6
+
7
+
@@ -0,0 +1,28 @@
1
+ = sunedison-cap
2
+
3
+ *
4
+
5
+ == DESCRIPTION:
6
+
7
+ Various capistrano tasks used for deployment of Sunedison Ruby web
8
+ applications
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ * cap -T should give a full list of supported tasks
13
+
14
+ == SYNOPSIS:
15
+
16
+ require 'sunedison-cap/recipes'
17
+
18
+ == REQUIREMENTS:
19
+
20
+ * capistrano
21
+
22
+ == INSTALL:
23
+
24
+ * sudo gem install sunedison-cap
25
+
26
+ == LICENSE:
27
+
28
+ Copyright © 2008-2009 SunEdison LLC. All rights reserved.
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/sunedison-cap'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'sunedison-cap' do
14
+ self.developer 'Greg Campbell', 'gcampbell@sunedison.com'
15
+ self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
+ self.rubyforge_name = self.name # TODO this is default value
17
+ self.extra_deps = [['capistrano', '~>2.5']]
18
+
19
+ end
20
+
21
+ require 'newgem/tasks'
22
+ Dir['tasks/**/*.rake'].each { |t| load t }
23
+
24
+ # TODO - want other tests/tasks run by default? Add them to the list
25
+ # remove_task :default
26
+ # task :default => [:spec, :features]
@@ -0,0 +1,8 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ module Sunedison
5
+ module Cap
6
+ VERSION = '0.3.0'
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ require 'sunedison-cap/utils'
2
+ require 'sunedison-cap/recipes/apache'
3
+ require 'sunedison-cap/recipes/configure'
4
+ require 'sunedison-cap/recipes/deploy'
5
+ require 'sunedison-cap/recipes/db'
6
+ require 'sunedison-cap/recipes/passenger'
@@ -0,0 +1,10 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ namespace :apache do
3
+ [:stop, :start, :restart, :reload].each do |action|
4
+ desc "#{action.to_s.capitalize} Apache"
5
+ task action, :roles => :web do
6
+ sudo "/etc/init.d/apache2 #{action.to_s}"
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,56 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ after 'configure:apache', 'configure:apache:link'
4
+
5
+ namespace :configure do
6
+ namespace :apache do
7
+ set(:sites_enabled_dir) { target_os == 'debian' ? '/etc/apache2/sites-enabled' : '/usr/local/apache2/conf' }
8
+ set(:dest_apache_config) { "#{config_path}/apache.conf" }
9
+ desc <<-DESC
10
+ Configure Apache2. Copies the configuration file to the config
11
+ directory, makes a bunch of appropriate variable substitutions,
12
+ and enables it.
13
+ DESC
14
+ task :default, :roles => :web do
15
+
16
+ if fetch(:force_configuration, false) == false
17
+ file_test(
18
+ '! -e',
19
+ dest_apache_config,
20
+ "Apache config file(#{dest_apache_config}) already exists.\nUse 'cap configure:apache:reset' to override."
21
+ )
22
+ end
23
+
24
+ if fetch(:mongrel_start_port, nil)
25
+ first_port = mongrel_start_port
26
+ last_port = first_port + mongrel_servers - 1
27
+ set :apache_balancer_members, (first_port..last_port).map { |port|
28
+ " BalancerMember http://#{host}:#{port}"
29
+ }.join("\n").strip
30
+ end
31
+
32
+ require 'erb'
33
+ f = File.read('config/templates/apache.conf.erb')
34
+ template = ERB.new(f)
35
+ result = template.result(binding)
36
+ put(result, dest_apache_config)
37
+ end #task :default, :roles => :web
38
+
39
+ desc "Resets configuration file for the Apache processes."
40
+ task :reset, :roles => :web do
41
+ set :force_configuration, true
42
+ configure.apache.default
43
+ end
44
+
45
+ desc <<-DESC
46
+ Creates a link from enabled apache2 sites to the application's apache
47
+ config file.
48
+ DESC
49
+ task :link, :roles => :web do
50
+ sudo "ln -fs #{dest_apache_config} #{sites_enabled_dir}/#{application}.conf"
51
+ sudo "chown #{app_user}:#{app_group} #{dest_apache_config}"
52
+ end
53
+ end
54
+ end
55
+ end
56
+
@@ -0,0 +1,24 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ namespace :db do
3
+ desc "Uses mysqldump to back up the database"
4
+ task :dump, :roles => :app, :only => { :primary => true} do
5
+ framework = fetch(:framework, "rails")
6
+ app_env = fetch("#{framework.downcase}_env".to_sym, "production")
7
+
8
+ dump_dir = File.join(db_dump_path, application, app_env)
9
+ run "mkdir -p #{dump_dir}"
10
+ dump_file = File.join(dump_dir, Time.now.strftime("%Y%m%d-%H%M") + '.sql')
11
+
12
+ case db_type = fetch(:db_type, 'mysql')
13
+ when 'mysql'
14
+ run "mysqldump \
15
+ --user=#{db_dump_user}
16
+ --password=#{db_dump_password}
17
+ --result-file=#{dump_file}
18
+ --host=#{roles[:db].servers.first.host}
19
+ #{db_name}"
20
+ run "gzip #{dump_file}"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,37 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ namespace :deploy do
3
+
4
+ desc <<-DESC
5
+ Run the migrate rake task. By default, it runs this in most recently \
6
+ deployed version of the app. However, you can specify a different release \
7
+ via the migrate_target variable, which must be one of :latest (for the \
8
+ default behavior), or :current (for the release indicated by the \
9
+ `current' symlink). Strings will work for those values instead of symbols, \
10
+ too. You can also specify additional environment variables to pass to rake \
11
+ via the migrate_env variable. Finally, you can specify the full path to the \
12
+ rake executable by setting the rake variable. The defaults are:
13
+ set :rake, "rake"
14
+ set :framework, "rails"
15
+ set :merb_env, "production"
16
+ set :migrate_env, ""
17
+ set :migrate_target, :latest
18
+ DESC
19
+ task :migrate, :roles => :app, :only => { :primary => true } do
20
+ rake = fetch(:rake, "rake")
21
+
22
+ framework = fetch(:framework, "rails")
23
+ app_env = fetch("#{framework.downcase}_env".to_sym, "production")
24
+
25
+ migrate_env = fetch(:migrate_env, "")
26
+ migrate_target = fetch(:migrate_target, :latest)
27
+
28
+ directory = case migrate_target.to_sym
29
+ when :current then current_path
30
+ when :latest then current_release
31
+ else raise ArgumentError, "unknown migration target #{migrate_target.inspect}"
32
+ end
33
+
34
+ run "cd #{directory}; #{rake} #{framework.upcase}_ENV=#{app_env} #{migrate_env} db:migrate"
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,18 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ namespace :passenger do
3
+ desc "Start (or un-stop) Passenger"
4
+ task :start, :roles => :app do
5
+ run "rm -f #{current_release}/tmp/stop.txt"
6
+ end
7
+
8
+ desc "Stop Passenger"
9
+ task :stop, :roles => :app do
10
+ run "touch #{current_release}/tmp/stop.txt"
11
+ end
12
+
13
+ desc "Restart Passenger"
14
+ task :restart, :roles => :app do
15
+ run "touch #{current_release}/tmp/restart.txt"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ def file_test( test, file, msg )
2
+ begin
3
+ run "test #{test} #{file}"
4
+ rescue
5
+ if( $!.to_str =~ /failed on (.*)/ )
6
+ abort "[#{$1}] #{msg}"
7
+ else
8
+ abort "#{msg}"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/sunedison-cap.rb'}"
9
+ puts "Loading sunedison-cap gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'sunedison-cap'
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ # Time to add your specs!
4
+ # http://rspec.info/
5
+ describe "Place your specs here" do
6
+
7
+ it "find this spec in spec directory" do
8
+ # violated "Be sure to write your specs"
9
+ end
10
+
11
+ end
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sunedison-cap
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
+ platform: ruby
12
+ authors:
13
+ - SunEdison
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2009-02-11 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: capistrano
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 9
29
+ segments:
30
+ - 2
31
+ - 5
32
+ version: "2.5"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: newgem
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 25
44
+ segments:
45
+ - 1
46
+ - 2
47
+ - 3
48
+ version: 1.2.3
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: hoe
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 55
60
+ segments:
61
+ - 1
62
+ - 8
63
+ - 0
64
+ version: 1.8.0
65
+ type: :development
66
+ version_requirements: *id003
67
+ description: FIX (describe your package)
68
+ email:
69
+ - gtan@sunedison.com
70
+ executables: []
71
+
72
+ extensions: []
73
+
74
+ extra_rdoc_files:
75
+ - History.txt
76
+ - Manifest.txt
77
+ - PostInstall.txt
78
+ - README.rdoc
79
+ files:
80
+ - lib/sunedison-cap.rb
81
+ - lib/sunedison-cap/recipes/apache.rb
82
+ - lib/sunedison-cap/recipes/configure.rb
83
+ - lib/sunedison-cap/recipes/db.rb
84
+ - lib/sunedison-cap/recipes/deploy.rb
85
+ - lib/sunedison-cap/recipes/passenger.rb
86
+ - lib/sunedison-cap/recipes.rb
87
+ - lib/sunedison-cap/utils.rb
88
+ - script/console
89
+ - script/destroy
90
+ - script/generate
91
+ - spec/spec.opts
92
+ - spec/spec_helper.rb
93
+ - spec/sunedison-cap_spec.rb
94
+ - tasks/rspec.rake
95
+ - History.txt
96
+ - LICENSE
97
+ - Manifest.txt
98
+ - PostInstall.txt
99
+ - README.rdoc
100
+ - Rakefile
101
+ homepage: ""
102
+ licenses: []
103
+
104
+ post_install_message: PostInstall.txt
105
+ rdoc_options:
106
+ - --main
107
+ - README.rdoc
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ hash: 3
116
+ segments:
117
+ - 0
118
+ version: "0"
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ hash: 3
125
+ segments:
126
+ - 0
127
+ version: "0"
128
+ requirements: []
129
+
130
+ rubyforge_project: sunedison-cap
131
+ rubygems_version: 1.8.6
132
+ signing_key:
133
+ specification_version: 2
134
+ summary: FIX (describe your package)
135
+ test_files: []
136
+