ruby-fs-stack 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/ruby-fs-stack/fs_communicator.rb +6 -2
- data/ruby-fs-stack.gemspec +5 -4
- data/spec/communicator_spec.rb +35 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.4
|
@@ -3,7 +3,7 @@ require 'net/https'
|
|
3
3
|
require 'uri'
|
4
4
|
|
5
5
|
class FsCommunicator
|
6
|
-
attr_accessor :domain, :key, :user_agent, :session, :handle_throttling, :logger
|
6
|
+
attr_accessor :domain, :key, :user_agent, :session, :handle_throttling, :logger, :timeout
|
7
7
|
include RubyFsStack
|
8
8
|
# ====Params
|
9
9
|
# <tt>options</tt> - a hash with the following options
|
@@ -29,7 +29,8 @@ class FsCommunicator
|
|
29
29
|
:user_agent => 'FsCommunicator/0.1 (Ruby)', # should be overridden by options user_agent
|
30
30
|
:session => nil,
|
31
31
|
:handle_throttling => false,
|
32
|
-
:logger => nil
|
32
|
+
:logger => nil,
|
33
|
+
:timeout => nil
|
33
34
|
}.merge(options)
|
34
35
|
@domain = o[:domain]
|
35
36
|
@key = o[:key]
|
@@ -37,6 +38,7 @@ class FsCommunicator
|
|
37
38
|
@session = o[:session]
|
38
39
|
@handle_throttling = o[:handle_throttling]
|
39
40
|
@logger = o[:logger]
|
41
|
+
@timeout = o[:timeout]
|
40
42
|
end
|
41
43
|
|
42
44
|
def post(url,payload)
|
@@ -49,6 +51,7 @@ class FsCommunicator
|
|
49
51
|
|
50
52
|
http = Net::HTTP.new(uri.host, uri.port)
|
51
53
|
set_ssl(http) if uri.scheme == 'https'
|
54
|
+
http.read_timeout = @timeout unless @timeout.nil?
|
52
55
|
|
53
56
|
log_request('POST',full_url,request) if logger
|
54
57
|
res = http.start do |ht|
|
@@ -76,6 +79,7 @@ class FsCommunicator
|
|
76
79
|
|
77
80
|
http = Net::HTTP.new(uri.host, uri.port)
|
78
81
|
set_ssl(http) if uri.scheme == 'https'
|
82
|
+
http.read_timeout = @timeout unless @timeout.nil?
|
79
83
|
|
80
84
|
log_request('GET',full_url,request) if logger
|
81
85
|
res = http.start do |ht|
|
data/ruby-fs-stack.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ruby-fs-stack}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jimmy Zimmerman"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-02-19}
|
13
13
|
s.description = %q{A library that enables you to read and update information with the new.familysearch.org API.}
|
14
14
|
s.email = %q{jimmy.zimmerman@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -101,3 +101,4 @@ Gem::Specification.new do |s|
|
|
101
101
|
s.add_dependency(%q<fakeweb>, [">= 0"])
|
102
102
|
end
|
103
103
|
end
|
104
|
+
|
data/spec/communicator_spec.rb
CHANGED
@@ -446,4 +446,39 @@ describe FsCommunicator do
|
|
446
446
|
|
447
447
|
end
|
448
448
|
|
449
|
+
describe "timeout" do
|
450
|
+
before(:each) do
|
451
|
+
options = {
|
452
|
+
:domain => 'https://api.familysearch.org',
|
453
|
+
:key => '1111-1111',
|
454
|
+
:user_agent => "FsCommunicator/0.1",
|
455
|
+
:session => 'SESSID',
|
456
|
+
:timeout => 300
|
457
|
+
}
|
458
|
+
@com = FsCommunicator.new options
|
459
|
+
|
460
|
+
stub_net_objects #found in the spec helper
|
461
|
+
@url = '/familytree/v1/person/KWQS-BBQ'
|
462
|
+
@session_url = @url + "?sessionId=#{@com.session}&dataFormat=application/json"
|
463
|
+
@res = mock('HTTP::Response')
|
464
|
+
@res.stub!(:code).and_return('200')
|
465
|
+
@http.stub!(:start).and_return(@res)
|
466
|
+
end
|
467
|
+
|
468
|
+
it "should set timeout attr" do
|
469
|
+
@com.domain.should == 'https://api.familysearch.org'
|
470
|
+
@com.timeout.should == 300
|
471
|
+
end
|
472
|
+
|
473
|
+
it "should set the http's read_timeout inside of the get method" do
|
474
|
+
@http.should_receive(:read_timeout=).with(300)
|
475
|
+
@com.get(@url)
|
476
|
+
end
|
477
|
+
|
478
|
+
it "should set the http's read_timeout inside of the post method" do
|
479
|
+
@http.should_receive(:read_timeout=).with(300)
|
480
|
+
@com.post(@url,'payload')
|
481
|
+
end
|
482
|
+
end
|
483
|
+
|
449
484
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-fs-stack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Zimmerman
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-02-19 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|