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 CHANGED
@@ -2,4 +2,4 @@
2
2
  coverage/
3
3
  spec/reports
4
4
  pkg/
5
- JSONService-*.gem
5
+ LVS-JSONService-*.gem
data/.specification CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: LVS-JSONService
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  require_paths:
6
6
  - lib
7
7
  platform: ruby
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{LVS-JSONService}
5
- s.version = "0.3.4"
5
+ s.version = "0.3.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["LVS", "andyjeffries"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
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 = @data[key]
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
- value = @data[key.capitalize]
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] = Digest::SHA1.hexdigest((rand(4294967295)+Time.now.usec).to_s)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: LVS-JSONService
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - LVS