rails_mysqldump 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +6 -0
- data/README.md +53 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rails_mysqldump/version.rb +3 -0
- data/lib/rails_mysqldump.rb +15 -0
- data/rails_mysqldump.gemspec +25 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9d6f5f35678b5b44d703dca8ec23c5767cfd5bb8
|
4
|
+
data.tar.gz: 8f615e3f738a4bee9fdb3b7cdb5ac0fa6bdca82c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 915803ca7a2f831cd9bab59e5b378648719fffb51a623dd70f88e092bfed581c3421db53d09d2de041a99f08f8fe785bf101225a5ba8a87a57169a346c06176b
|
7
|
+
data.tar.gz: 1856897c7147a7ab46fc57103c2a6f89ce80ef58c54c22df861485dae351deee8e67503563cafbb221e6115190c2e2f5f005246d84d4f128441421a37e5cce24
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# RailsMysqldump
|
2
|
+
|
3
|
+
rails_mysqldump run mysqldump in a Rails project.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rails_mysqldump'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
$ bundle install --path vendor/bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
or
|
20
|
+
|
21
|
+
```bash
|
22
|
+
$ bundle install
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```bash
|
28
|
+
$ bin/rails c
|
29
|
+
> RailsMysqldump.run
|
30
|
+
```
|
31
|
+
|
32
|
+
Then, for example, `tmp/mysqldump/development_20171102133556.dump` file is generated.
|
33
|
+
|
34
|
+
When production environment:
|
35
|
+
|
36
|
+
```bash
|
37
|
+
$ bin/rails c -e production
|
38
|
+
> RailsMysqldump.run
|
39
|
+
```
|
40
|
+
|
41
|
+
Then, for example, `tmp/mysqldump/production_20171102133556.dump` file is generated.
|
42
|
+
|
43
|
+
By default, it is output to `tmp/mysqldump` .
|
44
|
+
|
45
|
+
If you want to output to another directory, execute:
|
46
|
+
|
47
|
+
```bash
|
48
|
+
RailsMysqldump.run('path/to/dump')
|
49
|
+
```
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/mokuo/rails_mysqldump.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rails_mysqldump"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "rails_mysqldump/version"
|
2
|
+
|
3
|
+
module RailsMysqldump
|
4
|
+
def self.run(path = 'tmp/mysqldump')
|
5
|
+
dump_dir = Rails.root.join(path)
|
6
|
+
FileUtils.mkdir_p(dump_dir)
|
7
|
+
Dir.chdir(dump_dir)
|
8
|
+
|
9
|
+
db_conf = Rails.application.config.database_configuration[Rails.env]
|
10
|
+
password_option = db_conf['password'].nil? ? "" : "-p'#{db_conf['password']}'"
|
11
|
+
output_file = "#{Rails.env}_#{Time.current.to_s(:number)}.dump"
|
12
|
+
|
13
|
+
system "mysqldump -u #{db_conf['username']} #{password_option} -h localhost #{db_conf['database']} --single-transaction > #{output_file}"
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "rails_mysqldump/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rails_mysqldump"
|
8
|
+
spec.version = RailsMysqldump::VERSION
|
9
|
+
spec.authors = ["mokuo"]
|
10
|
+
spec.email = ["https://github.com/mokuo/rails_mysqldump"]
|
11
|
+
|
12
|
+
spec.summary = %q{Run mysqldump in the Rails project}
|
13
|
+
spec.description = %q{By default, it outputs dump file to 'tmp/mysqldump' directory.}
|
14
|
+
spec.homepage = "https://github.com/ultimate-works/rails_mysqldump"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails_mysqldump
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- mokuo
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: By default, it outputs dump file to 'tmp/mysqldump' directory.
|
42
|
+
email:
|
43
|
+
- https://github.com/mokuo/rails_mysqldump
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- bin/console
|
53
|
+
- bin/setup
|
54
|
+
- lib/rails_mysqldump.rb
|
55
|
+
- lib/rails_mysqldump/version.rb
|
56
|
+
- rails_mysqldump.gemspec
|
57
|
+
homepage: https://github.com/ultimate-works/rails_mysqldump
|
58
|
+
licenses: []
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.6.13
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Run mysqldump in the Rails project
|
80
|
+
test_files: []
|