Comments (3)
@h5y1m141 さん
ご提案ありがとうございます!
確かにRubyのバージョンについての記載がないですね。
バージョンによってハマる場合がある点については同意です。(経験あります、、、)
リポジトリとして想定バージョンをひとつ決めてしまうのであれば、現在の最新安定板である2.5.0として、バージョンアップがあるたびに更新(コードに変更が必要 or より良い書き方がある場合はコードを修正)が良いかと思いました。
一方で、実際の開発現場ではおっしゃる通り「最新に追従できない」場合もあると思いますので、そのような状況を想定して、コミットされる方それぞれがなんらかの形で動作保証バージョンを明記する方法もアリかな、と思いました。
そこで質問なのですが、プロジェクトごとに動作を保証するRubyのバージョンを明記したい場合、Rubyとして何か一般的な方法ってありますか?もしご存知でしたらご意見いただければと思います。
from code-your-ruby.
プロジェクトごとに動作を保証するRubyのバージョンを明記したい場合、Rubyとして何か一般的な方法ってありますか?
rbenvを利用してる場合になってしまいますが、自分はたいていこういう感じで管理してます。
- プロジェクト直下に、.ruby-versionというファイルを作る
- そのファイルにそのプロジェクトでの想定のRubyのバージョンを記載する
- ついでに書くと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.
なるほど!では、lib
やtest
と同じ階層に.ruby-version
ファイルを作って、そこにバージョンだけ記載しておくのがシンプルでよさそうですね。
もう少し調べてみて、特に問題や他の良い代替案がなさそうであればREADME.md
を更新しようと思います。ありがとうございます!
from code-your-ruby.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from code-your-ruby.