capistrano-file_db 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +14 -0
- data/README.md +31 -0
- data/capistrano-file_db.gemspec +18 -0
- data/lib/capistrano-file_db.rb +38 -0
- metadata +59 -0
data/LICENSE
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Copyright (c) 2011 Michal Papis
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Simle capistrano plugin to manage database files
|
2
|
+
|
3
|
+
Extracted it to not repeat myself next time I need to use sqlite db on server.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```bash
|
8
|
+
gem install capistrano-unicorn
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Add the gem to your `Gemfile`:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
group :development do
|
17
|
+
gem 'capistrano-file_db'
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
Ad the plugin in `config/deploy.rb`
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'capistrano-file_db'
|
25
|
+
```
|
26
|
+
|
27
|
+
## Configuration options
|
28
|
+
|
29
|
+
- `file_db_path` - Set path to databases dir. Default to `db`.
|
30
|
+
- `file_db_files` - Set list of database files. Default to `["#{RAILS_ENV||'production'}.sqlite3"]`.
|
31
|
+
- `file_db_rights` - Set rights to set for files. Default to `600` - read/wrtie only for owner.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Gem::Specification.new do |gem|
|
2
|
+
gem.name = 'capistrano-file_db'
|
3
|
+
gem.version = '0.1.0'
|
4
|
+
gem.date = "2012-03-11"
|
5
|
+
gem.authors = ["Michal Papis"]
|
6
|
+
gem.email = "mpapis@gmail.com"
|
7
|
+
gem.homepage = 'https://github.com/mpapis/capistrano-file_db'
|
8
|
+
gem.summary = "Sqlite3 integration for Capistrano"
|
9
|
+
gem.description = "Capistrano plugin that easies handling database files on production."
|
10
|
+
gem.has_rdoc = false
|
11
|
+
gem.files = [
|
12
|
+
"lib/capistrano-file_db.rb",
|
13
|
+
"LICENSE",
|
14
|
+
"README.md",
|
15
|
+
"capistrano-file_db.gemspec",
|
16
|
+
]
|
17
|
+
gem.add_runtime_dependency 'capistrano'
|
18
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
require 'capistrano/version'
|
3
|
+
|
4
|
+
class CapistranoFileDB
|
5
|
+
def self.load_into(capistrano_config)
|
6
|
+
capistrano_config.load do
|
7
|
+
_cset(:file_db_path, "db")
|
8
|
+
_cset(:file_db_files, ["#{fetch(:rails_env) rescue 'production'}.sqlite3"] )
|
9
|
+
_cset(:file_db_rights, "600")
|
10
|
+
|
11
|
+
namespace :file_db do
|
12
|
+
desc "Link sqlite database to shared location."
|
13
|
+
task :symlink_db do
|
14
|
+
_command = [ "mkdir -p \"#{shared_path}/#{file_db_path}\"" ]
|
15
|
+
_command += file_db_files.map do |file|
|
16
|
+
"ln -nfs \"#{shared_path}/#{file_db_path}/#{file}\" \"#{release_path}/#{file_db_path}/#{file}\""
|
17
|
+
end
|
18
|
+
run _command*"; \n"
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Limit access rights for sqlite database in shared location."
|
22
|
+
task :chmod_db do
|
23
|
+
_command = file_db_files.map do |file|
|
24
|
+
"chmod 600 \"#{shared_path}/#{file_db_path}/#{file}\""
|
25
|
+
end
|
26
|
+
run _command*"; \n"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
after 'deploy:finalize_update', 'file_db:symlink_db'
|
31
|
+
after 'db:migrate', 'file_db:chmod_db'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
if Capistrano::Configuration.instance
|
37
|
+
CapistranoFileDB.load_into(Capistrano::Configuration.instance)
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-file_db
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Michal Papis
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: &5948400 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *5948400
|
25
|
+
description: Capistrano plugin that easies handling database files on production.
|
26
|
+
email: mpapis@gmail.com
|
27
|
+
executables: []
|
28
|
+
extensions: []
|
29
|
+
extra_rdoc_files: []
|
30
|
+
files:
|
31
|
+
- lib/capistrano-file_db.rb
|
32
|
+
- LICENSE
|
33
|
+
- README.md
|
34
|
+
- capistrano-file_db.gemspec
|
35
|
+
homepage: https://github.com/mpapis/capistrano-file_db
|
36
|
+
licenses: []
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 1.8.16
|
56
|
+
signing_key:
|
57
|
+
specification_version: 3
|
58
|
+
summary: Sqlite3 integration for Capistrano
|
59
|
+
test_files: []
|