bard-rake 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bard-rake.gemspec +1 -1
- data/lib/bard/rake.rb +1 -1
- data/lib/bard/rake/db_dump_load.rb +67 -65
- data/lib/bard/rake/railtie.rb +7 -5
- data/lib/bard/rake/version.rb +4 -2
- metadata +3 -10
- data/VERSION +0 -1
- data/spec/bard-rake_spec.rb +0 -7
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd0800d5bb47d5e38f50d968b029a25310b4050e
|
4
|
+
data.tar.gz: f095dfe1483e924e3aac8b34fc6cf96cfd3a54ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bcc580341d4d8d4c45b38fbc0eef9867ca068edb80a4b57335e7eead0753193c1df05ffcb760102f324605fbfb03e84aafd636861e2f001e0ca5451b683fca9
|
7
|
+
data.tar.gz: a45b285dba1faeb0f1e3a67697229fc97557f0655ef18db424631390299d5a4793180fdf67463f943ac9e97ba4feb278e74f7d8592c2da7bc127dd85c7ac7dce
|
data/bard-rake.gemspec
CHANGED
@@ -4,7 +4,7 @@ require 'bard/rake/version'
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "bard-rake"
|
7
|
-
spec.version =
|
7
|
+
spec.version = Bard::Rake::VERSION
|
8
8
|
spec.authors = ["Micah Geisel"]
|
9
9
|
spec.email = ["micah@botandrose.com"]
|
10
10
|
spec.description = "Rake tasks for all bard projects.\n* Bootstrap projects\n* Database backup"
|
data/lib/bard/rake.rb
CHANGED
@@ -1,100 +1,102 @@
|
|
1
1
|
namespace :db do
|
2
2
|
desc "Dump the current database to db/data.sql"
|
3
3
|
task :dump => :environment do
|
4
|
-
klass = adapter_from_config
|
4
|
+
klass = adapter_from_config Bard::Rake.database_config
|
5
5
|
klass.dump
|
6
6
|
end
|
7
7
|
|
8
8
|
desc "Load the db/data.sql data into the current database."
|
9
9
|
task :load => ["db:drop:current", "db:create:current"] do
|
10
|
-
klass = adapter_from_config
|
10
|
+
klass = adapter_from_config Bard::Rake.database_config
|
11
11
|
klass.load
|
12
12
|
end
|
13
13
|
|
14
14
|
def adapter_from_config config
|
15
|
-
"
|
15
|
+
"Bard::Rake::#{config["adapter"].camelize}".constantize
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
module
|
20
|
-
|
19
|
+
module Bard
|
20
|
+
module Rake
|
21
|
+
FILE_PATH = "db/data.sql"
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
def self.database_config
|
24
|
+
@config ||= ActiveRecord::Base.configurations[Rails.env || "development"]
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
class Sqlite3
|
28
|
+
class << self
|
29
|
+
include ::Rake::DSL
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
def dump
|
32
|
+
FileUtils.cp database, FILE_PATH
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
def load
|
36
|
+
FileUtils.cp FILE_PATH, database
|
37
|
+
end
|
37
38
|
|
38
|
-
|
39
|
+
private
|
39
40
|
|
40
|
-
|
41
|
-
|
41
|
+
def database
|
42
|
+
Bard::Rake.database_config["database"]
|
43
|
+
end
|
42
44
|
end
|
43
45
|
end
|
44
|
-
end
|
45
46
|
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
class Postgresql
|
48
|
+
class << self
|
49
|
+
include ::Rake::DSL
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
def dump
|
52
|
+
pg_dump = `which pg_dump`.strip
|
53
|
+
raise RuntimeError, "Cannot find pg_dump." if pg_dump.blank?
|
54
|
+
sh "#{pg_dump} -f#{FILE_PATH} #{database}"
|
55
|
+
end
|
55
56
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
57
|
+
def load
|
58
|
+
psql = `which psql`.strip
|
59
|
+
raise RuntimeError, "Cannot find psql." if psql.blank?
|
60
|
+
sh "#{psql} -q -d#{database} -f#{FILE_PATH}"
|
61
|
+
end
|
61
62
|
|
62
|
-
|
63
|
+
private
|
63
64
|
|
64
|
-
|
65
|
-
|
65
|
+
def database
|
66
|
+
Bard::Rake.database_config["database"]
|
67
|
+
end
|
66
68
|
end
|
67
69
|
end
|
68
|
-
end
|
69
70
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
71
|
+
class Mysql
|
72
|
+
class << self
|
73
|
+
include ::Rake::DSL
|
74
|
+
|
75
|
+
def dump
|
76
|
+
mysqldump = `which mysqldump`.strip
|
77
|
+
raise RuntimeError, "Cannot find mysqldump." if mysqldump.blank?
|
78
|
+
sh "#{mysqldump} --single-transaction --quick --add-drop-database --databases -e #{mysql_options} > #{FILE_PATH}"
|
79
|
+
end
|
80
|
+
|
81
|
+
def load
|
82
|
+
mysql = `which mysql`.strip
|
83
|
+
raise RuntimeError, "Cannot find mysql." if mysql.blank?
|
84
|
+
sh "#{mysql} #{mysql_options} < #{FILE_PATH}"
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def mysql_options
|
90
|
+
config = Bard::Rake.database_config
|
91
|
+
options = " -u #{config["username"]}"
|
92
|
+
options += " -p'#{config["password"]}'" if config["password"]
|
93
|
+
options += " -h #{config["host"]}" if config["host"]
|
94
|
+
options += " -S #{config["socket"]}" if config["socket"]
|
95
|
+
options += " '#{config["database"]}'"
|
96
|
+
end
|
95
97
|
end
|
96
98
|
end
|
97
|
-
end
|
98
99
|
|
99
|
-
|
100
|
+
Mysql2 = Mysql
|
101
|
+
end
|
100
102
|
end
|
data/lib/bard/rake/railtie.rb
CHANGED
data/lib/bard/rake/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bard-rake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Micah Geisel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -70,7 +70,6 @@ files:
|
|
70
70
|
- README.md
|
71
71
|
- README.rdoc
|
72
72
|
- Rakefile
|
73
|
-
- VERSION
|
74
73
|
- bard-rake.gemspec
|
75
74
|
- lib/bard-rake.rb
|
76
75
|
- lib/bard/rake.rb
|
@@ -80,9 +79,6 @@ files:
|
|
80
79
|
- lib/bard/rake/railtie.rb
|
81
80
|
- lib/bard/rake/testing.rb
|
82
81
|
- lib/bard/rake/version.rb
|
83
|
-
- spec/bard-rake_spec.rb
|
84
|
-
- spec/spec.opts
|
85
|
-
- spec/spec_helper.rb
|
86
82
|
homepage: http://github.com/botandrose/bard-rake
|
87
83
|
licenses:
|
88
84
|
- MIT
|
@@ -107,7 +103,4 @@ rubygems_version: 2.1.10
|
|
107
103
|
signing_key:
|
108
104
|
specification_version: 4
|
109
105
|
summary: Rake tasks for all bard projects.
|
110
|
-
test_files:
|
111
|
-
- spec/bard-rake_spec.rb
|
112
|
-
- spec/spec.opts
|
113
|
-
- spec/spec_helper.rb
|
106
|
+
test_files: []
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.10.6
|
data/spec/bard-rake_spec.rb
DELETED
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|