hanami-omakase 0.0.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 +7 -0
- data/LICENSE +20 -0
- data/README.md +48 -0
- data/hanami-omakase.gemspec +36 -0
- data/lib/hanami/omakase/utils/core_ext/integer.rb +41 -0
- data/lib/hanami/omakase/utils/duration.rb +41 -0
- data/lib/hanami/omakase/utils.rb +11 -0
- data/lib/hanami/omakase/version.rb +7 -0
- data/lib/hanami/omakase.rb +20 -0
- metadata +124 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d4ba4416500e94e01f68c2330a598ab73c3bb36b36eafb5d2c7903cd0339f3f8
|
|
4
|
+
data.tar.gz: b51711a7a4d1ec0562af711469311e3ffefbebd9871ea8d21e1a5ca6807f7190
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a4f9bbebd22a057c88c1dcc6d9caca65876b20a126ca183da5e02bc671db20558da9d0a8d28c39e54765d64efeeb7bb8ebace0ba100b4bd2e32bbd7e3419c7cf
|
|
7
|
+
data.tar.gz: 36ce559ca5843a72ce42b5f646eb37c76b918af24acbda2913d973a6a54a7f28ec704d4665c6c41c6fd02bae39b8831f5697fa6e8d5b347b32fc81dde9e6e45b
|
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Andrea Fomera
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
> [!WARNING]
|
|
2
|
+
> This project is not affiliated with the Hanami team, but a mere user of Hanami itself. The name Hanami Omakase was chosen to indicate it works with Hanami specifically and not other frameworks. DO NOT REPORT ISSUES FROM HERE TO HANAMI.
|
|
3
|
+
|
|
4
|
+
# hanami-omakase [][rubygem] [][actions]
|
|
5
|
+
|
|
6
|
+
Hanami Omakase is a collection of defaults picked for you, to get productive with Hanami fast, along with some extensions and utilities to make you happy.
|
|
7
|
+
|
|
8
|
+
Inspired by mega-frameworks in the Ruby space where defaults out of the box allow you to get productive, but with the ability to retain and fall back to the modular aspect of Hanami.
|
|
9
|
+
|
|
10
|
+
## License
|
|
11
|
+
|
|
12
|
+
See `LICENSE` file.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
bundle add hanami-omakase
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
In `config/app.rb`:
|
|
21
|
+
|
|
22
|
+
```rb
|
|
23
|
+
require "hamami"
|
|
24
|
+
require "hamami/omakase"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
That's all for now, you'll have access to the Core Extensions listed below throughout your Hanami application.
|
|
28
|
+
|
|
29
|
+
## Features:
|
|
30
|
+
|
|
31
|
+
### Core Extensions
|
|
32
|
+
|
|
33
|
+
#### Integer
|
|
34
|
+
|
|
35
|
+
- Adds support for `seconds`, `minutes`, `hours`, `days`, `weeks` and `years` methods on Integers to return a given number multiplied by the respective values to return the integer in seconds.
|
|
36
|
+
|
|
37
|
+
```ruby
|
|
38
|
+
1.second #=> 1
|
|
39
|
+
5.seconds #=> 5
|
|
40
|
+
1.minute #=> 60
|
|
41
|
+
1.hours #=> 3600
|
|
42
|
+
1.day #=> 86400
|
|
43
|
+
1.week #=> 604800
|
|
44
|
+
365.days #=> 31536000
|
|
45
|
+
1.year #=> 31536000
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
There are plural and singular methods for those mentioned above.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
|
+
require "hanami/omakase/version"
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |spec|
|
|
8
|
+
spec.name = "hanami-omakase"
|
|
9
|
+
spec.authors = ["Andrea Fomera"]
|
|
10
|
+
spec.email = ["afomera@hey.com"]
|
|
11
|
+
spec.license = "MIT"
|
|
12
|
+
spec.version = Hanami::Omakase::VERSION.dup
|
|
13
|
+
|
|
14
|
+
spec.summary = "Hanami Omakase: Defaults picked for you"
|
|
15
|
+
spec.description = spec.summary
|
|
16
|
+
spec.homepage = "https://afomera.dev"
|
|
17
|
+
spec.files = Dir["LICENSE", "README.md", "hanami-omakase.gemspec", "lib/**/*"]
|
|
18
|
+
spec.bindir = "bin"
|
|
19
|
+
spec.executables = []
|
|
20
|
+
spec.require_paths = ["lib"]
|
|
21
|
+
|
|
22
|
+
spec.extra_rdoc_files = ["README.md", "LICENSE"]
|
|
23
|
+
|
|
24
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
|
25
|
+
spec.metadata["changelog_uri"] = "https://github.com/afomera/hanami-omakase/blob/main/CHANGELOG.md"
|
|
26
|
+
spec.metadata["source_code_uri"] = "https://github.com/afomera/hanami-omakase"
|
|
27
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/afomera/hanami-omakase/issues"
|
|
28
|
+
|
|
29
|
+
spec.required_ruby_version = ">= 3.1.0"
|
|
30
|
+
|
|
31
|
+
spec.add_runtime_dependency "hanami", ">= 2.2"
|
|
32
|
+
spec.add_runtime_dependency "zeitwerk", "~> 2.6"
|
|
33
|
+
spec.add_development_dependency "bundler"
|
|
34
|
+
spec.add_development_dependency "rspec"
|
|
35
|
+
spec.add_development_dependency "yard"
|
|
36
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Extending Integer to provide time duration methods
|
|
4
|
+
# such as `seconds`, `minutes`, `hours`, `days`, and `weeks`.
|
|
5
|
+
# This allows for more readable time duration calculations.
|
|
6
|
+
# Example:
|
|
7
|
+
# 5.minutes # => 300 (seconds)
|
|
8
|
+
# 2.hours # => 7200 (seconds)
|
|
9
|
+
# 1.day # => 86400 (seconds)
|
|
10
|
+
# 3.weeks # => 1814400 (seconds)
|
|
11
|
+
class Integer
|
|
12
|
+
def seconds
|
|
13
|
+
self
|
|
14
|
+
end
|
|
15
|
+
alias_method :second, :seconds
|
|
16
|
+
|
|
17
|
+
def minutes
|
|
18
|
+
Hanami::Omakase::Utils::Duration.minutes(self)
|
|
19
|
+
end
|
|
20
|
+
alias_method :minute, :minutes
|
|
21
|
+
|
|
22
|
+
def hours
|
|
23
|
+
Hanami::Omakase::Utils::Duration.hours(self)
|
|
24
|
+
end
|
|
25
|
+
alias_method :hour, :hours
|
|
26
|
+
|
|
27
|
+
def days
|
|
28
|
+
Hanami::Omakase::Utils::Duration.days(self)
|
|
29
|
+
end
|
|
30
|
+
alias_method :day, :days
|
|
31
|
+
|
|
32
|
+
def weeks
|
|
33
|
+
Hanami::Omakase::Utils::Duration.weeks(self)
|
|
34
|
+
end
|
|
35
|
+
alias_method :week, :weeks
|
|
36
|
+
|
|
37
|
+
def years
|
|
38
|
+
Hanami::Omakase::Utils::Duration.years(self)
|
|
39
|
+
end
|
|
40
|
+
alias_method :year, :years
|
|
41
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Hanami
|
|
4
|
+
module Omakase
|
|
5
|
+
module Utils
|
|
6
|
+
module Duration
|
|
7
|
+
SECONDS_IN_MINUTE = 60
|
|
8
|
+
MINUTES_IN_HOUR = 60
|
|
9
|
+
HOURS_IN_DAY = 24
|
|
10
|
+
SECONDS_IN_HOUR = SECONDS_IN_MINUTE * MINUTES_IN_HOUR
|
|
11
|
+
SECONDS_IN_DAY = SECONDS_IN_HOUR * HOURS_IN_DAY
|
|
12
|
+
|
|
13
|
+
class << self
|
|
14
|
+
def seconds(value)
|
|
15
|
+
value
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def minutes(value)
|
|
19
|
+
value * SECONDS_IN_MINUTE
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def hours(value)
|
|
23
|
+
value * SECONDS_IN_HOUR
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def days(value)
|
|
27
|
+
value * SECONDS_IN_DAY
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def weeks(value)
|
|
31
|
+
value * SECONDS_IN_DAY * 7
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def years(value)
|
|
35
|
+
value * SECONDS_IN_DAY * 365
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "zeitwerk"
|
|
4
|
+
|
|
5
|
+
require "hanami/omakase/utils"
|
|
6
|
+
|
|
7
|
+
module Hanami
|
|
8
|
+
module Omakase
|
|
9
|
+
# @api private
|
|
10
|
+
def self.loader
|
|
11
|
+
@loader ||= Zeitwerk::Loader.new.tap do |loader|
|
|
12
|
+
root = File.expand_path "..", __dir__
|
|
13
|
+
loader.inflector = Zeitwerk::GemInflector.new("#{root}/hanami/omakase.rb")
|
|
14
|
+
loader.tag = "hanami-omakase"
|
|
15
|
+
loader.push_dir root
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
loader.setup
|
|
19
|
+
end
|
|
20
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: hanami-omakase
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Andrea Fomera
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: hanami
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '2.2'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '2.2'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: zeitwerk
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '2.6'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '2.6'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: bundler
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - ">="
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: rspec
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: yard
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0'
|
|
75
|
+
type: :development
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '0'
|
|
82
|
+
description: 'Hanami Omakase: Defaults picked for you'
|
|
83
|
+
email:
|
|
84
|
+
- afomera@hey.com
|
|
85
|
+
executables: []
|
|
86
|
+
extensions: []
|
|
87
|
+
extra_rdoc_files:
|
|
88
|
+
- LICENSE
|
|
89
|
+
- README.md
|
|
90
|
+
files:
|
|
91
|
+
- LICENSE
|
|
92
|
+
- README.md
|
|
93
|
+
- hanami-omakase.gemspec
|
|
94
|
+
- lib/hanami/omakase.rb
|
|
95
|
+
- lib/hanami/omakase/utils.rb
|
|
96
|
+
- lib/hanami/omakase/utils/core_ext/integer.rb
|
|
97
|
+
- lib/hanami/omakase/utils/duration.rb
|
|
98
|
+
- lib/hanami/omakase/version.rb
|
|
99
|
+
homepage: https://afomera.dev
|
|
100
|
+
licenses:
|
|
101
|
+
- MIT
|
|
102
|
+
metadata:
|
|
103
|
+
allowed_push_host: https://rubygems.org
|
|
104
|
+
changelog_uri: https://github.com/afomera/hanami-omakase/blob/main/CHANGELOG.md
|
|
105
|
+
source_code_uri: https://github.com/afomera/hanami-omakase
|
|
106
|
+
bug_tracker_uri: https://github.com/afomera/hanami-omakase/issues
|
|
107
|
+
rdoc_options: []
|
|
108
|
+
require_paths:
|
|
109
|
+
- lib
|
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
|
+
requirements:
|
|
112
|
+
- - ">="
|
|
113
|
+
- !ruby/object:Gem::Version
|
|
114
|
+
version: 3.1.0
|
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
|
+
requirements:
|
|
117
|
+
- - ">="
|
|
118
|
+
- !ruby/object:Gem::Version
|
|
119
|
+
version: '0'
|
|
120
|
+
requirements: []
|
|
121
|
+
rubygems_version: 3.6.7
|
|
122
|
+
specification_version: 4
|
|
123
|
+
summary: 'Hanami Omakase: Defaults picked for you'
|
|
124
|
+
test_files: []
|