gedcomx-jruby 0.1.1 → 0.1.3

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,42 @@
1
+ module Gedcomx
2
+ class Place
3
+
4
+ attr_reader :fields
5
+
6
+ def self.java_class
7
+ Java::OrgGedcomxConclusion::PlaceReference
8
+ end
9
+
10
+ def self.create(attributes = {})
11
+ new_place = self.new
12
+ new_place.original = attributes[:original] if attributes[:original]
13
+ attributes[:fields].each { |field| new_place.add_field(field) } if attributes[:fields].is_a? Array
14
+ new_place
15
+ end
16
+
17
+ def initialize(input = nil)
18
+ @place = input || self.class.java_class.new
19
+ @fields = []
20
+ @fields = @place.fields.map { |field| Gedcomx::Field.new(field) } if @place.fields.is_a? Array
21
+ end
22
+
23
+ def add_field(field)
24
+ return false unless field.is_a? Gedcomx::Field
25
+ @place.add_field field.to_java
26
+ @place.fields << field
27
+ end
28
+
29
+ def original
30
+ @place.get_original
31
+ end
32
+
33
+ def original=(input_string)
34
+ return false unless input_string.is_a? String
35
+ @place.original = input_string
36
+ end
37
+
38
+ def to_java
39
+ @place
40
+ end
41
+ end
42
+ end
@@ -1,12 +1,50 @@
1
-
2
1
  module Gedcomx
3
2
  class Record
4
3
 
5
4
  attr_reader :people, :relationships
6
5
 
7
- def initialize(input)
8
- @record = input
9
- @people = @record.persons.map{|person| Person.new(person) }
6
+ def self.java_class
7
+ Java::OrgGedcomx::Gedcomx
8
+ end
9
+
10
+ def initialize(input = nil)
11
+ @record = input || self.class.java_class.new
12
+
13
+ @people = []
14
+ @people = @record.persons.map { |person| Gedcomx::Person.new(person) } if @record.persons
15
+
16
+ @relationships = []
17
+ if @record.relationships
18
+ @relationships = @record.relationships.map { |relationship| Gedcomx::Relationship.new(relationship) }
19
+ end
20
+ end
21
+
22
+ def add_person(person)
23
+ return false unless person.is_a? Gedcomx::Person
24
+ @record.add_person(person.to_java)
25
+ @people << person
26
+ end
27
+
28
+ def add_relationship(relationship)
29
+ return false unless relationship.is_a? Gedcomx::Relationship
30
+ @record.add_relationship(relationship.to_java)
31
+ @relationships << relationship
32
+ end
33
+
34
+ def relate_people(person1, person2, type)
35
+ return false unless ( person1.is_a?(Gedcomx::Person) && person2.is_a?(Gedcomx::Person) )
36
+ reference1 = Gedcomx::ResourceReference.create(resource: person1.relative_id)
37
+ reference2 = Gedcomx::ResourceReference.create(resource: person2.relative_id)
38
+ relationship = Gedcomx::Relationship.create(person1: reference1, person2: reference2, type: type)
39
+ add_relationship(relationship)
40
+ end
41
+
42
+ def add_couple(person1, person2)
43
+ relate_people(person1, person2, Gedcomx::TYPES[:couple])
44
+ end
45
+
46
+ def add_parent_child(parent, child)
47
+ relate_people(parent, child, Gedcomx::TYPES[:parent_child])
10
48
  end
11
49
 
12
50
  def each_person
@@ -15,5 +53,14 @@ module Gedcomx
15
53
  end
16
54
  end
17
55
 
56
+ def each_relationship
57
+ @relationships.each do |relationship|
58
+ yield relationship
59
+ end
60
+ end
61
+
62
+ def to_java
63
+ @record
64
+ end
18
65
  end
19
66
  end
@@ -0,0 +1,56 @@
1
+ module Gedcomx
2
+ class Relationship
3
+
4
+ attr_reader :person1, :person2
5
+
6
+ def self.java_class
7
+ Java::OrgGedcomxConclusion::Relationship
8
+ end
9
+
10
+ def self.create(attributes = {})
11
+ new_relationship = self.new
12
+ new_relationship.type = attributes[:type] if attributes[:type]
13
+ new_relationship.person1 = attributes[:person1] if attributes[:person1]
14
+ new_relationship.person2 = attributes[:person2] if attributes[:person2]
15
+ new_relationship
16
+ end
17
+
18
+ def initialize(input = nil)
19
+ @relationship = input || self.class.java_class.new
20
+ @person1 = Gedcomx::ResourceReference.new(@relationship.get_person1) if @relationship.get_person1
21
+ @person2 = Gedcomx::ResourceReference.new(@relationship.get_person2) if @relationship.get_person2
22
+ end
23
+
24
+ def couple?
25
+ type == TYPES[:couple]
26
+ end
27
+
28
+ def parent_child?
29
+ type == TYPES[:parent_child]
30
+ end
31
+
32
+ def person1=(person_reference)
33
+ return false unless person_reference.is_a? Gedcomx::ResourceReference
34
+ @relationship.person1 = person_reference.to_java
35
+ @person1 = person_reference
36
+ end
37
+
38
+ def person2=(person_reference)
39
+ return false unless person_reference.is_a? Gedcomx::ResourceReference
40
+ @relationship.person2 = person_reference.to_java
41
+ @person2 = person_reference
42
+ end
43
+
44
+ def type
45
+ @relationship.get_type.to_s
46
+ end
47
+
48
+ def type=(input_type)
49
+ @relationship.type = ( input_type.is_a? Gedcomx.java_uri_class ) ? input_type : Gedcomx.new_uri(input_type)
50
+ end
51
+
52
+ def to_java
53
+ @relationship
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,39 @@
1
+ module Gedcomx
2
+ class ResourceReference
3
+
4
+ def self.java_class
5
+ Java::OrgGedcomxCommon::ResourceReference
6
+ end
7
+
8
+ def self.create(attributes = {})
9
+ reference = self.new
10
+ reference.resource = attributes[:resource] if attributes[:resource]
11
+ reference.resource_id = attributes[:resource_id] if attributes[:resource_id]
12
+ reference
13
+ end
14
+
15
+ def initialize(input = nil)
16
+ @reference = input || self.class.java_class.new
17
+ end
18
+
19
+ def resource
20
+ @reference.get_resource.to_s
21
+ end
22
+
23
+ def resource=(new_resource)
24
+ @reference.resource = ( new_resource.is_a? Gedcomx.java_uri_class ) ? new_resource : Gedcomx.new_uri(new_resource)
25
+ end
26
+
27
+ def resource_id
28
+ @reference.get_resource_id
29
+ end
30
+
31
+ def resource_id=(new_resource_id)
32
+ @reference.resource_id = new_resource_id
33
+ end
34
+
35
+ def to_java
36
+ @reference
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,18 @@
1
+ module Gedcomx
2
+ class Writer
3
+
4
+ def initialize
5
+ @output_stream = java.io.ByteArrayOutputStream.new
6
+ @writer = org.gedcomx.util.RecordSetWriter.new(@output_stream)
7
+ end
8
+
9
+ def add_record(record)
10
+ @writer.writeRecord(record.to_java)
11
+ end
12
+
13
+ def close
14
+ @writer.close
15
+ java.lang.String.new(@output_stream.toByteArray).to_s
16
+ end
17
+ end
18
+ end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gedcomx-jruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Alkalai
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-26 00:00:00.000000000 Z
11
+ date: 2015-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
- version_requirements: !ruby/object:Gem::Requirement
15
+ requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.5'
20
- requirement: !ruby/object:Gem::Requirement
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
21
23
  requirements:
22
24
  - - ~>
23
25
  - !ruby/object:Gem::Version
24
26
  version: '1.5'
25
- prerelease: false
26
- type: :development
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
- version_requirements: !ruby/object:Gem::Requirement
29
+ requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
- requirement: !ruby/object:Gem::Requirement
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
35
37
  requirements:
36
38
  - - '>='
37
39
  - !ruby/object:Gem::Version
38
40
  version: '0'
39
- prerelease: false
40
- type: :development
41
41
  description: Provides ruby calls to import, process, and export Gedcomx files
42
42
  email:
43
43
  - djalkalai@gmail.com
@@ -51,11 +51,25 @@ files:
51
51
  - README.md
52
52
  - Rakefile
53
53
  - gedcomx-jruby.gemspec
54
- - lib/gedcomx/gedcomx.rb
54
+ - lib/gedcomx-jruby.rb
55
+ - lib/gedcomx.rb
56
+ - lib/gedcomx/date.rb
57
+ - lib/gedcomx/fact.rb
58
+ - lib/gedcomx/field.rb
59
+ - lib/gedcomx/field_value.rb
60
+ - lib/gedcomx/gender.rb
61
+ - lib/gedcomx/identifier.rb
55
62
  - lib/gedcomx/iterator.rb
56
63
  - lib/gedcomx/jruby/version.rb
64
+ - lib/gedcomx/name.rb
65
+ - lib/gedcomx/name_form.rb
66
+ - lib/gedcomx/name_part.rb
57
67
  - lib/gedcomx/person.rb
68
+ - lib/gedcomx/place.rb
58
69
  - lib/gedcomx/record.rb
70
+ - lib/gedcomx/relationship.rb
71
+ - lib/gedcomx/resource_reference.rb
72
+ - lib/gedcomx/writer.rb
59
73
  - lib/gedcomx_java_jars/enunciate-gedcomx-support-1.0.82.M1-SNAPSHOT-sources.jar
60
74
  - lib/gedcomx_java_jars/enunciate-gedcomx-support-1.0.82.M1-SNAPSHOT.jar
61
75
  - lib/gedcomx_java_jars/familysearch-api-client-1.0.82.M1-SNAPSHOT-sources.jar
@@ -83,7 +97,7 @@ homepage: ''
83
97
  licenses:
84
98
  - MIT
85
99
  metadata: {}
86
- post_install_message:
100
+ post_install_message:
87
101
  rdoc_options: []
88
102
  require_paths:
89
103
  - lib
@@ -98,9 +112,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
112
  - !ruby/object:Gem::Version
99
113
  version: '0'
100
114
  requirements: []
101
- rubyforge_project:
102
- rubygems_version: 2.2.2
103
- signing_key:
115
+ rubyforge_project:
116
+ rubygems_version: 2.0.14
117
+ signing_key:
104
118
  specification_version: 4
105
119
  summary: Gedcomx ruby parser
106
120
  test_files: []
@@ -1,40 +0,0 @@
1
- require "gedcomx/jruby/version"
2
- Dir.glob('lib/gedcomx_java_jars/*.jar').each { |jar| require jar }
3
-
4
- module Gedcomx
5
-
6
- TYPES = {
7
- birth: 'http://gedcomx.org/Birth',
8
- birth_place_father: 'http://gedcomx.org/FatherBirthPlace',
9
- birth_place_mother: 'http://gedcomx.org/MotherBirthPlace',
10
- census: 'http://gedcomx.org/Census',
11
- collection: 'http://gedcomx.org/Collection',
12
- collection_id: 'http://familysearch.org/types/fields/FS_COLLECTION_ID',
13
- couple: 'http://gedcomx.org/Couple',
14
- digital_artifact: 'http://gedcomx.org/DigitalArtifact',
15
- ethnicity: 'http://familysearch.org/types/fields/PR_ETHNICITY_CSS',
16
- female: 'http://gedcomx.org/Female',
17
- given: 'http://gedcomx.org/Given',
18
- household: 'http://familysearch.org/types/fields/HOUSEHOLD_ID',
19
- image_id: 'http://familysearch.org/types/fields/IMAGE_PAL',
20
- immigration: 'http://gedcomx.org/Immigration',
21
- male: 'http://gedcomx.org/Male',
22
- marital_status: 'http://gedcomx.org/MaritalStatus',
23
- month: 'http://gedcomx.org/Month',
24
- parent_child: 'http://gedcomx.org/ParentChild',
25
- persistent: 'http://gedcomx.org/Persistent',
26
- race: 'http://gedcomx.org/Race',
27
- record: 'http://gedcomx.org/Record',
28
- source_line: 'http://familysearch.org/types/fields/SOURCE_LINE_NBR',
29
- source_sheet: 'http://familysearch.org/types/fields/SOURCE_SHEET_NBR_LTR',
30
- source_sheet_letter: 'http://familysearch.org/types/fields/SOURCE_SHEET_LTR',
31
- source_sheet_number: 'http://familysearch.org/types/fields/SOURCE_SHEET_NBR',
32
- surname: 'http://gedcomx.org/Surname',
33
- unique_id: 'http://familysearch.org/types/fields/UNIQUE_IDENTIFIER',
34
- year: 'http://gedcomx.org/Year',
35
- years_married: 'http://familysearch.org/types/fields/PR_CNT_YEARS_MARR'
36
- }
37
-
38
- end
39
-
40
-