view_component 2.13.0 → 2.14.0

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.

Potentially problematic release.


This version of view_component might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3950532a26d2d6d1ddcf412383bfd9cde269c1f69c3d6f7f03dd4e51e7d638e2
4
- data.tar.gz: ee2524ef62b335376287f30709e62f2d39a71e43c0f5ec9853db8142b6c8fb3c
3
+ metadata.gz: d886f5b071663d4c5cd6bf96d94c02541d4fe86e470e79cc4ec51f1cfcc6c35b
4
+ data.tar.gz: 01f24da54ab8ebd5a701be24b019e7cbbd97e38cffc74b380d9af4fc006558e5
5
5
  SHA512:
6
- metadata.gz: c4cc6925445d3486e4c9a6ef915254cf3f28d973ad6a2876fca4fe3435b19ac273f18e89432622eaa38c8bba22ab9e9cafa07e417299dab8537848742175d1c8
7
- data.tar.gz: 66d2a44a74a07e78f694adc4790218ee7a9d729e8cd8bb9546d154669a79d5abaa20e7d0bffa0801dfc276ef539b93d5a13dd2b4d3d3093cd8d806972d2dac81
6
+ metadata.gz: f45dab99819a3b0cd15a812ebe4f678173212b3eaf7d33e76a1c5523462a144a8f8a47cf7466581a629614706a3e9176de0dac7dbda4f63fc7a0a96658a5e55e
7
+ data.tar.gz: ca67804e62bc095cd0a08373b1a5e415702173c770e9695b2242808546077211d571ccfda4c722031ad08c9d079d41eeaa627e0f206784648b3183debde71bd0
@@ -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 `preview_path` option:
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.preview_path = "#{Rails.root}/lib/component_previews"
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.preview_path = "#{Rails.root}/spec/components/previews"
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.preview_path ||= defined?(Rails.root) ? "#{Rails.root}/test/components/previews" : nil
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
- if preview_path
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 preview_path
74
- Base.preview_path
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.preview_path = "#{Rails.root}/lib/component_previews"
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
@@ -3,7 +3,7 @@
3
3
  module ViewComponent
4
4
  module VERSION
5
5
  MAJOR = 2
6
- MINOR = 13
6
+ MINOR = 14
7
7
  PATCH = 0
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH].join(".")
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.13.0
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-02 00:00:00.000000000 Z
11
+ date: 2020-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport