daddy 0.3.30 → 0.3.31

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6eebd070998a1406bf8a38933a9514098fda47ac
4
- data.tar.gz: 0c55ff816dd1a4c7da4540a069645041fa74cd23
3
+ metadata.gz: 2cc7ef0887a7cd403b0133540fb39a5e6a724cba
4
+ data.tar.gz: 2fe777a893685ea69331c534ea64032580d22dcc
5
5
  SHA512:
6
- metadata.gz: 8d2854a595d5db5720b237ed6f3fc13dda788d1f4772ebc4e63572a9744c01a810cf0bab48c8fbe7715be6a62ecc824298956c3e1c40df97c1167f4ffbedd743
7
- data.tar.gz: 1724891adf826b2b3f0e42b86500fc165cc53dafcbfe1fef900f46bc260bb6c755347c140dd65df3eb9a06a03798fec3aa97f9c47bb11f30cb1893d28cd6fea5
6
+ metadata.gz: c49d7737afbdf908a7aba6e21476c54a1dafad09a87387af18436151d598d31061482afba2cb8104bfe93d69003f3f18dcfeeabcff137b8d144ee501498de083
7
+ data.tar.gz: 820cb43fedc9661c5116cfb594cd7d77ec56172fbdd2aa8971acab81eeb361e7ab0a38cace9a03bb7c0f0458d41c9cf9313aeb6278f792526657271dc3eba469
data/lib/daddy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Daddy
2
- VERSION = '0.3.30'.freeze
2
+ VERSION = '0.3.31'.freeze
3
3
  end
@@ -1,5 +1,3 @@
1
- # coding: UTF-8
2
-
3
1
  require 'rake'
4
2
 
5
3
  namespace :dad do
@@ -1,5 +1,3 @@
1
- # coding: UTF-8
2
-
3
1
  require 'rake'
4
2
 
5
3
  namespace :dad do
@@ -0,0 +1,24 @@
1
+ require_relative 'task_helper'
2
+
3
+ namespace :dad do
4
+ namespace :db do
5
+
6
+ desc "データベースをダンプします。"
7
+ task :dump do
8
+ backup_dir = ask('出力先ディレクトリ', :required => true)
9
+
10
+ config = YAML.load_file(File.join('config', 'database.yml'))[Rails.env]
11
+ host = config['host'] || 'localhost'
12
+ database = config['database']
13
+ user = config['username']
14
+ password = config['password']
15
+ now = Time.now
16
+ filepath = File.join(backup_dir, "#{database}-#{now.strftime('%Y-%m-%d_%H%M')}.dump.gz")
17
+
18
+ run "mkdir -p #{File.dirname(filepath)}",
19
+ "mysqldump -u #{user} -p#{password} -h #{host} #{database} | gzip > #{filepath}",
20
+ :gsub => [/-p[^ ]+/, '-pFILTERED']
21
+ end
22
+ end
23
+
24
+ end
@@ -1,5 +1,3 @@
1
- # coding: UTF-8
2
-
3
1
  if defined?(RailsCsvFixtures)
4
2
  namespace :db do
5
3
  namespace :fixtures do
@@ -71,10 +71,14 @@ def self.ask(prompt, options = {})
71
71
  end
72
72
 
73
73
  def self.run(*commands)
74
- return if dry_run?
74
+ options = commands.pop if commands.last.is_a?(Hash)
75
75
 
76
76
  commands.each do |c|
77
- puts c
78
- fail unless system(c)
77
+ if dry_run?
78
+ puts "command to be run: #{options[:gsub] ? c.gsub(*options[:gsub]) : c}"
79
+ else
80
+ puts options[:gsub] ? c.gsub(*options[:gsub]) : c
81
+ fail unless system(c)
82
+ end
79
83
  end
80
84
  end
@@ -1,6 +1,7 @@
1
1
  require 'yaml'
2
2
 
3
3
  rails_root = "#{File.dirname(File.expand_path(__FILE__))}/.."
4
+ rails_env = ENV['RAILS_ENV'] || 'development'
4
5
 
5
6
  worker_processes 2
6
7
  working_directory rails_root
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.30
4
+ version: 0.3.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - ichy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-29 00:00:00.000000000 Z
11
+ date: 2015-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -320,6 +320,7 @@ files:
320
320
  - lib/tasks/database.yml.erb
321
321
  - lib/tasks/db_config.rake
322
322
  - lib/tasks/db_create.rake
323
+ - lib/tasks/db_dump.rake
323
324
  - lib/tasks/db_fixtures.rake
324
325
  - lib/tasks/diary.rake
325
326
  - lib/tasks/elasticsearch.rake