familysearch 0.2.0 → 0.3.0

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.
@@ -0,0 +1,117 @@
1
+ require 'spec_helper'
2
+ require 'familysearch/client'
3
+
4
+ describe FamilySearch::URLTemplate do
5
+
6
+ describe "initializing" do
7
+ def template_hash
8
+ {
9
+ "template" => "https://sandbox.familysearch.org/platform/tree/persons/{pid}/change-summary{?access_token}",
10
+ "type" => "application/atom+xml,application/json,application/x-gedcomx-atom+json,application/xml,text/html",
11
+ "accept" => "*/*",
12
+ "allow" => "GET",
13
+ "title" => "Person Change Summary"
14
+ }
15
+ end
16
+
17
+ def client
18
+ FamilySearch::Client.new
19
+ end
20
+
21
+ it "should accept the client object and a hash" do
22
+ template = FamilySearch::URLTemplate.new(client,template_hash)
23
+ end
24
+
25
+ it "should set instance attributes for the objects in the hash" do
26
+ template = FamilySearch::URLTemplate.new(client,template_hash)
27
+ template.template.should == "https://sandbox.familysearch.org/platform/tree/persons/{pid}/change-summary{?access_token}"
28
+ template.type.should == "application/atom+xml,application/json,application/x-gedcomx-atom+json,application/xml,text/html"
29
+ template.accept.should == '*/*'
30
+ template.allow.should == ['get']
31
+ template.title.should == 'Person Change Summary'
32
+ end
33
+ end
34
+
35
+ describe "get" do
36
+ def template_hash
37
+ {
38
+ "template" => "https://sandbox.familysearch.org/platform/tree/persons-with-relationships{?access_token,person}",
39
+ "type" => "application/json,application/x-fs-v1+json,application/x-fs-v1+xml,application/xml,text/html",
40
+ "accept" => "*/*",
41
+ "allow" => "GET",
42
+ "title" => "Person With Relationships"
43
+ }
44
+ end
45
+
46
+ def person_template_hash
47
+ {
48
+ "template" => "https://sandbox.familysearch.org/platform/tree/persons/{pid}{?access_token}",
49
+ "type" => "application/json,application/x-fs-v1+json,application/x-fs-v1+xml,application/x-gedcomx-v1+json,application/x-gedcomx-v1+xml,application/xml,text/html",
50
+ "accept" => "application/x-fs-v1+json,application/x-fs-v1+xml,application/x-gedcomx-v1+json,application/x-gedcomx-v1+xml",
51
+ "allow" => "HEAD,GET,POST,DELETE,GET,POST",
52
+ "title" => "Person"
53
+ }
54
+ end
55
+
56
+ def client()
57
+ unless @client
58
+ @client = FamilySearch::Client.new(:key => 'WCQY-7J1Q-GKVV-7DNM-SQ5M-9Q5H-JX3H-CMJK' )
59
+ @client.discover!
60
+ @client.basic_auth! 'api-user-1241', '1782'
61
+ end
62
+ @client
63
+ end
64
+
65
+ def template
66
+ @template ||= FamilySearch::URLTemplate.new client, template_hash
67
+ end
68
+
69
+ def person_template
70
+ @person_template ||= FamilySearch::URLTemplate.new client, person_template_hash
71
+ end
72
+
73
+ it "should accept a hash of options" do
74
+ VCR.use_cassette('person_with_relationship') do
75
+ template.get 'person' => 'KWQX-52J'
76
+ end
77
+ end
78
+
79
+ it "should raise an error if the get isn't in the allowed list" do
80
+ VCR.use_cassette('person_with_relationship') do
81
+ template.stub!(:allow).and_return([])
82
+ expect {template.get 'person' => 'KWQX-52J'}.to raise_error(FamilySearch::Error::MethodNotAllowed)
83
+ end
84
+ end
85
+
86
+ it "should raise an error if a template value isn't found in the template" do
87
+ VCR.use_cassette('person_with_relationship') do
88
+ expect {template.get 'person_id' => 'KWQX-52J'}.to raise_error(FamilySearch::Error::TemplateValueNotFound)
89
+ end
90
+ end
91
+
92
+ it "should call get on the client with the url and values on the querystring" do
93
+ VCR.use_cassette('person_with_relationship') do
94
+ client.should_receive(:get).with('https://sandbox.familysearch.org/platform/tree/persons-with-relationships',{'person' => 'KWQX-52J'}).and_call_original
95
+ template.get 'person' => 'KWQX-52J'
96
+ end
97
+ end
98
+
99
+ it "should call get on the client with the url and no querystring if nothing needs to be called" do
100
+ VCR.use_cassette('person_by_id') do
101
+ client.should_receive(:get).with('https://sandbox.familysearch.org/platform/tree/persons/KWQX-52J',{})
102
+ person_template.get 'pid' => 'KWQX-52J'
103
+ end
104
+ end
105
+
106
+ it "should accept symbols in the values hash" do
107
+ VCR.use_cassette('person_with_relationship') do
108
+ client.should_receive(:get).with('https://sandbox.familysearch.org/platform/tree/persons-with-relationships',{'person' => 'KWQX-52J'}).and_call_original
109
+ template.get :person => 'KWQX-52J'
110
+ end
111
+ VCR.use_cassette('person_by_id') do
112
+ client.should_receive(:get).with('https://sandbox.familysearch.org/platform/tree/persons/KWQX-52J',{})
113
+ person_template.get :pid => 'KWQX-52J'
114
+ end
115
+ end
116
+ end
117
+ end
@@ -45,7 +45,7 @@ person.save
45
45
  client.get("https://familysearch.org/platform/tree/persons/KWQS-BBQ")
46
46
 
47
47
  # The client may support URL templates too
48
- client.get(:person,'KWQS-BBQ')
48
+ client.template('person').get :pid => 'KWQS-BBQ'
49
49
 
50
50
  # Perhaps we could allow lazy-loaded relationship traversal?
51
51
  person.relationships.parents.father.get
@@ -0,0 +1,5 @@
1
+ Errors:
2
+
3
+ FamilySearch::Error::BadCredentials
4
+ FamilySearch::Error::NotAuthorized
5
+ FamilySearch::Error::NotFound
@@ -0,0 +1,7 @@
1
+ Gems:
2
+ familysearch - contain the client for making http calls, discovery, and URL templates (parses JSON by default)
3
+ familysearch-gedcomx - object model for parsing and serializing GedcomX (XML or JSON?)
4
+ familysearch-oauth2 - an client for doing oauth authentication (non-omniauth option)
5
+
6
+ Future:
7
+ familysearch-client - Break this out to contain the client for making http calls, discovery, and URL templates
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: familysearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-19 00:00:00.000000000 Z
12
+ date: 2013-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -59,38 +59,6 @@ dependencies:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.5.0
62
- - !ruby/object:Gem::Dependency
63
- name: hashie
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ~>
68
- - !ruby/object:Gem::Version
69
- version: 1.2.0
70
- type: :runtime
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ~>
76
- - !ruby/object:Gem::Version
77
- version: 1.2.0
78
- - !ruby/object:Gem::Dependency
79
- name: rash
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ~>
84
- - !ruby/object:Gem::Version
85
- version: 0.3.2
86
- type: :runtime
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ~>
92
- - !ruby/object:Gem::Version
93
- version: 0.3.2
94
62
  - !ruby/object:Gem::Dependency
95
63
  name: rspec
96
64
  requirement: !ruby/object:Gem::Requirement
@@ -128,7 +96,7 @@ dependencies:
128
96
  requirement: !ruby/object:Gem::Requirement
129
97
  none: false
130
98
  requirements:
131
- - - ~>
99
+ - - ! '>='
132
100
  - !ruby/object:Gem::Version
133
101
  version: 1.2.3
134
102
  type: :development
@@ -136,25 +104,9 @@ dependencies:
136
104
  version_requirements: !ruby/object:Gem::Requirement
137
105
  none: false
138
106
  requirements:
139
- - - ~>
107
+ - - ! '>='
140
108
  - !ruby/object:Gem::Version
141
109
  version: 1.2.3
142
- - !ruby/object:Gem::Dependency
143
- name: jeweler
144
- requirement: !ruby/object:Gem::Requirement
145
- none: false
146
- requirements:
147
- - - ~>
148
- - !ruby/object:Gem::Version
149
- version: 1.8.4
150
- type: :development
151
- prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
- requirements:
155
- - - ~>
156
- - !ruby/object:Gem::Version
157
- version: 1.8.4
158
110
  - !ruby/object:Gem::Dependency
159
111
  name: vcr
160
112
  requirement: !ruby/object:Gem::Requirement
@@ -188,35 +140,46 @@ dependencies:
188
140
  - !ruby/object:Gem::Version
189
141
  version: 1.10.0
190
142
  description: A gem for the FamilySearch Platform. Documentation for the FamilySearch
191
- Platform can be found at https://
192
- email: jimmy.zimmerman@gmail.com
143
+ Platform can be found at https://familysearch.org/developers/.
144
+ email:
145
+ - jimmy.zimmerman@gmail.com
193
146
  executables: []
194
147
  extensions: []
195
- extra_rdoc_files:
196
- - LICENSE.txt
197
- - README.md
148
+ extra_rdoc_files: []
198
149
  files:
199
150
  - .document
151
+ - .gitignore
200
152
  - .rvmrc
201
153
  - Gemfile
202
154
  - LICENSE.txt
203
155
  - README.md
204
156
  - Rakefile
205
- - VERSION
206
157
  - familysearch.gemspec
207
158
  - lib/familysearch.rb
208
159
  - lib/familysearch/client.rb
160
+ - lib/familysearch/error.rb
161
+ - lib/familysearch/middleware.rb
162
+ - lib/familysearch/middleware/response/familysearch_errors.rb
163
+ - lib/familysearch/middleware/response/multi_json.rb
164
+ - lib/familysearch/url_template.rb
165
+ - lib/familysearch/version.rb
209
166
  - spec/client_spec.rb
210
167
  - spec/familysearch_spec.rb
168
+ - spec/fixtures/vcr_cassettes/current_user_person_read.yml
211
169
  - spec/fixtures/vcr_cassettes/discovery.yml
212
170
  - spec/fixtures/vcr_cassettes/discovery_auth.yml
171
+ - spec/fixtures/vcr_cassettes/discovery_auth_wrong_creds.yml
172
+ - spec/fixtures/vcr_cassettes/person_by_id.yml
173
+ - spec/fixtures/vcr_cassettes/person_with_relationship.yml
213
174
  - spec/spec_helper.rb
175
+ - spec/url_template_spec.rb
214
176
  - workspace/notes/APIDesign.txt
215
177
  - workspace/notes/discovery_links.txt
178
+ - workspace/notes/errors.txt
179
+ - workspace/notes/gem_design.txt
216
180
  - workspace/notes/goals.txt
217
- homepage: http://github.com/jimmyz/familysearch-rb
218
- licenses:
219
- - MIT
181
+ homepage: https://github.com/jimmyz/familysearch-rb
182
+ licenses: []
220
183
  post_install_message:
221
184
  rdoc_options: []
222
185
  require_paths:
@@ -227,9 +190,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
227
190
  - - ! '>='
228
191
  - !ruby/object:Gem::Version
229
192
  version: '0'
230
- segments:
231
- - 0
232
- hash: 177874433212010284
233
193
  required_rubygems_version: !ruby/object:Gem::Requirement
234
194
  none: false
235
195
  requirements:
@@ -238,8 +198,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
198
  version: '0'
239
199
  requirements: []
240
200
  rubyforge_project:
241
- rubygems_version: 1.8.24
201
+ rubygems_version: 1.8.25
242
202
  signing_key:
243
203
  specification_version: 3
244
204
  summary: A gem for the FamilySearch Platform.
245
- test_files: []
205
+ test_files:
206
+ - spec/client_spec.rb
207
+ - spec/familysearch_spec.rb
208
+ - spec/fixtures/vcr_cassettes/current_user_person_read.yml
209
+ - spec/fixtures/vcr_cassettes/discovery.yml
210
+ - spec/fixtures/vcr_cassettes/discovery_auth.yml
211
+ - spec/fixtures/vcr_cassettes/discovery_auth_wrong_creds.yml
212
+ - spec/fixtures/vcr_cassettes/person_by_id.yml
213
+ - spec/fixtures/vcr_cassettes/person_with_relationship.yml
214
+ - spec/spec_helper.rb
215
+ - spec/url_template_spec.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.0