partial_logging 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c12799ac6163e83c9a716bc617ce3d891aea3191
4
+ data.tar.gz: 9b55c125b0e4278e1389b86334342d26fd3c316c
5
+ SHA512:
6
+ metadata.gz: 89744110f5e48e16928d8ab00b00ef42808aae5d9c8de93aa14f4ec7e87d4d51459bab2307872efaa5fb8ed7080de14522e906604701ecb95f7a75788266a9b1
7
+ data.tar.gz: 38390a6b72a385d2c554e444d0cfb6f3d70ce9e90fc8773c00073527a1f3287d8edd983042f0c572946f86a0d3b36a2f056729b59dc447eb8add703bb93ce61b
data/LICENSE.md ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013 Chris Maddox
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ module ActionView
2
+ class Renderer
3
+
4
+ def render_partial(context, options, &block) #:nodoc:
5
+ partial_class.new(@lookup_context).render(context, options, block)
6
+ end
7
+
8
+ def partial_class
9
+ if PartialLogging.config.log_partials?
10
+ PartialLogging::PartialRendererWithLogging
11
+ else
12
+ PartialRenderer
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+
@@ -0,0 +1,12 @@
1
+ module PartialLogging
2
+ class Configuration
3
+
4
+ def log_partials(&block)
5
+ @log_partials = block
6
+ end
7
+
8
+ def log_partials?
9
+ @log_partials && @log_partials.call
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ require 'action_view'
2
+
3
+ class PartialLogging::PartialRendererWithLogging < ActionView::PartialRenderer
4
+
5
+ # @return [ActionView::OutputBuffer]
6
+ def render(context, options, block)
7
+ content = super(context, options, block)
8
+ identifier = @template ? @template.identifier : @path
9
+ if @lookup_context.rendered_format == :html
10
+ output_buffer = ActionView::OutputBuffer.new
11
+ output_buffer.safe_concat """
12
+ <!-- START #{identifier} -->
13
+ #{content}
14
+ <!-- END #{identifier} -->
15
+ """
16
+ content = output_buffer
17
+ end
18
+ content
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ module PartialLogging
2
+ class Version
3
+ MAJOR = 0 unless defined? MAJOR
4
+ MINOR = 1 unless defined? MINOR
5
+ PATCH = 0 unless defined? PATCH
6
+ PRE = nil unless defined? PRE
7
+
8
+ class << self
9
+
10
+ # @return [String]
11
+ def to_s
12
+ [MAJOR, MINOR, PATCH, PRE].compact.join('.')
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ require 'partial_logging/configuration'
2
+ require 'partial_logging/partial_renderer_with_logging'
3
+ require 'partial_logging/action_view'
4
+
5
+ module PartialLogging
6
+ class << self
7
+ def config
8
+ if block_given?
9
+ yield configuration
10
+ else
11
+ configuration
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def configuration
18
+ @configuration ||= Configuration.new
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'partial_logging/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.add_runtime_dependency 'actionview', '~> 3.0', '>= 3.0.0'
8
+ spec.authors = ['Chris Maddox']
9
+ spec.date = '2014-01-12'
10
+ spec.description = 'HTML comments for Rails partial rendering.'
11
+ spec.email = 'tyre77@gmail.com'
12
+ spec.files = %w(LICENSE.md partial_logging.gemspec)
13
+ spec.files += Dir.glob('lib/**/*.rb')
14
+ spec.files += Dir.glob('spec/**/*')
15
+ spec.homepage = 'http://rubygems.org/gems/partial_logging'
16
+ spec.licenses = ['MIT']
17
+ spec.name = 'partial_logging'
18
+ spec.summary = 'HTML comments for Rails partial rendering'
19
+ spec.test_files += Dir.glob('spec/**/*')
20
+ spec.version = PartialLogging::Version.to_s
21
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: partial_logging
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Maddox
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionview
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ - - '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 3.0.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
33
+ description: HTML comments for Rails partial rendering.
34
+ email: tyre77@gmail.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - LICENSE.md
40
+ - lib/partial_logging.rb
41
+ - lib/partial_logging/action_view.rb
42
+ - lib/partial_logging/configuration.rb
43
+ - lib/partial_logging/partial_renderer_with_logging.rb
44
+ - lib/partial_logging/version.rb
45
+ - partial_logging.gemspec
46
+ homepage: http://rubygems.org/gems/partial_logging
47
+ licenses:
48
+ - MIT
49
+ metadata: {}
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ requirements: []
65
+ rubyforge_project:
66
+ rubygems_version: 2.2.1
67
+ signing_key:
68
+ specification_version: 4
69
+ summary: HTML comments for Rails partial rendering
70
+ test_files: []
71
+ has_rdoc: