exodus 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/lib/exodus/config/migration_info.rb +8 -3
- data/lib/exodus/version.rb +1 -1
- data/spec/exodus/exodus_spec.rb +24 -0
- data/spec/spec_helper.rb +8 -1
- data/spec/support/config.yml +1 -0
- data/tasks/exodus.rake +3 -4
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -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
|
-
|
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
|
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
|
data/lib/exodus/version.rb
CHANGED
data/spec/exodus/exodus_spec.rb
CHANGED
@@ -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
|
|
data/spec/support/config.yml
CHANGED
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
|
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.
|
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-
|
12
|
+
date: 2013-11-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongo_mapper
|