Sha256: 070b76c19a1856b5fadf519905023837a4a7b190ceff5427ce7b5277652c9888

Contents?: true

Size: 1.5 KB

Versions: 21

Compression:

Stored size: 1.5 KB

Contents

Execute.define_task do
  desc "config", "Config", :hide => true
  def config(settings_file=false)
    require 'uri'
    require 'yaml'
    if File.exist?(File.join('settings','settings.yml'))
      settings = YAML.load_file(File.join('settings','settings.yml'))
      rackup_config = "config.ru"
    elsif settings_file
      settings = YAML.load_file(settings_file)
      rackup_config = File.join(File.dirname(__FILE__), '..', 'utilities', 'blank_app.ru')
    elsif File.exist?(File.join(ENV['HOME'], '.rhoconnect.yml'))
      settings = YAML.load_file(File.join(ENV['HOME'], '.rhoconnect.yml'))
      rackup_config = File.join(File.dirname(__FILE__), '..', 'utilities', 'blank_app.ru')
    else
      options = { :syncserver => "http://localhost:#{RHOCONNECT_PORT}",
        :redis => REDIS_SERVER_URL, :push_server => PUSH_SERVER_URL, :api_token => API_TOKEN }
      settings = { :development => options, :test => options, :production => options }
      rackup_config = File.join(File.dirname(__FILE__), '..', 'utilities', 'blank_app.ru')
    end

    environment = (ENV['RHO_ENV'] || ENV['RACK_ENV'] || :development).to_sym # FIXME:
    settings = settings[environment]
    # syncserver settings
    uri = URI.parse(settings[:syncserver])
    port = uri.port unless port
    url = "#{uri.scheme}://#{uri.host}:#{port}"
    settings[:syncserver] = url
    settings[:rackup] = rackup_config
    # redis settings
    redis_conf = settings[:redis]
    settings[:redis] = [redis_conf] if redis_conf.is_a?(String)

    settings
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
rhoconnect-7.6.0 commands/rhoconnect/config.rb
rhoconnect-7.5.1 commands/rhoconnect/config.rb
rhoconnect-7.4.1 commands/rhoconnect/config.rb
rhoconnect-7.1.17 commands/rhoconnect/config.rb
rhoconnect-6.2.0 commands/rhoconnect/config.rb
rhoconnect-6.0.11 commands/rhoconnect/config.rb
rhoconnect-5.5.18 commands/rhoconnect/config.rb
rhoconnect-5.5.17 commands/rhoconnect/config.rb
rhoconnect-5.5.15 commands/rhoconnect/config.rb
rhoconnect-5.5.0.22 commands/rhoconnect/config.rb
rhoconnect-5.5.2 commands/rhoconnect/config.rb
rhoconnect-5.5.0.7 commands/rhoconnect/config.rb
rhoconnect-5.5.0.3 commands/rhoconnect/config.rb
rhoconnect-5.5.0 commands/rhoconnect/config.rb
rhoconnect-5.1.1 commands/rhoconnect/config.rb
rhoconnect-4.0.4 commands/rhoconnect/config.rb
rhoconnect-4.0.3 commands/rhoconnect/config.rb
rhoconnect-4.0.2 commands/rhoconnect/config.rb
rhoconnect-4.0.1 commands/rhoconnect/config.rb
rhoconnect-4.0.0 commands/rhoconnect/config.rb