capistrano_mongo 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano_mongo.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Timo Schilling
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # CapistranoMongo
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'capistrano_mongo'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install capistrano_mongo
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'capistrano_mongo'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "capistrano_mongo"
8
+ gem.version = CapistranoMongo::VERSION
9
+ gem.authors = ["Timo Schilling"]
10
+ gem.email = ["timo@schilling.io"]
11
+ gem.description = %q{Provides some capistrano recipes for MonogoDB}
12
+ gem.summary = %q{Provides some capistrano recipes for MonogoDB}
13
+ gem.homepage = "http://github.com/timoschilling/capistrano_mongo"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "capistrano", "~> 2"
21
+
22
+ gem.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,3 @@
1
+ module CapistranoMongo
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,39 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ namespace :db do
3
+ desc "Opens a remote mongo console"
4
+ task :console, :roles => :db do
5
+ abort "You must set a database" unless database
6
+ hostname = find_servers_for_task(current_task).first
7
+
8
+ exec "ssh -l #{user} #{hostname} -p #{port} -t 'cd #{current_path} && mongo #{database}'"
9
+ end
10
+
11
+ desc "Create a dump from the remote db"
12
+ task :dump, :roles => :db do
13
+ abort "You must set a database" unless database
14
+ dump_name = ENV['DUMP_NAME'] ||= "#{database}_#{Time.now.strftime("%Y%m%d%H%M%S")}"
15
+ dump_file = "#{dump_name}.tgz"
16
+
17
+ on_rollback do
18
+ run "rm -rf #{dump_file}; true"
19
+ end
20
+
21
+ run "mongodump -d #{database} -o #{dump_name} && tar czf #{dump_file} #{dump_name} && rm -rf #{dump_name};"
22
+
23
+ get dump_file, dump_file
24
+ run "rm -rf #{dump_file}"
25
+ run_locally "tar xzf #{dump_file}"
26
+ run_locally "rm -rf #{dump_name}.tgz"
27
+ end
28
+
29
+ desc "Sync DB from remote server to local machine"
30
+ task :down, :roles => :db do
31
+ abort "You must set a local database" unless local_database
32
+ dump
33
+ dump_name = ENV['DUMP_NAME']
34
+
35
+ run_locally "mongorestore --drop -d #{local_database} #{dump_name}/#{database}/"
36
+ run_locally "rm -rf #{dump_name}"
37
+ end
38
+ end
39
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano_mongo
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Timo Schilling
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2'
20
+ none: false
21
+ prerelease: false
22
+ name: capistrano
23
+ requirement: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '2'
28
+ none: false
29
+ type: :runtime
30
+ - !ruby/object:Gem::Dependency
31
+ version_requirements: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ none: false
37
+ prerelease: false
38
+ name: rake
39
+ requirement: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ none: false
45
+ type: :development
46
+ description: Provides some capistrano recipes for MonogoDB
47
+ email:
48
+ - timo@schilling.io
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - capistrano_mongo.gemspec
59
+ - lib/capistrano_mongo.rb
60
+ - lib/capistrano_mongo/recipes.rb
61
+ homepage: http://github.com/timoschilling/capistrano_mongo
62
+ licenses: []
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ segments:
73
+ - 0
74
+ hash: -3462441303613812494
75
+ none: false
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ segments:
82
+ - 0
83
+ hash: -3462441303613812494
84
+ none: false
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 1.8.24
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Provides some capistrano recipes for MonogoDB
91
+ test_files: []