ooor 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/ooor +9 -5
- data/lib/ooor/base.rb +5 -1
- data/lib/ooor/errors.rb +1 -1
- data/lib/ooor/field_methods.rb +0 -1
- data/lib/ooor/transport/json_client.rb +8 -6
- data/lib/ooor/version.rb +1 -1
- metadata +2 -1
data/bin/ooor
CHANGED
@@ -25,7 +25,15 @@ unless ARGV.empty?
|
|
25
25
|
else
|
26
26
|
port = "8069"
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
|
+
if ARGV[1] == "-s" || ARGV[2] == "-s" #secure mode
|
30
|
+
port = 443 unless port_given
|
31
|
+
protocol = "https"
|
32
|
+
else
|
33
|
+
protocol = "http"
|
34
|
+
end
|
35
|
+
|
36
|
+
url = "#{protocol}://#{base_url}:#{port}/xmlrpc"
|
29
37
|
if ARGV[1] && ARGV[1] != "-s"
|
30
38
|
password = ARGV[1]
|
31
39
|
else
|
@@ -35,10 +43,6 @@ unless ARGV.empty?
|
|
35
43
|
system "stty echo"
|
36
44
|
end
|
37
45
|
|
38
|
-
if ARGV[1] == "-s" || ARGV[2] == "-s" #secure mode
|
39
|
-
url.gsub!("http", "https")
|
40
|
-
url.gsub!("8069", "8071") unless port_given
|
41
|
-
end
|
42
46
|
else
|
43
47
|
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"
|
44
48
|
exit 0
|
data/lib/ooor/base.rb
CHANGED
@@ -97,7 +97,11 @@ module Ooor
|
|
97
97
|
attributes.each do |key, value|
|
98
98
|
skey = key.to_s
|
99
99
|
if self.class.associations_keys.index(skey) || value.is_a?(Array) #FIXME may miss m2o with inherits!
|
100
|
-
|
100
|
+
if value.is_a?(Ooor::Base) || value.is_a?(Array) && value.all? {|i| i.is_a?(Ooor::Base)}
|
101
|
+
@loaded_associations[skey] = value #we want the method to load the association through method missing
|
102
|
+
else
|
103
|
+
@associations[skey] = value
|
104
|
+
end
|
101
105
|
else
|
102
106
|
@attributes[skey] = value || nil #don't bloat with false values
|
103
107
|
end
|
data/lib/ooor/errors.rb
CHANGED
@@ -17,7 +17,7 @@ module Ooor
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.build(faultCode, faultString, method, *args)
|
20
|
-
if faultCode =~ /AttributeError: /
|
20
|
+
if faultCode =~ /AttributeError: / || faultCode =~ /object has no attribute/
|
21
21
|
return UnknownAttributeOrAssociationError.new("method: #{method} - args: #{args.inspect}", faultCode, faultString)
|
22
22
|
elsif faultCode =~ /TypeError: /
|
23
23
|
return TypeError.new(method, faultCode, faultString, *args)
|
data/lib/ooor/field_methods.rb
CHANGED
@@ -37,7 +37,6 @@ module Ooor
|
|
37
37
|
|
38
38
|
# this is used by fields_for in ActionView FormHelper
|
39
39
|
def define_nested_attributes_method(meth)
|
40
|
-
p "define_nested_attributes_method", meth
|
41
40
|
unless self.respond_to?(meth)
|
42
41
|
self.instance_eval do
|
43
42
|
define_method "#{meth}_attributes=" do |*args|
|
@@ -25,6 +25,11 @@ module Ooor
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def oe_request(session_info, url, params, method, *args)
|
28
|
+
if session_info[:req_id]
|
29
|
+
session_info[:req_id] += 1
|
30
|
+
else
|
31
|
+
session_info[:req_id] = 1
|
32
|
+
end
|
28
33
|
if session_info[:sid] # required on v7 but forbidden in v8
|
29
34
|
params.merge!({"session_id" => session_info[:session_id]})
|
30
35
|
end
|
@@ -32,7 +37,7 @@ module Ooor
|
|
32
37
|
req.headers['Cookie'] = session_info[:cookie]
|
33
38
|
req.url url
|
34
39
|
req.headers['Content-Type'] = 'application/json'
|
35
|
-
req.body = {"jsonrpc"=>"2.0","method"=>"call", "params" => params, "id"=>
|
40
|
+
req.body = {"jsonrpc"=>"2.0","method"=>"call", "params" => params, "id"=>session_info[:req_id]}.to_json
|
36
41
|
end.body)
|
37
42
|
if response["error"]
|
38
43
|
faultCode = response["error"]['data']['fault_code'] || response["error"]['data']['debug']
|
@@ -45,11 +50,8 @@ module Ooor
|
|
45
50
|
|
46
51
|
Faraday::Connection.send :include, OeAdapter
|
47
52
|
|
48
|
-
def self.new(url = nil, options =
|
49
|
-
|
50
|
-
options ||= {}
|
51
|
-
options[:ssl] = {:verify => false}
|
52
|
-
end
|
53
|
+
def self.new(url = nil, options = {})
|
54
|
+
options[:ssl] = {:verify => false}
|
53
55
|
Faraday.new(url, options) # TODO use middlewares
|
54
56
|
end
|
55
57
|
end
|
data/lib/ooor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ooor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -117,3 +117,4 @@ test_files:
|
|
117
117
|
- spec/helpers/test_helper.rb
|
118
118
|
- spec/install_nightly.sh
|
119
119
|
- spec/ooor_spec.rb
|
120
|
+
has_rdoc:
|