fluoroscope 0.0.1
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/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +27 -0
- data/app/views/fluoroscope/_close_fluoroscope.html.erb +2 -0
- data/app/views/fluoroscope/_open_fluoroscope.html.erb +2 -0
- data/config/routes.rb +2 -0
- data/lib/fluoroscope.rb +7 -0
- data/lib/fluoroscope/engine.rb +4 -0
- data/lib/fluoroscope/fluoroscope_renderer.rb +135 -0
- data/lib/fluoroscope/rendering.rb +27 -0
- data/lib/fluoroscope/version.rb +3 -0
- data/lib/tasks/fluoroscope_tasks.rake +4 -0
- metadata +95 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'Fluoroscope'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
data/config/routes.rb
ADDED
data/lib/fluoroscope.rb
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
require 'active_support/core_ext/object/blank'
|
2
|
+
|
3
|
+
module ActionView
|
4
|
+
class FluoroscopeRenderer < AbstractRenderer
|
5
|
+
PARTIAL_NAMES = Hash.new { |h,k| h[k] = {} }
|
6
|
+
|
7
|
+
def initialize(*)
|
8
|
+
super
|
9
|
+
@context_prefix = @lookup_context.prefixes.first
|
10
|
+
@partial_names = PARTIAL_NAMES[@context_prefix]
|
11
|
+
end
|
12
|
+
|
13
|
+
def render(context, options, block)
|
14
|
+
setup(context, options, block)
|
15
|
+
identifier = (@template = find_partial) ? @template.identifier : @path
|
16
|
+
|
17
|
+
@lookup_context.rendered_format ||= begin
|
18
|
+
if @template && @template.formats.present?
|
19
|
+
@template.formats.first
|
20
|
+
else
|
21
|
+
formats.first
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
render_partial
|
26
|
+
end
|
27
|
+
|
28
|
+
def render_partial
|
29
|
+
locals, view, block = @locals, @view, @block
|
30
|
+
object, as = @object, @variable
|
31
|
+
|
32
|
+
if !block && (layout = @options[:layout])
|
33
|
+
layout = find_template(layout.to_s)
|
34
|
+
end
|
35
|
+
|
36
|
+
object ||= locals[as]
|
37
|
+
locals[as] = object
|
38
|
+
|
39
|
+
content = @template.render(view, locals) do |*name|
|
40
|
+
view._layout_for(*name, &block)
|
41
|
+
end
|
42
|
+
|
43
|
+
content = layout.render(view, locals){ content } if layout
|
44
|
+
content
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def setup(context, options, block)
|
50
|
+
@view = context
|
51
|
+
partial = options[:partial]
|
52
|
+
|
53
|
+
@options = options
|
54
|
+
@locals = options[:locals] || {}
|
55
|
+
@block = block
|
56
|
+
@details = extract_details(options)
|
57
|
+
|
58
|
+
if String === partial
|
59
|
+
@object = options[:object]
|
60
|
+
@path = partial
|
61
|
+
else
|
62
|
+
@object = partial
|
63
|
+
@path = partial_path
|
64
|
+
end
|
65
|
+
|
66
|
+
if @path
|
67
|
+
@variable, @variable_counter = retrieve_variable(@path)
|
68
|
+
else
|
69
|
+
paths.map! { |path| retrieve_variable(path).unshift(path) }
|
70
|
+
end
|
71
|
+
|
72
|
+
if String === partial && @variable.to_s !~ /^[a-z_][a-zA-Z_0-9]*$/
|
73
|
+
raise ArgumentError.new("The partial name (#{partial}) is not a valid Ruby identifier; " +
|
74
|
+
"make sure your partial name starts with a letter or underscore, " +
|
75
|
+
"and is followed by any combinations of letters, numbers, or underscores.")
|
76
|
+
end
|
77
|
+
|
78
|
+
extract_format(@path, @details)
|
79
|
+
self
|
80
|
+
end
|
81
|
+
|
82
|
+
def find_partial
|
83
|
+
if path = @path
|
84
|
+
locals = @locals.keys
|
85
|
+
locals << @variable
|
86
|
+
find_template(path, locals)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def find_template(path=@path, locals=@locals.keys)
|
91
|
+
prefixes = path.include?(?/) ? [] : @lookup_context.prefixes
|
92
|
+
@lookup_context.find_template(path, prefixes, true, locals, @details)
|
93
|
+
end
|
94
|
+
|
95
|
+
def partial_path(object = @object)
|
96
|
+
object = object.to_model if object.respond_to?(:to_model)
|
97
|
+
|
98
|
+
path = if object.respond_to?(:to_partial_path)
|
99
|
+
object.to_partial_path
|
100
|
+
else
|
101
|
+
klass = object.class
|
102
|
+
if klass.respond_to?(:model_name)
|
103
|
+
ActiveSupport::Deprecation.warn "ActiveModel-compatible objects whose classes return a #model_name that responds to #partial_path are deprecated. Please respond to #to_partial_path directly instead."
|
104
|
+
klass.model_name.partial_path
|
105
|
+
else
|
106
|
+
raise ArgumentError.new("'#{object.inspect}' is not an ActiveModel-compatible object that returns a valid partial path.")
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
@partial_names[path] ||= merge_prefix_into_object_path(@context_prefix, path.dup)
|
111
|
+
end
|
112
|
+
|
113
|
+
def merge_prefix_into_object_path(prefix, object_path)
|
114
|
+
if prefix.include?(?/) && object_path.include?(?/)
|
115
|
+
prefixes = []
|
116
|
+
prefix_array = File.dirname(prefix).split('/')
|
117
|
+
object_path_array = object_path.split('/')[0..-3] # skip model dir & partial
|
118
|
+
|
119
|
+
prefix_array.each_with_index do |dir, index|
|
120
|
+
break if dir == object_path_array[index]
|
121
|
+
prefixes << dir
|
122
|
+
end
|
123
|
+
|
124
|
+
(prefixes << object_path).join("/")
|
125
|
+
else
|
126
|
+
object_path
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def retrieve_variable(path)
|
131
|
+
variable = @options.fetch(:as) { path[%r'_?(\w+)(\.\w+)*$', 1] }.try(:to_sym)
|
132
|
+
[variable]
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ActionView
|
2
|
+
class PartialRenderer
|
3
|
+
alias_method :render_original, :render
|
4
|
+
def render(context, options, block)
|
5
|
+
if context.request.params[:fluoroscope] == 'true'
|
6
|
+
setup(context, options, block)
|
7
|
+
fluoroscope_renderer = FluoroscopeRenderer.new(@lookup_context)
|
8
|
+
result = ActionView::OutputBuffer.new
|
9
|
+
template = find_template(path=@path, locals=@locals.keys).inspect
|
10
|
+
|
11
|
+
result << fluoroscope_renderer.render(context,
|
12
|
+
{:partial => '/fluoroscope/open_fluoroscope',
|
13
|
+
:locals => {:path => template}
|
14
|
+
}, nil)
|
15
|
+
result << render_original(context, options, block)
|
16
|
+
result << fluoroscope_renderer.render(context,
|
17
|
+
{:partial => '/fluoroscope/close_fluoroscope',
|
18
|
+
:locals => {:path => template}
|
19
|
+
}, nil)
|
20
|
+
result
|
21
|
+
else
|
22
|
+
render_original(context, options, block)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluoroscope
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Steve Saarinen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '3.2'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.2'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec-rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Provides inline browser access to rendering details and page makeup.
|
47
|
+
email:
|
48
|
+
- ssaarinen@whitepages.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- app/views/fluoroscope/_close_fluoroscope.html.erb
|
54
|
+
- app/views/fluoroscope/_open_fluoroscope.html.erb
|
55
|
+
- config/routes.rb
|
56
|
+
- lib/fluoroscope/engine.rb
|
57
|
+
- lib/fluoroscope/fluoroscope_renderer.rb
|
58
|
+
- lib/fluoroscope/rendering.rb
|
59
|
+
- lib/fluoroscope/version.rb
|
60
|
+
- lib/fluoroscope.rb
|
61
|
+
- lib/tasks/fluoroscope_tasks.rake
|
62
|
+
- MIT-LICENSE
|
63
|
+
- Rakefile
|
64
|
+
- README.rdoc
|
65
|
+
homepage: http://www.whitepages.com
|
66
|
+
licenses: []
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
hash: 3909471059743653126
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
hash: 3909471059743653126
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 1.8.24
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: Rails rendering analyzer
|
95
|
+
test_files: []
|