-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
111 additions
and
13 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
require_relative "app_settings" | ||
require_relative "initializers/aws_stubs" | ||
|
||
Dir["#{File.dirname(__FILE__)}/../lib/**/*.rb"].sort.each { |f| require f } | ||
Dir["#{File.dirname(__FILE__)}/../lib/**/*.rb"].each { |f| require f } | ||
|
||
EncryptedEnvironmentVariables.new.decrypt | ||
|
||
Dir["#{File.dirname(__FILE__)}/**/*.rb"].sort.each { |f| require f } | ||
Dir["#{File.dirname(__FILE__)}/../app/**/*.rb"].sort.each { |f| require f } | ||
Dir["#{File.dirname(__FILE__)}/**/*.rb"].each { |f| require f } | ||
Dir["#{File.dirname(__FILE__)}/../app/**/*.rb"].each { |f| require f } |
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,3 @@ | ||
SomlengRegions.configure do |config| | ||
config.region_data = ENV.fetch("REGION_DATA") | ||
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,22 @@ | ||
module SomlengRegions | ||
class << self | ||
def configure | ||
yield(configuration) | ||
configuration | ||
end | ||
|
||
def configuration | ||
@configuration ||= Configuration.new | ||
end | ||
alias config configuration | ||
|
||
def regions | ||
@regions ||= Collection.new(Parser.new.parse(configuration.region_data)) | ||
end | ||
end | ||
end | ||
|
||
require_relative "somleng_regions/configuration" | ||
require_relative "somleng_regions/parser" | ||
require_relative "somleng_regions/collection" | ||
require_relative "somleng_regions/region" |
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,21 @@ | ||
module SomlengRegions | ||
class Collection | ||
class RegionNotFoundError < StandardError; end | ||
|
||
attr_reader :regions | ||
|
||
def initialize(regions) | ||
@regions = regions | ||
end | ||
|
||
def find_by(attributes) | ||
regions.find do |region| | ||
attributes.all? { |key, value| region[key] == value } | ||
end | ||
end | ||
|
||
def find_by!(*) | ||
find_by(*) || raise(RegionNotFoundError.new) | ||
end | ||
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,5 @@ | ||
module SomlengRegions | ||
class Configuration | ||
attr_accessor :region_data | ||
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,7 @@ | ||
module SomlengRegions | ||
class Parser | ||
def parse(region_data) | ||
JSON.parse(region_data).map { |region| Region.new(region) } | ||
end | ||
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,5 @@ | ||
require "ostruct" | ||
|
||
module SomlengRegions | ||
class Region < OpenStruct; 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
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
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
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