hanami-model 1.2.0 → 1.3.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
  SHA256:
3
- metadata.gz: cb2655d298d2a0a66dd13c2d0f8818b8732feb84a5f5260e3b9ccddb1b6e5969
4
- data.tar.gz: d6321500dc644537f9e86051c777f7d6ad37ff4f587fc3f890acb83b0249df04
3
+ metadata.gz: 519ae98ba5a6e331ed7bf16fe018c5c860a07693afe1d7654887d99b5b715a14
4
+ data.tar.gz: c305d077057133bd74f61576cce147397fb8420e875c52bd34c66525e4ef6dad
5
5
  SHA512:
6
- metadata.gz: 98a2d0bef71b03e6d4bc3998932e1dfbe8be9c45585fc9f96fb4333677ffd824b4d1eb558e0fa36251e12708da560e01f6bd7a0ee7cc737de39bafe65fca857b
7
- data.tar.gz: e8a3a99737f647c0ac10dd8d16a2da99dd3f605b6a32660422b675302336530b67a30805e14320aa91444d7102bb0cc2265f0cbdfda2ba16db3a24b1a058d764
6
+ metadata.gz: d7b17ce6a99b8ad25bd8fdf322f07a5765e25c2ee16d5c67f268b76ec44b9e464e5f3346ef4056ce6f44261a4b851933a2926fb8c7a0dcdc9598fa91e083aa20
7
+ data.tar.gz: 88e58eb2a11db0c97cddb873711ddc2210afbeb106ae3b07acd097ea6d0aedb76e679eaf20eef63b5efd8a76674c2d38cf02a359c69cc501c6b471f29cb4e885
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Hanami::Model
2
2
  A persistence layer for Hanami
3
3
 
4
+ ## v1.3.0.beta1 - 2018-08-08
5
+ ### Fixed
6
+ - [Luca Guidi] Print meaningful error message when connection URL is misconfigured (eg. `Unknown database adapter for URL: "". Please check your database configuration (hint: ENV['DATABASE_URL']).`)
7
+
4
8
  ## v1.2.0 - 2018-04-11
5
9
 
6
10
  ## v1.2.0.rc2 - 2018-04-06
data/README.md CHANGED
@@ -14,12 +14,12 @@ Like all the other Hanami components, it can be used as a standalone framework o
14
14
 
15
15
  ## Status
16
16
 
17
- [![Gem Version](https://badge.fury.io/rb/hanami-model.svg)](http://badge.fury.io/rb/hanami-model)
18
- [![Build Status](https://secure.travis-ci.org/hanami/model.svg?branch=master)](http://travis-ci.org/hanami/model?branch=master)
19
- [![Coverage](https://codecov.io/gh/hanami/model/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/model)
20
- [![Code Climate](https://codeclimate.com/github/hanami/model/badges/gpa.svg)](https://codeclimate.com/github/hanami/model)
21
- [![Dependencies](https://gemnasium.com/hanami/model.svg)](https://gemnasium.com/hanami/model)
22
- [![Inline docs](http://inch-ci.org/github/hanami/model.png)](http://inch-ci.org/github/hanami/model)
17
+ [![Gem Version](https://badge.fury.io/rb/hanami-model.svg)](https://badge.fury.io/rb/hanami-model)
18
+ [![TravisCI](https://travis-ci.org/hanami/model.svg?branch=master)](https://travis-ci.org/hanami/model)
19
+ [![CircleCI](https://circleci.com/gh/hanami/model/tree/master.svg?style=svg)](https://circleci.com/gh/hanami/model/tree/master)
20
+ [![Test Coverage](https://codecov.io/gh/hanami/model/branch/master/graph/badge.svg)](https://codecov.io/gh/hanami/model)
21
+ [![Depfu](https://badges.depfu.com/badges/3a5d3f9e72895493bb6f39402ac4f129/overview.svg)](https://depfu.com/github/hanami/model?project=Bundler)
22
+ [![Inline Docs](http://inch-ci.org/github/hanami/model.svg)](http://inch-ci.org/github/hanami/model)
23
23
 
24
24
  ## Contact
25
25
 
data/hanami-model.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ['lib']
19
19
  spec.required_ruby_version = '>= 2.3.0'
20
20
 
21
- spec.add_runtime_dependency 'hanami-utils', '~> 1.2'
21
+ spec.add_runtime_dependency 'hanami-utils', '~> 1.3.beta'
22
22
  spec.add_runtime_dependency 'rom', '~> 3.3', '>= 3.3.3'
23
23
  spec.add_runtime_dependency 'rom-sql', '~> 1.3', '>= 1.3.5'
24
24
  spec.add_runtime_dependency 'rom-repository', '~> 1.4'
data/lib/hanami-model.rb CHANGED
@@ -1 +1 @@
1
- require 'hanami/model' # rubocop:disable Naming/FileName
1
+ require 'hanami/model'
@@ -47,6 +47,9 @@ module Hanami
47
47
 
48
48
  # NOTE: This must be changed when we want to support several adapters at the time
49
49
  #
50
+ # @raise [Hanami::Model::UnknownDatabaseAdapterError] if `url` is blank,
51
+ # or it uses an unknown adapter.
52
+ #
50
53
  # @since 0.7.0
51
54
  # @api private
52
55
  def connection
@@ -55,6 +58,9 @@ module Hanami
55
58
 
56
59
  # NOTE: This must be changed when we want to support several adapters at the time
57
60
  #
61
+ # @raise [Hanami::Model::UnknownDatabaseAdapterError] if `url` is blank,
62
+ # or it uses an unknown adapter.
63
+ #
58
64
  # @since 0.7.0
59
65
  # @api private
60
66
  def gateway
@@ -122,12 +128,21 @@ module Hanami
122
128
  gateway.use_logger(@logger = value)
123
129
  end
124
130
 
131
+ # @raise [Hanami::Model::UnknownDatabaseAdapterError] if `url` is blank,
132
+ # or it uses an unknown adapter.
133
+ #
125
134
  # @since 1.0.0
126
135
  # @api private
127
136
  def rom
128
137
  @rom ||= ROM::Configuration.new(@backend, @url, infer_relations: false)
138
+ rescue => e
139
+ raise UnknownDatabaseAdapterError.new(@url) if e.message =~ /adapters/
140
+ raise e
129
141
  end
130
142
 
143
+ # @raise [Hanami::Model::UnknownDatabaseAdapterError] if `url` is blank,
144
+ # or it uses an unknown adapter.
145
+ #
131
146
  # @since 1.0.0
132
147
  # @api private
133
148
  def load!(repositories, &blk) # rubocop:disable Metrics/AbcSize
@@ -118,5 +118,14 @@ module Hanami
118
118
  # @since 1.2.0
119
119
  class UnknownAttributeError < Error
120
120
  end
121
+
122
+ # Unknown database adapter error
123
+ #
124
+ # @since 1.2.1
125
+ class UnknownDatabaseAdapterError < Error
126
+ def initialize(url)
127
+ super("Unknown database adapter for URL: #{url.inspect}. Please check your database configuration (hint: ENV['DATABASE_URL']).")
128
+ end
129
+ end
121
130
  end
122
131
  end
@@ -1,3 +1,5 @@
1
+ require 'cgi'
2
+
1
3
  module Hanami
2
4
  module Model
3
5
  class Migrator
@@ -153,8 +155,11 @@ module Hanami
153
155
  #
154
156
  # @since 0.5.0
155
157
  # @api private
156
- def parsed_opt(option)
157
- parsed_uri.to_s.match(/[\?|\&]#{ option }=(\w+)\&?/).to_a.last
158
+ def parsed_opt(option, query: parsed_uri.query)
159
+ return if query.nil?
160
+
161
+ @parsed_query_opts ||= CGI.parse(query)
162
+ @parsed_query_opts[option].to_a.last
158
163
  end
159
164
  end
160
165
  end
@@ -95,7 +95,7 @@ module Hanami
95
95
  # @since 1.0.2
96
96
  # @api private
97
97
  def self.pg_json?(pristine)
98
- pristine == pg_json_pristines['JSONB'.freeze] ||
98
+ pristine == pg_json_pristines['JSONB'.freeze] || # rubocop:disable Style/MultipleComparison
99
99
  pristine == pg_json_pristines['JSON'.freeze]
100
100
  end
101
101
 
@@ -3,6 +3,6 @@ module Hanami
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '1.2.0'.freeze
6
+ VERSION = '1.3.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-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.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: 2018-04-11 00:00:00.000000000 Z
11
+ date: 2018-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hanami-utils
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.2'
19
+ version: 1.3.beta
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.2'
26
+ version: 1.3.beta
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rom
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -215,12 +215,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
215
215
  version: 2.3.0
216
216
  required_rubygems_version: !ruby/object:Gem::Requirement
217
217
  requirements:
218
- - - ">="
218
+ - - ">"
219
219
  - !ruby/object:Gem::Version
220
- version: '0'
220
+ version: 1.3.1
221
221
  requirements: []
222
222
  rubyforge_project:
223
- rubygems_version: 2.7.6
223
+ rubygems_version: 2.7.7
224
224
  signing_key:
225
225
  specification_version: 4
226
226
  summary: A persistence layer for Hanami