codesnik-rails-recipes 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +67 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/lib/rails-recipes.rb +3 -0
- data/lib/rails-recipes/console.rb +51 -0
- data/rails-recipes.gemspec +47 -0
- data/test/rails-recipes_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +65 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 codesnik
|
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/README.rdoc
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
= rails-recipes
|
2
|
+
|
3
|
+
capistrano recipes for invoking rails script/console, script/dbconsole, rake etc.
|
4
|
+
on first server in a cluster
|
5
|
+
|
6
|
+
== Synopsis
|
7
|
+
|
8
|
+
starts script/console on the first :app server in currently released directory
|
9
|
+
be careful with your production server data - it's the power under your fingers now!
|
10
|
+
|
11
|
+
cap rails:console
|
12
|
+
|
13
|
+
starts script/dbconsole, still on the :app server, but connected to a
|
14
|
+
right database, probably
|
15
|
+
|
16
|
+
cap rails:dbconsole
|
17
|
+
|
18
|
+
even this should work, providing you authenticate via ssh key
|
19
|
+
and you're not using ssh gateway (breaks pipeline sometimes)
|
20
|
+
|
21
|
+
cap rails:dbconsole < sqldump.sql
|
22
|
+
|
23
|
+
sorry, haven't figured how to provide additional arguments for rake yet.
|
24
|
+
|
25
|
+
cap rails:rake task=db:abort_if_pending_migrations
|
26
|
+
|
27
|
+
(NOT DONE YET) do not try it at work
|
28
|
+
|
29
|
+
(NOT DONE YET) cap rails:runner cmd='User.delete_all'
|
30
|
+
|
31
|
+
using some multistage deployment scheme (capistrano/ext/multistage or something homebrew)?
|
32
|
+
this should work too right from the box
|
33
|
+
|
34
|
+
cap staging rails:console
|
35
|
+
|
36
|
+
== Installation
|
37
|
+
|
38
|
+
sudo gem install codesnik-rails-recipes --source=http://gems.github.com
|
39
|
+
|
40
|
+
then stick
|
41
|
+
|
42
|
+
require 'rails-recipes'
|
43
|
+
|
44
|
+
at the end of your Capfile or ~/.caprc
|
45
|
+
|
46
|
+
== Configuration
|
47
|
+
|
48
|
+
TODO
|
49
|
+
|
50
|
+
== Hidden details
|
51
|
+
|
52
|
+
It doesn't use ruby net/ssh2 library for interactive script/console and script/dbconsole
|
53
|
+
but invokes real 'ssh' executable so that readline interface works as expected.
|
54
|
+
Still this means that all the subtile differences of parsing ~/.ssh/config and other files
|
55
|
+
between openssh executables and net/ssh2 apply here.
|
56
|
+
|
57
|
+
Used on Ubuntu and MacOS X, for deployment on Gentoo, Fedora, FreeBSD
|
58
|
+
|
59
|
+
Sorry, no tests yet, not that there's much code you can actually test here
|
60
|
+
|
61
|
+
== Suggestions, feature requests, bugreports
|
62
|
+
|
63
|
+
...are always welcome.
|
64
|
+
|
65
|
+
== Copyright
|
66
|
+
|
67
|
+
Copyright (c) 2009 Alexey 'codesnik' Trofimenko. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "rails-recipes"
|
8
|
+
gem.summary = %Q{capistrano recipes for invoking script/console, script/dbconsole and rake on a rails app server}
|
9
|
+
gem.email = "aronaxis@gmail.com"
|
10
|
+
gem.homepage = "http://github.com/codesnik/rails-recipes"
|
11
|
+
gem.authors = ["Alexey 'codesnik' Trofimenko"]
|
12
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
13
|
+
end
|
14
|
+
|
15
|
+
rescue LoadError
|
16
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
Rake::TestTask.new(:test) do |test|
|
21
|
+
test.libs << 'lib' << 'test'
|
22
|
+
test.pattern = 'test/**/*_test.rb'
|
23
|
+
test.verbose = true
|
24
|
+
end
|
25
|
+
|
26
|
+
begin
|
27
|
+
require 'rcov/rcovtask'
|
28
|
+
Rcov::RcovTask.new do |test|
|
29
|
+
test.libs << 'test'
|
30
|
+
test.pattern = 'test/**/*_test.rb'
|
31
|
+
test.verbose = true
|
32
|
+
end
|
33
|
+
rescue LoadError
|
34
|
+
task :rcov do
|
35
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
task :default => :test
|
41
|
+
|
42
|
+
require 'rake/rdoctask'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
if File.exist?('VERSION.yml')
|
45
|
+
config = YAML.load(File.read('VERSION.yml'))
|
46
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
47
|
+
else
|
48
|
+
version = ""
|
49
|
+
end
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "rails-recipes #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
56
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
@@ -0,0 +1,51 @@
|
|
1
|
+
unless Capistrano::Configuration.respond_to?(:instance)
|
2
|
+
abort "rails-recipes requires Capistrano 2"
|
3
|
+
end
|
4
|
+
|
5
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
6
|
+
namespace :rails do
|
7
|
+
desc "script/console on a remote server"
|
8
|
+
task :console do
|
9
|
+
rails_env = fetch(:rails_env, "production")
|
10
|
+
server = find_servers(:roles => [:app]).first
|
11
|
+
run_with_tty server, %W( script/console #{rails_env} )
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "script/dbconsole on a remote server"
|
15
|
+
task :dbconsole do
|
16
|
+
rails_env = fetch(:rails_env, "production")
|
17
|
+
server = find_servers(:roles => [:app]).first
|
18
|
+
run_with_tty server, %W( script/dbconsole #{rails_env} )
|
19
|
+
end
|
20
|
+
|
21
|
+
set :rake_cmd do
|
22
|
+
rails_env = fetch(:rails_env, "production")
|
23
|
+
"cd #{current_path} && rake RAILS_ENV=#{rails_env}"
|
24
|
+
end
|
25
|
+
|
26
|
+
# FIXME run on only one server?
|
27
|
+
desc "task=command runs rake 'command' on application servers"
|
28
|
+
task :rake, :roles => [:app] do
|
29
|
+
if ENV['task']
|
30
|
+
run "#{rake_cmd} #{ENV['task']}"
|
31
|
+
else
|
32
|
+
# FIXME use logger instead of warn?
|
33
|
+
warn "USAGE: cap rails:rake task=..."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def run_with_tty server, cmd
|
38
|
+
# looks like total pizdets
|
39
|
+
command = []
|
40
|
+
command += %W( ssh -t #{gateway} -l #{self[:gateway_user] || self[:user]} ) if self[:gateway]
|
41
|
+
command += %W( ssh -t )
|
42
|
+
command += %W( -p #{server.port}) if server.port
|
43
|
+
command += %W( -l #{user} #{server.host} )
|
44
|
+
command += %W( cd #{current_path} )
|
45
|
+
# have to escape this once if running via double ssh
|
46
|
+
command += [self[:gateway] ? '\&\&' : '&&']
|
47
|
+
command += Array(cmd)
|
48
|
+
system *command
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{rails-recipes}
|
5
|
+
s.version = "0.1.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Alexey 'codesnik' Trofimenko"]
|
9
|
+
s.date = %q{2009-07-22}
|
10
|
+
s.email = %q{aronaxis@gmail.com}
|
11
|
+
s.extra_rdoc_files = [
|
12
|
+
"LICENSE",
|
13
|
+
"README.rdoc"
|
14
|
+
]
|
15
|
+
s.files = [
|
16
|
+
".document",
|
17
|
+
".gitignore",
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc",
|
20
|
+
"Rakefile",
|
21
|
+
"VERSION",
|
22
|
+
"lib/rails-recipes.rb",
|
23
|
+
"lib/rails-recipes/console.rb",
|
24
|
+
"rails-recipes.gemspec",
|
25
|
+
"test/rails-recipes_test.rb",
|
26
|
+
"test/test_helper.rb"
|
27
|
+
]
|
28
|
+
s.homepage = %q{http://github.com/codesnik/rails-recipes}
|
29
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
30
|
+
s.require_paths = ["lib"]
|
31
|
+
s.rubygems_version = %q{1.3.3}
|
32
|
+
s.summary = %q{capistrano recipes for invoking script/console, script/dbconsole and rake on a rails app server}
|
33
|
+
s.test_files = [
|
34
|
+
"test/rails-recipes_test.rb",
|
35
|
+
"test/test_helper.rb"
|
36
|
+
]
|
37
|
+
|
38
|
+
if s.respond_to? :specification_version then
|
39
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
40
|
+
s.specification_version = 3
|
41
|
+
|
42
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
43
|
+
else
|
44
|
+
end
|
45
|
+
else
|
46
|
+
end
|
47
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: codesnik-rails-recipes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexey 'codesnik' Trofimenko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-22 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: aronaxis@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.rdoc
|
25
|
+
files:
|
26
|
+
- .document
|
27
|
+
- .gitignore
|
28
|
+
- LICENSE
|
29
|
+
- README.rdoc
|
30
|
+
- Rakefile
|
31
|
+
- VERSION
|
32
|
+
- lib/rails-recipes.rb
|
33
|
+
- lib/rails-recipes/console.rb
|
34
|
+
- rails-recipes.gemspec
|
35
|
+
- test/rails-recipes_test.rb
|
36
|
+
- test/test_helper.rb
|
37
|
+
has_rdoc: false
|
38
|
+
homepage: http://github.com/codesnik/rails-recipes
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options:
|
41
|
+
- --charset=UTF-8
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
version:
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
requirements: []
|
57
|
+
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 1.2.0
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: capistrano recipes for invoking script/console, script/dbconsole and rake on a rails app server
|
63
|
+
test_files:
|
64
|
+
- test/rails-recipes_test.rb
|
65
|
+
- test/test_helper.rb
|