Skip to content

Commit 9119cce

Browse files
committed
Merge branch 'release/v0.0.8'
2 parents f1367bc + 4538441 commit 9119cce

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/fancybox2/migrations/runner.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ module Migrations
33
class Runner
44
include Exceptions
55

6-
VERSION_REGEXP = /^(\d{14})/.freeze
6+
VERSION_REGEXP = /^(\d+)/.freeze
77

88
class << self
99

1010
def extract_and_validate_version_from(migration_name)
1111
version = migration_name.to_s.scan(VERSION_REGEXP).flatten.first
1212
unless version
13-
raise ArgumentError, 'migration version must be a 14 digits integer'
13+
raise ArgumentError, 'migration name must start with an integer number e.g: 02_do_something.rb'
1414
end
1515

1616
version.to_i
@@ -24,7 +24,7 @@ def initialize(files_path)
2424

2525
load_migrations
2626
end
27-
27+
2828
# @param from a valid migration name or version
2929
# @param to a valid migration name or version
3030
def run(from: nil, to: nil)
@@ -40,13 +40,13 @@ def run(from: nil, to: nil)
4040

4141
def load_migrations
4242
# Load files from files_path and create classes
43-
@migrations = Dir[File.join(File.expand_path(files_path), '**', '*.rb')].sort.map do |f_path|
44-
migration_name = File.basename(f_path)
43+
@migrations = Dir[File.join(File.expand_path(files_path), '**', '*.rb')].map do |file_path|
44+
migration_name = File.basename(file_path)
4545
klass = Class.new(Base)
46-
klass.class_eval(File.read(f_path), f_path)
46+
klass.class_eval(File.read(file_path), file_path)
4747
klass.freeze
4848
klass.new migration_name
49-
end
49+
end.sort_by { |migration| migration.version }
5050
end
5151

5252
# Select migrations to run depending given a starting and an ending one

lib/fancybox2/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module Fancybox2
4-
VERSION = '0.0.7'
4+
VERSION = '0.0.8'
55
end

0 commit comments

Comments
 (0)