bard-rake 0.2.0 → 0.2.1

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/bard-rake.gemspec +2 -2
  3. data/lib/bard/rake/db.rb +20 -14
  4. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/bard-rake.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bard-rake}
8
- s.version = "0.2.0"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Micah Geisel}]
12
- s.date = %q{2011-08-16}
12
+ s.date = %q{2011-08-30}
13
13
  s.description = %q{Rake tasks for all bard projects.
14
14
  * Bootstrap projects
15
15
  * Database backup}
data/lib/bard/rake/db.rb CHANGED
@@ -1,24 +1,30 @@
1
1
  namespace :db do
2
2
  desc "Dump the current database to db/data.sql"
3
- task :dump => :"backup:db" do
4
- config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
5
- db_file = Dir.glob("../#{config['database'].gsub(/_/, '-')}-*.sql").first
6
- FileUtils.move db_file, "db/data.sql"
3
+ task :dump => :environment do
4
+ mysqldump = `which mysqldump`.strip
5
+ raise RuntimeError, "Cannot find mysqldump." if mysqldump.blank?
6
+ sh "#{mysqldump} -e #{mysql_options} > #{file_path}"
7
7
  end
8
8
 
9
9
  desc "Load the db/data.sql data into the current database."
10
- task :load => :environment do
11
- config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
12
- Rake::Task["db:drop"].invoke
13
- Rake::Task["db:create"].invoke
10
+ task :load => ["db:drop", "db:create"] do
14
11
  mysql = `which mysql`.strip
15
- options = " -u#{config['username']}"
16
- options += " -p#{config['password']}" if config['password']
17
- options += " -h #{config['host']}" if config['host']
18
-
19
- raise RuntimeError, "I only work with mysql." unless config['adapter'].include? 'mysql'
20
12
  raise RuntimeError, "Cannot find mysql." if mysql.blank?
13
+ sh "#{mysql} #{mysql_options} < #{file_path}"
14
+ end
15
+
16
+ def file_path
17
+ "db/data.sql"
18
+ end
19
+
20
+ def mysql_options
21
+ config = ActiveRecord::Base.configurations[Rails.env || "development"]
22
+ raise RuntimeError, "I only work with mysql." unless config["adapter"].starts_with? "mysql"
21
23
 
22
- sh "#{mysql} #{options} '#{config["database"]}' < db/data.sql"
24
+ options = " -u #{config["username"]}"
25
+ options += " -p'#{config["password"]}'" if config["password"]
26
+ options += " -h #{config["host"]}" if config["host"]
27
+ options += " -S #{config["socket"]}" if config["socket"]
28
+ options += " '#{config["database"]}'"
23
29
  end
24
30
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bard-rake
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 0
10
- version: 0.2.0
9
+ - 1
10
+ version: 0.2.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Micah Geisel
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-16 00:00:00 Z
18
+ date: 2011-08-30 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rspec