hanami 1.1.0 → 1.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: '08756b65d8071b4c2f4c22049f5d9ddf3e9af66f'
4
- data.tar.gz: 9df6b02aaf3564abaea00f5e03d8b7d504f8390c
2
+ SHA256:
3
+ metadata.gz: d87fe440f006e096c96ad18f1c20428ba4a279df2ee1dbce4ee122cf9ff59b12
4
+ data.tar.gz: 8f40361860a2eef0fdbf9eea31cc88588cc3caa2bcc509b1fa40d6817060b951
5
5
  SHA512:
6
- metadata.gz: 47165021aa4418cfbefcd15c9eaaa0f4b2913fecc42f587faae3402ac42d93193393edc25c3ddc011ad70724580bf2efd047d1860701ef0159d105d1558473c4
7
- data.tar.gz: b251d2791a24e9e9e03fb15be5b4473aecc6aae43d946397938cbce710064461d8b4f4dfb43405e2e548d05d555ae23753e39a703d78294dca0cb73239facc31
6
+ metadata.gz: 3228003ed57778a29753c440948cc82b2b4a93f9f201ec5836372bf33a3ca8af1535acd36d4ca94eb55c227df3c2503409e2ac9c8972809184e7eafa1e3f855e
7
+ data.tar.gz: b57b87929454289abc9ce08d8ddcb35ab57ece912b12fd66791e486785187a222fa36a425d89853589c63e0e40950b6afca3a73f93a80f0cf5f6d540d6690c43
@@ -1,6 +1,14 @@
1
1
  # Hanami
2
2
  The web, with simplicity.
3
3
 
4
+ ## v1.1.1 - 2018-02-27
5
+ ### Added
6
+ - [Luca Guidi] Official support for Ruby MRI 2.5+
7
+
8
+ ### Fixed
9
+ - [Alfonso Uceda] Fixed regression for mailer generator: when using options like `--from` and `--to` the generated Ruby code isn't valid as it was missing string quotes.
10
+ - [Luca Guidi] Generate tests for views including `:format` in `exposures`. This fixes view unit tests when the associated template renders a partial.
11
+
4
12
  ## v1.1.0 - 2017-10-25
5
13
  ### Fixed
6
14
  - [Luca Guidi] Ensure `hanami db rollback` steps to be a positive integer
@@ -3,7 +3,9 @@
3
3
 
4
4
  ## Features
5
5
 
6
- ## v1.1.0 (unreleased)
6
+ ## v1.1.1 - 2018-02-27
7
+
8
+ ## v1.1.0 - 2017-10-25
7
9
 
8
10
  - One-To-Many association (aka `belongs_to`)
9
11
  - One-To-One association (aka `has_one`)
data/README.md CHANGED
@@ -91,7 +91,7 @@ If you want to test Hanami's HEAD to try a new feature or to test a bug fix, her
91
91
  ```
92
92
  git clone https://github.com/hanami/hanami.git
93
93
  cd hanami && bundle
94
- bundle exec hanami new --hanami-head=true bookshelf
94
+ bundle exec hanami new bookshelf --hanami-head
95
95
  cd bookshelf
96
96
  vim Gemfile # edit with: gem 'hanami', path: '..'
97
97
  bundle
@@ -40,10 +40,11 @@ module Hanami
40
40
  # @since 0.1.0
41
41
  # @api private
42
42
  def initialize(namespace, configurations, path_prefix, env: Environment.new)
43
- @namespace = namespace
44
- @configurations = configurations
45
- @path_prefix = path_prefix
46
- @env = env
43
+ @namespace = namespace
44
+ @configurations = configurations
45
+ @path_prefix = path_prefix
46
+ @env = env
47
+ @handle_exceptions = true
47
48
 
48
49
  evaluate_configurations!
49
50
  end
@@ -1,15 +1,12 @@
1
1
  require_relative '../../../spec_helper'
2
2
 
3
3
  describe <%= app.classify %>::Views::<%= classified_controller_name %>::<%= action.classify %> do
4
- let(:exposures) { Hash[foo: 'bar'] }
4
+ let(:exposures) { Hash[format: :html] }
5
5
  let(:template) { Hanami::View::Template.new('<%= template %>') }
6
6
  let(:view) { <%= app.classify %>::Views::<%= classified_controller_name %>::<%= action.classify %>.new(template, exposures) }
7
7
  let(:rendered) { view.render }
8
8
 
9
- it 'exposes #foo' do
10
- skip 'This is an auto-generated test. Edit it and add your own tests.'
11
-
12
- # Example
13
- view.foo.must_equal exposures.fetch(:foo)
9
+ it 'exposes #format' do
10
+ view.format.must_equal exposures.fetch(:format)
14
11
  end
15
12
  end
@@ -1,13 +1,10 @@
1
1
  RSpec.describe <%= app.classify %>::Views::<%= classified_controller_name %>::<%= action.classify %>, type: :view do
2
- let(:exposures) { Hash[foo: 'bar'] }
2
+ let(:exposures) { Hash[format: :html] }
3
3
  let(:template) { Hanami::View::Template.new('<%= template %>') }
4
4
  let(:view) { described_class.new(template, exposures) }
5
5
  let(:rendered) { view.render }
6
6
 
7
- it 'exposes #foo' do
8
- pending 'This is an auto-generated test. Edit it and add your own tests.'
9
-
10
- # Example
11
- expect(view.foo).to eq exposures.fetch(:foo)
7
+ it 'exposes #format' do
8
+ expect(view.format).to eq exposures.fetch(:format)
12
9
  end
13
10
  end
@@ -25,9 +25,9 @@ module Hanami
25
25
  # @since 1.1.0
26
26
  # @api private
27
27
  def call(mailer:, **options)
28
- from = options.fetch(:from, DEFAULT_FROM)
29
- to = options.fetch(:to, DEFAULT_TO)
30
- subject = options.fetch(:subject, DEFAULT_SUBJECT)
28
+ from = clean_option(options.fetch(:from, DEFAULT_FROM))
29
+ to = clean_option(options.fetch(:to, DEFAULT_TO))
30
+ subject = clean_option(options.fetch(:subject, DEFAULT_SUBJECT))
31
31
  context = Context.new(mailer: mailer, test: options.fetch(:test), from: from, to: to, subject: subject, options: options)
32
32
 
33
33
  generate_mailer(context)
@@ -40,15 +40,19 @@ module Hanami
40
40
 
41
41
  # @since 1.1.0
42
42
  # @api private
43
- DEFAULT_FROM = "'<from>'".freeze
43
+ DEFAULT_FROM = "<from>".freeze
44
44
 
45
45
  # @since 1.1.0
46
46
  # @api private
47
- DEFAULT_TO = "'<to>'".freeze
47
+ DEFAULT_TO = "<to>".freeze
48
48
 
49
49
  # @since 1.1.0
50
50
  # @api private
51
- DEFAULT_SUBJECT = "'Hello'".freeze
51
+ DEFAULT_SUBJECT = "Hello".freeze
52
+
53
+ # @sice x.x.x
54
+ # @api private
55
+ QUOTES_REGEX = /^("|')|("|')$/
52
56
 
53
57
  # @since 1.1.0
54
58
  # @api private
@@ -87,6 +91,12 @@ module Hanami
87
91
  files.touch(destination)
88
92
  say(:create, destination)
89
93
  end
94
+
95
+ # @since x.x.x
96
+ # @api private
97
+ def clean_option(option)
98
+ option.gsub(QUOTES_REGEX, '')
99
+ end
90
100
  end
91
101
  end
92
102
  end
@@ -1,7 +1,7 @@
1
1
  class Mailers::<%= mailer.classify %>
2
2
  include Hanami::Mailer
3
3
 
4
- from <%= from %>
5
- to <%= to %>
6
- subject <%= subject %>
4
+ from '<%= from %>'
5
+ to '<%= to %>'
6
+ subject '<%= subject %>'
7
7
  end
@@ -30,4 +30,4 @@ How to prepare (create and migrate) DB for `development` and `test` environments
30
30
  % HANAMI_ENV=test bundle exec hanami db prepare
31
31
  ```
32
32
 
33
- Explore Hanami [guides](http://hanamirb.org/guides/), [API docs](http://hanamirb.org/docs/1.0.0/), or jump in [chat](http://chat.hanamirb.org) for help. Enjoy! 🌸
33
+ Explore Hanami [guides](http://hanamirb.org/guides/), [API docs](http://docs.hanamirb.org/<%= Hanami::VERSION %>/), or jump in [chat](http://chat.hanamirb.org) for help. Enjoy! 🌸
@@ -24,13 +24,13 @@ module Hanami
24
24
  SUCCESSFUL_STATUSES = (200..201).freeze
25
25
  # @api private
26
26
  RENDERABLE_FORMATS = [:all, :html].freeze
27
+ # @api private
28
+ ERROR_STATUS = 500
27
29
 
28
30
  # @api private
29
31
  def initialize(configuration)
30
32
  @controller_pattern = %r{#{ configuration.controller_pattern.gsub(/\%\{(controller|action)\}/) { "(?<#{ $1 }>(.*))" } }}
31
- @view_pattern = configuration.view_pattern
32
- @namespace = configuration.namespace
33
- @templates = configuration.templates
33
+ @configuration = configuration
34
34
  end
35
35
 
36
36
  # @api private
@@ -56,16 +56,19 @@ module Hanami
56
56
  view_for(action, response).render(
57
57
  action.exposures
58
58
  )
59
- rescue => e
59
+ rescue StandardError => e
60
60
  env[RACK_EXCEPTION] = e
61
- raise e
61
+ raise e unless @configuration.handle_exceptions
62
+
63
+ response[STATUS] = ERROR_STATUS
64
+ false
62
65
  end
63
66
  end
64
67
 
65
68
  # @api private
66
69
  def _render_status_page(action, response)
67
70
  if render_status_page?(action, response)
68
- Hanami::Views::Default.render(@templates, response[STATUS], response: response, format: :html)
71
+ Hanami::Views::Default.render(@configuration.templates, response[STATUS], response: response, format: :html)
69
72
  end
70
73
  end
71
74
 
@@ -83,7 +86,7 @@ module Hanami
83
86
  def view_for(action, response)
84
87
  view = if response[BODY].respond_to?(:empty?) && response[BODY].empty?
85
88
  captures = @controller_pattern.match(action.class.name)
86
- Utils::Class.load(@view_pattern % { controller: captures[:controller], action: captures[:action] }, @namespace)
89
+ Utils::Class.load(@configuration.view_pattern % { controller: captures[:controller], action: captures[:action] }, @configuration.namespace)
87
90
  end
88
91
 
89
92
  view || Views::NullView.new
@@ -6,7 +6,7 @@ module Hanami
6
6
  module Version
7
7
  # @since 0.9.0
8
8
  # @api private
9
- VERSION = '1.1.0'.freeze
9
+ VERSION = '1.1.1'.freeze
10
10
 
11
11
  # @since 0.9.0
12
12
  # @api private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
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-10-25 00:00:00.000000000 Z
11
+ date: 2018-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hanami-utils
@@ -387,7 +387,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
387
387
  version: '0'
388
388
  requirements: []
389
389
  rubyforge_project:
390
- rubygems_version: 2.6.13
390
+ rubygems_version: 2.7.5
391
391
  signing_key:
392
392
  specification_version: 4
393
393
  summary: The web, with simplicity