|
16 | 16 | # You may use sqlite3 as an alias for sqlite |
17 | 17 | # You may use all to mean all three |
18 | 18 | # |
| 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 | +# |
19 | 23 | # INCLUDE_JAR_IN_GEM [default task - false, other taks - true]: |
20 | 24 | # Note: This is something you should not normally have to set. |
21 | 25 | # For local development we always will end up including the jar file |
@@ -124,27 +128,25 @@ task 'release:push' do |
124 | 128 | sh "for gem in `ls pkg/*-#{current_version.call}-java.gem`; do gem push $gem; done" |
125 | 129 | end |
126 | 130 |
|
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 | +}) |
135 | 137 |
|
136 | 138 | def invalid_dbs! |
137 | 139 | raise ArgumentError, "Invalid DBS env var\nThe DBS env var must be set to a combination of mysql, postgres, or " \ |
138 | 140 | "sqlite, separated by commas. For example:\n\nmysql,postgres,sqlite\n\nYou may use pg or " \ |
139 | 141 | "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" |
141 | 143 | end |
142 | 144 |
|
143 | 145 | def make_db_list |
144 | 146 | 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" |
146 | 148 | 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 |
148 | 150 |
|
149 | 151 | canonical = requested.map do |name| |
150 | 152 | DB_ALIASES.fetch(name) { invalid_dbs! } |
|
0 commit comments