iq_rdf 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -15,7 +15,7 @@
15
15
  require 'bundler'
16
16
  Bundler::GemHelper.install_tasks
17
17
 
18
- require 'rake/rdoctask'
18
+ require 'rdoc/task'
19
19
  require 'rake/testtask'
20
20
 
21
21
  Rake::RDocTask.new do |rdoc|
@@ -34,7 +34,6 @@ require 'uri'
34
34
 
35
35
  if defined?(ActionView::Template)
36
36
  require 'iq_rdf/rails/iq_rdf'
37
- ActionView::Template.register_template_handler('iqrdf', ActionView::Template::Handlers::IqRdf)
38
37
  end
39
38
 
40
39
  # The main module of IqRdf.
@@ -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
- class IqRdf
37
+ if Rails.version >= "3"
19
38
 
39
+ class Template::Handlers::IqRdf
20
40
  def self.call(template)
21
- <<-EOV
22
-
23
- document = IqRdf::Document.new()
24
- #{template.source}
25
- if params[:format].to_s == "ttl"
26
- controller.response.headers["Content-Type"] ||= 'text/turtle'
27
- document.to_turtle
28
- elsif params[:format].to_s == "nt"
29
- controller.response.headers["Content-Type"] ||= 'text/plain'
30
- document.to_ntriples
31
- elsif params[:format].to_s == "rdf"
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
@@ -13,5 +13,5 @@
13
13
  # limitations under the License.
14
14
 
15
15
  module IqRdf
16
- VERSION = "0.1.3"
16
+ VERSION = "0.1.4"
17
17
  end
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: 29
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Till Schulte-Coerne