rghost_rails 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/rghost_rails.rb +30 -23
  2. metadata +22 -11
data/lib/rghost_rails.rb CHANGED
@@ -6,29 +6,36 @@ end
6
6
 
7
7
  class ActionController::Base
8
8
  def rghost_render(format, options)
9
- v=case options[:report]
9
+ report = options.delete(:report)
10
+
11
+ template = case report
10
12
  when Hash
11
- File.join(view_paths, options[:report][:controller] ||self.controller_name, options[:report][:action])
12
- when String,Symbol
13
- File.join(view_paths, controller_path, options[:report].to_s)
13
+ File.join(report[:controller] || controller_name, report[:action])
14
+ when String, Symbol
15
+ File.join(controller_path, report.to_s)
14
16
  when NilClass
15
- File.join(view_paths, controller_path, self.action_name)
17
+ File.join(controller_path, action_name)
18
+ end
19
+
20
+ template = view_paths.find_template(template, "rghost.rb", false)
21
+
22
+ ActionView::Helpers.included_modules.each do |m|
23
+ extend m
16
24
  end
17
-
18
- ActionView::Helpers.included_modules.each{|m| extend m}
19
- r=File.readlines("#{v}.rghost.rb")
20
- @__rgdoc__=nil
21
- eval("@__rgdoc__=#{r}")
22
- #instance_eval("@__doc__=#{r}")
23
- options.delete(:report)
24
- filename=options.delete(:filename)
25
- disposition=options.delete(:disposition)
26
-
27
- rg=@__rgdoc__.render(format,options)
28
- out=rg.output
29
- raise "RGhost::Error #{rg.errors} - #{out}" if rg.error?
30
- data=out.readlines.join
31
- rg.clear_output
32
- send_data(data, :filename => filename, :disposition => disposition, :type => Mime::Type.lookup_by_extension(format.to_s))
33
- end
34
- end
25
+
26
+ lines = File.readlines(template.filename)
27
+ doc = eval(lines.join)
28
+
29
+ filename = options.delete(:filename)
30
+ rghost = doc.render(format, options)
31
+ output = rghost.output
32
+
33
+ raise "RGhost::Error #{rghost.errors} - #{output}" if rghost.error?
34
+
35
+ data = output.readlines.join
36
+ rghost.clear_output
37
+
38
+ send_data(data, :filename => filename, :type => Mime::Type.lookup_by_extension(format.to_s))
39
+ end
40
+ end
41
+
metadata CHANGED
@@ -1,29 +1,38 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rghost_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 2
9
+ version: 0.3.2
5
10
  platform: ruby
6
11
  authors:
7
- - Shairon Toledo
12
+ - Shairon Toledo, Gabriel Sobrinho
8
13
  autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-03-06 00:00:00 -05:00
17
+ date: 2010-06-01 00:00:00 -04:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rghost
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 8
30
+ - 7
23
31
  version: 0.8.7
24
- version:
32
+ type: :runtime
33
+ version_requirements: *id001
25
34
  description:
26
- email: shairon.toledo@gmail.com
35
+ email: shairon.toledo@gmail.com, gabriel.sobrinho@gmail.com
27
36
  executables: []
28
37
 
29
38
  extensions: []
@@ -45,18 +54,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
45
54
  requirements:
46
55
  - - ">="
47
56
  - !ruby/object:Gem::Version
57
+ segments:
58
+ - 0
48
59
  version: "0"
49
- version:
50
60
  required_rubygems_version: !ruby/object:Gem::Requirement
51
61
  requirements:
52
62
  - - ">="
53
63
  - !ruby/object:Gem::Version
64
+ segments:
65
+ - 0
54
66
  version: "0"
55
- version:
56
67
  requirements: []
57
68
 
58
69
  rubyforge_project: An Rails adapter to work with RGhost in the view layer
59
- rubygems_version: 1.3.5
70
+ rubygems_version: 1.3.6
60
71
  signing_key:
61
72
  specification_version: 3
62
73
  summary: A Rails adapter to work with RGhost in the view layer