Class: OoorProxy

Inherits:
BasicObject
Defined in:
lib/cucumber/lib/utils/ooor_utils.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(log) ⇒ OoorProxy

Returns a new instance of OoorProxy.



67
68
69
# File 'lib/cucumber/lib/utils/ooor_utils.rb', line 67

def initialize(log)
  @log = log
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (protected)



119
120
121
# File 'lib/cucumber/lib/utils/ooor_utils.rb', line 119

def method_missing(name, *args, &block)
  @ooor.send(name, *args, &block)
end

Instance Attribute Details

#logObject (readonly)

Delegate to OOOR except the OERPScenario methods to manage the connections



65
66
67
# File 'lib/cucumber/lib/utils/ooor_utils.rb', line 65

def log
  @log
end

Instance Method Details

#create_database(params) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/cucumber/lib/utils/ooor_utils.rb', line 106

def create_database(params)
  log.info("Creating a new database")
  begin
    @ooor = Ooor.new(:url => xmlrpc_url(params))
    @ooor.create(ooor_config[:pwd], params[:dbname], false, 'en_US', params[:pwd])
    @ooor.load_models(false)
  rescue RuntimeError
    log.fatal("ERROR : Cannot create database")
    raise 'Cannot create database'
  end
  self
end

#login(params) ⇒ Object



76
77
78
# File 'lib/cucumber/lib/utils/ooor_utils.rb', line 76

def (params)
  @ooor.(params[:user], params[:pwd])
end

#open_connection(params) ⇒ Object

read the base.conf file to set all the parameter to begin an xml rpc session with openerp you can override any of the parameters



91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/cucumber/lib/utils/ooor_utils.rb', line 91

def open_connection(params)
  if @ooor
    (params)
  else
    begin
      @ooor = init_ooor_connection(params)
    rescue RuntimeError #We catch RuntimeError because ooor doesn't give the error name.
                        #we deduce in that case that the database doesn't exist and we have to create it.
      log.warn("No database, try to create it")
      create_database_with_ooor(params)
    end
  end
  self
end