Class: PlatformSH
- Inherits:
-
Object
- Object
- PlatformSH
- Defined in:
- lib/platform_sh.rb,
lib/platform_sh/version.rb
Constant Summary collapse
- VERSION =
"0.2.11"
Class Method Summary collapse
-
.config ⇒ Object
Reads Platform.sh configuration from environment and returns a single object.
- .is_build_environment? ⇒ Boolean
- .on_platform? ⇒ Boolean
- .relationship(rel_name, attr) ⇒ Object
Class Method Details
.config ⇒ Object
Reads Platform.sh configuration from environment and returns a single object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/platform_sh.rb', line 15 def self.config if !on_platform? $logger.info "This is not running on platform.sh" return nil end conf = {} conf["application"] = read_base64_json('PLATFORM_APPLICATION') conf["routes"] = read_base64_json('PLATFORM_ROUTES') conf["application_name"] =ENV["PLATFORM_APPLICATION_NAME"] || nil conf["app_dir"] =ENV["PLATFORM_APP_DIR"] || nil conf["project"] =ENV["PLATFORM_PROJECT"] || nil conf["document_root"] =ENV["PLATFORM_DOCUMENT_ROOT"] || nil if !is_build_environment? conf["environment"] =ENV["PLATFORM_ENVIRONMENT"] || nil conf["project_entropy"] =ENV["PLATFORM_PROJECT_ENTROPY"] || nil conf["port"] =ENV["PORT"] || nil conf["socket"] =ENV["SOCKET"] || nil conf["relationships"] = read_base64_json('PLATFORM_RELATIONSHIPS') conf["variables"] = read_base64_json('PLATFORM_VARIABLES') end conf end |
.is_build_environment? ⇒ Boolean
42 43 44 |
# File 'lib/platform_sh.rb', line 42 def self.is_build_environment? (!ENV.has_key?('PLATFORM_ENVIRONMENT') && ENV.has_key?('PLATFORM_PROJECT')) end |
.on_platform? ⇒ Boolean
38 39 40 |
# File 'lib/platform_sh.rb', line 38 def self.on_platform? ENV.has_key? 'PLATFORM_PROJECT' end |
.relationship(rel_name, attr) ⇒ Object
46 47 48 |
# File 'lib/platform_sh.rb', line 46 def self.relationship rel_name, attr on_platform? ? config["relationships"][rel_name].first[attr] : nil end |