wallaby-view 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f9bf01cc8876f03b073afdaa8b322f00d781ff50fefd39f2eaac22f8feb535d
4
- data.tar.gz: 04e7113c6650b3b756d886d859d08369f96beb39c2f2e5ffac4d8ba5c44c16c9
3
+ metadata.gz: b3a499676db69e41f08251a98cd380af6875ac62ec9dee5f0e0a3b417ea04c8d
4
+ data.tar.gz: f614b7e34a5d24843550ccd17fd8f30e2f684c3d8a0198cab0ff09e6e9bea76b
5
5
  SHA512:
6
- metadata.gz: bd9d7a5a6985bfd6e317a44d8adf737a8e5639227e154fed90bdb2ac7230d6094efd0bebf5a60763826571b3cbc574365a1bf22d4dd4a6f326df279fd4f049e4
7
- data.tar.gz: 7658edb6c169b0e577043856abe82583b3312a24c514cb4355584e15e2c2dd695dca2994731207a51f9b48c6e4575f0ece43c4de06edb133aae387db555fcbfa
6
+ metadata.gz: a2011712b90441fab47976d2b9b381b6e7a879dbf5959be12bb5730ffb15472fc38f29985b615e46ea67821a7ab9657fa496750c71a904900a90e6c6c9cc0775
7
+ data.tar.gz: de63a2f32221fabbbfd905368ba74e95ba2342a96eda42b8d0e52f021e3e029387f25da8cb4be58f077156bb47fb4c24f69400120daa74af11ba90ce3aa4f306
data/README.md CHANGED
@@ -53,7 +53,7 @@ end
53
53
  # app/controllers/admin/users_controller
54
54
  class Admin::UsersController < Admin::ApplicationController
55
55
  self.theme_name = 'account'
56
- self.prefix_options = { mapping_actions: { edit: 'form' } }
56
+ self.prefix_options = { edit: 'form' }
57
57
  end
58
58
  ```
59
59
 
@@ -81,7 +81,7 @@ Then in the `admin/application#edit` template, rendering the relative `form` par
81
81
  <% render 'form' %>
82
82
  ```
83
83
 
84
- For `admin/users#edit` action, since `mapping_actions` option is set, `edit` will be mapped to `form`, and `form` will be added to the prefixes as well.
84
+ For `admin/users#edit` action, since `prefix_options` option is set, `edit` will be mapped to `form`, and `form` will be added to the prefixes as well.
85
85
  Therefore, the lookup folder order of `admin/users#edit` becomes:
86
86
 
87
87
  - app/views/admin/users/edit
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'request_store'
4
- require 'action_view/partial_renderer'
5
-
6
3
  require 'wallaby/view/version'
7
4
  require 'wallaby/view/action_viewable'
8
5
  require 'wallaby/view/themeable'
@@ -8,14 +8,21 @@ module Wallaby
8
8
  extend ActiveSupport::Concern
9
9
 
10
10
  module ClassMethods # :nodoc:
11
- # @!attribute[w] prefix_options
11
+ # @!attribute [w] prefix_options
12
12
  attr_writer :prefix_options
13
13
 
14
- # @!attribute[r] prefix_options
15
- # It stores the options for {#_prefixes}. It can inherit options from superclass.
14
+ # @!attribute [r] prefix_options
15
+ # It stores the options for {#_prefixes #_prefixes}. It can inherit options from superclass.
16
16
  # @return [Hash] prefix options
17
17
  def prefix_options
18
- @prefix_options ||= superclass.try(:prefix_options)
18
+ @prefix_options ||= superclass.try(:prefix_options).try(:dup) || {}
19
+ end
20
+
21
+ # Add prefix options
22
+ # @param new_options [Hash]
23
+ # @return [Hash] merged prefix options
24
+ def merge_prefix_options(new_options)
25
+ prefix_options.merge!(new_options)
19
26
  end
20
27
  end
21
28
 
@@ -31,7 +38,7 @@ module Wallaby
31
38
  # Override
32
39
  # {https://github.com/rails/rails/blob/master/actionview/lib/action_view/view_paths.rb#L97 lookup_context}
33
40
  # to provide caching for template/partial lookup.
34
- # @return {Wallaby::View::CustomLookupContext}
41
+ # @return {CustomLookupContext}
35
42
 
36
43
  # (see #lookup_context)
37
44
  def override_lookup_context
@@ -41,12 +48,12 @@ module Wallaby
41
48
 
42
49
  # @!method _prefixes(prefixes: nil, controller_path: nil, action_name: nil, themes: nil, options: nil, &block)
43
50
  # Override {https://github.com/rails/rails/blob/master/actionview/lib/action_view/view_paths.rb#L90 _prefixes}
44
- # to allow other (e.g. {Wallaby::View::CustomPrefixes#action_name},
45
- # {Wallaby::View::CustomPrefixes#themes}) to be added to the prefixes list.
51
+ # to allow other (e.g. {CustomPrefixes#action_name},
52
+ # {CustomPrefixes#themes}) to be added to the prefixes list.
46
53
  # @param prefixes [Array<String>] the base prefixes
47
54
  # @param action_name [String] the action name to add to the prefixes list
48
55
  # @param themes [String] the theme name to add to the prefixes list
49
- # @param options [Hash] the options that {Wallaby::View::CustomPrefixes} accepts
56
+ # @param options [Hash] the options that {CustomPrefixes} accepts
50
57
  # @return [Array<String>]
51
58
 
52
59
  # (see #_prefixes)
@@ -61,7 +68,7 @@ module Wallaby
61
68
  prefixes: prefixes || original_prefixes,
62
69
  action_name: action_name || params[:action],
63
70
  themes: themes || self.class.themes,
64
- options: options || self.class.prefix_options, &block
71
+ options: self.class.prefix_options.merge(options || {}), &block
65
72
  )
66
73
  end
67
74
  end
@@ -4,11 +4,11 @@ module Wallaby
4
4
  module View
5
5
  # Custom lookup context to cache lookup results.
6
6
  class CustomLookupContext < ::ActionView::LookupContext
7
- # Convert an ActionView::LookupContext instance into {Wallaby::View::CustomLookupContext}
7
+ # Convert an ActionView::LookupContext instance into {CustomLookupContext}
8
8
  # @param lookup_context [ActionView::LookupContext]
9
9
  # @param details [Hash]
10
10
  # @param prefixes [Array<String>]
11
- # @return [Wallaby::View::CustomLookupContext]
11
+ # @return [CustomLookupContext]
12
12
  def self.convert(lookup_context, details: nil, prefixes: nil)
13
13
  return lookup_context if lookup_context.is_a? self
14
14
 
@@ -7,7 +7,7 @@ module Wallaby
7
7
  # @!attribute [r] prefixes
8
8
  # Base prefixes to extend
9
9
  # @return [Array<String>]
10
- # @see Wallaby::View::ActionViewable#_prefixes
10
+ # @see ActionViewable#_prefixes
11
11
  attr_reader :prefixes
12
12
 
13
13
  # @!attribute [r] action_name
@@ -18,7 +18,7 @@ module Wallaby
18
18
  # @!attribute [r] themes
19
19
  # Themes to be inserted
20
20
  # @return [Array<Hash>]
21
- # @see Wallaby::View::Themeable#.themes
21
+ # @see Themeable#.themes
22
22
  attr_reader :themes
23
23
 
24
24
  # @!attribute [r] options
@@ -55,7 +55,7 @@ module Wallaby
55
55
  # @example To extend given prefixes with mapped action:
56
56
  # Wallaby::View::CustomPrefixes.execute(
57
57
  # prefixes: ['users', 'application'], action_name: 'edit',
58
- # options: { mapping_actions: { 'edit' => 'form' } }
58
+ # options: { 'edit' => 'form' }
59
59
  # )
60
60
  #
61
61
  # # => [
@@ -110,7 +110,7 @@ module Wallaby
110
110
  insert_themes_into array
111
111
 
112
112
  # Be able to change the array in overriding methods
113
- # in {Wallaby::View::ActionViewable#override_prefixes}
113
+ # in {ActionViewable#override_prefixes}
114
114
  new_array = yield array if block_given?
115
115
 
116
116
  # If the above block doesn't return a new array, it returns the old `array`.
@@ -120,7 +120,7 @@ module Wallaby
120
120
 
121
121
  # @return [Array<String>] Action names
122
122
  def actions
123
- @actions ||= [action_name, mapped_action_name].compact
123
+ @actions ||= [action_name, *mapped_action_name].compact
124
124
  end
125
125
 
126
126
  # Insert theme names into the prefixes
@@ -133,9 +133,9 @@ module Wallaby
133
133
  end
134
134
 
135
135
  # Map the {#action_name} using `options[:mapping_actions]`
136
- # @return [String, nil] mapped action name
136
+ # @return [Array<String>] mapped action name
137
137
  def mapped_action_name
138
- options[:mapping_actions].try(:[], action_name)
138
+ Array((options[:mapping_actions] || options).try(:[], action_name))
139
139
  end
140
140
  end
141
141
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Wallaby
4
4
  module View
5
- VERSION = '0.1.5' # :nodoc:
5
+ VERSION = '0.1.6' # :nodoc:
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wallaby-view
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tian Chen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-13 00:00:00.000000000 Z
11
+ date: 2020-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.2.0
20
+ - - "<="
21
+ - !ruby/object:Gem::Version
22
+ version: 6.2.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,14 +27,17 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 4.2.0
30
+ - - "<="
31
+ - !ruby/object:Gem::Version
32
+ version: 6.2.0
27
33
  - !ruby/object:Gem::Dependency
28
- name: request_store
34
+ name: github-markup
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
39
  version: '0'
34
- type: :runtime
40
+ type: :development
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
@@ -52,6 +58,48 @@ dependencies:
52
58
  - - ">="
53
59
  - !ruby/object:Gem::Version
54
60
  version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: redcarpet
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: simplecov
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: sqlite3
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
55
103
  - !ruby/object:Gem::Dependency
56
104
  name: wallaby-cop
57
105
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +114,20 @@ dependencies:
66
114
  - - ">="
67
115
  - !ruby/object:Gem::Version
68
116
  version: '0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: yard
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
69
131
  description: Wallaby View to extend Rails layout/template/partial inheritance chain.
70
132
  email:
71
133
  - me@tian.im
@@ -75,7 +137,6 @@ extra_rdoc_files: []
75
137
  files:
76
138
  - LICENSE
77
139
  - README.md
78
- - lib/action_view/partial_renderer.rb
79
140
  - lib/wallaby/view.rb
80
141
  - lib/wallaby/view/action_viewable.rb
81
142
  - lib/wallaby/view/custom_lookup_context.rb
@@ -89,7 +150,7 @@ metadata:
89
150
  homepage_uri: https://github.com/wallaby-rails/wallaby-view
90
151
  source_code_uri: https://github.com/wallaby-rails/wallaby-view
91
152
  changelog_uri: https://github.com/wallaby-rails/wallaby-view/blob/master/CHANGELOG.md
92
- post_install_message:
153
+ post_install_message:
93
154
  rdoc_options: []
94
155
  require_paths:
95
156
  - lib
@@ -105,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
166
  version: '0'
106
167
  requirements: []
107
168
  rubygems_version: 3.1.2
108
- signing_key:
169
+ signing_key:
109
170
  specification_version: 4
110
171
  summary: Wallaby View to extend Rails layout/template/partial inheritance chain.
111
172
  test_files: []
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActionView # :nodoc:
4
- # Re-open ActionView::PartialRenderer to disable logging for partials
5
- # that have been rendered for more than once.
6
- #
7
- # Every log requires the IO. Reducing the logs will dramatically improve the performance.
8
- # @see #instrument
9
- class PartialRenderer
10
- protected
11
-
12
- # @!method original_instrument(name, **options, &block)
13
- # Original method of {#instrument}
14
- # @param name [String]
15
- # @param options [Hash]
16
- # @yield [payload]
17
- # @yieldparam payload [Hash] payload object for instrument
18
- # @return [ActionView::OutputBuffer]
19
- alias original_instrument instrument
20
-
21
- # Logs for partial rendering. Only one log will be printed
22
- # even if a partial has been rendered for more than once.
23
- #
24
- # To disable this feature and see all logs,
25
- # set `ENV['ALL_PARTIAL_LOGS']` to `true`
26
- # @param name [String]
27
- # @param options [Hash]
28
- # @yield [payload]
29
- # @yieldparam payload [Hash] payload object for instrument
30
- # @return [ActionView::OutputBuffer]
31
- def instrument(name, **options, &block)
32
- identifier = options[:identifier] || @template.try(:identifier) || @path
33
- instrumented = RequestStore.store[:instrumented] ||= {}
34
-
35
- return yield({}) if !ENV['ALL_PARTIAL_LOGS'] && instrumented[identifier]
36
-
37
- original_instrument(name, **options, &block).tap do
38
- instrumented[identifier] ||= true
39
- end
40
- end
41
- end
42
- end