hanami-utils 1.0.0.beta3 → 1.0.0.rc1

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: 627e0486c780c11f9ce000f6d80b2a8b691b5e45
4
- data.tar.gz: 033e15d05ac40fb8ad76174108a4b54b0aeb21ca
3
+ metadata.gz: 451f3a95a054ee9c8b43e77ff9b508606c587cd4
4
+ data.tar.gz: 6290517874803863fbbb295739a7d25e4d3e6b61
5
5
  SHA512:
6
- metadata.gz: 8bc330a6116872fb4a8d072d74fe99d8b961b1c78cdb4e9237b4153283148e704fa3a0d60369b23cb3b733076b7e200fe4ddaafa908a928cc12c3e6e3d1f92e5
7
- data.tar.gz: 68670773d3fa4ef2b4d30030fdeb08f52d752a46366c94dd9f8abf0713d95ed91fc33b524ef7c3998bc274bee677a18fe32944f56b34e70dcc431a7a00d0766b
6
+ metadata.gz: 677588b9ad278e4496e0a08025e6f73efbcf4eaebfcb2e3a47f722fa39017217cfe1cbf9602c3593b6c691e3bda7e7bfb3f60b7b3463402c592b5840265a0585
7
+ data.tar.gz: e4c52ea6103c19e69b18802a31719da59c6ff14fc48e509e26dffd5750432300467b857bf6c60a8db91a5de0a4134e7b61b02c219c7281e872003459b9d6348a
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Hanami::Utils
2
2
  Ruby core extentions and class utilities for Hanami
3
3
 
4
+ ## v1.0.0.rc1 - 2017-03-31
5
+ ### Added
6
+ - [Luca Guidi] Allow `Hanami::Logger#initialize` to accept arguments to be compliant with Ruby's `Logger`
7
+
4
8
  ## v1.0.0.beta3 - 2017-03-17
5
9
  ### Fixed
6
10
  - [Luca Guidi] Use `$stdout` instead of `STDOUT` as default stream for `Hanami::Logger`
data/hanami-utils.gemspec CHANGED
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'hanami/utils/version'
@@ -6,8 +7,8 @@ require 'hanami/utils/version'
6
7
  Gem::Specification.new do |spec|
7
8
  spec.name = 'hanami-utils'
8
9
  spec.version = Hanami::Utils::VERSION
9
- spec.authors = ['Luca Guidi', 'Trung Lê', 'Alfonso Uceda']
10
- spec.email = ['me@lucaguidi.com', 'trung.le@ruby-journal.com', 'uceda73@gmail.com']
10
+ spec.authors = ['Luca Guidi']
11
+ spec.email = ['me@lucaguidi.com']
11
12
  spec.description = 'Hanami utilities'
12
13
  spec.summary = 'Ruby core extentions and Hanami utilities'
13
14
  spec.homepage = 'http://hanamirb.org'
@@ -21,7 +21,6 @@ module Hanami
21
21
  success?: true,
22
22
  successful?: true,
23
23
  failure?: true,
24
- failing?: true,
25
24
  fail!: true,
26
25
  prepare!: true,
27
26
  errors: true,
@@ -211,12 +210,12 @@ module Hanami
211
210
  # end
212
211
  #
213
212
  # def call
214
- # @user = UserRepository.persist(@user)
213
+ # @user = UserRepository.new.persist(@user)
215
214
  # end
216
215
  # end
217
216
  #
218
217
  # result = Signup.new(name: 'Luca').call
219
- # result.failing? # => false
218
+ # result.failure? # => false
220
219
  # result.successful? # => true
221
220
  #
222
221
  # result.user # => #<User:0x007fa311105778 @id=1 @name="Luca">
@@ -237,7 +236,7 @@ module Hanami
237
236
  #
238
237
  # # THIS WON'T BE INVOKED BECAUSE #valid? WILL RETURN false
239
238
  # def call
240
- # @user = UserRepository.persist(@user)
239
+ # @user = UserRepository.new.persist(@user)
241
240
  # end
242
241
  #
243
242
  # private
@@ -248,7 +247,7 @@ module Hanami
248
247
  #
249
248
  # result = Signup.new(name: nil).call
250
249
  # result.successful? # => false
251
- # result.failing? # => true
250
+ # result.failure? # => true
252
251
  #
253
252
  # result.user # => #<User:0x007fa311105778 @id=nil @name="Luca">
254
253
  #
@@ -303,7 +302,7 @@ module Hanami
303
302
  #
304
303
  # private
305
304
  # def persist_email_test!
306
- # @email_test = EmailTestRepository.persist(@email_test)
305
+ # @email_test = EmailTestRepository.new.persist(@email_test)
307
306
  # end
308
307
  #
309
308
  # # IF THIS RAISES AN EXCEPTION WE FORCE A FAILURE
data/lib/hanami/logger.rb CHANGED
@@ -110,7 +110,7 @@ module Hanami
110
110
 
111
111
  # @since 1.0.0.beta1
112
112
  # @api private
113
- RESERVED_KEYS = [:app, :severity, :time].freeze
113
+ RESERVED_KEYS = %i(app severity time).freeze
114
114
 
115
115
  include Utils::ClassAttribute
116
116
 
@@ -256,12 +256,127 @@ module Hanami
256
256
  # @param application_name [String] an optional application name used for
257
257
  # tagging purposes
258
258
  #
259
- # @param stream [String, IO, StringIO, Pathname] an optional log stream. This is a filename
260
- # (String) or IO object (typically `$stdout`, `$stderr`, or an open file).
259
+ # @param args [Array<Object>] an optional set of arguments to honor Ruby's
260
+ # `Logger#initialize` arguments. See Ruby documentation for details.
261
+ #
262
+ # @param stream [String, IO, StringIO, Pathname] an optional log stream.
263
+ # This is a filename (`String`) or `IO` object (typically `$stdout`,
264
+ # `$stderr`, or an open file). It defaults to `$stderr`.
265
+ #
266
+ # @param level [Integer,String] logging level. It can be expressed as an
267
+ # integer, according to Ruby's `Logger` from standard library or as a
268
+ # string with the name of the level
269
+ #
270
+ # @param formatter [Symbol,#_format] a formatter - We support `:json` as
271
+ # JSON formatter or an object that respond to `#_format(data)`
261
272
  #
262
273
  # @since 0.5.0
263
- def initialize(application_name = nil, stream: $stdout, level: DEBUG, formatter: nil)
264
- super(stream)
274
+ #
275
+ # @see https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html#class-Logger-label-How+to+create+a+logger
276
+ #
277
+ # @example Basic usage
278
+ # require 'hanami/logger'
279
+ #
280
+ # logger = Hanami::Logger.new
281
+ # logger.info "Hello World"
282
+ #
283
+ # # => [Hanami] [DEBUG] [2017-03-30 15:41:01 +0200] Hello World
284
+ #
285
+ # @example Custom application name
286
+ # require 'hanami/logger'
287
+ #
288
+ # logger = Hanami::Logger.new('bookshelf')
289
+ # logger.info "Hello World"
290
+ #
291
+ # # => [bookshelf] [DEBUG] [2017-03-30 15:44:23 +0200] Hello World
292
+ #
293
+ # @example Logger level (Integer)
294
+ # require 'hanami/logger'
295
+ #
296
+ # logger = Hanami::Logger.new(level: 2) # WARN
297
+ # logger.info "Hello World"
298
+ # # => true
299
+ #
300
+ # logger.info "Hello World"
301
+ # # => true
302
+ #
303
+ # logger.warn "Hello World"
304
+ # # => [Hanami] [WARN] [2017-03-30 16:00:48 +0200] Hello World
305
+ #
306
+ # @example Logger level (Constant)
307
+ # require 'hanami/logger'
308
+ #
309
+ # logger = Hanami::Logger.new(level: Hanami::Logger::WARN)
310
+ # logger.info "Hello World"
311
+ # # => true
312
+ #
313
+ # logger.info "Hello World"
314
+ # # => true
315
+ #
316
+ # logger.warn "Hello World"
317
+ # # => [Hanami] [WARN] [2017-03-30 16:00:48 +0200] Hello World
318
+ #
319
+ # @example Logger level (String)
320
+ # require 'hanami/logger'
321
+ #
322
+ # logger = Hanami::Logger.new(level: 'warn')
323
+ # logger.info "Hello World"
324
+ # # => true
325
+ #
326
+ # logger.info "Hello World"
327
+ # # => true
328
+ #
329
+ # logger.warn "Hello World"
330
+ # # => [Hanami] [WARN] [2017-03-30 16:00:48 +0200] Hello World
331
+ #
332
+ # @example Use a file
333
+ # require 'hanami/logger'
334
+ #
335
+ # logger = Hanami::Logger.new(stream: "development.log")
336
+ # logger.info "Hello World"
337
+ #
338
+ # # => true
339
+ #
340
+ # File.read("development.log")
341
+ # # =>
342
+ # # # Logfile created on 2017-03-30 15:52:48 +0200 by logger.rb/56815
343
+ # # [Hanami] [DEBUG] [2017-03-30 15:52:54 +0200] Hello World
344
+ #
345
+ # @example Period rotation
346
+ # require 'hanami/logger'
347
+ #
348
+ # # Rotate daily
349
+ # logger = Hanami::Logger.new('bookshelf', 'daily', stream: 'development.log')
350
+ #
351
+ # @example File size rotation
352
+ # require 'hanami/logger'
353
+ #
354
+ # # leave 10 old log files where the size is about 1,024,000 bytes
355
+ # logger = Hanami::Logger.new('bookshelf', 10, 1024000, stream: 'development.log')
356
+ #
357
+ # @example Use a StringIO
358
+ # require 'hanami/logger'
359
+ #
360
+ # stream = StringIO.new
361
+ # logger = Hanami::Logger.new(stream: stream)
362
+ # logger.info "Hello World"
363
+ #
364
+ # # => true
365
+ #
366
+ # stream.rewind
367
+ # stream.read
368
+ #
369
+ # # => "[Hanami] [DEBUG] [2017-03-30 15:55:22 +0200] Hello World\n"
370
+ #
371
+ # @example JSON formatter
372
+ # require 'hanami/logger'
373
+ #
374
+ # logger = Hanami::Logger.new(formatter: :json)
375
+ # logger.info "Hello World"
376
+ #
377
+ # # => {"app":"Hanami","severity":"DEBUG","time":"2017-03-30T13:57:59Z","message":"Hello World"}
378
+ def initialize(application_name = nil, *args, stream: $stdout, level: DEBUG, formatter: nil)
379
+ super(stream, *args)
265
380
 
266
381
  @level = _level(level)
267
382
  @stream = stream
@@ -44,7 +44,7 @@ module Hanami
44
44
  # # Append a Proc to be used as a callback, it will be wrapped by `Callback`
45
45
  # # The optional argument(s) correspond to the one passed when invoked the chain with `run`.
46
46
  # chain.append { Authenticator.authenticate! }
47
- # chain.append { |params| ArticleRepository.find(params[:id]) }
47
+ # chain.append { |params| ArticleRepository.new.find(params[:id]) }
48
48
  #
49
49
  # # Append a Symbol as a reference to a method name that will be used as a callback.
50
50
  # # It will wrapped by `MethodCallback`
@@ -83,7 +83,7 @@ module Hanami
83
83
  # # Add a Proc to be used as a callback, it will be wrapped by `Callback`
84
84
  # # The optional argument(s) correspond to the one passed when invoked the chain with `run`.
85
85
  # chain.prepend { Authenticator.authenticate! }
86
- # chain.prepend { |params| ArticleRepository.find(params[:id]) }
86
+ # chain.prepend { |params| ArticleRepository.new.find(params[:id]) }
87
87
  #
88
88
  # # Add a Symbol as a reference to a method name that will be used as a callback.
89
89
  # # It will wrapped by `MethodCallback`
@@ -3,6 +3,6 @@ module Hanami
3
3
  # Defines the version
4
4
  #
5
5
  # @since 0.1.0
6
- VERSION = '1.0.0.beta3'.freeze
6
+ VERSION = '1.0.0.rc1'.freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,16 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta3
4
+ version: 1.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
- - Trung Lê
9
- - Alfonso Uceda
10
8
  autorequire:
11
9
  bindir: bin
12
10
  cert_chain: []
13
- date: 2017-03-17 00:00:00.000000000 Z
11
+ date: 2017-03-31 00:00:00.000000000 Z
14
12
  dependencies:
15
13
  - !ruby/object:Gem::Dependency
16
14
  name: bundler
@@ -43,8 +41,6 @@ dependencies:
43
41
  description: Hanami utilities
44
42
  email:
45
43
  - me@lucaguidi.com
46
- - trung.le@ruby-journal.com
47
- - uceda73@gmail.com
48
44
  executables: []
49
45
  extensions: []
50
46
  extra_rdoc_files: []
@@ -95,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
91
  version: 1.3.1
96
92
  requirements: []
97
93
  rubyforge_project:
98
- rubygems_version: 2.6.8
94
+ rubygems_version: 2.6.11
99
95
  signing_key:
100
96
  specification_version: 4
101
97
  summary: Ruby core extentions and Hanami utilities