ext_ooor 2.3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +354 -0
  4. data/Rakefile +5 -0
  5. data/bin/ooor +43 -0
  6. data/lib/ext_ooor.rb +5 -0
  7. data/lib/ext_ooor/version.rb +5 -0
  8. data/lib/generators/ooor/install_generator.rb +18 -0
  9. data/lib/generators/ooor/ooor.yml +49 -0
  10. data/lib/ooor.rb +230 -0
  11. data/lib/ooor/associations.rb +78 -0
  12. data/lib/ooor/autosave_association.rb +197 -0
  13. data/lib/ooor/base.rb +130 -0
  14. data/lib/ooor/base64.rb +20 -0
  15. data/lib/ooor/callbacks.rb +18 -0
  16. data/lib/ooor/errors.rb +120 -0
  17. data/lib/ooor/field_methods.rb +213 -0
  18. data/lib/ooor/helpers/core_helpers.rb +83 -0
  19. data/lib/ooor/locale.rb +11 -0
  20. data/lib/ooor/mini_active_resource.rb +86 -0
  21. data/lib/ooor/model_registry.rb +24 -0
  22. data/lib/ooor/model_schema.rb +25 -0
  23. data/lib/ooor/naming.rb +92 -0
  24. data/lib/ooor/nested_attributes.rb +57 -0
  25. data/lib/ooor/persistence.rb +353 -0
  26. data/lib/ooor/rack.rb +137 -0
  27. data/lib/ooor/railtie.rb +27 -0
  28. data/lib/ooor/reflection.rb +151 -0
  29. data/lib/ooor/reflection_ooor.rb +121 -0
  30. data/lib/ooor/relation.rb +204 -0
  31. data/lib/ooor/relation/finder_methods.rb +153 -0
  32. data/lib/ooor/report.rb +53 -0
  33. data/lib/ooor/serialization.rb +49 -0
  34. data/lib/ooor/services.rb +134 -0
  35. data/lib/ooor/session.rb +250 -0
  36. data/lib/ooor/session_handler.rb +66 -0
  37. data/lib/ooor/transport.rb +34 -0
  38. data/lib/ooor/transport/json_client.rb +65 -0
  39. data/lib/ooor/transport/xml_rpc_client.rb +15 -0
  40. data/lib/ooor/type_casting.rb +223 -0
  41. data/lib/ooor/version.rb +8 -0
  42. data/spec/cli_spec.rb +129 -0
  43. data/spec/helpers/test_helper.rb +11 -0
  44. data/spec/ooor_spec.rb +867 -0
  45. metadata +118 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 12be1d7a5be1167ea243658097a73f70b7aa339ece3545ca1c9cf5a84f860384
4
+ data.tar.gz: 3d0b06fe67c04770f35879348e978a6a20e3f613d91012c3190ffd741fc63692
5
+ SHA512:
6
+ metadata.gz: 89513ad088b46d6765cee1b859cbf8ae5ada7f20561f024a863e2d9b3ed4b863f4ed1a96cbe8b0aca8f8e66ce8bd909219b6b645f8b8a827d325773ae6cf51af
7
+ data.tar.gz: 07ae825d24135ab8d4e6147474bc74821a1c116b96fecad1817f51733edf167f4bb79fa7251021d499c26a4a2958bed2f4cecbca999871929109e63c8e839f2a
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009-2012 Raphaël Valyi - Akretion LTDA
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,354 @@
1
+ [![Build Status](https://secure.travis-ci.org/akretion/ooor.png?branch=master)](http://travis-ci.org/akretion/ooor) [![Code Climate](https://codeclimate.com/github/akretion/ooor.png)](https://codeclimate.com/github/akretion/ooor)
2
+ [![Coverage Status](https://coveralls.io/repos/akretion/ooor/badge.png?branch=master)](https://coveralls.io/r/akretion/ooor?branch=master) [![Gem Version](https://badge.fury.io/rb/ooor.png)](http://badge.fury.io/rb/ooor) [![Dependency Status](https://www.versioneye.com/ruby/ooor/badge.png)](https://www.versioneye.com/ruby/ooor)
3
+
4
+ [![OOOR by Akretion](https://s3.amazonaws.com/akretion/assets/ooor_by_akretion.png)](http://akretion.com)
5
+
6
+
7
+ Why use Ooor?
8
+ -------------
9
+
10
+ * Ooor is an administration **Swiss Army knife** in an interactive Ruby session. You connect remotely to any running Odoo instance without stopping it, without compromising its security. It has tab auto-completion and object introspection features. You can script anything you would do in the web interface or in an Odoo module with the same level of query optimization.
11
+ * Ooor is the basis for unleashed **web development**. It is **Rack** based and inject proxies to Odoo entities in your Rack env just like you use them in your env registry in Odoo modules. You use it in popular Ruby web frameworks such as **Sinatra** or **Rails**.
12
+
13
+ Odoo is all the rage for efficiently building an ERP back-office, but sometimes you want **freedom and scalablity** for your web front ends. Ooor enables you to model your web app using standard web frameworks like Rails while using Odoo as the persistence layer - **without data duplication or synchronization/mapping logic** - and reusing the Odoo business logic.
14
+ Ooor even has an optionnal Rack filter that enables you to proxy some Odoo applications of your choice (say the shopping cart for instance) and share the HTTP session with it.
15
+
16
+ Because Ooor is ActiveModel based and emulates the ActiveRecord API well enough, it just works with popular Ruby gems such as Devise for authentication, will_paginate for pagination, SimpleForm, Cocoon for nested forms...
17
+
18
+ Ooor is also a lot more advanced than its Python clones: it is very carefuly designed to save Odoo requests. It can avoid the N+1 queries and also works smartly with the Rails cache so that the meta-data used to define the Odoo proxies can be cached shared between concurrent Rails workers without the need to hit Odoo again with requests such as fields_get.
19
+
20
+ Related projects - a full web stack!
21
+ ------------------------------------
22
+
23
+ * [Ooorest](http://github.com/akretion/ooorest), Ooor is the **Model** layer of **MVC**. Ooorest is the **Controller** layer, enforcing a clean Railish **REST API** and offering handy **helper** to use Odoo in your Rails application.
24
+ * [Aktooor](http://github.com/akretion/aktooor), Aktooor is the missing **View** layer of **MVC**. It's based on [SimpleForm](https://github.com/plataformatec/simple_form), that is a clean minimalist framework that extend Rails form framework over [Twitter Bootstrap](http://getbootstrap.com)
25
+ * [Erpify](http://github.com/akretion/erpify), Erpify is Odoo inside the Liquid non evaling language, that is the templating language of Shopify or LocomotiveCMS for instance.
26
+ * [Locomotive-erpify](http://github.com/akretion/locomtive-erpify), Erpify for LocomotiveCMS, both the engine and the Wagon local editor
27
+ * [Solarize](http://github.com/akretion/solarize), pulling data from Odoo relational database may not scale to your need. No problem with Solarize: you can index your OpenERP data with the [Solerp](http://github.com/akretion/solerp) OpenERP module, then search it using SolR API and even load it from SolR without even hitting OpenERP!
28
+ * [TerminatOOOR](http://github.com/rvalyi/terminatooor), a Pentaho ETL Kettle plugin allowing to push/pull data into/from Odoo with an incomparable flexibility and yet benefit all standard ETL features, including the AgileBI OLAP business intelligence plugin.
29
+
30
+
31
+ How?
32
+ ------------
33
+
34
+ Odoo is a Python based open source ERP. But every Odoo business method is actually exposed as a JSON-RPC webservice (SOA orientation, close to being RESTful).
35
+ Ooor doesn't connect to the Odoo database directly, Instead it uses the Odoo JSON-RPC API so it fully enforces Odoo security model and business logic.
36
+
37
+ Ooor is around 2000 lines of code and has a test coverage over 93%. The API it exposes is not invented but it is the one of Rails: it is modeled after Rails [ActiveModel](http://api.rubyonrails.org/classes/ActiveModel/Model.html), [ActiveResource](https://github.com/rails/activeresource) and [ActiveRecord](http://api.rubyonrails.org/classes/ActiveRecord/Base.html) layers.
38
+
39
+ More specifically, an Odoo Ooor proxy implements the ActiveModel API. Instead of depending on ActiveResource which is actually a bit different (not multi-tenant, little access right management), we copied a tiny subset of it in the `mini_active_resource.rb` file and Odoo proxies include this module. Finally Ooor emulates the ActiveRecord API wherever possible delegating its requests to Odoo using Odoo domain [S expressions](http://en.wikipedia.org/wiki/S-expression) instead of SQL. The ActiveRecord API emulation is actually pretty good: think **Ooor looks more like ActiveRecord than Mongoid**; it has associations, surface ARel API, Reflection API, can be paginated via Kaminary, can be integrated with SimpleForm or Cocoon seamlessly...
40
+
41
+ Ooor features **several session modes**: in the default IRB console usage it uses a global login scheme and generate constants for your OpenERP proxies, such as ProductProduct for the product.product OpenERP object much like Rails ActiveRecord. In web mode instead, you can have several sessions and do session['product.product'] to get a proxy to the Product object matching your current session credentials, chosen database and OpenERP url (yes Ooor is not only multi-database like OpenEP, it's in fact **multi-OpenERP**!)
42
+
43
+
44
+ Installation
45
+ ------------
46
+
47
+ $ gem install ooor
48
+
49
+ **Warning Ooor has been ureleased for several months, don't hesitate to run the git version instead**
50
+
51
+ Trying it simply
52
+ ------------
53
+
54
+ Once you installed the OOOR gem, you get a new OOOR command line. Basic usage is:
55
+
56
+ $ ooor username:password@host:port/database
57
+
58
+
59
+ This will bring you in a standard IRB interpreter with an ooor client already connected to your Odoo server so you can start playing with it.
60
+
61
+
62
+ ### Standalone (J)Ruby application:
63
+
64
+ Let's test ooor in an irb console (irb command):
65
+
66
+ ```ruby
67
+ require 'rubygems'
68
+ require 'ooor'
69
+ Ooor.new(:url => 'http://localhost:8069/xmlrpc', :database => 'mybase', :username => 'admin', :password => 'admin')
70
+ ```
71
+
72
+ This should load all your Odoo models into Ruby proxy Activeresource objects. Of course there are option to load only some models.
73
+ Let's try to retrieve the user with id 1:
74
+
75
+ ```ruby
76
+ ResUsers.find(1)
77
+ ```
78
+
79
+ (in case you have an error like "no such file to load -- net/https", then on Debian/Ubuntu, you might need to do before: apt-get install libopenssl-ruby)
80
+
81
+
82
+ ### (J)Ruby on Rails application:
83
+
84
+ Please read details [https://github.com/rvalyi/ooor/wiki/(J)Ruby-on-Rails-application](here)
85
+
86
+
87
+ API usage
88
+ ------------
89
+
90
+ Note: Ruby proxy objects are named after Odoo models in but removing the '.' and using CamelCase.
91
+ (we remind you that Odoo tables are also named after Odoo models but replacing the '.' by '_'.)
92
+
93
+ Basic finders:
94
+
95
+ ```ruby
96
+ ProductProduct.find(1)
97
+ ProductProduct.find([1,2])
98
+ ProductProduct.find([1])
99
+ ProductProduct.find(:all)
100
+ ProductProduct.find(:last)
101
+ ```
102
+
103
+ Odoo domain support (same as Odoo):
104
+
105
+ ```ruby
106
+ ResPartner.find(:all, :domain=>[['supplier', '=', 1],['active','=',1]])
107
+ #More subtle now, remember Odoo use a kind of inverse polish notation for complex domains,
108
+ #here we look for a product in category 1 AND which name is either 'PC1' OR 'PC2':
109
+ ProductProduct.find(:all, :domain=>[['categ_id','=',1],'|',['name', '=', 'PC1'],['name','=','PC2']])
110
+ ```
111
+
112
+
113
+ Odoo context support (same as Odoo):
114
+
115
+ ```ruby
116
+ ProductProduct.find(1, :context => {:my_key => 'value'})
117
+ ```
118
+
119
+ Request params or ActiveResource equivalence of Odoo domain (but degraded as only the = operator is supported, else use domain):
120
+
121
+ ```ruby
122
+ ResPartner.find(:all, :params => {:supplier => true})
123
+ ```
124
+
125
+ Odoo search method:
126
+
127
+ ```ruby
128
+ ResPartner.search([['name', 'ilike', 'a']], 0, 2)
129
+ ```
130
+
131
+ Arguments are: domain, offset=0, limit=false, order=false, context={}, count=false
132
+
133
+
134
+ Relations (many2one, one2many, many2many) support:
135
+
136
+ ```ruby
137
+ SaleOrder.find(1).order_line #one2many relation
138
+ p = ProductProduct.find(1)
139
+ p.product_tmpl_id #many2one relation
140
+ p.taxes_id #automagically reads man2many relation inherited via the product_tmpl_id inheritance relation
141
+ p.taxes_id = [1,2] #save a many2many relation, notice how we bypass the awkward Odoo syntax for many2many (would require [6,0, [1,2]]) ,
142
+ p.save #assigns taxes with id 1 and 2 as sale taxes,
143
+ see [the official Odoo documentation](http://doc.openerp.com/developer/5_18_upgrading_server/19_1_upgrading_server.html?highlight=many2many)```
144
+
145
+
146
+ Inherited relations support:
147
+
148
+ ```ruby
149
+ ProductProduct.find(1).categ_id #where categ_id is inherited from the ProductTemplate
150
+ ```
151
+
152
+ Please notice that loaded relations are cached (to avoid hitting Odoo over and over)
153
+ until the root object is reloaded (after save/update for instance).
154
+
155
+
156
+ Load only specific fields support (faster than loading all fields):
157
+
158
+ ```ruby
159
+ ProductProduct.find(1, :fields=>["state", "id"])
160
+ ProductProduct.find(:all, :fields=>["state", "id"])
161
+ ProductProduct.find([1,2], :fields=>["state", "id"])
162
+ ProductProduct.find(:all, :fields=>["state", "id"])
163
+ ```
164
+
165
+ even in relations:
166
+
167
+ ```ruby
168
+ SaleOrder.find(1).order_line(:fields => ["state"])
169
+ ```
170
+
171
+ Create:
172
+
173
+ ```ruby
174
+ pc = ProductCategory.new(:name => 'Categ From Rails!')
175
+ # <ProductCategory:0xb702c42c @prefix_options={}, @attributes={"name"=>"Categ From Rails!"}>
176
+ pc.create
177
+ pc.id
178
+ # $ => 14
179
+ ```
180
+
181
+
182
+ Update:
183
+
184
+ ```ruby
185
+ pc.name = "A new name"
186
+ pc.save
187
+ ```
188
+
189
+ Copy:
190
+
191
+ ```ruby
192
+ copied_object = pc.copy({:categ_id => 2}) #first optionnal arg is new default values, second is context
193
+ ```
194
+
195
+ Delete:
196
+
197
+ ```ruby
198
+ pc.destroy
199
+ ```
200
+
201
+ Call workflow:
202
+
203
+ ```ruby
204
+ s = SaleOrder.find(2)
205
+ s.wkf_action('cancel')
206
+ s.state
207
+ # => 'cancel'
208
+ ```
209
+
210
+ On Change methods:
211
+
212
+ Note: currently OOOR doesn't deal with the View layer, or has a very limited support for forms for the wizards.
213
+ So, it's not possible so far for OOOR to know an on_change signature. Because of this, the on_change syntax is bit awkward
214
+ as you will see (fortunately OpenERP SA announced they will fix that on_change API in subsequent v6 OpenERP releases):
215
+ you need to explicitely tell the on_change name, the parameter name that changed, the new value and finally
216
+ enforce the on_change syntax (looking at the OpenERP model code or view or XML/RPC logs will help you to find out). But
217
+ ultimately it works:
218
+
219
+ ```ruby
220
+ l = SaleOrderLine.new
221
+ l.on_change('product_id_change', :product_id, 20, 1, 20, 1, false, 1, false, false, 7, 'en_US', true, false, false, false)
222
+ # => #<SaleOrderLine:0x7f76118b4348 @prefix_options={}, @relations={"product_uos"=>false, "product_id"=>20, "product_uom"=>1, "tax_id"=>[]}, @loaded_relations={}, @attributes={"name"=>"[TOW1] ATX Mid-size Tower", "product_uos_qty"=>1, "delay"=>1.0, "price_unit"=>37.5, "type"=>"make_to_stock", "th_weight"=>0}>
223
+ ```
224
+ Notice that it reloads the Objects attrs and print warning message accordingly
225
+
226
+
227
+ On the fly one2many object graph update/creation:
228
+
229
+ Just like the OpenERP GTK client (and unlike the web client), in OOOR you can pass create/update
230
+ one2many relation in place directly. For instance:
231
+
232
+ ```ruby
233
+ so = SaleOrder.new
234
+ so.on_change('onchange_partner_id', :partner_id, 1, 1, false) #auto-complete the address and other data based on the partner
235
+ so.order_line = [SaleOrderLine.new(:name => 'sl1', :product_id => 1, :price_unit => 42, :product_uom => 1)] #create one order line
236
+ so.save
237
+ so.amount_total
238
+ # => 42.0
239
+ ```
240
+
241
+
242
+ Call aribtrary method:
243
+
244
+ $ use static ObjectClass.rpc_execute_with_all method
245
+ $ or object.call(method_name, args*) #were args is an aribtrary list of arguments
246
+
247
+ Class methods from are osv.py/orm.py proxied to OpenERP directly (as the web client does):
248
+
249
+ ```ruby
250
+ ResPartner.name_search('ax', [], 'ilike', {})
251
+ ProductProduct.fields_view_get(132, 'tree', {})
252
+ ```
253
+
254
+
255
+ Call old style wizards (OpenERP v5):
256
+
257
+ ```ruby
258
+ inv = AccountInvoice.find(4)
259
+ # in case the inv.state is 'draft', do inv.wkf_action('invoice_open')
260
+ wizard = inv.old_wizard_step('account.invoice.pay') #tip: you can inspect the wizard fields, arch and datas
261
+ wizard.reconcile({:journal_id => 6, :name =>"from_rails"}) #if you want to pay all; will give you a reloaded invoice
262
+ inv.state
263
+ # => "paid"
264
+ # or if you want a payment with a write off:
265
+ wizard.writeoff_check({"amount" => 12, "journal_id" => 6, "name" =>'from_rails'}) #use the button name as the wizard method
266
+ wizard.reconcile({required missing write off fields...}) #will give you a reloaded invoice because state is 'end'
267
+ # TODO test and document new osv_memory wizards API
268
+ ```
269
+
270
+
271
+ Absolute OpenERP ids aka ir_model_data:
272
+
273
+ just like Rails fixtures, OpenERP supports absolute ids for its records, especially those imported from XML or CSV.
274
+ We are here speaking about the string id of the XML or CSV records, eventually prefixed by the module name.
275
+ Using those ids rather than the SQL ids is a good idea to avoid relying on a particular installation.
276
+ In OOOR, you can both retrieve one or several records using those ids, like for instance:
277
+
278
+ ```ruby
279
+ ProductCategory.find('product.product_category_3')
280
+ ```
281
+
282
+ Notice that the 'product.' module prefix is optional here but important if you have similar ids in different module scopes.
283
+ You can also create a resource and it's ir_model_data record alltogether using the ir_mode_data_id param:
284
+
285
+ ```ruby
286
+ ProductCategory.create(:name => 'rails_categ', :ir_model_data_id =>['product', 'categ_x']) #1st tab element is the module, 2nd the id in the module
287
+ ```
288
+
289
+ Obtain report binary data:
290
+
291
+ To obtain the binary data of an object report simply use the function get_report_data(report_name). This function returns a list that contains the binary data encoded in base64 and a string with the file format.
292
+ Example:
293
+
294
+ ```ruby
295
+ inv = AccountInvoice.find(3)
296
+ report = inv.get_report_data('account.invoice') #account.invoice is the service name defined in Invoices report
297
+ # Save the report to a file
298
+ # report[1] contains the file extension and report[0] contains the binary data of the report encoded in base64
299
+ File.open("invoice_report.#{report[1]}", "w") {|f| f.write(Base64.decode64(report[0]))}
300
+ ```
301
+
302
+ Change logged user:
303
+
304
+ An Ooor client can have a global user logged in, to change it:
305
+
306
+ ```ruby
307
+ Ooor.global_login('demo', 'demo')
308
+ s = SaleOrder.find(2)
309
+ # => 'Access denied error'
310
+ ```
311
+
312
+ Instead, every Ooor business objects can also belong to some specific user. To achieve that, generate your object passing
313
+ proper :user_id and :password parameters inside the context of the method creating the object (typically a find).
314
+ Notice that methods invoked on an objet use the same credentials as the business objects.
315
+ Objects generated by this object (by a call to an association for instance) will also have the same credentials.
316
+
317
+ ```ruby
318
+ p = ProductProduct.find(1, :context => {:user_id=>3, :password=>'test'})
319
+ ```
320
+
321
+ This is tipycally the system you will use in a Ruby (Rails or not) web application.
322
+
323
+ Change log level:
324
+
325
+ By default the log level is very verbose (debug level) to help newcomers to jumpstart.
326
+ However you might want to change that. 2 solutions:
327
+
328
+ ```ruby
329
+ Ooor.logger.level = 1 #available levels are those of the standard Ruby Logger class: 0 debug, 1 info, 2 error
330
+ ```
331
+ In the config yaml file or hash, set the :log_level parameter
332
+
333
+
334
+ [Drawing OpenERP UML diagrams with OOOR](http://wiki.github.com/rvalyi/ooor/drawing-openerp-uml-diagrams-with-ooor)
335
+
336
+ [Finger in the nose multi-OpenERP instances migration/management with OOOR](http://wiki.github.com/rvalyi/ooor/howto-connect-ooor-to-multiple-openerp-instance-easy-data-migration)
337
+
338
+
339
+ Detailed API in the automated test suite
340
+ ------------
341
+
342
+ OOOR ships with an [RSpec](http://rspec.info/) automated unit test suite to avoid regressions. This is also the place
343
+ where you can easily read the exact API detail to master every OOOR features.
344
+ You can read the test suite here: [http://github.com/rvalyi/ooor/blob/master/spec/ooor_spec.rb](http://github.com/rvalyi/ooor/blob/master/spec/ooor_spec.rb)
345
+ Of course this also shows you can use RSpec to specify and test your OpenERP modules.
346
+ OOOR is actually used to test OpenERP complex features in a specification language business experts can read and even write!
347
+ In this case [CampToCamp](http://www.camptocamp.com/) used the famous [Cucumber functionnal test suite](http://cukes.info/) in the [OERPScenario project](https://launchpad.net/oerpscenario).
348
+
349
+
350
+
351
+ FAQ
352
+ ------------
353
+
354
+ Please read the [FAQ here](https://github.com/rvalyi/ooor/wiki/FAQ)
@@ -0,0 +1,5 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec)
4
+
5
+ task :default => :spec
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/ruby
2
+
3
+ puts "*** OOOR - OpenObject on Ruby! Published under the MIT license by Akretion.com ***"
4
+
5
+ require 'irb'
6
+ require 'rubygems'
7
+ require 'logger'
8
+ require 'ooor'
9
+ require 'irb/completion'
10
+
11
+
12
+ if ARGV.empty? || ARGV[0].sub('--', '') == 'help'
13
+ puts "USAGE: ooor admin.database@host\nor ooor admin.database@host:port\nor ooor admin.database for localhost\nyou can specify the password with ooor admin.database@host password\nyou can use the -s option for secure HTTPS mode"
14
+ exit 0
15
+ end
16
+
17
+ cs = ARGV.join
18
+ ARGV[0] = "--readline"
19
+ ARGV[1] = "--prompt"
20
+ ARGV[2] = "inf-ruby"
21
+
22
+ Ooor.new(cs)
23
+
24
+ unless Ooor.default_config[:password]
25
+ puts "password?"
26
+ system "stty -echo"
27
+ password = $stdin.gets.chomp!
28
+ system "stty echo"
29
+ password = 'admin' if password.blank?
30
+ Ooor.default_config[:password] = password
31
+ end
32
+
33
+ unless Ooor.default_config[:database]
34
+ puts "database?"
35
+ system "stty -echo"
36
+ password = $stdin.gets.chomp!
37
+ system "stty echo"
38
+ database = 'db' if database.blank?
39
+ Ooor.default_config[:database] = database
40
+ end
41
+
42
+ @ooor = Ooor.new(Ooor.default_config)
43
+ IRB.start(__FILE__)
@@ -0,0 +1,5 @@
1
+ require 'ooor'
2
+
3
+ module ExtOoor
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,5 @@
1
+ require 'ooor/version'
2
+
3
+ module ExtOoor
4
+ VERSION = "#{Ooor::VERSION}.1"
5
+ end
@@ -0,0 +1,18 @@
1
+ require 'rails/generators/base'
2
+
3
+ module Ooor
4
+ module Generators
5
+ MissingORMError = Class.new(Thor::Error)
6
+
7
+ class InstallGenerator < Rails::Generators::Base
8
+ source_root File.expand_path("..", __FILE__)
9
+
10
+ desc "Creates an Ooor configuration in your application."
11
+
12
+ def copy_configuration
13
+ template "ooor.yml", "config/ooor.yml"
14
+ end
15
+
16
+ end
17
+ end
18
+ end