hanami-view 2.0.0.alpha2 → 2.0.0.alpha3

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: c0a9e22a0413e4519d8cec81b9561779ee0834e7db1786468459d0d8e96aa4d1
4
- data.tar.gz: 186b6b5fb8e24c60b65dc3cda95f66aac760e364bd33bbb4aecd9abca5c5ed1f
3
+ metadata.gz: b6b6dc01adb32ad3baabc7a15012119e8814de8ec999c4b5da2009204c3b047c
4
+ data.tar.gz: 8ef681f6101b085dec6e03f6de0815dfa55d8cbd91e960bf0144e4a46da5cce9
5
5
  SHA512:
6
- metadata.gz: 246f383f6ca472687a0bd5bad8c138af7775388ec7c0a53465b3aecff934afd10c8a083dcdf3f60393292499f90e48caef9bf9f6c8b814ea9e712389e5460e0d
7
- data.tar.gz: 660af0f10eef9892ae224a6383732984b76169690df59cbab8a660626d54c7fa0de027d2e18a4aae75d41111a7baadd0736548a75f87778874d574c64510f2f7
6
+ metadata.gz: b5704c147558d2a0e3e86d59f3b665ee65265a9398584b1d3478970551d9a022551ea04420444622c2c4967ab3406d29ea9dab7c13462207364ea985aa4af723
7
+ data.tar.gz: 5909511de76e1daf91a375c5947103040c2ec40208ea52882771204249cc2d4aef23d2ceaa8dac24cc960dbba978f3e4c6c08fac52118673b9c22580571f10fb
data/CHANGELOG.md CHANGED
@@ -1,10 +1,15 @@
1
1
  # Hanami::View
2
2
  View layer for Hanami
3
3
 
4
- ## v2.0.0.alpha2 - 2021-05-04
4
+ ## v2.0.0.alpha3 - 2021-11-09
5
+ ### Added
6
+ - [Pablo Vicente] Raise `LayoutNotFoundError` exception with friendlier, more specific error message when layouts cannot be found
5
7
 
6
8
  ### Changed
9
+ - [Tim Riley] (Internal) Updated settings to use updated dry-configurable `setting` 0.13.0 API
7
10
 
11
+ ## v2.0.0.alpha2 - 2021-05-04
12
+ ### Changed
8
13
  - [Tim Riley] Replaced entire gem with dry-view (now renamed to hanami-view). See [dry-view's documentation](https://dry-rb.org/gems/dry-view/) for its capabilities and [the dry-view changelog](CHANGELOG.dry-view.md) for its history.
9
14
 
10
15
  ## v1.3.1 - 2019-01-18
data/README.md CHANGED
@@ -1,28 +1,52 @@
1
- [gem]: https://rubygems.org/gems/hanami-view
2
- [actions]: https://github.com/hanami/view/actions
3
- [codacy]: https://www.codacy.com/gh/hanami/view
4
- [chat]: https://dry-rb.zulipchat.com
5
- [inchpages]: http://inch-ci.org/github/hanami/view
1
+ # Hanami::View
6
2
 
7
- # hanami-view [![Join the chat at https://dry-rb.zulipchat.com](https://img.shields.io/badge/dry--rb-join%20chat-%23346b7a.svg)][chat]
3
+ A view layer for [Hanami](http://hanamirb.org)
8
4
 
9
- [![Gem Version](https://badge.fury.io/rb/hanami-view.svg)][gem]
10
- [![CI Status](https://github.com/hanami/view/workflows/ci/badge.svg)][actions]
11
- [![Codacy Badge](https://api.codacy.com/project/badge/Grade/fe8a45d76d8b45f6a680a29c48b43a99)][codacy]
12
- [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/fe8a45d76d8b45f6a680a29c48b43a99)][codacy]
13
- [![Inline docs](http://inch-ci.org/github/hanami/view.svg?branch=master)][inchpages]
5
+ ## Version
14
6
 
15
- ## Links
7
+ **This branch contains the code for `hanami-view` 2.x.**
16
8
 
17
- * [User documentation](http://dry-rb.org/gems/hanami-view)
18
- * [API documentation](http://rubydoc.info/gems/hanami-view)
9
+ ## Status
19
10
 
20
- ## Supported Ruby versions
11
+ [![Gem Version](https://badge.fury.io/rb/hanami-view.svg)](https://badge.fury.io/rb/hanami-view)
12
+ [![CI](https://github.com/hanami/view/workflows/ci/badge.svg?branch=main)](https://github.com/hanami/view/actions?query=workflow%3Aci+branch%3Amain)
13
+ [![Test Coverage](https://codecov.io/gh/hanami/view/branch/main/graph/badge.svg)](https://codecov.io/gh/hanami/view)
14
+ [![Depfu](https://badges.depfu.com/badges/7cd17419fba78b726be1353118fb01de/overview.svg)](https://depfu.com/github/hanami/view?project=Bundler)
15
+ [![Inline Docs](http://inch-ci.org/github/hanami/view.svg)](http://inch-ci.org/github/hanami/view)
21
16
 
22
- This library officially supports the following Ruby versions:
17
+ ## Contact
23
18
 
24
- * MRI >= `2.4`
25
- * jruby >= `9.2`
19
+ * Home page: http://hanamirb.org
20
+ * Community: http://hanamirb.org/community
21
+ * Guides: https://guides.hanamirb.org
22
+ * Mailing List: http://hanamirb.org/mailing-list
23
+ * API Doc: http://rdoc.info/gems/hanami-view
24
+ * Bugs/Issues: https://github.com/hanami/view/issues
25
+ * Chat: http://chat.hanamirb.org
26
+
27
+ ## Rubies
28
+
29
+ __Hanami::view__ supports Ruby (MRI) 2.6+
30
+
31
+ ## Installation
32
+
33
+ Add this line to your application's Gemfile:
34
+
35
+ ```ruby
36
+ gem "hanami/view"
37
+ ```
38
+
39
+ And then execute:
40
+
41
+ ```shell
42
+ $ bundle
43
+ ```
44
+
45
+ Or install it yourself as:
46
+
47
+ ```shell
48
+ $ gem install hanami-view
49
+ ```
26
50
 
27
51
  ## License
28
52
 
data/hanami-view.gemspec CHANGED
@@ -20,14 +20,14 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ['lib']
21
21
 
22
22
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
23
- spec.metadata['changelog_uri'] = 'https://github.com/hanami/view/blob/master/CHANGELOG.md'
23
+ spec.metadata['changelog_uri'] = 'https://github.com/hanami/view/blob/main/CHANGELOG.md'
24
24
  spec.metadata['source_code_uri'] = 'https://github.com/hanami/view'
25
25
  spec.metadata['bug_tracker_uri'] = 'https://github.com/hanami/view/issues'
26
26
 
27
27
  spec.required_ruby_version = ">= 2.4.0"
28
28
 
29
29
  spec.add_runtime_dependency "concurrent-ruby", "~> 1.0"
30
- spec.add_runtime_dependency "dry-configurable", "~> 0.1"
30
+ spec.add_runtime_dependency "dry-configurable", "~> 0.13", ">= 0.13.0"
31
31
  spec.add_runtime_dependency "dry-core", "~> 0.5", ">= 0.5"
32
32
  spec.add_runtime_dependency "dry-inflector", "~> 0.1"
33
33
  spec.add_runtime_dependency "tilt", "~> 2.0", ">= 2.0.6"
@@ -8,7 +8,7 @@ module Hanami
8
8
  class ApplicationConfiguration
9
9
  include Dry::Configurable
10
10
 
11
- setting :parts_path, "views/parts"
11
+ setting :parts_path, default: "views/parts"
12
12
 
13
13
  def initialize(*)
14
14
  super
@@ -25,5 +25,20 @@ module Hanami
25
25
  super(msg)
26
26
  end
27
27
  end
28
+
29
+ # Error raised when layout could not be found within a view's configured
30
+ # paths
31
+ #
32
+ # @api private
33
+ class LayoutNotFoundError < StandardError
34
+ def initialize(layout_name, lookup_paths)
35
+ msg = [
36
+ "Layout +#{layout_name}+ could not be found in paths:",
37
+ lookup_paths.map { |path| " - #{path}" }
38
+ ].join("\n\n")
39
+
40
+ super(msg)
41
+ end
42
+ end
28
43
  end
29
44
  end
@@ -351,10 +351,14 @@ module Hanami
351
351
 
352
352
  if layout?
353
353
  layout_env = self.class.layout_env(format: format, context: context)
354
- output = env.template(
355
- self.class.layout_path,
356
- layout_env.scope(config.scope, layout_locals(locals))
357
- ) { output }
354
+ begin
355
+ output = env.template(
356
+ self.class.layout_path,
357
+ layout_env.scope(config.scope, layout_locals(locals))
358
+ ) { output }
359
+ rescue TemplateNotFoundError
360
+ raise LayoutNotFoundError.new(config.layout, config.paths)
361
+ end
358
362
  end
359
363
 
360
364
  Rendered.new(output: output, locals: locals)
@@ -3,6 +3,6 @@
3
3
  module Hanami
4
4
  class View
5
5
  # @api private
6
- VERSION = "2.0.0.alpha2"
6
+ VERSION = "2.0.0.alpha3"
7
7
  end
8
8
  end
data/lib/hanami/view.rb CHANGED
@@ -56,9 +56,9 @@ module Hanami
56
56
  #
57
57
  # @api public
58
58
  # @!scope class
59
- setting :paths do |paths|
59
+ setting :paths, constructor: -> paths {
60
60
  Array(paths).map { |path| Path[path] }
61
- end
61
+ }
62
62
 
63
63
  # @overload config.template=(name)
64
64
  # Set the name of the template for rendering this view. Template name
@@ -96,7 +96,7 @@ module Hanami
96
96
  # @param name [String, FalseClass, nil] layout name, or false to indicate no layout
97
97
  # @api public
98
98
  # @!scope class
99
- setting :layout, false
99
+ setting :layout, default: false
100
100
 
101
101
  # @overload config.layouts_dir=(dir)
102
102
  # Set the name of the directory (within the configured `paths`) holding
@@ -105,7 +105,7 @@ module Hanami
105
105
  # @param dir [String] directory name
106
106
  # @api public
107
107
  # @!scope class
108
- setting :layouts_dir, "layouts"
108
+ setting :layouts_dir, default: "layouts"
109
109
 
110
110
  # @overload config.scope=(scope_class)
111
111
  # Set the scope class to use when rendering the view's template.
@@ -131,7 +131,7 @@ module Hanami
131
131
  # @param context [Hanami::View::Context] context object
132
132
  # @api public
133
133
  # @!scope class
134
- setting :default_context, Context.new.freeze
134
+ setting :default_context, default: Context.new.freeze
135
135
 
136
136
  # @overload config.default_format=(format)
137
137
  # Set the default format to use when rendering.
@@ -141,7 +141,7 @@ module Hanami
141
141
  # @param format [Symbol]
142
142
  # @api public
143
143
  # @!scope class
144
- setting :default_format, :html
144
+ setting :default_format, default: :html
145
145
 
146
146
  # @overload config.scope_namespace=(namespace)
147
147
  # Set a namespace that will be searched when building scope classes.
@@ -162,7 +162,7 @@ module Hanami
162
162
  # @param part_builder [Class]
163
163
  # @api public
164
164
  # @!scope class
165
- setting :part_builder, PartBuilder
165
+ setting :part_builder, default: PartBuilder
166
166
 
167
167
  # @overload config.scope_namespace=(namespace)
168
168
  # Set a namespace that will be searched when building scope classes.
@@ -183,7 +183,7 @@ module Hanami
183
183
  # @param scope_builder [Class]
184
184
  # @api public
185
185
  # @!scope class
186
- setting :scope_builder, ScopeBuilder
186
+ setting :scope_builder, default: ScopeBuilder
187
187
 
188
188
  # @overload config.inflector=(inflector)
189
189
  # Set an inflector to provide to the part_builder and scope_builder.
@@ -193,7 +193,7 @@ module Hanami
193
193
  # @param inflector
194
194
  # @api public
195
195
  # @!scope class
196
- setting :inflector, Dry::Inflector.new
196
+ setting :inflector, default: Dry::Inflector.new
197
197
 
198
198
  # @overload config.renderer_options=(options)
199
199
  # A hash of options to pass to the template engine. Template engines are
@@ -208,9 +208,9 @@ module Hanami
208
208
  # @param options [Hash] renderer options
209
209
  # @api public
210
210
  # @!scope class
211
- setting :renderer_options, DEFAULT_RENDERER_OPTIONS do |options|
211
+ setting :renderer_options, default: DEFAULT_RENDERER_OPTIONS, constructor: -> options {
212
212
  DEFAULT_RENDERER_OPTIONS.merge(options.to_h).freeze
213
- end
213
+ }
214
214
 
215
215
  # @overload config.renderer_engine_mapping=(mapping)
216
216
  # A hash specifying the (Tilt-compatible) template engine class to use
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-view
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.alpha2
4
+ version: 2.0.0.alpha3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Riley
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-05-04 00:00:00.000000000 Z
12
+ date: 2021-11-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby
@@ -31,14 +31,20 @@ dependencies:
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '0.1'
34
+ version: '0.13'
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: 0.13.0
35
38
  type: :runtime
36
39
  prerelease: false
37
40
  version_requirements: !ruby/object:Gem::Requirement
38
41
  requirements:
39
42
  - - "~>"
40
43
  - !ruby/object:Gem::Version
41
- version: '0.1'
44
+ version: '0.13'
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.13.0
42
48
  - !ruby/object:Gem::Dependency
43
49
  name: dry-core
44
50
  requirement: !ruby/object:Gem::Requirement
@@ -179,7 +185,7 @@ licenses:
179
185
  - MIT
180
186
  metadata:
181
187
  allowed_push_host: https://rubygems.org
182
- changelog_uri: https://github.com/hanami/view/blob/master/CHANGELOG.md
188
+ changelog_uri: https://github.com/hanami/view/blob/main/CHANGELOG.md
183
189
  source_code_uri: https://github.com/hanami/view
184
190
  bug_tracker_uri: https://github.com/hanami/view/issues
185
191
  post_install_message:
@@ -197,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
203
  - !ruby/object:Gem::Version
198
204
  version: 1.3.1
199
205
  requirements: []
200
- rubygems_version: 3.2.4
206
+ rubygems_version: 3.2.3
201
207
  signing_key:
202
208
  specification_version: 4
203
209
  summary: A complete, standalone view rendering system that gives you everything you