module Peas

Constants

SWITCHBOARD_PORT

The port for Peas’ Switchboard socket server

VERSION

Public Class Methods

api_domain() click to toggle source

Hierarchy of sources for the Peas API domain

# File lib/peas/config.rb, line 24
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:4443'
  end
  unless domain[/\Ahttp:\/\//] || domain[/\Ahttps:\/\//]
    "https://#{domain}"
  else
    domain
  end
end
config() click to toggle source

Read JSON config from file

# 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() click to toggle source
# File lib/peas/config.rb, line 5
def self.config_file
  "#{ENV['HOME']}/.peas"
end
error_message(string) click to toggle source
# File lib/peas/config.rb, line 47
def self.error_message(string)
  puts string.color(:red)
end
host() click to toggle source
# File lib/peas/config.rb, line 43
def self.host
  URI.parse(Peas.api_domain).host
end
update_config(hash) click to toggle source

Merge new key/values into the config file

# File lib/peas/config.rb, line 18
def self.update_config(hash)
  content = Peas.config.merge(hash).to_json
  File.open(Peas.config_file, 'w+') { |f| f.write(content) }
end
warning_message(string) click to toggle source
# File lib/peas/config.rb, line 51
def self.warning_message(string)
  puts string.color(:magenta)
end