LVS-JSONService 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/.specification +1 -1
- data/LVS-JSONService.gemspec +1 -1
- data/VERSION +1 -1
- data/lib/lvs/json_service/base.rb +3 -4
- data/lib/lvs/json_service/request.rb +5 -1
- data/spec/lvs/json_service/json_methods_spec.rb +1 -1
- data/spec/lvs/json_service/request_spec.rb +2 -0
- metadata +1 -1
data/.gitignore
CHANGED
data/.specification
CHANGED
data/LVS-JSONService.gemspec
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.5
|
@@ -158,14 +158,15 @@ module LVS
|
|
158
158
|
def respond_to?(name)
|
159
159
|
name = name.to_s
|
160
160
|
key = name_to_key(name)
|
161
|
-
value =
|
161
|
+
value = value_for_key(key)
|
162
162
|
!value.nil?
|
163
163
|
end
|
164
164
|
|
165
165
|
def value_for_key(key)
|
166
166
|
value = @data[key]
|
167
167
|
if value.blank?
|
168
|
-
|
168
|
+
key[0..0] = key[0..0].upcase # TODO: This feels like an awful hack, but having a day when nothing's working
|
169
|
+
value = @data[key]
|
169
170
|
end
|
170
171
|
value
|
171
172
|
end
|
@@ -176,8 +177,6 @@ module LVS
|
|
176
177
|
return respond_to?(args[0])
|
177
178
|
end
|
178
179
|
key = name_to_key(name)
|
179
|
-
puts "Name #{name} is key #{key}"
|
180
|
-
value = @data[key]
|
181
180
|
value = value_for_key(key)
|
182
181
|
if name =~ /=$/
|
183
182
|
@data[key] = ManuallySetData.new(args[0])
|
@@ -11,11 +11,15 @@ module LVS
|
|
11
11
|
end
|
12
12
|
|
13
13
|
module ClassMethods
|
14
|
+
def unique_request_id
|
15
|
+
Digest::SHA1.hexdigest((rand(4294967295)+Time.now.usec).to_s)
|
16
|
+
end
|
17
|
+
|
14
18
|
def http_request_with_timeout(service, args, options)
|
15
19
|
uri = URI.parse(service)
|
16
20
|
|
17
21
|
req = Net::HTTP::Post.new(uri.path)
|
18
|
-
args[:requestId] =
|
22
|
+
args[:requestId] = unique_request_id
|
19
23
|
req.form_data = { "object_request" => args.to_json }
|
20
24
|
|
21
25
|
options[:encrypted] ||= require_ssl?
|
@@ -56,6 +56,6 @@ describe LVS::JsonService::Base do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should recognise keys that start with two capital letters" do
|
59
|
-
TestServiceForJsonMethodsCall.details.e_credit.should eql(1)
|
59
|
+
lambda {TestServiceForJsonMethodsCall.details.e_credit.should eql(1)}.should_not raise_error(NoMethodError)
|
60
60
|
end
|
61
61
|
end
|
@@ -54,6 +54,8 @@ describe LVS::JsonService::Request do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "should assign the JSON parameters to a Net::HTTP::Post object" do
|
57
|
+
ClassWithRequest.stub!(:unique_request_id).and_return("1")
|
58
|
+
@args[:requestId] = "1"
|
57
59
|
@mock_post.should_receive(:form_data=).with({ "object_request" => @args.to_json })
|
58
60
|
do_request
|
59
61
|
end
|