rtm 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/activetopicmaps.rb +55 -6
- data/lib/rtm.rb +27 -8
- data/lib/rtm/backend/active_record.rb +29 -24
- data/lib/rtm/backend/active_record/association_and_role.rb +3 -24
- data/lib/rtm/backend/active_record/locators.rb +2 -0
- data/lib/rtm/backend/active_record/name_variant_occurrence.rb +5 -4
- data/lib/rtm/backend/active_record/tm_delegator.rb +0 -75
- data/lib/rtm/backend/active_record/tmdm.rb +5 -0
- data/lib/rtm/backend/active_record/topic.rb +10 -76
- data/lib/rtm/backend/active_record/topic_map.rb +30 -1
- data/lib/rtm/backend/active_record/traverse_associations.rb +86 -0
- data/lib/rtm/io/from_xtm2_libxml.rb +1 -1
- data/lib/rtm/locator_helpers.rb +16 -0
- data/lib/rtm/sugar/role/counterparts.rb +51 -0
- data/lib/rtm/sugar/topic/characteristics.rb +15 -0
- data/lib/rtm/sugar/topic/counterparts.rb +15 -0
- data/lib/rtm/sugar/topic/hash_access.rb +55 -0
- data/lib/rtm/sugar/topic/identifier_direct.rb +11 -0
- data/lib/rtm/sugar/topic/predefined_associations.rb +42 -0
- data/test/base_test.rb +153 -0
- metadata +84 -67
- data/lib/rtm/io/from_xtm2_jaxp.rb +0 -89
metadata
CHANGED
@@ -1,39 +1,48 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
2
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
3
|
-
requirements:
|
4
|
-
- - '>='
|
5
|
-
- !ruby/object:Gem::Version
|
6
|
-
version: !str 0
|
7
|
-
version:
|
8
|
-
email: bb--rtm-gem@bockb.de
|
9
|
-
cert_chain: []
|
10
|
-
summary: Ruby Topic Maps is a Topic Maps engine written in Ruby.
|
11
|
-
post_install_message:
|
12
|
-
extra_rdoc_files: []
|
13
|
-
homepage: http://rtm.rubyforge.org/
|
14
|
-
signing_key:
|
1
|
+
--- !ruby/object:Gem::Specification
|
15
2
|
name: rtm
|
16
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Benjamin Bock
|
17
8
|
autorequire:
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-10-01 00:00:00 +02:00
|
22
13
|
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activerecord
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.1.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: activesupport
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.1.0
|
34
|
+
version:
|
35
|
+
description: Ruby Topic Maps is a Topic Maps engine written in Ruby.
|
36
|
+
email: bb--rtm-gem@bockb.de
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
23
43
|
files:
|
24
44
|
- lib/activetopicmaps.rb
|
25
45
|
- lib/Rakefile.rb
|
26
|
-
- lib/rtm.rb
|
27
|
-
- lib/rtm/base.rb
|
28
|
-
- lib/rtm/connect.rb
|
29
|
-
- lib/rtm/core_ext.rb
|
30
|
-
- lib/rtm/extensions.rb
|
31
|
-
- lib/rtm/helpers.rb
|
32
|
-
- lib/rtm/locator_helpers.rb
|
33
|
-
- lib/rtm/pimp_my_api.rb
|
34
|
-
- lib/rtm/psi.rb
|
35
|
-
- lib/rtm/validation.rb
|
36
|
-
- lib/rtm/backend/active_record.rb
|
37
46
|
- lib/rtm/backend/active_record/001_initial_schema.rb
|
38
47
|
- lib/rtm/backend/active_record/association_and_role.rb
|
39
48
|
- lib/rtm/backend/active_record/locators.rb
|
@@ -47,55 +56,63 @@ files:
|
|
47
56
|
- lib/rtm/backend/active_record/tm_set_delegator.rb
|
48
57
|
- lib/rtm/backend/active_record/topic.rb
|
49
58
|
- lib/rtm/backend/active_record/topic_map.rb
|
59
|
+
- lib/rtm/backend/active_record/traverse_associations.rb
|
60
|
+
- lib/rtm/backend/active_record.rb
|
61
|
+
- lib/rtm/base.rb
|
62
|
+
- lib/rtm/connect.rb
|
63
|
+
- lib/rtm/core_ext.rb
|
64
|
+
- lib/rtm/extensions.rb
|
65
|
+
- lib/rtm/helpers.rb
|
50
66
|
- lib/rtm/io/from_xtm2.rb
|
51
|
-
- lib/rtm/io/from_xtm2_jaxp.rb
|
52
67
|
- lib/rtm/io/from_xtm2_libxml.rb
|
53
68
|
- lib/rtm/io/to_jtm.rb
|
54
69
|
- lib/rtm/io/to_string.rb
|
55
70
|
- lib/rtm/io/to_xtm1.rb
|
56
71
|
- lib/rtm/io/to_xtm2.rb
|
57
72
|
- lib/rtm/io/to_yaml.rb
|
73
|
+
- lib/rtm/locator_helpers.rb
|
58
74
|
- lib/rtm/merging/merging.rb
|
75
|
+
- lib/rtm/pimp_my_api.rb
|
76
|
+
- lib/rtm/psi.rb
|
77
|
+
- lib/rtm/sugar/role/counterparts.rb
|
78
|
+
- lib/rtm/sugar/topic/characteristics.rb
|
79
|
+
- lib/rtm/sugar/topic/counterparts.rb
|
80
|
+
- lib/rtm/sugar/topic/hash_access.rb
|
81
|
+
- lib/rtm/sugar/topic/identifier_direct.rb
|
82
|
+
- lib/rtm/sugar/topic/predefined_associations.rb
|
83
|
+
- lib/rtm/validation.rb
|
84
|
+
- lib/rtm.rb
|
85
|
+
- test/base_test.rb
|
59
86
|
- COPYRIGHT
|
60
87
|
- DISCLAIMER
|
61
88
|
- README
|
62
|
-
|
89
|
+
has_rdoc: false
|
90
|
+
homepage: http://rtm.rubyforge.org/
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
97
|
requirements:
|
64
|
-
- -
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: "0"
|
101
|
+
version:
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: "0"
|
67
107
|
version:
|
68
|
-
extensions: []
|
69
|
-
rubygems_version: 1.0.1
|
70
108
|
requirements:
|
71
|
-
-
|
72
|
-
|
73
|
-
-
|
74
|
-
|
75
|
-
|
109
|
+
- json_pure >= 1.1.2
|
110
|
+
- sqlite3-ruby >= 1.2.2
|
111
|
+
- libxml-ruby >= 0.6.0
|
112
|
+
rubyforge_project: rtm
|
113
|
+
rubygems_version: 1.2.0
|
114
|
+
signing_key:
|
115
|
+
specification_version: 2
|
116
|
+
summary: Ruby Topic Maps is a Topic Maps engine written in Ruby.
|
76
117
|
test_files: []
|
77
|
-
|
78
|
-
version: 0.1.1
|
79
|
-
require_paths:
|
80
|
-
- lib
|
81
|
-
dependencies:
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
|
-
version_requirements: !ruby/object:Gem::Requirement
|
84
|
-
requirements:
|
85
|
-
- - '>='
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
version: 2.0.1
|
88
|
-
version:
|
89
|
-
version_requirement:
|
90
|
-
name: activerecord
|
91
|
-
- !ruby/object:Gem::Dependency
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - '>='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 2.0.1
|
97
|
-
version:
|
98
|
-
version_requirement:
|
99
|
-
name: activesupport
|
100
|
-
bindir: bin
|
101
|
-
has_rdoc: false
|
118
|
+
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require 'java'
|
2
|
-
include_class %w[SAXParser SAXParserFactory].map{|i| "javax.xml.parsers.#{i}"}
|
3
|
-
|
4
|
-
module RTM::IO
|
5
|
-
# XTM2 Import using JAXP
|
6
|
-
|
7
|
-
module FROMXTM2JAXP
|
8
|
-
XTM2DEBUG = false
|
9
|
-
# Reads XTM2 from source (io object).
|
10
|
-
# Example: RTM::IO::FROMXTM2JAXP.from_xtm2(File.open(file_name),"http://rtm.rubyforge.org/topicmaps/tm1/")
|
11
|
-
# supported options:
|
12
|
-
# :strip_whitespace (defaults to false, may be set to true),
|
13
|
-
# :deprefix (defaults to nil, may be set to a string (or regex) which will be removed from the beginning of an (unresolved) item_identifier if it is there.
|
14
|
-
def self.from_xtm2(source, base_locator, target=nil,options={})
|
15
|
-
tm = RTM.create(base_locator) unless target
|
16
|
-
factory = javax.xml.parsers.SAXParserFactory.newInstance()
|
17
|
-
# Specifies that the parser produced by this code will provide support for XML namespaces.
|
18
|
-
factory.setNamespaceAware(true);
|
19
|
-
# Specifies that the parser produced by this code will validate documents as they are parsed.
|
20
|
-
factory.setValidating(true);
|
21
|
-
parser = factory.newSAXParser();
|
22
|
-
internal_handler = FROMXTM2::XTM2Listener.new(base_locator, target || tm, options)
|
23
|
-
#internal_handler = EmptyHandler.new
|
24
|
-
handler = XML::JAXPSax2wrapper.new(internal_handler)
|
25
|
-
parser.parse(source, handler)
|
26
|
-
#true
|
27
|
-
end
|
28
|
-
end
|
29
|
-
class EmptyHandler
|
30
|
-
def start_document(*args)
|
31
|
-
end
|
32
|
-
def end_document(*args)
|
33
|
-
end
|
34
|
-
def start_element(*args)
|
35
|
-
puts "start_element: #{args.inspect}"
|
36
|
-
end
|
37
|
-
def end_element(*args)
|
38
|
-
puts "end_element: #{args.inspect}"
|
39
|
-
end
|
40
|
-
def characters(*args)
|
41
|
-
puts "characters: #{args.inspect}"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
module XML
|
47
|
-
# Acts as Callback structure for the JAXP SAX Parser and calls
|
48
|
-
# a REXML SAX2Listener API.
|
49
|
-
include_class "org.xml.sax.helpers.DefaultHandler"
|
50
|
-
class JAXPSax2wrapper < DefaultHandler
|
51
|
-
def initialize(rexml_sax2listener)
|
52
|
-
super()
|
53
|
-
@dest = rexml_sax2listener
|
54
|
-
end
|
55
|
-
def startDocument
|
56
|
-
@dest.start_document
|
57
|
-
end
|
58
|
-
def endDocument
|
59
|
-
@dest.end_document
|
60
|
-
end
|
61
|
-
def startElement(namespaceURI, localName, qName, attr)
|
62
|
-
# copy attributes into hash - this is NOT namespace aware!
|
63
|
-
# comments for implementing namespace-awareness:
|
64
|
-
# if qname==localname, namespace uri seems to be == ""
|
65
|
-
# if uri is "" it should be expanded to the default ns which might be http://www.topicmaps.org/xtm/ if we are "main"
|
66
|
-
# the following just takes all attributes and passes them on, with their qnames,
|
67
|
-
# so it possibly won't work if attributes we need have a namespace declared, even if it is correct.
|
68
|
-
attr2 = {}
|
69
|
-
attr.length.times {|i| attr2[attr.qname(i)] = attr.value(i)}
|
70
|
-
@dest.start_element(namespaceURI, localName, qName, attr2)
|
71
|
-
end
|
72
|
-
|
73
|
-
def characters(ch, start, length)
|
74
|
-
s = java.lang.String.new(ch,start,length).to_s # hard work to get a ruby string out of a java char[]
|
75
|
-
s.strip!
|
76
|
-
return if s.size == 0 # we suppress whitespace-only characters. it's not 100% correct but...
|
77
|
-
@dest.characters(s)
|
78
|
-
end
|
79
|
-
|
80
|
-
def endElement(namespaceURI, localName, qName)
|
81
|
-
# puts "endElement: #{namespaceURI.inspect} #{localName.inspect} #{qName.inspect}"
|
82
|
-
@dest.end_element(namespaceURI, localName, qName)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|