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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1b72dbe55d0b2e75ac7f7252523cc0a6e9aa0e8c
4
- data.tar.gz: 14941b0f5403a9f8d808dab344a1311ba478d5e6
3
+ metadata.gz: a0be368a6cfd39c55ff6d08907ac0a9b64d8dc1a
4
+ data.tar.gz: 7db889643e97db81a6a547a0850da3d071183820
5
5
  SHA512:
6
- metadata.gz: a580120bb878da83920740b14f0897633026a4fbdb080df8a206fd8ade2c7351e7ea461e7bebd4220b9d301f50c7e88060479e540fff04dd6b07f4fa4a5abf28
7
- data.tar.gz: a2d3ed6ab93bed2e952dd51e387be6c3a6cdb549521a8e2057649390a540b7d4397e89ad1f65be24a9809a93e1689bce5810ed3916ab7ed45102ed15f245adb4
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, :database, :logger
9
+ attr_accessor :migrations_path, :logger, :setup_hook
10
+ attr_writer :database
10
11
 
11
12
  def initialize(options: {})
12
- @migrations_path = options.fetch(:migrations_path) { "migrate" }
13
- @database = options.fetch(:database) { DB if defined?(DB) }
14
- @logger = options.fetch(:logger) { Logger.new($stdout) }
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)
@@ -1,3 +1,3 @@
1
1
  module Batteries
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.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-07-06 00:00:00.000000000 Z
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.12
90
+ rubygems_version: 2.6.13
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Powering your Roda/Sinatra applications