simple_migrator 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1af28597af8a7d9a0068fc91c9e7eeb9b64e649f
4
- data.tar.gz: b4a11ef877bf056967a39dc6bed5b5dc8b7dac98
3
+ metadata.gz: 71ac5f22636b7fc9b4ecc37945d3e713ed6095dc
4
+ data.tar.gz: 3b3aa758fe366adf86593bb980eec6c2497bb1cc
5
5
  SHA512:
6
- metadata.gz: 7d5b0d68efc106da8056d5325b08292a6ba3ece01c4d9b22d1ddcf3ec6a333527e82f1253ccaddbfc26784883e6b29406c6c5f4f4e0ca1a2f9486e199a710e4a
7
- data.tar.gz: 73961d603025b408c1f7ed032718efb24cf2b471e05a7307300dd7cd4f76c1dc3377eaf07de5504b8614101ec98f4ec9879f71e803ac8cce2ad4b8e7523342e3
6
+ metadata.gz: 3731c2a652d08cb1df200708df0530dac35274529e45003f197476bcc36d2fa50c6fc0d46554cf509930e2ee8012e46ed0ba2935271a274b97ea6e0569ad18e8
7
+ data.tar.gz: 6cba75f0ac1f2474b24e9436555f2d0f6d3cca6fb8fde9266255baf690ae08cf75e3b518cd03c6c8fad23840ab611d81af01055682be60dae16ce900d909554f
@@ -22,7 +22,7 @@ module SimpleMigrator
22
22
  raise NoMigratorError, "`migrate!` called without a migrator.\nEither provide a migrator or define a `migrator` method"
23
23
  end
24
24
 
25
- def rebind_proc(proc)5
25
+ def rebind_proc(proc)
26
26
  Proc.new do |db|
27
27
  instance_exec(db, &proc)
28
28
  end
@@ -1,6 +1,7 @@
1
1
  module SimpleMigrator
2
2
  class Migrator
3
- def initialize(connection)
3
+ def initialize(connection, migration_table_name = nil)
4
+ @table_name = migration_table_name
4
5
  @connection = connection
5
6
  ensure_migration_table!
6
7
  end
@@ -22,12 +23,12 @@ module SimpleMigrator
22
23
  connection[table_name]
23
24
  end
24
25
 
25
- def self.table_name
26
- :schema_migrations
26
+ def self.default_table_name
27
+ :simple_migrator_schema_migrations
27
28
  end
28
29
 
29
30
  def table_name
30
- self.class.table_name
31
+ @table_name || self.class.default_table_name
31
32
  end
32
33
 
33
34
  private
@@ -1,3 +1,3 @@
1
1
  module SimpleMigrator
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -7,11 +7,26 @@ module SimpleMigrator
7
7
 
8
8
  describe "#initialize" do
9
9
  context "when no prior migration table exists" do
10
- before do
11
- Migrator.new(connection)
10
+ context "when given no explicit table name" do
11
+ before do
12
+ Migrator.new(connection)
13
+ end
14
+
15
+ it "creates one" do
16
+ expect(connection.tables).to include(Migrator.default_table_name)
17
+ end
12
18
  end
13
- it "creates one" do
14
- expect(connection.tables).to include(Migrator.table_name)
19
+
20
+ context "when given an explicit table name" do
21
+ context "when given a table name" do
22
+ let(:table_name) { :foobar }
23
+ before do
24
+ Migrator.new(connection, table_name)
25
+ end
26
+ it "creates a table with that name" do
27
+ expect(connection.tables).to include(table_name)
28
+ end
29
+ end
15
30
  end
16
31
  end
17
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_migrator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesper Josefsson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-04 00:00:00.000000000 Z
11
+ date: 2015-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel