jena-jruby 0.4.0-java → 0.4.1-java

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 CHANGED
@@ -6,3 +6,4 @@ pkg
6
6
  .buildpath
7
7
  rdoc
8
8
  pkg
9
+ *~
@@ -25,8 +25,8 @@ cp $tdb_root/target/dependency/*.jar javalib
25
25
  cp $tdb_root/target/jena-tdb-*SNAPSHOT.jar $tdb_root/target/tdb-*{0,1,2,3,4,5,6,7,8,9}.jar javalib 2>/dev/null
26
26
  rm -f javalib/*test*.jar
27
27
 
28
- #echo "Creating log4j config"
29
- #jar -cf javalib/log4j-config.jar log4j.xml
28
+ echo "Creating log4j config"
29
+ jar -cf javalib/log4j-config.jar log4j.xml
30
30
 
31
31
 
32
32
 
Binary file
data/jena-jruby.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform.new("java")
9
9
  s.authors = ["Ian Dickinson"]
10
10
  s.email = ["ian@epimorphics.com"]
11
- s.homepage = ""
11
+ s.homepage = "https://github.com/ephemerian/jena-jruby"
12
12
  s.summary = %q{JRuby wrapper for Apache Jena}
13
13
  s.description = %q{A simple packaging of Apache Jena for JRuby}
14
14
 
@@ -2,18 +2,21 @@
2
2
  # Use mvn dependency:tree to show deps from the pom.xml
3
3
 
4
4
  %w[
5
- log4j-1.2.16.jar
6
- slf4j-api-1.6.4.jar
7
- slf4j-log4j12-1.6.4.jar
5
+ log4j-config.jar
8
6
  commons-codec-1.5.jar
7
+ hamcrest-core-1.1.jar
9
8
  httpclient-4.1.2.jar
10
9
  httpcore-4.1.3.jar
11
- jena-iri-0.9.1-SNAPSHOT.jar
10
+ junit-4.9.jar
11
+ log4j-1.2.16.jar
12
+ slf4j-api-1.6.4.jar
13
+ slf4j-log4j12-1.6.4.jar
12
14
  xercesImpl-2.10.0.jar
13
15
  xml-apis-1.4.01.jar
14
- jena-core-2.7.1-SNAPSHOT.jar
15
- jena-arq-2.9.1-SNAPSHOT.jar
16
- jena-tdb-0.9.1-SNAPSHOT.jar
16
+ jena-iri-0.9.2-SNAPSHOT.jar
17
+ jena-core-2.7.2-SNAPSHOT.jar
18
+ jena-arq-2.9.2-SNAPSHOT.jar
19
+ jena-tdb-0.9.2-SNAPSHOT.jar
17
20
  ].each do |jar|
18
21
  require jar
19
22
  end
@@ -71,8 +71,12 @@ module Jena
71
71
  # @param options [Hash] Options (see above)
72
72
  # @return [Array] Non-empty array of hashes, one per result
73
73
  def self.describe( m, query, options = nil )
74
- qexec = setup_query_execution( m, query, options )
74
+ describe_qe( setup_query_execution( m, query, options ) )
75
+ end
75
76
 
77
+ # Perform a describe query using the given query execution object, and
78
+ # return the resulting model
79
+ def self.describe_qe( qexec )
76
80
  begin
77
81
  return qexec.execDescribe
78
82
  ensure
@@ -146,6 +150,32 @@ module Jena
146
150
  select_each_qe( sparql_service( url, query ), *vars, &block )
147
151
  end
148
152
 
153
+ # Return a model from a describe query against a remote SPARQL endpoint
154
+ def self.service_describe( url, query )
155
+ describe_qe( sparql_service( url, query ) )
156
+ end
157
+
158
+ # Format a given value in a manner suitable for inclusion in a SPARQL query
159
+ def self.sparql_format( value )
160
+ if value.is_a? Core::Resource
161
+ value.is_anon ? "_:#{value.get_id.to_string.gsub(/[^[[:alnum:]]]/, '_')}" : "<#{value.get_uri}>"
162
+ elsif value.is_a? Core::Literal
163
+ if dt = value.get_datatype_uri
164
+ "\"#{value.get_lexical_form}\"^^<#{dt}>"
165
+ else
166
+ "\"#{value.to_string}\""
167
+ end
168
+ elsif value.to_s =~ /\A(file|http):\/\//
169
+ "<#{value}>"
170
+ elsif value.to_s =~ /\A[-_[[:alnum:]]]*:/
171
+ # looks like a qname
172
+ value.to_s
173
+ else
174
+ # guess
175
+ "\"#{value.to_s}\""
176
+ end
177
+ end
178
+
149
179
  :private
150
180
 
151
181
  def self.option( options, opt, default )
@@ -12,9 +12,9 @@ module Jena
12
12
  pm
13
13
  end
14
14
 
15
- # Return a new resource URN made from a UUID
16
- def self.uuid_resource
17
- Core::ResourceFactory.createResource( Util::JenaUUID.factory.generate.asURN )
15
+ # Return a new resource URN made from a UUID. If the given
16
+ def self.uuid_resource( model = nil )
17
+ (model || Core::ResourceFactory).createResource( Util::JenaUUID.factory.generate.asURN )
18
18
  end
19
19
 
20
20
  # Return the current time as a literal
@@ -1,5 +1,5 @@
1
1
  module Jena
2
2
  JENA_VERSION='2.7.1-SNAPSHOT'
3
3
  TDB_VERSION='0.9.1-SNAPSHOT'
4
- JENA_JRUBY_GEM_VERSION='0.4.0'
4
+ JENA_JRUBY_GEM_VERSION='0.4.1'
5
5
  end
data/lib/jena_jruby.rb CHANGED
@@ -91,19 +91,29 @@ module Jena
91
91
 
92
92
  module Query
93
93
  java_import com.hp.hpl.jena.query.ARQ
94
- java_import com.hp.hpl.jena.query.DatasetFactory
94
+ java_import com.hp.hpl.jena.query.BIOInput
95
95
  java_import com.hp.hpl.jena.query.Dataset
96
+ java_import com.hp.hpl.jena.query.DatasetFactory
96
97
  java_import com.hp.hpl.jena.query.DataSource
97
- java_import com.hp.hpl.jena.query.QueryExecutionFactory
98
+ java_import com.hp.hpl.jena.query.LabelExistsException
99
+ java_import com.hp.hpl.jena.query.ParameterizedSparqlString
100
+ java_import com.hp.hpl.jena.query.Query
101
+ java_import com.hp.hpl.jena.query.QueryBuildException
102
+ java_import com.hp.hpl.jena.query.QueryCancelledException
103
+ java_import com.hp.hpl.jena.query.QueryException
104
+ java_import com.hp.hpl.jena.query.QueryExecException
98
105
  java_import com.hp.hpl.jena.query.QueryExecution
106
+ java_import com.hp.hpl.jena.query.QueryExecutionFactory
99
107
  java_import com.hp.hpl.jena.query.QueryFactory
100
- java_import com.hp.hpl.jena.query.Query
108
+ java_import com.hp.hpl.jena.query.QueryFatalException
109
+ java_import com.hp.hpl.jena.query.QueryParseException
101
110
  java_import com.hp.hpl.jena.query.QuerySolution
102
111
  java_import com.hp.hpl.jena.query.QuerySolutionMap
103
112
  java_import com.hp.hpl.jena.query.QueryVisitor
113
+ java_import com.hp.hpl.jena.query.ReadWrite
114
+ java_import com.hp.hpl.jena.query.ResultSet
104
115
  java_import com.hp.hpl.jena.query.ResultSetFactory
105
116
  java_import com.hp.hpl.jena.query.ResultSetFormatter
106
- java_import com.hp.hpl.jena.query.ResultSet
107
117
  java_import com.hp.hpl.jena.query.ResultSetRewindable
108
118
  java_import com.hp.hpl.jena.query.SortCondition
109
119
  java_import com.hp.hpl.jena.query.Syntax
@@ -153,6 +163,17 @@ module Jena
153
163
  java_import com.hp.hpl.jena.tdb.TDBLoader
154
164
  java_import com.hp.hpl.jena.tdb.TDBFactory
155
165
  end
166
+
167
+ module Assembler
168
+ java_import com.hp.hpl.jena.assembler.Assembler
169
+ java_import com.hp.hpl.jena.assembler.Content
170
+ java_import com.hp.hpl.jena.assembler.AssemblerHelp
171
+ java_import com.hp.hpl.jena.assembler.JA
172
+ java_import com.hp.hpl.jena.assembler.Mode
173
+ java_import com.hp.hpl.jena.assembler.ModelExpansion
174
+ java_import com.hp.hpl.jena.assembler.ImportManager
175
+ java_import com.hp.hpl.jena.assembler.RuleSet
176
+ end
156
177
  end
157
178
 
158
179
  %w[
@@ -103,4 +103,14 @@ class QueryUtilsTest < Test::Unit::TestCase
103
103
  result = Jena::Query.select_first @m, "select * {?s ?p 42}"
104
104
  assert_nil result
105
105
  end
106
+
107
+ # SPARQL formatting tests
108
+ def test_sparql_format
109
+ assert_equal "<http://foo.bar>", Jena::Query.sparql_format( @m.create_resource( "http://foo.bar" ))
110
+ assert_equal '"foo"', Jena::Query.sparql_format( @m.create_literal( "foo" ))
111
+ assert_equal '"42"^^<http://www.w3.org/2001/XMLSchema#long>', Jena::Query.sparql_format( @m.create_typed_literal( 42 ))
112
+ assert_equal "foo:bar", Jena::Query.sparql_format( "foo:bar" )
113
+ assert_equal "<http://foo.bar>", Jena::Query.sparql_format( "http://foo.bar" )
114
+ assert Jena::Query.sparql_format( @m.create_resource ).match( /_:([[:alnum:]]*)/ )
115
+ end
106
116
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jena-jruby
3
3
  version: !ruby/object:Gem::Version
4
+ version: 0.4.1
4
5
  prerelease:
5
- version: 0.4.0
6
6
  platform: java
7
7
  authors:
8
8
  - Ian Dickinson
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-07 00:00:00.000000000 Z
12
+ date: 2012-09-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: haml
@@ -72,19 +72,20 @@ files:
72
72
  - test/query_utils_test.rb
73
73
  - javalib/httpclient-4.1.2.jar
74
74
  - javalib/hamcrest-core-1.1.jar
75
- - javalib/jena-tdb-0.9.1-SNAPSHOT.jar
76
- - javalib/jena-core-2.7.1-SNAPSHOT.jar
75
+ - javalib/jena-iri-0.9.2-SNAPSHOT.jar
76
+ - javalib/jena-arq-2.9.2-SNAPSHOT.jar
77
77
  - javalib/xml-apis-1.4.01.jar
78
78
  - javalib/xercesImpl-2.10.0.jar
79
+ - javalib/jena-tdb-0.9.2-SNAPSHOT.jar
79
80
  - javalib/slf4j-api-1.6.4.jar
81
+ - javalib/log4j-config.jar
80
82
  - javalib/httpcore-4.1.3.jar
83
+ - javalib/jena-core-2.7.2-SNAPSHOT.jar
81
84
  - javalib/log4j-1.2.16.jar
82
- - javalib/jena-arq-2.9.1-SNAPSHOT.jar
83
- - javalib/jena-iri-0.9.1-SNAPSHOT.jar
84
85
  - javalib/junit-4.9.jar
85
86
  - javalib/commons-codec-1.5.jar
86
87
  - javalib/slf4j-log4j12-1.6.4.jar
87
- homepage: ''
88
+ homepage: https://github.com/ephemerian/jena-jruby
88
89
  licenses: []
89
90
  post_install_message:
90
91
  rdoc_options: []