actionview-component 1.13.0 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/Gemfile.lock +1 -1
  4. data/README.md +43 -55
  5. data/actionview-component.gemspec +2 -2
  6. data/app/controllers/rails/components_controller.rb +4 -4
  7. data/lib/action_view/component.rb +1 -21
  8. data/lib/action_view/component/base.rb +1 -262
  9. data/lib/action_view/component/preview.rb +1 -72
  10. data/lib/action_view/component/railtie.rb +1 -1
  11. data/lib/action_view/component/test_case.rb +1 -4
  12. data/lib/rails/generators/component/component_generator.rb +1 -1
  13. data/lib/rails/generators/test_unit/templates/component_test.rb.tt +1 -1
  14. data/lib/view_component.rb +29 -0
  15. data/lib/view_component/base.rb +273 -0
  16. data/lib/view_component/conversion.rb +9 -0
  17. data/lib/view_component/engine.rb +65 -0
  18. data/lib/view_component/preview.rb +77 -0
  19. data/lib/view_component/previewable.rb +25 -0
  20. data/lib/view_component/render_monkey_patch.rb +31 -0
  21. data/lib/view_component/rendering_monkey_patch.rb +13 -0
  22. data/lib/view_component/template_error.rb +9 -0
  23. data/lib/view_component/test_case.rb +9 -0
  24. data/lib/view_component/test_helpers.rb +43 -0
  25. data/lib/view_component/version.rb +11 -0
  26. data/script/console +1 -1
  27. metadata +14 -10
  28. data/lib/action_view/component/conversion.rb +0 -11
  29. data/lib/action_view/component/engine.rb +0 -67
  30. data/lib/action_view/component/previewable.rb +0 -27
  31. data/lib/action_view/component/render_monkey_patch.rb +0 -34
  32. data/lib/action_view/component/rendering_monkey_patch.rb +0 -15
  33. data/lib/action_view/component/template_error.rb +0 -11
  34. data/lib/action_view/component/test_helpers.rb +0 -45
  35. data/lib/action_view/component/version.rb +0 -13
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActionView
4
- module Component
5
- class TemplateError < StandardError
6
- def initialize(errors)
7
- super(errors.join(", "))
8
- end
9
- end
10
- end
11
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "capybara/minitest"
4
-
5
- module ActionView
6
- module Component
7
- module TestHelpers
8
- include Capybara::Minitest::Assertions
9
-
10
- def page
11
- Capybara::Node::Simple.new(@raw)
12
- end
13
-
14
- def render_inline(component, **args, &block)
15
- @raw = controller.view_context.render(component, args, &block)
16
-
17
- Nokogiri::HTML.fragment(@raw)
18
- end
19
-
20
- def controller
21
- @controller ||= Base.test_controller.constantize.new.tap { |c| c.request = request }.extend(Rails.application.routes.url_helpers)
22
- end
23
-
24
- def request
25
- @request ||= ActionDispatch::TestRequest.create
26
- end
27
-
28
- def render_component(component, **args, &block)
29
- ActiveSupport::Deprecation.warn(
30
- "`render_component` has been deprecated in favor of `render_inline`, and will be removed in v2.0.0."
31
- )
32
-
33
- render_inline(component, args, &block)
34
- end
35
-
36
- def with_variant(variant)
37
- old_variants = controller.view_context.lookup_context.variants
38
-
39
- controller.view_context.lookup_context.variants = variant
40
- yield
41
- controller.view_context.lookup_context.variants = old_variants
42
- end
43
- end
44
- end
45
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActionView
4
- module Component
5
- module VERSION
6
- MAJOR = 1
7
- MINOR = 13
8
- PATCH = 0
9
-
10
- STRING = [MAJOR, MINOR, PATCH].join(".")
11
- end
12
- end
13
- end