Sha256: b6c7e45fe7436ef252e4567f19afce7e51649feb112624fc04e85ce7147b0015

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

class Fanforce::App::Sinatra

  get '/internals/config.json' do
    file = File.open("#{Fanforce::App.base_dir}/config.json")
    config = MultiJson.load(file.read, symbolize_keys: true)
    config[:iron_workers] ||= []

    if params[:include_iron_credentials].to_i > 0
      config[:iron_workers].each do |iron_worker|
        iron_worker[:project_id] = ENV['IRON_PROJECT_ID']
        iron_worker[:token] = ENV['IRON_TOKEN']
      end
    end

    config.to_json
  end

  post '/internals/config.json' do
    filename = "#{Fanforce::App.base_dir}/config.json"
    file = File.open(filename)
    old_config = MultiJson.load(file.read, symbolize_keys: true)
    new_config = MultiJson.load(params[:config], symbolize_keys: true)
    raise 'IUIDs do not match' if old_config[:_iuid] and old_config[:_iuid] != new_config[:_iuid]

    File.open(filename, 'w') {|f| f.write(JSON.pretty_generate(Hash[new_config.sort])) }
    json status: 'finished'
  end

  get '/app_factory/directives/:filename' do
    factory_directive(params[:filename])
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fanforce-app-factory-2.0.0.rc31 lib/fanforce/app_factory/Routes.rb