merbiful-release 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'pathname'
5
5
 
6
6
  PLUGIN = "merbiful-release"
7
7
  NAME = "merbiful-release"
8
- GEM_VERSION = "0.2.2"
8
+ GEM_VERSION = "0.2.3"
9
9
  AUTHOR = "Martin Kihlgren"
10
10
  EMAIL = "martin@wemind.se"
11
11
  HOMEPAGE = ""
@@ -14,9 +14,19 @@ module Merbiful
14
14
  self.body
15
15
  else
16
16
  controller.send(Merb::Template::METHOD_LIST[render_id] ||=
17
- Merb::Template::EXTENSIONS[self.filter].compile_template(FAKE_IO_CLASS.new(self.body, render_id),
18
- render_id,
19
- Merb::InlineTemplates))
17
+ begin
18
+ filter = Merb::Template::EXTENSIONS[self.filter]
19
+ if filter.method(:compile_template).arity == 3
20
+ Merb::Template::EXTENSIONS[self.filter].compile_template(FAKE_IO_CLASS.new(self.body, render_id),
21
+ render_id,
22
+ Merb::InlineTemplates)
23
+ elsif filter.method(:compile_template).arity == 4
24
+ Merb::Template::EXTENSIONS[self.filter].compile_template(FAKE_IO_CLASS.new(self.body, render_id),
25
+ render_id,
26
+ [],
27
+ Merb::InlineTemplates)
28
+ end
29
+ end)
20
30
  end
21
31
  unless Merb.environment == "development"
22
32
  caches.each do |destination, to_cache|
@@ -3,17 +3,26 @@ module Merbiful
3
3
 
4
4
  module Body
5
5
 
6
+ FAKE_IO_CLASS = Struct.new(:read, :path)
7
+
8
+ def render_id
9
+ Merb::Template.template_name("#{self.class}##{self.id}")
10
+ end
11
+
6
12
  def render(controller, caches = {})
7
13
  rval = if self.filter.blank?
8
14
  self.body
9
15
  else
10
- filter_class = Merbiful.const_get(self.filter.to_sym)
11
- filter_class.new.render(self.body, controller)
16
+ controller.send(Merb::Template::METHOD_LIST[render_id] ||=
17
+ Merb::Template::EXTENSIONS[self.filter].compile_template(FAKE_IO_CLASS.new(self.body, render_id),
18
+ render_id,
19
+ [],
20
+ Merb::InlineTemplates))
12
21
  end
13
22
  unless Merb.environment == "development"
14
23
  caches.each do |destination, to_cache|
15
24
  if to_cache
16
- path = Pathname.new(File.join(Merb.root, "public", destination))
25
+ path = destination.cached_path
17
26
  Merb.logger.info("Flushing to #{path.inspect}")
18
27
  path.parent.mkpath
19
28
  path.open("w") do |out|
@@ -25,12 +34,6 @@ module Merbiful
25
34
  return rval
26
35
  end
27
36
 
28
- def clear_cache(target)
29
- return if target == "/"
30
- path = Pathname.new(File.join(Merb.root, "public", target))
31
- path.unlink if path.exist?
32
- end
33
-
34
37
  end
35
38
 
36
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merbiful-release
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Kihlgren