This repository has been archived by the owner on Mar 14, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from stitchfix/feature/allow-alternate-url-format
Allows a second format for URLs
- Loading branch information
Showing
5 changed files
with
41 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,4 @@ script: | |
services: | ||
- redis-server | ||
rvm: | ||
- 2.1.0 | ||
- 2.2.0 | ||
- 2.1.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class MissingResqueConfigurationError < StandardError | ||
def initialize(environment_variables,resque_name) | ||
super("Couldn't find environment variable for Resque #{resque_name}. Tried: #{environment_variables.join(',')}") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class ResqueUrl | ||
def initialize(resque_name) | ||
@resque_name = resque_name | ||
end | ||
|
||
def url | ||
@url ||= environment_variables.map { |environment_variable| | ||
ENV[environment_variable] | ||
}.compact.first | ||
if @url.nil? | ||
raise MissingResqueConfigurationError.new(environment_variables,@resque_name) | ||
end | ||
@url | ||
end | ||
|
||
private | ||
|
||
def environment_variables | ||
[ | ||
"RESQUE_BRAIN_INSTANCES_#{@resque_name}", | ||
"#{@resque_name.gsub(/-/,'_').upcase}_RESQUE_REDIS_URL", | ||
] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters