batteries 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/batteries/tasks/migrations.rb +15 -4
- data/lib/batteries/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0be368a6cfd39c55ff6d08907ac0a9b64d8dc1a
|
4
|
+
data.tar.gz: 7db889643e97db81a6a547a0850da3d071183820
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa4a786620129b69b068b746bb357289450daef25539424c6ca9cd53681cf2af57c1e61d4ecbcd6a64c54d2df0f4dacdda563fdfb7586453a4e1eb14020ee819
|
7
|
+
data.tar.gz: 42dc68a0e112ac93ed1c13e8305461c4e05a462324b4f6eeb1dd6de4bed9c5fed23e31dc72893c82dbbfed16eb387106c9ef69639e345078eed7c269096b781e
|
@@ -6,12 +6,14 @@ require "logger"
|
|
6
6
|
module Batteries
|
7
7
|
module Tasks
|
8
8
|
class Migrations < ::Rake::TaskLib
|
9
|
-
attr_accessor :migrations_path, :
|
9
|
+
attr_accessor :migrations_path, :logger, :setup_hook
|
10
|
+
attr_writer :database
|
10
11
|
|
11
12
|
def initialize(options: {})
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
self.migrations_path = options.fetch(:migrations_path) { "migrate" }
|
14
|
+
self.database = options.fetch(:database) { DB if defined?(DB) }
|
15
|
+
self.logger = options.fetch(:logger) { Logger.new($stdout) }
|
16
|
+
self.setup_hook = options[:setup_hook]
|
15
17
|
|
16
18
|
yield self if block_given?
|
17
19
|
|
@@ -62,7 +64,16 @@ module Batteries
|
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
67
|
+
def database
|
68
|
+
case @database
|
69
|
+
when String then Object.const_get(@database)
|
70
|
+
else @database
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
65
74
|
def migrate(env, version)
|
75
|
+
ENV["RACK_ENV"] = env
|
76
|
+
setup_hook.call if setup_hook.respond_to?(:call)
|
66
77
|
Sequel.extension :migration
|
67
78
|
database.loggers << logger if logger
|
68
79
|
Sequel::Migrator.apply(database, migrations_path, version)
|
data/lib/batteries/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: batteries
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Daniels
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubygems-tasks
|
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
version: '0'
|
88
88
|
requirements: []
|
89
89
|
rubyforge_project:
|
90
|
-
rubygems_version: 2.6.
|
90
|
+
rubygems_version: 2.6.13
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
93
|
summary: Powering your Roda/Sinatra applications
|