iq_rdf 0.1.3 → 0.1.4
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/Rakefile +1 -1
- data/lib/iq_rdf.rb +0 -1
- data/lib/iq_rdf/rails/iq_rdf.rb +36 -20
- data/lib/iq_rdf/version.rb +1 -1
- metadata +3 -3
data/Rakefile
CHANGED
data/lib/iq_rdf.rb
CHANGED
data/lib/iq_rdf/rails/iq_rdf.rb
CHANGED
@@ -12,32 +12,48 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
+
def IqRdf.rails_template(template)
|
16
|
+
<<-EOV
|
17
|
+
document = IqRdf::Document.new()
|
18
|
+
#{template.source}
|
19
|
+
if params[:format].to_s == "ttl"
|
20
|
+
controller.response.headers["Content-Type"] ||= 'text/turtle'
|
21
|
+
document.to_turtle
|
22
|
+
elsif params[:format].to_s == "nt"
|
23
|
+
controller.response.headers["Content-Type"] ||= 'text/plain'
|
24
|
+
document.to_ntriples
|
25
|
+
elsif params[:format].to_s == "rdf"
|
26
|
+
controller.response.headers["Content-Type"] ||= 'application/xml+rdf'
|
27
|
+
document.to_xml
|
28
|
+
else # Default => turtle
|
29
|
+
controller.response.headers["Content-Type"] ||= 'text/turtle'
|
30
|
+
document.to_turtle
|
31
|
+
end
|
32
|
+
EOV
|
33
|
+
end
|
34
|
+
|
15
35
|
module ActionView
|
16
|
-
module Template::Handlers
|
17
36
|
|
18
|
-
|
37
|
+
if Rails.version >= "3"
|
19
38
|
|
39
|
+
class Template::Handlers::IqRdf
|
20
40
|
def self.call(template)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
controller.response.headers["Content-Type"] ||= 'application/xml+rdf'
|
33
|
-
document.to_xml
|
34
|
-
else # Default => turtle
|
35
|
-
controller.response.headers["Content-Type"] ||= 'text/turtle'
|
36
|
-
document.to_turtle
|
37
|
-
end
|
38
|
-
EOV
|
41
|
+
IqRdf.rails_template(template)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
ActionView::Template.register_template_handler('iqrdf', ActionView::Template::Handlers::IqRdf)
|
45
|
+
|
46
|
+
else
|
47
|
+
|
48
|
+
class TemplateHandlers::IqRdf < ActionView::TemplateHandler
|
49
|
+
include ActionView::TemplateHandlers::Compilable
|
50
|
+
def compile(template)
|
51
|
+
IqRdf.rails_template(template)
|
39
52
|
end
|
40
53
|
end
|
54
|
+
ActionView::Template.register_template_handler('iqrdf', ActionView::TemplateHandlers::IqRdf)
|
41
55
|
|
42
56
|
end
|
57
|
+
|
58
|
+
|
43
59
|
end
|
data/lib/iq_rdf/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iq_rdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Till Schulte-Coerne
|