class WashoutBuilder::EnvChecker
Attributes
app[RW]
Public Class Methods
new(app)
click to toggle source
# File lib/washout_builder/env_checker.rb, line 7 def initialize(app) self.app = app end
Public Instance Methods
available_for_env?(env_name)
click to toggle source
# File lib/washout_builder/env_checker.rb, line 11 def available_for_env?(env_name) if whitelist.present? || blacklist.present? if whitelist.find{|a| blacklist.include?(a) }.blank? if whitelist.include?('*') || (!valid_for_env?(blacklist, env_name) && valid_for_env?(whitelist, env_name)) return true end end else return true end false end
Private Instance Methods
app_config()
click to toggle source
# File lib/washout_builder/env_checker.rb, line 35 def app_config app.config.washout_builder end
blacklist()
click to toggle source
# File lib/washout_builder/env_checker.rb, line 31 def blacklist get_valid_data(app_config[:blacklisted_envs]) end
get_valid_data(list)
click to toggle source
# File lib/washout_builder/env_checker.rb, line 43 def get_valid_data(list) (list.is_a?(Array) ? list : [list]).compact end
try_find_suitable_env(list, env_name)
click to toggle source
# File lib/washout_builder/env_checker.rb, line 47 def try_find_suitable_env(list, env_name) return if list.blank? # The keys of the map can be strings or regular expressions that are # matched against the env name and returns the found value list.find do |env_pattern| if env_pattern.is_a? Regexp env_pattern.match env_name elsif env_pattern.is_a? String env_pattern == env_name end end end
valid_for_env?(list, env_name)
click to toggle source
# File lib/washout_builder/env_checker.rb, line 39 def valid_for_env?(list, env_name) try_find_suitable_env(list, env_name).present? end
whitelist()
click to toggle source
# File lib/washout_builder/env_checker.rb, line 27 def whitelist get_valid_data(app_config[:whitelisted_envs]) end