Module: Peas
- Defined in:
- lib/peas/config.rb,
lib/peas/version.rb
Constant Summary collapse
- SWITCHBOARD_PORT =
The port for Peas’ Switchboard socket server
ENV['SWITCHBOARD_PORT'] || 9345
- VERSION =
File.read File.("../../../VERSION", __FILE__)
Class Method Summary collapse
-
.api_domain ⇒ Object
Hierarchy of sources for the Peas API domain.
-
.config ⇒ Object
Read JSON config from file.
- .config_file ⇒ Object
- .error_message(string) ⇒ Object
- .host ⇒ Object
- .warning_message(string) ⇒ Object
Class Method Details
.api_domain ⇒ Object
Hierarchy of sources for the Peas API domain
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/peas/config.rb', line 18 def self.api_domain git_domain = Git.sh 'git config peas.domain' domain = if ENV['PEAS_API_ENDPOINT'] ENV['PEAS_API_ENDPOINT'] elsif !git_domain.nil? && git_domain != '' git_domain elsif Peas.config['domain'] Peas.config['domain'] else 'vcap.me:4000' end unless domain[/\Ahttp:\/\//] || domain[/\Ahttps:\/\//] "http://#{domain}" else domain end end |
.config ⇒ Object
Read JSON config from file
10 11 12 13 14 15 |
# File 'lib/peas/config.rb', line 10 def self.config file = File.open config_file, "a+" contents = file.read contents = '{}' if contents == '' JSON.parse contents end |
.config_file ⇒ Object
5 6 7 |
# File 'lib/peas/config.rb', line 5 def self.config_file "#{ENV['HOME']}/.peas" end |
.error_message(string) ⇒ Object
41 42 43 |
# File 'lib/peas/config.rb', line 41 def self.(string) puts string.color(:red) end |
.host ⇒ Object
37 38 39 |
# File 'lib/peas/config.rb', line 37 def self.host URI.parse(Peas.api_domain).host end |
.warning_message(string) ⇒ Object
45 46 47 |
# File 'lib/peas/config.rb', line 45 def self.(string) puts string.color(:magenta) end |