Skip to content

Commit 21fa5b7

Browse files
authored
Make it easier to add a DB type to release
1 parent c1542c7 commit 21fa5b7

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Rakefile

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
# You may use sqlite3 as an alias for sqlite
1717
# You may use all to mean all three
1818
#
19+
# NOTE: if you ever want to add a new type of database to be released,
20+
# just fix up this documentation, the error string in invalid_dbs,
21+
# and add it to the ALL_DBS array. Everything else should just work!
22+
#
1923
# INCLUDE_JAR_IN_GEM [default task - false, other taks - true]:
2024
# Note: This is something you should not normally have to set.
2125
# For local development we always will end up including the jar file
@@ -124,27 +128,25 @@ task 'release:push' do
124128
sh "for gem in `ls pkg/*-#{current_version.call}-java.gem`; do gem push $gem; done"
125129
end
126130

127-
DB_ALIASES = {
128-
'mysql' => 'mysql',
129-
'postgresql' => 'postgresql',
130-
'postgres' => 'postgresql',
131-
'pg' => 'postgresql',
132-
'sqlite3' => 'sqlite3',
133-
'sqlite' => 'sqlite3'
134-
}
131+
ALL_DBS = ["mysql", "postgresql", "sqlite3"] #NOTE: if we add a new database type to be released, just add it here!
132+
DB_ALIASES = ALL_DBS.map {|db| [db, db]}.to_h.merge({
133+
"pg" => "postgresql",
134+
"postgres" => "postgresql",
135+
"sqlite" => "sqlite3"
136+
})
135137

136138
def invalid_dbs!
137139
raise ArgumentError, "Invalid DBS env var\nThe DBS env var must be set to a combination of mysql, postgres, or " \
138140
"sqlite, separated by commas. For example:\n\nmysql,postgres,sqlite\n\nYou may use pg or " \
139141
"postgres as aliases for postgresql\nYou may use sqlite3 as an alias for sqlite\n" \
140-
"You may use all to mean all three"
142+
"You may use all as a shortcut to listing them all out"
141143
end
142144

143145
def make_db_list
144146
env_dbs = ENV["DBS"]
145-
env_dbs = "mysql,postgresql,sqlite3" if !env_dbs || env_dbs == "all"
147+
return ALL_DBS if !env_dbs || env_dbs == "all"
146148
requested = env_dbs.split(",").map(&:strip).reject(&:empty?).map(&:downcase)
147-
invalid_dbs! unless requested.size > 0 && requested.size <= 3 && requested == requested.uniq
149+
invalid_dbs! unless requested.size > 0 && requested == requested.uniq
148150

149151
canonical = requested.map do |name|
150152
DB_ALIASES.fetch(name) { invalid_dbs! }

0 commit comments

Comments
 (0)