Giter Site home page Giter Site logo

Comments (3)

chooyan-eng avatar chooyan-eng commented on July 26, 2024

@h5y1m141 さん

ご提案ありがとうございます!

確かにRubyのバージョンについての記載がないですね。
バージョンによってハマる場合がある点については同意です。(経験あります、、、)

リポジトリとして想定バージョンをひとつ決めてしまうのであれば、現在の最新安定板である2.5.0として、バージョンアップがあるたびに更新(コードに変更が必要 or より良い書き方がある場合はコードを修正)が良いかと思いました。

一方で、実際の開発現場ではおっしゃる通り「最新に追従できない」場合もあると思いますので、そのような状況を想定して、コミットされる方それぞれがなんらかの形で動作保証バージョンを明記する方法もアリかな、と思いました。

そこで質問なのですが、プロジェクトごとに動作を保証するRubyのバージョンを明記したい場合、Rubyとして何か一般的な方法ってありますか?もしご存知でしたらご意見いただければと思います。

from code-your-ruby.

h5y1m141 avatar h5y1m141 commented on July 26, 2024

プロジェクトごとに動作を保証するRubyのバージョンを明記したい場合、Rubyとして何か一般的な方法ってありますか?

rbenvを利用してる場合になってしまいますが、自分はたいていこういう感じで管理してます。

  1. プロジェクト直下に、.ruby-versionというファイルを作る
  2. そのファイルにそのプロジェクトでの想定のRubyのバージョンを記載する
  3. ついでに書くとGemfileはそのRubyのバージョンを利用してるのがわかるように後述のような記載をしておく

.ruby-versionの記載

単にこういう↓感じで記載するだけ

2.4.0

Gemfileから、.ruby-versionを読み取る設定

ruby File.read(File.expand_path('../.ruby-version', __FILE__)).strip
source 'https://rubygems.org'
# 以下省略

私は、rvmは利用してないのですが、人によってはこういうのを利用してRubyの管理されてるかもしれないですが、公式見ると

isted in order of precedence:

.rvmrc - shell script allowing full customization of the environment,
.versions.conf - key=value configuration file
.ruby-version - single line ruby-version only
Gemfile - comment: #ruby=1.9.3 and directive: ruby "1.9.3"

という感じでこっちも、.ruby-versionを参照してくれる仕組みあるようなので、.ruby-versionを利用して動作保証するのを、推奨しておく程度が無難なのかもしれませんね!

from code-your-ruby.

chooyan-eng avatar chooyan-eng commented on July 26, 2024

なるほど!では、libtestと同じ階層に.ruby-versionファイルを作って、そこにバージョンだけ記載しておくのがシンプルでよさそうですね。

もう少し調べてみて、特に問題や他の良い代替案がなさそうであればREADME.mdを更新しようと思います。ありがとうございます!

from code-your-ruby.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.