Class: EY::Metadata::Outsider
- Inherits:
-
EY::Metadata
- Object
- EY::Metadata
- EY::Metadata::Outsider
- Defined in:
- lib/engineyard-metadata/outsider.rb
Overview
This gets pulled in when you’re running from your developer machine (i.e., not on a cloud instance).
Constant Summary collapse
- UNGETTABLE =
METHODS.grep(/present/) + METHODS.grep(/password/) + METHODS.grep(/mysql/)
- GETTABLE =
METHODS - instance_methods.map { |m| m.to_s } - UNGETTABLE
Constants inherited from EY::Metadata
DEFAULT_IDENTIFIER, METHODS, VERSION
Instance Method Summary collapse
- #app_name ⇒ Object
-
#engine_yard_cloud_api ⇒ Object
An adapter that reads from the public EngineYard Cloud API (cloud.engineyard.com).
-
#environment_name ⇒ Object
The name of the EngineYard AppCloud environment.
-
#environment_name=(str) ⇒ Object
Sets the environment you want, in case it can’t be detected from ENV or .git/config.
-
#ey_cloud_token ⇒ Object
The secret API token to access cloud.engineyard.com.
-
#ey_cloud_token=(str) ⇒ Object
Sets the (secret) cloud token, in case it’s not in ENV or ~/.eyrc.
- #eyrc_path ⇒ Object
- #preset_app_name? ⇒ Boolean
- #preset_environment_name? ⇒ Boolean
Methods inherited from EY::Metadata
Instance Method Details
#app_name ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/engineyard-metadata/outsider.rb', line 16 def app_name return @app_name if @app_name.is_a?(String) if ENV['EY_APP_NAME'] @app_name = ENV['EY_APP_NAME'] elsif engine_yard_cloud_api.possible_to_detect_app_from_environment_name? @app_name = engine_yard_cloud_api.app_name elsif engine_yard_cloud_api.possible_to_detect_app_from_git_config? @app_name = engine_yard_cloud_api.app_name end @app_name end |
#engine_yard_cloud_api ⇒ Object
An adapter that reads from the public EngineYard Cloud API (cloud.engineyard.com)
68 69 70 |
# File 'lib/engineyard-metadata/outsider.rb', line 68 def engine_yard_cloud_api @engine_yard_cloud_api ||= EngineYardCloudApi.new ey_cloud_token end |
#environment_name ⇒ Object
The name of the EngineYard AppCloud environment.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/engineyard-metadata/outsider.rb', line 38 def environment_name return @environment_name if @environment_name.is_a? String if ENV['EY_ENVIRONMENT_NAME'] @environment_name = ENV['EY_ENVIRONMENT_NAME'] elsif engine_yard_cloud_api.possible_to_detect_environment_from_git_config? @environment_name = engine_yard_cloud_api.environment_name end raise RuntimeError, "[engineyard-metadata gem] You need to run this from the application repo, set EY.metadata.environment_name= or set ENV['EY_ENVIRONMENT_NAME']" unless @environment_name.to_s.strip.length > 0 @environment_name end |
#environment_name=(str) ⇒ Object
Sets the environment you want, in case it can’t be detected from ENV or .git/config
33 34 35 |
# File 'lib/engineyard-metadata/outsider.rb', line 33 def environment_name=(str) @environment_name = str end |
#ey_cloud_token ⇒ Object
The secret API token to access cloud.engineyard.com
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/engineyard-metadata/outsider.rb', line 56 def ey_cloud_token return @ey_cloud_token if @ey_cloud_token.is_a? String if ENV['EY_CLOUD_TOKEN'] @ey_cloud_token = ENV['EY_CLOUD_TOKEN'] elsif File.exist? eyrc_path @ey_cloud_token = YAML.load(File.read(eyrc_path))['api_token'] end raise RuntimeError, "[engineyard-metadata gem] You need to have #{eyrc_path}, set EY.metadata.ey_cloud_token= or set ENV['EY_CLOUD_TOKEN']" unless @ey_cloud_token.to_s.strip.length > 0 @ey_cloud_token end |
#ey_cloud_token=(str) ⇒ Object
Sets the (secret) cloud token, in case it’s not in ENV or ~/.eyrc
50 51 52 53 |
# File 'lib/engineyard-metadata/outsider.rb', line 50 def ey_cloud_token=(str) @engine_yard_cloud_api = nil # because it depends on cloud token @ey_cloud_token = str end |
#eyrc_path ⇒ Object
8 9 10 |
# File 'lib/engineyard-metadata/outsider.rb', line 8 def eyrc_path File.join File.("~#{Etc.getpwuid.name}"), '.eyrc' end |
#preset_app_name? ⇒ Boolean
12 13 14 |
# File 'lib/engineyard-metadata/outsider.rb', line 12 def preset_app_name? @app_name.is_a?(String) or ENV['EY_APP_NAME'] end |
#preset_environment_name? ⇒ Boolean
28 29 30 |
# File 'lib/engineyard-metadata/outsider.rb', line 28 def preset_environment_name? @environment_name.is_a?(String) or ENV['EY_ENVIRONMENT_NAME'] end |