view_component 2.13.0 → 2.14.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of view_component might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +3 -3
- data/lib/view_component/engine.rb +9 -1
- data/lib/view_component/preview.rb +3 -3
- data/lib/view_component/previewable.rb +4 -1
- data/lib/view_component/test_helpers.rb +1 -1
- data/lib/view_component/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d886f5b071663d4c5cd6bf96d94c02541d4fe86e470e79cc4ec51f1cfcc6c35b
|
4
|
+
data.tar.gz: 01f24da54ab8ebd5a701be24b019e7cbbd97e38cffc74b380d9af4fc006558e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f45dab99819a3b0cd15a812ebe4f678173212b3eaf7d33e76a1c5523462a144a8f8a47cf7466581a629614706a3e9176de0dac7dbda4f63fc7a0a96658a5e55e
|
7
|
+
data.tar.gz: ca67804e62bc095cd0a08373b1a5e415702173c770e9695b2242808546077211d571ccfda4c722031ad08c9d079d41eeaa627e0f206784648b3183debde71bd0
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# master
|
2
2
|
|
3
|
+
# 2.14.0
|
4
|
+
|
5
|
+
* Add `config.preview_paths` to support multiple locations of component preview files. Deprecate `config.preview_path`.
|
6
|
+
|
7
|
+
*Tomas Celizna*
|
8
|
+
|
9
|
+
* Only print warning about a missing capybara dependency if the `DEBUG` environment variable is set.
|
10
|
+
|
11
|
+
*Richard Macklin*
|
12
|
+
|
3
13
|
# 2.13.0
|
4
14
|
|
5
15
|
* Add the ability to disable the render monkey patch with `config.view_component.render_monkey_patch_enabled`. In versions of Rails < 6.1, add `render_component` and `render_component_to_string` methods which can be used for rendering components instead of `render`.
|
data/README.md
CHANGED
@@ -664,11 +664,11 @@ class TestComponentPreview < ViewComponent::Preview
|
|
664
664
|
end
|
665
665
|
```
|
666
666
|
|
667
|
-
Preview classes live in `test/components/previews`, which can be configured using the `
|
667
|
+
Preview classes live in `test/components/previews`, which can be configured using the `preview_paths` option:
|
668
668
|
|
669
669
|
`config/application.rb`
|
670
670
|
```ruby
|
671
|
-
config.view_component.
|
671
|
+
config.view_component.preview_paths << "#{Rails.root}/lib/component_previews"
|
672
672
|
```
|
673
673
|
|
674
674
|
Previews are served from <http://localhost:3000/rails/view_components> by default. To use a different endpoint, set the `preview_route` option:
|
@@ -708,7 +708,7 @@ To use component previews:
|
|
708
708
|
|
709
709
|
`config/application.rb`
|
710
710
|
```ruby
|
711
|
-
config.view_component.
|
711
|
+
config.view_component.preview_paths << "#{Rails.root}/spec/components/previews"
|
712
712
|
```
|
713
713
|
|
714
714
|
### Disabling the render monkey patch (Rails < 6.1)
|
@@ -6,6 +6,7 @@ require "view_component"
|
|
6
6
|
module ViewComponent
|
7
7
|
class Engine < Rails::Engine # :nodoc:
|
8
8
|
config.view_component = ActiveSupport::OrderedOptions.new
|
9
|
+
config.view_component.preview_paths ||= []
|
9
10
|
|
10
11
|
initializer "view_component.set_configs" do |app|
|
11
12
|
options = app.config.view_component
|
@@ -15,7 +16,14 @@ module ViewComponent
|
|
15
16
|
options.preview_route ||= ViewComponent::Base.preview_route
|
16
17
|
|
17
18
|
if options.show_previews
|
18
|
-
options.
|
19
|
+
options.preview_paths << "#{Rails.root}/test/components/previews" if defined?(Rails.root)
|
20
|
+
|
21
|
+
if options.preview_path.present?
|
22
|
+
ActiveSupport::Deprecation.warn(
|
23
|
+
"`preview_path` will be removed in v3.0.0. Use `preview_paths` instead."
|
24
|
+
)
|
25
|
+
options.preview_paths << options.preview_path
|
26
|
+
end
|
19
27
|
end
|
20
28
|
|
21
29
|
ActiveSupport.on_load(:view_component) do
|
@@ -65,13 +65,13 @@ module ViewComponent # :nodoc:
|
|
65
65
|
private
|
66
66
|
|
67
67
|
def load_previews
|
68
|
-
|
68
|
+
Array(preview_paths).each do |preview_path|
|
69
69
|
Dir["#{preview_path}/**/*_preview.rb"].sort.each { |file| require_dependency file }
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
def
|
74
|
-
Base.
|
73
|
+
def preview_paths
|
74
|
+
Base.preview_paths
|
75
75
|
end
|
76
76
|
|
77
77
|
def show_previews
|
@@ -9,8 +9,11 @@ module ViewComponent # :nodoc:
|
|
9
9
|
included do
|
10
10
|
# Set the location of component previews through app configuration:
|
11
11
|
#
|
12
|
-
# config.view_component.
|
12
|
+
# config.view_component.preview_paths << "#{Rails.root}/lib/component_previews"
|
13
13
|
#
|
14
|
+
mattr_accessor :preview_paths, instance_writer: false
|
15
|
+
|
16
|
+
# TODO: deprecated, remove in v3.0.0
|
14
17
|
mattr_accessor :preview_path, instance_writer: false
|
15
18
|
|
16
19
|
# Enable or disable component previews through app configuration:
|
@@ -14,7 +14,7 @@ module ViewComponent
|
|
14
14
|
assert_no_selector("body")
|
15
15
|
end
|
16
16
|
rescue LoadError
|
17
|
-
warn "WARNING in `ViewComponent::TestHelpers`: You must add `capybara` to your Gemfile to use Capybara assertions."
|
17
|
+
warn "WARNING in `ViewComponent::TestHelpers`: You must add `capybara` to your Gemfile to use Capybara assertions." if ENV["DEBUG"]
|
18
18
|
end
|
19
19
|
|
20
20
|
attr_reader :rendered_component
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|