ruby-fs-stack 0.1.7
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/.document +5 -0
- data/.gitignore +7 -0
- data/LICENSE +20 -0
- data/README.rdoc +26 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/examples/familytree_example.rb +26 -0
- data/examples/login_example.rb +11 -0
- data/lib/ruby-fs-stack/assets/entrust-ca.crt +104 -0
- data/lib/ruby-fs-stack/enunciate/LICENSE +15 -0
- data/lib/ruby-fs-stack/enunciate/README +6 -0
- data/lib/ruby-fs-stack/enunciate/familytree.rb +12608 -0
- data/lib/ruby-fs-stack/enunciate/identity.rb +964 -0
- data/lib/ruby-fs-stack/familytree.rb +827 -0
- data/lib/ruby-fs-stack/fs_communicator.rb +109 -0
- data/lib/ruby-fs-stack/fs_utils.rb +27 -0
- data/lib/ruby-fs-stack/identity.rb +45 -0
- data/lib/ruby-fs-stack/warning_suppressor.rb +18 -0
- data/lib/ruby-fs-stack.rb +2 -0
- data/spec/communicator_spec.rb +214 -0
- data/spec/familytree_v2/familytree_communicator_spec.rb +309 -0
- data/spec/familytree_v2/json/match_KW3B-NNM.js +1 -0
- data/spec/familytree_v2/json/person/KJ86-3VD_all.js +1 -0
- data/spec/familytree_v2/json/person/KJ86-3VD_version.js +1 -0
- data/spec/familytree_v2/json/person/post_response.js +1 -0
- data/spec/familytree_v2/json/person/relationship_not_found.js +1 -0
- data/spec/familytree_v2/json/person/relationship_read.js +1 -0
- data/spec/familytree_v2/json/person/relationship_update.js +1 -0
- data/spec/familytree_v2/json/search.js +1 -0
- data/spec/familytree_v2/person_spec.rb +563 -0
- data/spec/familytree_v2/search_results_spec.rb +131 -0
- data/spec/fs_utils_spec.rb +33 -0
- data/spec/identity_v1/identity_spec.rb +50 -0
- data/spec/identity_v1/json/login.js +1 -0
- data/spec/ruby-fs-stack_spec.rb +6 -0
- data/spec/spec_helper.rb +27 -0
- metadata +119 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require 'ruby-fs-stack/fs_utils'
|
3
|
+
|
4
|
+
describe FsUtils do
|
5
|
+
|
6
|
+
describe "querystring_from_hash" do
|
7
|
+
it "should return a querystring" do
|
8
|
+
qstring = FsUtils.querystring_from_hash :names => 'all'
|
9
|
+
qstring.should == 'names=all'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return a querystring with &s delimiting params" do
|
13
|
+
qstring = FsUtils.querystring_from_hash :names => 'all', :events => 'all'
|
14
|
+
# a hash never guarantees the order so we'll split the string and test
|
15
|
+
# that it contain s all of the pieces
|
16
|
+
qstring.should include('names=all')
|
17
|
+
qstring.should include('events=all')
|
18
|
+
qstring.should include('&')
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should url_encode all of the hash values" do
|
22
|
+
qstring = FsUtils.querystring_from_hash :name => "Parker Felch"
|
23
|
+
qstring.should == 'name=Parker%20Felch'
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should convert sub-hashes into key.subkey=value" do
|
27
|
+
qstring = FsUtils.querystring_from_hash :father => {:name => 'Parker Felch'}
|
28
|
+
qstring.should == 'father.name=Parker%20Felch'
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require 'ruby-fs-stack/identity'
|
3
|
+
|
4
|
+
describe FsCommunicator do
|
5
|
+
include HttpCommunicatorHelper # found in the spec_helper
|
6
|
+
|
7
|
+
def do_get(url, credentials = {})
|
8
|
+
@com.get(url, credentials)
|
9
|
+
end
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
stub_net_objects
|
13
|
+
@com = FsCommunicator.new :domain => 'http://www.dev.usys.org', :key => 'KEY'
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have an extended identity_v1 method on the communicator" do
|
17
|
+
@com.identity_v1.should be_instance_of(IdentityV1::Communicator)
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "authenticate" do
|
21
|
+
before(:each) do
|
22
|
+
filename = File.join(File.dirname(__FILE__),'json','login.js')
|
23
|
+
body = File.read(filename)
|
24
|
+
@mock_response = mock('HTTP::Response', :body => body, :code => '200')
|
25
|
+
@http.should_receive(:start).and_return(@mock_response)
|
26
|
+
@request.should_receive(:basic_auth).with('user','pass')
|
27
|
+
@request.should_receive(:[]=).with('User-Agent',@com.user_agent)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should make a call to /identity/v1/login" do
|
31
|
+
url = "/identity/v1/login?key=KEY"
|
32
|
+
Net::HTTP::Get.should_receive(:new).with(url+"&dataFormat=application/json").and_return(@request)
|
33
|
+
response = @com.identity_v1.authenticate(:username => 'user', :password => 'pass')
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should return true if successful" do
|
37
|
+
success = @com.identity_v1.authenticate(:username => 'user', :password => 'pass')
|
38
|
+
success.should == true
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should set the communicator's session to the logged in session" do
|
42
|
+
@com.identity_v1.authenticate(:username => 'user', :password => 'pass')
|
43
|
+
@com.session.should == 'USYS6325F49E7E47C181EA7E73E897F9A8ED.ptap009-034'
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return false if the login was not successful" do
|
47
|
+
pending
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"session":{"id":"USYS6325F49E7E47C181EA7E73E897F9A8ED.ptap009-034"},"version":"1.3.20090928.4855","statusCode":200,"statusMessage":"OK"}
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
require 'ruby-fs-stack'
|
4
|
+
require 'spec'
|
5
|
+
require 'spec/autorun'
|
6
|
+
|
7
|
+
Spec::Runner.configure do |config|
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
module HttpCommunicatorHelper
|
12
|
+
|
13
|
+
def stub_net_objects
|
14
|
+
@request = mock("Net::HTTP::Get|Post")
|
15
|
+
@request.stub!(:[]=)
|
16
|
+
@request.stub!(:body=)
|
17
|
+
@http = mock("Net::HTTP")
|
18
|
+
Net::HTTP.stub!(:new).and_return(@http)
|
19
|
+
Net::HTTP::Get.stub!(:new).and_return(@request)
|
20
|
+
Net::HTTP::Post.stub!(:new).and_return(@request)
|
21
|
+
@http.stub!(:use_ssl=)
|
22
|
+
@http.stub!(:ca_file=)
|
23
|
+
@http.stub!(:verify_mode=)
|
24
|
+
@http.stub!(:start)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-fs-stack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.7
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jimmy Zimmerman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-05 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: json
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.7
|
34
|
+
version:
|
35
|
+
description: A library that enables you to read and update information with the new.familysearch.org API.
|
36
|
+
email: jimmy.zimmerman@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- examples/familytree_example.rb
|
52
|
+
- examples/login_example.rb
|
53
|
+
- lib/ruby-fs-stack.rb
|
54
|
+
- lib/ruby-fs-stack/assets/entrust-ca.crt
|
55
|
+
- lib/ruby-fs-stack/enunciate/LICENSE
|
56
|
+
- lib/ruby-fs-stack/enunciate/README
|
57
|
+
- lib/ruby-fs-stack/enunciate/familytree.rb
|
58
|
+
- lib/ruby-fs-stack/enunciate/identity.rb
|
59
|
+
- lib/ruby-fs-stack/familytree.rb
|
60
|
+
- lib/ruby-fs-stack/fs_communicator.rb
|
61
|
+
- lib/ruby-fs-stack/fs_utils.rb
|
62
|
+
- lib/ruby-fs-stack/identity.rb
|
63
|
+
- lib/ruby-fs-stack/warning_suppressor.rb
|
64
|
+
- spec/communicator_spec.rb
|
65
|
+
- spec/familytree_v2/familytree_communicator_spec.rb
|
66
|
+
- spec/familytree_v2/json/match_KW3B-NNM.js
|
67
|
+
- spec/familytree_v2/json/person/KJ86-3VD_all.js
|
68
|
+
- spec/familytree_v2/json/person/KJ86-3VD_version.js
|
69
|
+
- spec/familytree_v2/json/person/post_response.js
|
70
|
+
- spec/familytree_v2/json/person/relationship_not_found.js
|
71
|
+
- spec/familytree_v2/json/person/relationship_read.js
|
72
|
+
- spec/familytree_v2/json/person/relationship_update.js
|
73
|
+
- spec/familytree_v2/json/search.js
|
74
|
+
- spec/familytree_v2/person_spec.rb
|
75
|
+
- spec/familytree_v2/search_results_spec.rb
|
76
|
+
- spec/fs_utils_spec.rb
|
77
|
+
- spec/identity_v1/identity_spec.rb
|
78
|
+
- spec/identity_v1/json/login.js
|
79
|
+
- spec/ruby-fs-stack_spec.rb
|
80
|
+
- spec/spec_helper.rb
|
81
|
+
has_rdoc: true
|
82
|
+
homepage: http://github.com/jimmyz/ruby-fs-stack
|
83
|
+
licenses: []
|
84
|
+
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options:
|
87
|
+
- --charset=UTF-8
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: "0"
|
95
|
+
version:
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: "0"
|
101
|
+
version:
|
102
|
+
requirements: []
|
103
|
+
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 1.3.5
|
106
|
+
signing_key:
|
107
|
+
specification_version: 2
|
108
|
+
summary: Ruby wrapper for all FamilySearch APIs.
|
109
|
+
test_files:
|
110
|
+
- spec/communicator_spec.rb
|
111
|
+
- spec/familytree_v2/familytree_communicator_spec.rb
|
112
|
+
- spec/familytree_v2/person_spec.rb
|
113
|
+
- spec/familytree_v2/search_results_spec.rb
|
114
|
+
- spec/fs_utils_spec.rb
|
115
|
+
- spec/identity_v1/identity_spec.rb
|
116
|
+
- spec/ruby-fs-stack_spec.rb
|
117
|
+
- spec/spec_helper.rb
|
118
|
+
- examples/familytree_example.rb
|
119
|
+
- examples/login_example.rb
|