geni 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *~
2
+ Thumbs.db
3
+ .DS_Store
4
+ *.gem
5
+ .rvmrc
6
+ ~*
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010 Aurélien Malisart
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # About
2
+
3
+ Simple Ruby client to the geni.com REST/OAuth API.
4
+
5
+ # Installation
6
+
7
+ $ gem install geni
8
+
9
+ # Example usage
10
+
11
+ geni = Geni::Client.new({
12
+ :app_id => 'XX',
13
+ :app_secret => 'XX',
14
+ :access_token => an_oauth_access_token
15
+ })
16
+
17
+ profile = geni.profile('an_id')
18
+
19
+ puts profile.name
20
+ puts profile.birth_date
21
+
22
+ geni.parents.each do |profile|
23
+ puts profile.name
24
+ end
25
+
26
+ geni.children.each do |profile|
27
+ puts profile.name
28
+ end
29
+
30
+ geni.siblings.each do |profile|
31
+ puts profile.name
32
+ end
data/geni.gemspec ADDED
@@ -0,0 +1,43 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{geni}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Aurélien Malisart"]
9
+ s.date = %q{2011-02-03}
10
+ s.description = %q{A Ruby client to the geni.com API}
11
+ s.email = %q{aurelien.malisart@gmail.com}
12
+ s.executables = []
13
+
14
+ s.extra_rdoc_files = [
15
+ "README.md"
16
+ ]
17
+
18
+ s.files = [
19
+ ".gitignore",
20
+ "README.md",
21
+ "lib/geni.rb",
22
+ "lib/geni/array.rb",
23
+ "lib/geni/base.rb",
24
+ "lib/geni/client.rb",
25
+ "lib/geni/family.rb",
26
+ "lib/geni/profile.rb",
27
+ "geni.gemspec",
28
+ "LICENSE"
29
+ ]
30
+ s.homepage = %q{http://github.com/aurels/geni}
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.require_paths = ['lib']
33
+ s.rubygems_version = %q{1.3.7}
34
+ s.summary = %q{A Ruby client to the geni.com API}
35
+ s.test_files = []
36
+
37
+ if s.respond_to? :specification_version then
38
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
39
+ s.specification_version = 3
40
+ s.add_dependency(%q<oauth2>, ["= 0.1.1"])
41
+ s.add_dependency(%q<json>, ["= 1.5.0"])
42
+ end
43
+ end
data/lib/geni.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'geni/array'
2
+ require 'geni/client'
3
+ require 'geni/base'
4
+ require 'geni/profile'
5
+ require 'geni/family'
6
+
7
+ puts "OK"
data/lib/geni/array.rb ADDED
@@ -0,0 +1,5 @@
1
+ class Array
2
+ def tail
3
+ self[1..(self.size-1)] || []
4
+ end
5
+ end
data/lib/geni/base.rb ADDED
@@ -0,0 +1,10 @@
1
+ module Geni
2
+ class Base
3
+ def initialize(params = {})
4
+ @access_token = params[:access_token]
5
+ params[:attrs].each_pair do |attr, value|
6
+ instance_variable_set("@#{attr}".to_sym, value)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,28 @@
1
+ module Geni
2
+ class Client
3
+
4
+ # Constants
5
+
6
+ SITE = 'https://www.geni.com'
7
+
8
+ # Attributes
9
+
10
+ attr_reader :app_id, :app_secret, :access_token
11
+
12
+ # Methods
13
+
14
+ def initialize(params = {})
15
+ @app_id = params[:app_id]
16
+ @app_secret = params[:app_secret]
17
+ @access_token = params[:access_token]
18
+ end
19
+
20
+ def profile(id = nil)
21
+ profile_id = id.nil? ? '' : "-#{id}"
22
+ Geni::Profile.new({
23
+ :access_token => @access_token,
24
+ :attrs => @access_token.get("/api/profile#{profile_id}")
25
+ })
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,44 @@
1
+ module Geni
2
+ class Family < Base
3
+ def parents
4
+ @parents ||= profiles(walk(focus_node, ['child', 'partner']))
5
+ end
6
+
7
+ def partners
8
+ @partners ||= profiles(walk(focus_node, ['partner', 'partner']))
9
+ end
10
+
11
+ def children
12
+ @children ||= profiles(walk(focus_node, ['partner', 'child']))
13
+ end
14
+
15
+ def siblings
16
+ @siblings ||= profiles(walk(focus_node, ['child', 'child']))
17
+ end
18
+
19
+ protected
20
+
21
+ def focus_node
22
+ @nodes[@focus['id']]
23
+ end
24
+
25
+ def walk(node, rels)
26
+ return node if rels.empty?
27
+
28
+ node['edges'].collect do |edge_id, edge|
29
+ if edge['rel'] == rels.first && edge_id != @focus['id']
30
+ walk(@nodes[edge_id], rels.tail)
31
+ end
32
+ end.compact.flatten
33
+ end
34
+
35
+ def profiles(nodes)
36
+ nodes.collect do |node|
37
+ Geni::Profile.new({
38
+ :access_token => @access_token,
39
+ :attrs => @access_token.get("/api/#{node['id']}")
40
+ })
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,63 @@
1
+ module Geni
2
+ class Profile < Base
3
+ attr_reader :id
4
+ attr_reader :first_name
5
+ attr_reader :middle_name
6
+ attr_reader :maiden_name
7
+ attr_reader :last_name
8
+ attr_reader :suffix
9
+ attr_reader :display_name
10
+ attr_reader :name
11
+ attr_reader :gender
12
+ attr_reader :current_residence
13
+ attr_reader :created_by
14
+ attr_reader :managers
15
+ attr_reader :merged_into
16
+ attr_reader :requested_merges
17
+ attr_reader :merge_note
18
+ attr_reader :public
19
+ attr_reader :big_tree
20
+ attr_reader :claimed
21
+ attr_reader :locked
22
+ attr_reader :birth_date
23
+ attr_reader :birth_location
24
+ attr_reader :birth_location
25
+ attr_reader :death_date
26
+ attr_reader :death_location
27
+ attr_reader :burial_date
28
+ attr_reader :url
29
+ attr_reader :language
30
+ attr_reader :curator
31
+
32
+ def parents
33
+ immediate_family.parents
34
+ end
35
+
36
+ def father
37
+ @father ||= parents.select { |profile| profile.gender == 'male' }.first
38
+ end
39
+
40
+ def mother
41
+ @mother ||= parents.select { |profile| profile.gender == 'female' }.first
42
+ end
43
+
44
+ def children
45
+ immediate_family.children
46
+ end
47
+
48
+ def siblings
49
+ immediate_family.siblings
50
+ end
51
+
52
+ def partners
53
+ immediate_family.partners
54
+ end
55
+
56
+ def immediate_family
57
+ @immediate_family ||= Geni::Family.new({
58
+ :access_token => @access_token,
59
+ :attrs => @access_token.get("/api/profile-#{id}/immediate-family")
60
+ })
61
+ end
62
+ end
63
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: geni
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - "Aur\xC3\xA9lien Malisart"
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-02-03 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: oauth2
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - "="
28
+ - !ruby/object:Gem::Version
29
+ hash: 25
30
+ segments:
31
+ - 0
32
+ - 1
33
+ - 1
34
+ version: 0.1.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: json
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - "="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 1
48
+ - 5
49
+ - 0
50
+ version: 1.5.0
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: A Ruby client to the geni.com API
54
+ email: aurelien.malisart@gmail.com
55
+ executables: []
56
+
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - README.md
61
+ files:
62
+ - .gitignore
63
+ - README.md
64
+ - lib/geni.rb
65
+ - lib/geni/array.rb
66
+ - lib/geni/base.rb
67
+ - lib/geni/client.rb
68
+ - lib/geni/family.rb
69
+ - lib/geni/profile.rb
70
+ - geni.gemspec
71
+ - LICENSE
72
+ has_rdoc: true
73
+ homepage: http://github.com/aurels/geni
74
+ licenses: []
75
+
76
+ post_install_message:
77
+ rdoc_options:
78
+ - --charset=UTF-8
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ hash: 3
96
+ segments:
97
+ - 0
98
+ version: "0"
99
+ requirements: []
100
+
101
+ rubyforge_project:
102
+ rubygems_version: 1.4.1
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: A Ruby client to the geni.com API
106
+ test_files: []
107
+