exodus 1.1.1 → 1.1.2

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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v1.1.2
2
+
3
+ * Exodus now supports custom namespacing to not conflict with AR db:migrate
4
+
1
5
  ## v1.1.1
2
6
 
3
7
  * Extracted methods from the rake file itself into a module
@@ -1,7 +1,7 @@
1
1
  module Exodus
2
2
  class MigrationInfo
3
3
  attr_accessor :info, :migrations_directory
4
- attr_reader :config_file, :db, :connection
4
+ attr_reader :config_file, :db, :connection, :rake_namespace
5
5
 
6
6
  def initialize(file = nil)
7
7
  config_file = file if file
@@ -18,12 +18,17 @@ module Exodus
18
18
  def config_file=(file)
19
19
  if File.exists?(file)
20
20
  @config_file = file
21
- @info = YAML.load_file(file)
21
+ self.info = YAML.load_file(file)
22
+ self.rake_namespace = (info['migration'] && info['migration']['rake_namespace']).to_s
22
23
  else
23
24
  raise ArgumentError, "#{file} not found"
24
25
  end
25
26
  end
26
27
 
28
+ def rake_namespace=(namespace)
29
+ @rake_namespace = namespace.to_s.empty? || namespace[-1] == ':' ? namespace.to_s : namespace + ':'
30
+ end
31
+
27
32
  def migrate
28
33
  verify_yml_syntax { @info['migration']['migrate'] }
29
34
  end
@@ -52,7 +57,7 @@ module Exodus
52
57
  begin
53
58
  yield if block_given?
54
59
  rescue
55
- Raise StandardError, "Syntax error detected in config file #{self.config_file}. To find the good syntax take a look at the documentation."
60
+ Raise StandardError, "Syntax error detected in config file #{self.config_file}. To find the correct syntax take a look at the documentation."
56
61
  end
57
62
  end
58
63
  end
@@ -1,3 +1,3 @@
1
1
  module Exodus
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
@@ -1,6 +1,30 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Exodus do
4
+ describe Exodus::MigrationInfo do
5
+ describe "#rake_namespace" do
6
+ it "should use the namespace provided in the yml file" do
7
+ Exodus.configuration.rake_namespace.should == 'test:'
8
+ end
9
+
10
+ it "should be blank when no namespace is given" do
11
+ Exodus.configuration.rake_namespace = nil
12
+ Exodus.configuration.rake_namespace.should == ''
13
+
14
+ Exodus.configuration.rake_namespace = ''
15
+ Exodus.configuration.rake_namespace.should == ''
16
+ end
17
+
18
+ it "should end with ':' when a namespace is given" do
19
+ Exodus.configuration.rake_namespace = 'test1'
20
+ Exodus.configuration.rake_namespace.should == 'test1:'
21
+
22
+ Exodus.configuration.rake_namespace = 'test2:'
23
+ Exodus.configuration.rake_namespace.should == 'test2:'
24
+ end
25
+ end
26
+ end
27
+
4
28
  before do
5
29
  Exodus::Migration.collection.drop
6
30
  end
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,17 @@
1
1
  require File.dirname(__FILE__) + '/../lib/exodus'
2
2
  Dir["#{File.dirname(__FILE__)}/support/*.rb"].each { |f| require f }
3
3
  mongo_uri = 'mongodb://exodus:exodus@dharma.mongohq.com:10048/Exodus-test'
4
+ local_uri = 'mongodb://localhost:27017/Exodus-test'
4
5
 
5
6
  Exodus.configure do |config|
6
7
  config.db = 'Exodus-test'
7
- config.connection = Mongo::MongoClient.from_uri(mongo_uri)
8
8
  config.config_file = File.dirname(__FILE__) + '/support/config.yml'
9
+
10
+ begin
11
+ config.connection = Mongo::MongoClient.from_uri(mongo_uri)
12
+ rescue Mongo::ConnectionFailure => e
13
+ puts e.message, 'Connecting to local db...'
14
+ config.connection = Mongo::MongoClient.from_uri(local_uri)
15
+ end
9
16
  end
10
17
 
@@ -1,4 +1,5 @@
1
1
  migration:
2
+ rake_namespace: 'test'
2
3
  migrate:
3
4
  rollback:
4
5
  custom:
data/tasks/exodus.rake CHANGED
@@ -1,14 +1,13 @@
1
1
  require 'rake'
2
+ require File.dirname(__FILE__) + '/../lib/exodus'
3
+ require File.dirname(__FILE__) + '/../lib/exodus/helpers/rake_helper'
2
4
 
3
5
  task :require_env do
4
- require 'csv'
5
- require File.dirname(__FILE__) + '/../lib/exodus'
6
- require File.dirname(__FILE__) + '/../lib/exodus/helpers/rake_helper'
7
6
  include Exodus::RakeHelper
8
7
  Exodus.load_migrations
9
8
  end
10
9
 
11
- namespace :db do
10
+ namespace Exodus.configuration.rake_namespace + 'db' do
12
11
  desc "Migrate the database"
13
12
  task :migrate => :require_env do
14
13
  time_it "db:migrate#{" step #{step}" if step}" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exodus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-08 00:00:00.000000000 Z
12
+ date: 2013-11-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mongo_mapper