Class: Engineyard::Hudson::AppcloudEnv
- Inherits:
-
Object
- Object
- Engineyard::Hudson::AppcloudEnv
- Includes:
- EY::UtilityMethods
- Defined in:
- lib/engineyard-hudson/appcloud_env.rb
Instance Method Summary collapse
-
#clean_host_name(environment) ⇒ Object
Currently the engineyard gem has badly formed URLs in its same data This method cleans app_master_hostname.compute-1.amazonaws.com -> app-master-hostname.compute-1.amazonaws.com.
- #default_query_environments ⇒ Object
-
#find_environments(options = {}) ⇒ Object
Returns [environment, account] based on current .eyrc credentials and/or CLI options Returns [nil, nil] if no unique environment can be selected.
Instance Method Details
#clean_host_name(environment) ⇒ Object
Currently the engineyard gem has badly formed URLs in its same data This method cleans app_master_hostname.compute-1.amazonaws.com -> app-master-hostname.compute-1.amazonaws.com
44 45 46 |
# File 'lib/engineyard-hudson/appcloud_env.rb', line 44 def clean_host_name(environment) environment.instances.first.public_hostname.gsub!(/_/,'-') if environment.instances.first end |
#default_query_environments ⇒ Object
38 39 40 |
# File 'lib/engineyard-hudson/appcloud_env.rb', line 38 def default_query_environments %w[hudson hudson_server hudson_production hudson_server_production] end |
#find_environments(options = {}) ⇒ Object
Returns [environment, account] based on current .eyrc credentials and/or CLI options Returns [nil, nil] if no unique environment can be selected
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/engineyard-hudson/appcloud_env.rb', line 13 def find_environments( = {}) Thor::Base.shell = EY::CLI::UI EY.ui = EY::CLI::UI.new query_environments = [:environment] ? [[:environment]] : default_query_environments query_environments.inject([]) do |envs, env_name| begin if environment = fetch_environment(env_name, [:account]) clean_host_name(environment) envs << [env_name, environment.account.name, environment] end rescue EY::NoEnvironmentError rescue EY::MultipleMatchesError => e # e.message looks something like: # Multiple environments possible, please be more specific: # # hudson # ey <command> --environment='hudson' --account='drnic-demo' # hudson # ey <command> --environment='hudson' --account='rails-hudson' e..scan(/--environment='([^']+)' --account='([^']+)'/) do envs << [$1, $2, nil] end end envs end end |