将 dry gems 从非常旧的版本升级到较新的版本(以兼容 ruby​​ 2.7)

发布于 2025-01-17 02:38:29 字数 1642 浏览 6 评论 0原文

我的公司目前正在尝试将我们的项目基础更新到 ruby​​ 2.7,为进一步更新到 ruby​​ 3.x 做准备。

我们所有的项目目前都在使用 ruby​​ 2.5 运行。

其中很多都很容易更新,但我必须处理一个非常旧的 gem,它是很久以前在内部开发的(并在另一个主要项目中使用),并且在非常过时的版本上运行 dry-rb gems。

我做了一个非常简单的尝试,没有太多希望,只是升级到最新版本并尝试修复运行规范时发生的错误,但正如预期的那样,效果不太好,因为最新版本需要的不仅仅是替换一些调用,而是一个更大的返工。

这是 gemspec 和 gemfile 的样子:

Gemspec

Gem::Specification.new do |s|
    #......

    s.add_runtime_dependency 'activesupport', '~> 5.2.4'
    s.add_dependency 'dry-configurable', '<0.13'
    s.add_dependency 'dry-container', '<0.8'
    s.add_dependency 'dry-struct', '~> 0.5.0'
    s.add_dependency 'dry-types', '~> 0.13.0'
    s.add_dependency 'dry-validation', '~> 0.12.0'
    s.add_dependency 'geo_coord', '~> 0.1'
    s.add_dependency 'i18n', '~> 1.0'
    s.add_dependency 'proj4rb', '~> 3.0'
    s.add_dependency 'psych', '~> 3.1'
    s.add_dependency 'ruby-netcdf', '~> 0.7'
    s.add_runtime_dependency 'thor', '~> 1.0', '~> 1.0.1'
end

Gemfile

source 'https://rubygems.org'
gemspec
gem 'dry-validation'

group :development, :test do
    gem 'bundler-audit'
    gem 'dry-validation-matchers', '~> 1.1.0'
    gem 'hashdiff'
    gem 'pry', '~> 0.11'
    gem 'railties', '> 0', require: false
    gem 'rake', '~> 12.3'
    gem 'rspec', '~> 3.7'
    gem 'rspec-dry-struct', '~> 0.3.0'
    gem 'rspec-prof'
    gem 'rubocop', '~> 0.62.0'
    gem 'simplecov', '~> 0.16'
    gem 'yard', '~> 0.9'
end

我对这类东西有点迷失,不知道从哪里开始。 如果有人有升级干宝石的经验,任何关于这些宝石与 ruby​​ 2.7 的第一个兼容版本的想法,或者我可以遵循的任何程序,以减少这个过程的痛苦,我将非常感激!

谢谢!

My company is currently trying to update our porject base to ruby 2.7 to prepare for a further update to ruby 3.x.

All our projects are currently running with ruby 2.5.

A lot of them were easy to update but i have to handle a very old gem that was developed internally a long time ago (and used in another main project) and which is running dry-rb gems on very outdated versions.

I made a very straightforward try with not much hope just upgrading to latest versions and trying to fix the errors occuring when i ran the specs but as expected that didn't work quite well as latest versions required more than just replacing a few calls but a bigger rework.

Here is what the gemspec and gemfile look like:

Gemspec

Gem::Specification.new do |s|
    #......

    s.add_runtime_dependency 'activesupport', '~> 5.2.4'
    s.add_dependency 'dry-configurable', '<0.13'
    s.add_dependency 'dry-container', '<0.8'
    s.add_dependency 'dry-struct', '~> 0.5.0'
    s.add_dependency 'dry-types', '~> 0.13.0'
    s.add_dependency 'dry-validation', '~> 0.12.0'
    s.add_dependency 'geo_coord', '~> 0.1'
    s.add_dependency 'i18n', '~> 1.0'
    s.add_dependency 'proj4rb', '~> 3.0'
    s.add_dependency 'psych', '~> 3.1'
    s.add_dependency 'ruby-netcdf', '~> 0.7'
    s.add_runtime_dependency 'thor', '~> 1.0', '~> 1.0.1'
end

Gemfile

source 'https://rubygems.org'
gemspec
gem 'dry-validation'

group :development, :test do
    gem 'bundler-audit'
    gem 'dry-validation-matchers', '~> 1.1.0'
    gem 'hashdiff'
    gem 'pry', '~> 0.11'
    gem 'railties', '> 0', require: false
    gem 'rake', '~> 12.3'
    gem 'rspec', '~> 3.7'
    gem 'rspec-dry-struct', '~> 0.3.0'
    gem 'rspec-prof'
    gem 'rubocop', '~> 0.62.0'
    gem 'simplecov', '~> 0.16'
    gem 'yard', '~> 0.9'
end

I'm kind of lost with this kind of stuff and don't really know where to start.
If anybody has any experience with upgrading dry gems, any idea of the first compatible versions of those gems with ruby 2.7 or any procedure i could follow to make the process less painful that would be really appreciated!

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜声 2025-01-24 02:38:29

首先在 ruby​​gems 文档上检查您的版本要求(如下所示 dry-configurable) 。并通过将每一个干宝石都制作为一个接一个的小版本来取得进展。

旁注:拥有铁路项目的公司使用了一些共轨升级策略。检查如何 双启动next_rails gem它可能会帮助您在此过程中升级,此外,一些良好的测试覆盖率和 CI/CD 设置将在升级过程中非常有帮助。

检查 FastRuby 页面并单击“获取图书”。这是一本非常有用的 Rails 升级书籍。

First of all check your versions requirements on rubygems docs (as in here dry-configurable). And progress by making each of those dry gems a minor version bumping one-by-one.

Side note: There are a few common rails upgrades strategies used by companies with rails projects. Check how to dual boot with next_rails gem it might help you upgrade during the process, also, some good test coverage and a CI/CD setup would be very helpful through this upgrade process.

Check FastRuby page and click the 'Get the book'. It's a very helpful rails upgrade book.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文