hanami-ruby3 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7d1ea1f6542da9c25967c48b656397f2a399e51ed288a9cd8606b8e806fbbab0
4
+ data.tar.gz: 9a9b8072477e17078498ba1e51b4fd8232f144aa7c293b0f7a9f16adebac5dcd
5
+ SHA512:
6
+ metadata.gz: f810cc9a7bd9424dbb397fdee27bd8f3bc06d828e764e4dc639506ba159ead5cd9d564b0b502570ee36e42dbead8212a96b4ba062c4b63c1432acd3343d0aed1
7
+ data.tar.gz: 94c8a0e900e62798242fd9ee242ab44aef9b0c0f51b9378a74f9f792c30c52a08250286b17f13baa8fbf957c879b48da7df1db5d9510a4c6c66a1254b3e700cf
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in hanami-ruby3.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,118 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hanami-ruby3 (0.0.1)
5
+ hanami (= 1.3.4)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ concurrent-ruby (1.2.0)
11
+ date (3.3.3)
12
+ dry-cli (0.7.0)
13
+ dry-configurable (1.0.1)
14
+ dry-core (~> 1.0, < 2)
15
+ zeitwerk (~> 2.6)
16
+ dry-core (1.0.0)
17
+ concurrent-ruby (~> 1.0)
18
+ zeitwerk (~> 2.6)
19
+ dry-inflector (1.0.0)
20
+ dry-initializer (3.1.1)
21
+ dry-logic (1.5.0)
22
+ concurrent-ruby (~> 1.0)
23
+ dry-core (~> 1.0, < 2)
24
+ zeitwerk (~> 2.6)
25
+ dry-schema (1.13.0)
26
+ concurrent-ruby (~> 1.0)
27
+ dry-configurable (~> 1.0, >= 1.0.1)
28
+ dry-core (~> 1.0, < 2)
29
+ dry-initializer (~> 3.0)
30
+ dry-logic (>= 1.5, < 2)
31
+ dry-types (>= 1.7, < 2)
32
+ zeitwerk (~> 2.6)
33
+ dry-types (1.7.0)
34
+ concurrent-ruby (~> 1.0)
35
+ dry-core (~> 1.0, < 2)
36
+ dry-inflector (~> 1.0, < 2)
37
+ dry-logic (>= 1.4, < 2)
38
+ zeitwerk (~> 2.6)
39
+ dry-validation (1.10.0)
40
+ concurrent-ruby (~> 1.0)
41
+ dry-core (~> 1.0, < 2)
42
+ dry-initializer (~> 3.0)
43
+ dry-schema (>= 1.12, < 2)
44
+ zeitwerk (~> 2.6)
45
+ hanami (1.3.4)
46
+ bundler (>= 1.6, < 3)
47
+ concurrent-ruby (~> 1.0)
48
+ dry-cli (~> 0.5)
49
+ hanami-assets (~> 1.3)
50
+ hanami-controller (~> 1.3)
51
+ hanami-helpers (~> 1.3)
52
+ hanami-mailer (~> 1.3)
53
+ hanami-router (~> 1.3)
54
+ hanami-utils (~> 1.3)
55
+ hanami-validations (>= 1.3, < 3)
56
+ hanami-view (~> 1.3)
57
+ hanami-assets (1.3.5)
58
+ hanami-helpers (~> 1.3)
59
+ hanami-utils (~> 1.3)
60
+ tilt (~> 2.0, >= 2.0.2)
61
+ hanami-controller (1.3.3)
62
+ hanami-utils (~> 1.3)
63
+ rack (~> 2.0)
64
+ hanami-helpers (1.3.3)
65
+ hanami-utils (~> 1.3)
66
+ hanami-mailer (1.3.3)
67
+ hanami-utils (~> 1.3)
68
+ mail (~> 2.6)
69
+ tilt (~> 2.0, >= 2.0.1)
70
+ hanami-router (1.3.2)
71
+ hanami-utils (~> 1.3)
72
+ http_router (= 0.11.2)
73
+ rack (~> 2.0)
74
+ hanami-utils (1.3.8)
75
+ concurrent-ruby (~> 1.0)
76
+ transproc (~> 1.0)
77
+ hanami-validations (2.0.1)
78
+ dry-validation (>= 1.10, < 2)
79
+ zeitwerk (~> 2.6.0)
80
+ hanami-view (1.3.3)
81
+ hanami-utils (~> 1.3)
82
+ tilt (~> 2.0, >= 2.0.1)
83
+ http_router (0.11.2)
84
+ rack (>= 1.0.0)
85
+ url_mount (~> 0.2.1)
86
+ mail (2.8.0.1)
87
+ mini_mime (>= 0.1.1)
88
+ net-imap
89
+ net-pop
90
+ net-smtp
91
+ mini_mime (1.1.2)
92
+ net-imap (0.3.4)
93
+ date
94
+ net-protocol
95
+ net-pop (0.1.2)
96
+ net-protocol
97
+ net-protocol (0.2.1)
98
+ timeout
99
+ net-smtp (0.3.3)
100
+ net-protocol
101
+ rack (2.2.6.2)
102
+ rake (12.3.3)
103
+ tilt (2.0.11)
104
+ timeout (0.3.1)
105
+ transproc (1.1.1)
106
+ url_mount (0.2.1)
107
+ rack
108
+ zeitwerk (2.6.6)
109
+
110
+ PLATFORMS
111
+ x86_64-darwin-21
112
+
113
+ DEPENDENCIES
114
+ hanami-ruby3!
115
+ rake (~> 12.0)
116
+
117
+ BUNDLED WITH
118
+ 2.4.3
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Hanami Ruby 3.0
2
+
3
+ Monkey patches Hanami components to support Ruby 3.0
4
+
5
+ ## Overview
6
+
7
+ To use this gem, make sure your app works with Ruby 2.7.6.
8
+
9
+ This should only be installed for a short time, during the Hanami Upgrade process.
10
+ It just overrides a few of the Hanami classes, replacing code raising deprecation
11
+ warnings with updated code supported Ruby 3.0 syntax.
12
+
13
+ ## Warning!!!
14
+
15
+ This code just overrides the Hanami components, does not introduce tests of any sort.
16
+ Before you upgrade your Ruby version, make sure, that your code is covered with tests,
17
+ and your deprecations tracked.
18
+
19
+ ## Usage
20
+
21
+ In your project, install overrides for the given classes
22
+
23
+ ```ruby
24
+ gem 'hanami-utils', github: 'swilgosz/hanami-utils', branch: '1.3.x-support-ruby-3.0'
25
+ gem 'hanami-ruby3', path: '../hanami-ruby3'
26
+ ```
27
+
28
+ Then load overrides in the `environment.rb`, after loading Hanami files.
29
+
30
+ ```ruby
31
+ require 'hanami/setup'
32
+ require 'hanami/ruby3'
33
+ ```
34
+
35
+ With this, you should not have any Ruby Deprecation warnings and you should be fine do update to Ruby 3.0
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "rspec/core/rake_task"
2
+
3
+ RSpec::Core::RakeTask.new(:spec)
4
+
5
+ task default: :spec
6
+
7
+ desc "Print out the gem version in gemspec file"
8
+ task :gem_version do
9
+ puts Bundler.load_gemspec("hanami-ruby.gemspec").version.to_s
10
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "hanami/ruby3"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,30 @@
1
+ require_relative 'lib/hanami/ruby3/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "hanami-ruby3"
5
+ spec.version = Hanami::Ruby3::VERSION
6
+ spec.authors = ["Ascenda Developers"]
7
+ spec.email = ["developers@ascendaloyalty.com"]
8
+
9
+ spec.summary = "Set of component overrides for Hanami 1.3.X to support Ruby 3.0"
10
+ spec.description = "Set of component overrides for Hanami 1.3.X to support Ruby 3.0"
11
+ spec.homepage = "http://github.com/Kaligo/hanami-ruby3"
12
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.6")
13
+
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = "http://github.com/Kaligo/hanami-ruby3"
16
+ spec.metadata["changelog_uri"] = "http://github.com/Kaligo/hanami-ruby3/releases"
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
+ spec.metadata["github_repo"] = "ssh://github.com/Kaligo/hanami-ruby3"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_dependency "hanami", "1.3.4"
30
+ end
@@ -0,0 +1 @@
1
+ require_relative "./hanami/ruby3"
Binary file
@@ -0,0 +1,13 @@
1
+ module Hanami
2
+ module Action
3
+ module Mime
4
+ module InstanceMethods
5
+ def initialize(*, **)
6
+ super
7
+ @content_type = nil
8
+ @charset = nil
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ # TODO: remove when https://github.com/hanami/controller/pull/339 is merged
2
+ module Hanami
3
+ module Action
4
+ module Rack
5
+ module InstanceMethods
6
+ def initialize(*, **)
7
+ super
8
+ @_status = nil
9
+ @_body = nil
10
+ end
11
+ end
12
+
13
+ module ClassMethods
14
+ def use(middleware, *args, **kwargs, &block)
15
+ rack_builder.use(middleware, *args, **kwargs, &block)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ # TODO: remove when Hanami supports ruby 3.0
2
+ module Hanami
3
+ class App
4
+ private
5
+
6
+ def middleware(configuration, environment)
7
+ builder.use Hanami::CommonLogger, Hanami.logger unless Hanami.logger.nil?
8
+ builder.use Rack::ContentLength
9
+
10
+ configuration.middleware.each do |m, args, kwargs, &blk|
11
+ builder.use(m, *args, **kwargs, &blk)
12
+ end
13
+
14
+ if configuration.early_hints
15
+ require 'hanami/early_hints'
16
+ builder.use Hanami::EarlyHints
17
+ end
18
+
19
+ if (middleware = environment.static_assets_middleware)
20
+ builder.use middleware
21
+ end
22
+
23
+ builder.use Rack::MethodOverride
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,22 @@
1
+ require 'hanami/cli/commands/command'
2
+
3
+ # TODO: remove once Hanami supports ruby 3.0
4
+ module Hanami
5
+ class CLI
6
+ module Commands
7
+ module Assets
8
+ # @since 1.1.0
9
+ # @api private
10
+ class Precompile < ::Hanami::CLI::Commands::Command
11
+ # @since 1.1.0
12
+ # @api private
13
+ def call(*, **options)
14
+ context = Context.new(options: options)
15
+
16
+ precompile_assets(context)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,34 @@
1
+ module Hanami
2
+ module Components
3
+ # NOTE: Monkey-patch Hanami console to avoid reloading lib folder.
4
+ # So that it does not interfere with ROM::Struct & Dry::Validation::Contract
5
+ register 'code' do
6
+ run do
7
+ directory = Hanami.root.join('lib')
8
+ Utils.require!(directory)
9
+ end
10
+ end
11
+
12
+ # NOTE: Hanami 1.3 does not support Ruby 3.0, and there is no plan to add
13
+ # official support just yet. Monkey Patching for now
14
+ #
15
+ register 'logger' do
16
+ prepare do
17
+ require 'hanami/logger'
18
+
19
+ resolve do |configuration|
20
+ if configuration.logger.is_a?(Array)
21
+ if logger_interface?(configuration.logger.first)
22
+ configuration.logger.first
23
+ else
24
+ kwargs = configuration.logger.last
25
+ Hanami::Logger.new(Hanami.environment.project_name, *configuration.logger, **kwargs)
26
+ end
27
+ else
28
+ Hanami::Logger.new(Hanami.environment.project_name, **configuration.logger)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,9 @@
1
+ module Hanami
2
+ class Configuration
3
+ class Middleware
4
+ def use(middleware, *args, **kwargs, &blk)
5
+ @middleware.push([middleware, args, kwargs, blk])
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ # TODO: remove when Hanami supports ruby 3.0
2
+ module Hanami
3
+ class Configuration
4
+ def logger(*args, **kwargs)
5
+ if args.empty? && kwargs.empty?
6
+ settings.fetch(:logger, nil)
7
+ else
8
+ settings[:logger] = [*args, kwargs]
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,47 @@
1
+ require 'hanami/utils/basic_object'
2
+ require 'hanami/view/escape'
3
+
4
+ module Hanami
5
+ module View
6
+ module Rendering
7
+ class LayoutScope < Utils::BasicObject
8
+ protected
9
+
10
+ # Forward all the missing methods to the view scope or to the layout.
11
+ #
12
+ # @api private
13
+ # @since 0.1.0
14
+ #
15
+ # @see Hanami::View::Rendering::Scope
16
+ # @see Hanami::Layout
17
+ #
18
+ # @example
19
+ # # In the layout template:
20
+ # # templates/application.html.erb
21
+ # #
22
+ # # Use like this:
23
+ # <title><%= article.title %></title>
24
+ #
25
+ # # `article` will be looked up in the view scope first.
26
+ # # If not found, it will be searched within the layout.
27
+ # rubocop:disable Style/MissingRespondToMissing, Lint/DuplicateBranch
28
+ def method_missing(m_name, *args, **kwargs, &blk)
29
+ # FIXME: this isn't compatible with Hanami 2.0, as it extends a view
30
+ # that we want to be frozen in the future
31
+ #
32
+ # See https://github.com/hanami/view/issues/130#issuecomment-319326236
33
+ if @scope.respond_to?(m_name, true) && @scope.locals.key?(m_name) && layout.respond_to?(m_name, true)
34
+ layout.__send__(m_name, *args, **kwargs, &blk)
35
+ elsif @scope.respond_to?(m_name, true)
36
+ @scope.__send__(m_name, *args, **kwargs, &blk)
37
+ elsif layout.respond_to?(m_name, true)
38
+ layout.__send__(m_name, *args, **kwargs, &blk)
39
+ else
40
+ ::Hanami::View::Escape.html(super)
41
+ end
42
+ end
43
+ # rubocop:enable Style/MissingRespondToMissing, Lint/DuplicateBranch
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,29 @@
1
+ module Hanami
2
+ module View
3
+ module Rendering
4
+ class Scope < LayoutScope
5
+
6
+ protected
7
+
8
+ # @api private
9
+ # rubocop:disable Style/MissingRespondToMissing
10
+ def method_missing(m_name, *args, **kwargs, &block)
11
+ ::Hanami::View::Escape.html(
12
+ # FIXME: this isn't compatible with Hanami 2.0, as it extends a view
13
+ # that we want to be frozen in the future
14
+ #
15
+ # See https://github.com/hanami/view/issues/130#issuecomment-319326236
16
+ if @view.respond_to?(m_name, true)
17
+ @view.__send__ m_name, *args, **kwargs, &block
18
+ elsif @locals.key?(m_name)
19
+ @locals[m_name]
20
+ else
21
+ super
22
+ end
23
+ )
24
+ end
25
+ # rubocop:enable Style/MissingRespondToMissing
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ require 'hanami/views/default_template_finder'
2
+
3
+ module Hanami
4
+ module Views
5
+ class Default
6
+ def self.render(root, template_name, context)
7
+ format = context[:format]
8
+ template = DefaultTemplateFinder.new(self, root, template_name, format).find
9
+
10
+ if template
11
+ new(template, **context).render
12
+ else
13
+ super(context)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hanami
4
+ module Ruby3
5
+ VERSION = "0.0.1"
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ require_relative "./ruby3/version"
2
+
3
+ require "hanami"
4
+
5
+ Dir["#{__dir__}/ruby3/hanami/**/*.rb"].each do |f|
6
+ require_relative f
7
+ end
8
+
9
+ module Hanami
10
+ module Ruby3; end
11
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hanami-ruby3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ascenda Developers
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-01-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hanami
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.3.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.3.4
27
+ description: Set of component overrides for Hanami 1.3.X to support Ruby 3.0
28
+ email:
29
+ - developers@ascendaloyalty.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - README.md
39
+ - Rakefile
40
+ - bin/console
41
+ - hanami-ruby3.gemspec
42
+ - lib/hanami/hanami-ruby3.rb
43
+ - lib/hanami/ruby3.rb
44
+ - lib/hanami/ruby3/.DS_Store
45
+ - lib/hanami/ruby3/hanami/action/mime.rb
46
+ - lib/hanami/ruby3/hanami/action/rack.rb
47
+ - lib/hanami/ruby3/hanami/app.rb
48
+ - lib/hanami/ruby3/hanami/cli/commands/assets/precompile.rb
49
+ - lib/hanami/ruby3/hanami/components/components.rb
50
+ - lib/hanami/ruby3/hanami/configuration.rb
51
+ - lib/hanami/ruby3/hanami/configuration/middleware.rb
52
+ - lib/hanami/ruby3/hanami/view/rendering/layout_scope.rb
53
+ - lib/hanami/ruby3/hanami/view/rendering/scope.rb
54
+ - lib/hanami/ruby3/hanami/views/default.rb
55
+ - lib/hanami/ruby3/version.rb
56
+ homepage: http://github.com/Kaligo/hanami-ruby3
57
+ licenses: []
58
+ metadata:
59
+ homepage_uri: http://github.com/Kaligo/hanami-ruby3
60
+ source_code_uri: http://github.com/Kaligo/hanami-ruby3
61
+ changelog_uri: http://github.com/Kaligo/hanami-ruby3/releases
62
+ allowed_push_host: https://rubygems.org
63
+ github_repo: ssh://github.com/Kaligo/hanami-ruby3
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 2.7.6
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubygems_version: 3.2.31
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Set of component overrides for Hanami 1.3.X to support Ruby 3.0
83
+ test_files: []