geni 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.gitignore +2 -1
  2. data/README.md +8 -3
  3. data/Rakefile +9 -0
  4. data/geni.gemspec +7 -15
  5. data/lib/geni.rb +8 -2
  6. data/lib/geni/base.rb +30 -3
  7. data/lib/geni/client.rb +41 -19
  8. data/lib/geni/document.rb +9 -0
  9. data/lib/geni/photo.rb +10 -0
  10. data/lib/geni/profile.rb +68 -37
  11. data/lib/geni/profile/immediate_family.rb +51 -0
  12. data/lib/geni/project.rb +19 -0
  13. data/lib/geni/taggable.rb +27 -0
  14. data/lib/geni/union.rb +15 -0
  15. data/lib/geni/video.rb +9 -0
  16. data/spec/geni/client_spec.rb +79 -0
  17. data/spec/geni/document_spec.rb +53 -0
  18. data/spec/geni/immediate_family_spec.rb +45 -0
  19. data/spec/geni/photo_spec.rb +67 -0
  20. data/spec/geni/profile_spec.rb +73 -0
  21. data/spec/geni/project_spec.rb +44 -0
  22. data/spec/geni/union_spec.rb +44 -0
  23. data/spec/geni/video_spec.rb +56 -0
  24. data/spec/spec_helper.rb +91 -0
  25. data/spec/support/mocked_responses/06668c1bc97e251b3c2965712e3b990e.json +1 -0
  26. data/spec/support/mocked_responses/09df004f19d20d8d685db52796b552bf.json +1 -0
  27. data/spec/support/mocked_responses/12536c37e1bcef230f105a0fa930eae9.json +1 -0
  28. data/spec/support/mocked_responses/155ed9f9c6912c19cd4d6be2ad4b9163.json +1 -0
  29. data/spec/support/mocked_responses/1b640e767a27039b60daab80aa3e38da.json +1 -0
  30. data/spec/support/mocked_responses/44795c1cebac8aee4c72ab4cde5b7c34.json +1 -0
  31. data/spec/support/mocked_responses/4e55df6914e067b371e7ea54ac372591.json +1 -0
  32. data/spec/support/mocked_responses/55c9a8f9e64187f2e7389b7cecec4bd0.json +1 -0
  33. data/spec/support/mocked_responses/5643d7ffaa0b17a4340b57446228f455.json +1 -0
  34. data/spec/support/mocked_responses/6df2af74f5544a90b96921edc9aa346d.json +1 -0
  35. data/spec/support/mocked_responses/7215a02ec26d1c9df055275958824c7b.json +1 -0
  36. data/spec/support/mocked_responses/7c4840e03bece51bb7154893682ec2a6.json +1 -0
  37. data/spec/support/mocked_responses/9ae308e89eb74fc5aea5164c8affa422.json +1 -0
  38. data/spec/support/mocked_responses/9e1dcf9ed89704ecac0e1734f9ac9e6e.json +1 -0
  39. data/spec/support/mocked_responses/a060207b22ab180a065704b8dd031511.json +1 -0
  40. data/spec/support/mocked_responses/a4a8ee1c8c387c8cad34c7c62f2d1d27.json +1 -0
  41. data/spec/support/mocked_responses/a5a1df59373b2159fbd3b906b9494f6f.json +1 -0
  42. data/spec/support/mocked_responses/b28e773e9568bf5e2ac10e425241bf51.json +1 -0
  43. data/spec/support/mocked_responses/b4856ae6ff428888301f716b52ea161b.json +1 -0
  44. data/spec/support/mocked_responses/b73322abb23cf869241bda85b20080f5.json +1 -0
  45. data/spec/support/mocked_responses/c21daf2c09c09b947b5b8de0a69278d9.json +1 -0
  46. data/spec/support/mocked_responses/c234b7016ed809af64cfaf699a509512.json +1 -0
  47. data/spec/support/mocked_responses/d2e9479730282f7493eaf6513497d454.json +1 -0
  48. data/spec/support/mocked_responses/d5b2f2087b8831ce4df5e7e9f5a1085a.json +1 -0
  49. data/spec/support/mocked_responses/dee607809468ee9a94e56eeae28ecc34.json +1 -0
  50. data/spec/support/mocked_responses/deea226a6d94d6165febb07a56ba4261.json +1 -0
  51. data/spec/support/mocked_responses/f4f38a4038abc4227a1b4b18fd12b978.json +1 -0
  52. metadata +83 -8
  53. data/lib/geni/family.rb +0 -39
@@ -0,0 +1,15 @@
1
+ module Geni
2
+ class Union < Base
3
+ has_fetchable_attributes %w[
4
+ status marriage_location marriage_date marriage_date_parts url
5
+ ]
6
+
7
+ def partners
8
+ @partner_profiles ||= client.get_profiles(@partners.collect { |uri| uri.split('-').last })
9
+ end
10
+
11
+ def children
12
+ @children_profiles ||= client.get_profiles(@children.collect { |uri| uri.split('-').last })
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ module Geni
2
+ class Video < Base
3
+ has_fetchable_attributes %w[
4
+ title url date date_parts sizes created_on
5
+ ]
6
+
7
+ include Taggable
8
+ end
9
+ end
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ describe Geni::Client do
4
+ before :all do
5
+ @client = get_geni_client
6
+ end
7
+
8
+ it "has an authorize URL" do
9
+ #puts @client.authorize_url
10
+ pending
11
+ end
12
+
13
+ it "has an OAuth2 access token" do
14
+ @client.access_token.class.should == OAuth2::AccessToken
15
+ pending
16
+ end
17
+
18
+ it "has an OAuth2 callback URL" do
19
+ pending
20
+ end
21
+
22
+ it "can get current user's profile" do
23
+ profile = @client.me
24
+ profile.class.should == Geni::Profile
25
+ profile.id.should == 'profile-90990667'
26
+ end
27
+
28
+ it "can get a single profile" do
29
+ profile = @client.get_profile('profile-90990667')
30
+ profile.class.should == Geni::Profile
31
+ profile.id.should == 'profile-90990667'
32
+ end
33
+
34
+ it "can get multiple profiles" do
35
+ profiles = @client.get_profiles(['profile-90990667', 'profile-90990668'])
36
+ profiles.class.should == Array
37
+ profiles.should have(2).items
38
+ profiles.collect(&:id).should include('profile-90990667')
39
+ end
40
+
41
+ it "can get a union" do
42
+ union = @client.get_union('union-12276689')
43
+ union.class.should == Geni::Union
44
+ union.id.should == 'union-12276689'
45
+ end
46
+
47
+ it "can get a photo" do
48
+ photo = @client.get_photo('photo-21557506')
49
+ photo.class.should == Geni::Photo
50
+ photo.id.should == 'photo-21557506'
51
+ end
52
+
53
+ it "can get a project" do
54
+ project = @client.get_project('project-6')
55
+ project.class.should == Geni::Project
56
+ project.id.should == 'project-6'
57
+ end
58
+
59
+ it "can get a document" do
60
+ document = @client.get_document('document-339953')
61
+ document.class.should == Geni::Document
62
+ document.id.should == 'document-339953'
63
+ end
64
+
65
+ it "can get a video" do
66
+ video = @client.get_video('video-1')
67
+ video.class.should == Geni::Video
68
+ video.id.should == 'video-1'
69
+ end
70
+
71
+ it "can get entities via a basic hash-style syntax" do
72
+ @client['profile-90990667'].class.should == Geni::Profile
73
+ @client['union-12276689'].class.should == Geni::Union
74
+ @client['photo-21557506'].class.should == Geni::Photo
75
+ @client['project-6'].class.should == Geni::Project
76
+ @client['document-339953'].class.should == Geni::Document
77
+ @client['video-1'].class.should == Geni::Video
78
+ end
79
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Geni::Document do
4
+ before :all do
5
+ @client = get_geni_client
6
+ @document = Geni::Document.new(:id => 'document-339953', :client => @client)
7
+ end
8
+
9
+ it "has a title" do
10
+ @document.title.should == 'Jaworow AGAD Births 1877-96'
11
+ end
12
+
13
+ it "has a url" do
14
+ @document.url.should == 'https://www.geni.com/api/document-339953'
15
+ end
16
+
17
+ it "has a date" do
18
+
19
+ end
20
+
21
+ it "has date_parts" do
22
+ @document.date_parts.should == {}
23
+ end
24
+
25
+ it "has a content_type" do
26
+ @document.content_type.should == 'image/png'
27
+ end
28
+
29
+ it "has a description" do
30
+ @document.description.should == "Jewish Records Indexing - Poland\nhttp://www.jewishgen.org/jri-pl/index.htm"
31
+ end
32
+
33
+ it "has sizes" do
34
+ @document.sizes.class.should == Hash
35
+ @document.sizes.keys.should include('thumb')
36
+ @document.sizes.keys.should include('original')
37
+ @document.sizes.keys.should include('large')
38
+ end
39
+
40
+ it "has tags" do
41
+ tags = @document.tags
42
+ end
43
+
44
+ it "can be tagged" do
45
+ # FIXME
46
+ pending
47
+ end
48
+
49
+ it "can be untagged" do
50
+ # FIXME
51
+ pending
52
+ end
53
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe Geni::Profile::ImmediateFamily do
4
+ before :all do
5
+ @client = get_geni_client
6
+ @family = @client.get_profile('profile-90990739').immediate_family
7
+ end
8
+
9
+ it 'has a focus node' do
10
+ @family.focus.class.should == Hash
11
+ @family.focus['id'].should == 'profile-90990739'
12
+ end
13
+
14
+ it 'has parents' do
15
+ @family.parents.should have(2).items
16
+ @family.parents[0].name.should == 'Simon Moiny'
17
+ @family.parents[1].name.should == 'Arlette PAIX'
18
+ end
19
+
20
+ it 'has partners' do
21
+ @family.partners.should have(1).items
22
+ @family.partners[0].name.should == 'Alain Malisart'
23
+ end
24
+
25
+ it 'has children' do
26
+ @family.children.should have(3).items
27
+
28
+ child_names = @family.children.collect(&:name)
29
+
30
+ child_names.should include('Aurélien Malisart')
31
+ child_names.should include('Timothy Malisart')
32
+ child_names.should include('Benjamin Malisart')
33
+ end
34
+
35
+ it 'has siblings' do
36
+ @family.siblings.should have(4).items
37
+
38
+ sibling_names = @family.siblings.collect(&:name)
39
+
40
+ sibling_names.should include('Fabienne Moiny')
41
+ sibling_names.should include('Bérengère MOINY')
42
+ sibling_names.should include('Luc Moiny')
43
+ sibling_names.should include('Armelle MOINY')
44
+ end
45
+ end
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe Geni::Photo do
4
+ before :all do
5
+ @client = get_geni_client
6
+ @photo = Geni::Photo.new(:id => 'photo-22466661', :client => @client)
7
+ end
8
+
9
+ it "has a title" do
10
+ # not given by Geni at all times
11
+ end
12
+
13
+ it "has an URL" do
14
+ @photo.url.should == 'https://www.geni.com/api/photo-22466661'
15
+ end
16
+
17
+ it "has a creation date/time" do
18
+ @photo.created_on.should == '2011-01-23 00:01:18'
19
+ end
20
+
21
+ it "has a date" do
22
+ @photo.date.should == '4/17/2010'
23
+ end
24
+
25
+ it "has date parts" do
26
+ @photo.date_parts.should == {
27
+ 'day' => 17,
28
+ 'month' => 4,
29
+ 'year' => 2010
30
+ }
31
+ end
32
+
33
+ it "has a content type" do
34
+ @photo.content_type.should == 'image/jpeg'
35
+ end
36
+
37
+ it "belongs to an album" do
38
+ @photo.album_id.should == '6000000009078813207'
39
+ end
40
+
41
+ it "has sizes" do
42
+ @photo.sizes.class.should == Hash
43
+ @photo.sizes.keys.should include('thumb')
44
+ @photo.sizes.keys.should include('original')
45
+ @photo.sizes.keys.should include('large')
46
+ @photo.sizes.keys.should include('medium')
47
+ @photo.sizes.keys.should include('small')
48
+ @photo.sizes.keys.should include('thumb2')
49
+ end
50
+
51
+ it "has tags" do
52
+ tags = @photo.tags
53
+ tags.class.should == Array
54
+ tags.first.class.should == Geni::Profile
55
+ tags.first.id.should == 'profile-90990889'
56
+ end
57
+
58
+ it "can be tagged" do
59
+ # FIXME
60
+ pending
61
+ end
62
+
63
+ it "can be untagged" do
64
+ # FIXME
65
+ pending
66
+ end
67
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ describe Geni::Profile do
4
+ before :all do
5
+ @client = get_geni_client
6
+ @profile = Geni::Profile.new(:id => 'profile-90990667', :client => @client)
7
+ end
8
+
9
+ it "is not fetched by default" do
10
+ @profile.should_not be_fetched
11
+ end
12
+
13
+ it "is fetchable" do
14
+ @profile.fetch
15
+ @profile.should be_fetched
16
+ end
17
+
18
+ it "has a name" do
19
+ @profile.name.should == "Aurélien Malisart"
20
+ end
21
+
22
+ it "has a birth date" do
23
+ @profile.birth_date.should == "6/30/1986"
24
+ end
25
+
26
+ it "is alive" do
27
+ @profile.is_alive.should == true
28
+ end
29
+
30
+ it "has an immediate family" do
31
+ family = @profile.immediate_family
32
+ family.class.should == Geni::Profile::ImmediateFamily
33
+ end
34
+
35
+ it "has managers" do
36
+ @profile.managers.class.should == Array
37
+ # NEEDS MORE STUFF
38
+ pending
39
+ end
40
+
41
+ it "has been merged into profiles" do
42
+ @profile.merged_into.class.should == Array
43
+ # NEEDS MORE STUFF
44
+ pending
45
+ end
46
+
47
+ it "has requested merges" do
48
+ @profile.requested_merges.class.should == Array
49
+ # NEEDS MORE STUFF
50
+ end
51
+
52
+ it "has a curator" do
53
+ @profile.instance_variable_set('@curator', 'https://www.geni.com/api/profile-90990667') # stub
54
+ curator = @profile.curator
55
+ curator.class.should == Geni::Profile
56
+ curator.id.should == 'profile-90990667'
57
+ end
58
+
59
+ it "has photos" do
60
+ photos = @profile.photos
61
+ photos.class.should == Array
62
+ end
63
+
64
+ it "has videos" do
65
+ videos = @profile.videos
66
+ videos.class.should == Array
67
+ end
68
+
69
+ it "has documents" do
70
+ documents = @profile.documents
71
+ documents.class.should == Array
72
+ end
73
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe Geni::Project do
4
+ before :all do
5
+ @client = get_geni_client
6
+ @project = Geni::Project.new(:id => 'project-6', :client => @client)
7
+ end
8
+
9
+ it "has a name" do
10
+ @project.name.should == 'Magna Carta Sureties and Witnesses'
11
+ end
12
+
13
+ it "has a description" do
14
+ @project.description.should_not == ''
15
+ end
16
+
17
+ it "has an URL" do
18
+ @project.url.should == 'https://www.geni.com/api/project-6'
19
+ end
20
+
21
+ it "has collaborators" do
22
+ collaborators = @project.collaborators
23
+ collaborators.class.should == Array
24
+ collaborators.collect(&:id).should include('profile-34069147')
25
+ collaborators.first.class.should == Geni::Profile
26
+ collaborators.first.should be_fetched
27
+ end
28
+
29
+ it "has profiles" do
30
+ profiles = @project.profiles
31
+ profiles.class.should == Array
32
+ profiles.collect(&:id).should include('profile-37184377')
33
+ profiles.first.class.should == Geni::Profile
34
+ profiles.first.should be_fetched
35
+ end
36
+
37
+ it "has followers" do
38
+ followers = @project.followers
39
+ followers.class.should == Array
40
+ followers.collect(&:id).should include('profile-34069147')
41
+ followers.first.class.should == Geni::Profile
42
+ followers.first.should be_fetched
43
+ end
44
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe Geni::Union do
4
+ before :all do
5
+ @client = get_geni_client
6
+ @union = Geni::Union.new(:id => 'union-12276689', :client => @client)
7
+ end
8
+
9
+ it "has a status" do
10
+ @union.status.should == 'current'
11
+ end
12
+
13
+ it "has a marriage location" do
14
+ @union.marriage_location.should == 'Chicago, Illinois, United States'
15
+ end
16
+
17
+ it "has a marriage date" do
18
+ @union.marriage_date.should == '10/18/1992'
19
+ end
20
+
21
+ it "has marriage date parts" do
22
+ @union.marriage_date_parts.should == {
23
+ 'day' => 18,
24
+ 'month' => 10,
25
+ 'year' => 1992
26
+ }
27
+ end
28
+
29
+ it "has an URL" do
30
+ @union.url.should == 'https://www.geni.com/api/union-12276689'
31
+ end
32
+
33
+ it 'has partners' do
34
+ partners = @union.partners
35
+ partners.class.should == Array
36
+ partners.first.class.should == Geni::Profile
37
+ end
38
+
39
+ it 'has children' do
40
+ children = @union.children
41
+ children.class.should == Array
42
+ children.should be_empty
43
+ end
44
+ end
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Geni::Video do
4
+ before :all do
5
+ @client = get_geni_client
6
+ @video = Geni::Video.new({
7
+ :id => 'video-99385',
8
+ :client => @client
9
+ })
10
+ end
11
+
12
+ it "has an URL" do
13
+ @video.url.should == 'https://www.geni.com/api/video-99385'
14
+ end
15
+
16
+ it "has a title" do
17
+ @video.title.should == 'Aurelien playing the drums'
18
+ end
19
+
20
+ it "has a creation date/time" do
21
+ @video.created_on.should == '2011-04-15 19:16:53'
22
+ end
23
+
24
+ it "has a date" do
25
+ @video.date.should == '4/8/2009'
26
+ end
27
+
28
+ it "has date parts" do
29
+ @video.date_parts.should == {
30
+ 'year' => 2009,
31
+ 'month' => 4,
32
+ 'day' => 8
33
+ }
34
+ end
35
+
36
+ it "has sizes" do
37
+ @video.sizes.class.should == Hash
38
+ end
39
+
40
+ it "has tags" do
41
+ tags = @video.tags
42
+ tags.class.should == Array
43
+ tags.first.class.should == Geni::Profile
44
+ tags.first.id.should == 'profile-90990667'
45
+ end
46
+
47
+ it "can be tagged" do
48
+ # FIXME
49
+ pending
50
+ end
51
+
52
+ it "can be untagged" do
53
+ # FIXME
54
+ pending
55
+ end
56
+ end