Module: CPEE::Instantiation

Defined in:
lib/cpee-instantiation/instantiation.rb

Defined Under Namespace

Modules: Helpers Classes: ContinueTask, HandleInstance, InstantiateGit, InstantiateUrl, InstantiateXML

Constant Summary collapse

SERVER =
File.expand_path(File.join(__dir__,'instantiation.xml'))

Class Method Summary collapse

Class Method Details

.implementation(opts) ⇒ Object

}}}



410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/cpee-instantiation/instantiation.rb', line 410

def self::implementation(opts)
  opts[:cpee]       ||= 'http://localhost:9298/'
  opts[:redis_path] ||= '/tmp/redis.sock'
  opts[:redis_db]   ||= 14
  opts[:self]       ||= "http#{opts[:secure] ? 's' : ''}://#{opts[:host]}:#{opts[:port]}/"
  opts[:cblist]       = Redis.new(path: opts[:redis_path], db: opts[:redis_db])
  Proc.new do
    on resource do
      run InstantiateXML, opts[:cpee], true if post 'xmlsimple'
      on resource 'xml' do
        run InstantiateXML, opts[:cpee], false if post 'xml'
      end
      on resource 'url' do
        run InstantiateUrl, opts[:cpee], opts[:self], opts[:cblist], false if post 'url'
        run InstantiateUrl, opts[:cpee], opts[:self], opts[:cblist], true  if post 'url_info'
      end
      on resource 'git' do
        run InstantiateGit, opts[:cpee], opts[:self], opts[:cblist] if post 'git'
      end
      on resource 'instance' do
        run HandleInstance, opts[:cpee], opts[:self], opts[:cblist] if post 'instance'
      end
      on resource 'callback' do
        on resource do
          run ContinueTask, opts[:cpee], opts[:cblist] if post
        end
      end
    end
  end
end