hanami-view 1.0.1 → 1.1.0.beta1

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
  SHA1:
3
- metadata.gz: f3f3b5a91fabf790905218d179350b9ca5b09ea5
4
- data.tar.gz: 90708fec73255ef891fa0210527ea32bf49c82a5
3
+ metadata.gz: '0499a5ecaa4e50c44d7e759ea91747b42332a13c'
4
+ data.tar.gz: '066865e74b723cea4e703accc5ea1e45ad76e7ff'
5
5
  SHA512:
6
- metadata.gz: e414c7c8df49dfa4e33ff5e694baa9408ac8336aff315f631044ed8f86300dfbad8fdf066bed6e8227ba96d77c2e6e46cf20600d0cc7480e56ed83e55429f1f3
7
- data.tar.gz: b21512ad851b40cd8dca788ff9c93ae98f40eec8a1087ee855e2c8858324543f45d3c403872b061f1c772f1a42d10332830f66f43607c3a2da7fec83b111f0b9
6
+ metadata.gz: d161a7bac58d23014c570372f456555ad993f5a191e024f4f50a925771bc53ca8181c8d6a3aa1884a1ead62b3b00e0e70a60bbee50319358896b1e9d0638c7e8
7
+ data.tar.gz: 46ee3fde97ffa129632ad10209aab687e08b72571a565b4bd384f17c9c1bccc9234e6231b674725090bfc95e94f532492beba5eeebe43c9130c877a74215e83a
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Hanami::View
2
2
  View layer for Hanami
3
3
 
4
+ ## v1.1.0.beta1 - 2017-08-11
5
+ ### Fixed
6
+ - [yjukaku] Raise `Hanami::View::UnknownRenderTypeError` when an argument different from `:template` or `:partial` is passed to `render`
7
+
4
8
  ## v1.0.1 - 2017-08-04
5
9
  ### Added
6
10
  - [Luca Guidi] Compatibility with `haml` 5.0
data/hanami-view.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.required_ruby_version = '>= 2.3.0'
21
21
 
22
22
  spec.add_runtime_dependency 'tilt', '~> 2.0', '>= 2.0.1'
23
- spec.add_runtime_dependency 'hanami-utils', '~> 1.0'
23
+ spec.add_runtime_dependency 'hanami-utils', '1.1.0.beta1'
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 1.5'
26
26
  spec.add_development_dependency 'rspec', '~> 3.5'
@@ -91,7 +91,7 @@ module Hanami
91
91
  # # => will return from MyApp::View
92
92
  def self.for(base)
93
93
  # TODO this implementation is similar to Hanami::Controller::Configuration consider to extract it into Hanami::Utils
94
- namespace = Utils::String.new(base).namespace
94
+ namespace = Utils::String.namespace(base)
95
95
  framework = Utils::Class.load_from_pattern!("(#{namespace}|Hanami)::View")
96
96
  framework.configuration
97
97
  end
@@ -48,13 +48,13 @@ module Hanami
48
48
  end
49
49
  end
50
50
 
51
- # Unknown or missing render type
51
+ # Unknown or render type
52
52
  #
53
- # This is raised at the runtime when Hanami::Layout doesn't recognize the render type.
53
+ # This is raised at the runtime when `Hanami::Layout` doesn't recognize the render type.
54
54
  #
55
- # @since X.X.X
56
- class UnknownOrMissingRenderTypeLayoutError < Error
57
- # @since X.X.X
55
+ # @since 1.1.0
56
+ class UnknownRenderTypeError < Error
57
+ # @since 1.1.0
58
58
  # @api private
59
59
  def initialize(known_types, supplied_options)
60
60
  known_types_list = known_types.map{|t| "':#{t}'"}.join(', ')
@@ -65,7 +65,7 @@ module Hanami
65
65
  case layout
66
66
  when Symbol, String
67
67
  # TODO Move this low level logic into a Hanami::Utils solution
68
- class_name = "#{ Utils::String.new(layout).classify }#{ SUFFIX }"
68
+ class_name = "#{ Utils::String.classify(layout) }#{ SUFFIX }"
69
69
  namespace = Utils::Class.load_from_pattern!(namespace)
70
70
  namespace.const_get(class_name)
71
71
  when Class
@@ -4,13 +4,13 @@ require 'hanami/utils/escape'
4
4
  module Hanami
5
5
  module View
6
6
  module Rendering
7
-
8
- # List of render types that exactly one of must be included when calling `#render`.
7
+ # List of render types that exactly one of must be included when calling `#render`.
9
8
  # For example, when calling `<%= render something: 'my_thing', locals: {} %>`,
10
9
  # 'something' must be one of the values listed here.
11
- #
12
- # @since X.X.X
13
- KNOWN_RENDER_TYPES = [:partial, :template]
10
+ #
11
+ # @since 1.1.0
12
+ # @api private
13
+ KNOWN_RENDER_TYPES = [:partial, :template].freeze
14
14
 
15
15
  # Scope for layout rendering
16
16
  #
@@ -60,6 +60,9 @@ module Hanami
60
60
  #
61
61
  # @return [String] the output of the rendering process
62
62
  #
63
+ # @raise [Hanami::Error::UnknownRenderTypeError] if the given type to
64
+ # be rendered is unknown
65
+ #
63
66
  # @since 0.1.0
64
67
  #
65
68
  # @example Rendering partial
@@ -95,9 +98,6 @@ module Hanami
95
98
  # #
96
99
  # # `user` will be available in the scope of the sidebar rendering
97
100
  def render(options)
98
- if !KNOWN_RENDER_TYPES.any?{|render_type| options[render_type]}
99
- ::Kernel.raise UnknownOrMissingRenderTypeLayoutError.new(KNOWN_RENDER_TYPES, options)
100
- end
101
101
  renderer(options).render
102
102
  end
103
103
 
@@ -243,6 +243,8 @@ module Hanami
243
243
  Rendering::Partial
244
244
  elsif options[:template]
245
245
  Rendering::Template
246
+ else
247
+ ::Kernel.raise UnknownRenderTypeError.new(KNOWN_RENDER_TYPES, options)
246
248
  end.new(view, _options(options))
247
249
  end
248
250
 
@@ -28,7 +28,7 @@ module Hanami
28
28
  # @api private
29
29
  def compile!(namespace)
30
30
  tokens(namespace) {|token| replace!(token) }
31
- @name = Utils::String.new(@name).underscore
31
+ @name = Utils::String.underscore(@name)
32
32
  end
33
33
 
34
34
  # @since 0.2.0
@@ -3,6 +3,6 @@ module Hanami
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '1.0.1'.freeze
6
+ VERSION = '1.1.0.beta1'.freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-view
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-04 00:00:00.000000000 Z
11
+ date: 2017-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tilt
@@ -34,16 +34,16 @@ dependencies:
34
34
  name: hanami-utils
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: '1.0'
39
+ version: 1.1.0.beta1
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
44
+ - - '='
45
45
  - !ruby/object:Gem::Version
46
- version: '1.0'
46
+ version: 1.1.0.beta1
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -141,9 +141,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
141
141
  version: 2.3.0
142
142
  required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  requirements:
144
- - - ">="
144
+ - - ">"
145
145
  - !ruby/object:Gem::Version
146
- version: '0'
146
+ version: 1.3.1
147
147
  requirements: []
148
148
  rubyforge_project:
149
149
  rubygems_version: 2.6.11