lib/kpm/migrations.rb in kpm-0.7.2 vs lib/kpm/migrations.rb in kpm-0.8.0
- old
+ new
@@ -1,18 +1,19 @@
+# frozen_string_literal: true
+
require 'base64'
require 'json'
require 'logger'
require 'open-uri'
require 'pathname'
module KPM
class Migrations
+ KILLBILL_MIGRATION_PATH = %r{src/main/resources/org/killbill/billing/[a-z]+/migration/(V[0-9a-zA-Z_]+.sql)}.freeze
+ JAVA_PLUGIN_MIGRATION_PATH = %r{src/main/resources/migration/(V[0-9a-zA-Z_]+.sql)}.freeze
+ RUBY_PLUGIN_MIGRATION_PATH = %r{db/migrate/([0-9a-zA-Z_]+.rb)}.freeze
- KILLBILL_MIGRATION_PATH = /src\/main\/resources\/org\/killbill\/billing\/[a-z]+\/migration\/(V[0-9a-zA-Z_]+.sql)/
- JAVA_PLUGIN_MIGRATION_PATH = /src\/main\/resources\/migration\/(V[0-9a-zA-Z_]+.sql)/
- RUBY_PLUGIN_MIGRATION_PATH = /db\/migrate\/([0-9a-zA-Z_]+.rb)/
-
# Go to https://github.com/settings/tokens to generate a token
def initialize(from_version, to_version = nil, repository = 'killbill/killbill', oauth_token = nil, logger = Logger.new(STDOUT))
@from_version = from_version
@to_version = to_version
@repository = repository
@@ -32,11 +33,11 @@
end
end
end
def save(dir = nil)
- return nil if migrations.size == 0
+ return nil if migrations.empty?
dir ||= Dir.mktmpdir
@logger.debug("Storing migrations to #{dir}")
migrations.each do |migration|
@logger.info("Migration to run: #{migration[:name]}")
@@ -69,11 +70,11 @@
blob_metadata = get_as_json("#{entry['url']}?access_token=#{@oauth_token}")
sql = decode(blob_metadata['content'], blob_metadata['encoding'])
end
migrations << {
- :name => migration_name,
- :sql => sql
+ name: migration_name,
+ sql: sql
}
end
migrations
end