8. 高階語言開發的相依性
Applications
How can we make
Libraries
it more smooth?
Virtual Machine/Interpreter/Compiler
Abstraction!
Native Code / Libraries
Write once, debug
run anywhere OS
Hardware
9. High-Level Languages Development
in 2012 should…
1. 容易安裝、切換執行環境
2. 容易安裝函式庫
3. 確保所有開發者、部署環境使用相同版本
的函式庫
4. 使用版本控制系統,程式化地管理相依性
5. 函式庫應使用一致的版號規則描述相容性
10. “Getting Started” Scenario
Install environment
Clone the project
Install project
dependencies
Run the program Execute unit test
TDD
11. 安裝 Ruby Rubies
Install environment
$ apt-get install ruby
$ yum –y install ruby Clone the project
Install project
• Not always up-to-date dependencies
• Always not up-to-date
• Multiple Rubies: MRI Execute unit test
1.8.7, 1.9.2, 1.9.3, REE, JRuby, Ru TDD
binius, IronRuby, MacRuby, …
12. RVM (Ruby Version Manager)
安裝RVM Install environment
$ curl -L get.rvm.io | bash -s stable
Clone the project
安裝Rubies
$ rvm install 1.8.7
Install project
$ rvm install 1.9.3-p125 dependencies
$ rvm install jruby
切換不同Rubies Execute unit test
$ rvm use 1.8.7
$ rvm use 1.9.3 --default TDD
See Also: PerlBrew, PythonBrew, PHPBrew…
20. Semantic Versioning
• Authored by Tom Preston-Werner, inventor of
Gravatars and cofounder of GitHub
• 一致的版號規則: Major.Minor.Patch
• Rails 3.1.10
– Major version: 3
– Minor version: 1
– Patch version: 10
21. Semantic Versioning
• Major version change
– 不向下相容
– Ex. Rails 2.3.7 -> 3.0.0
• Minor version change
– 向下相容,增加新功能
– Ex. Rails 3.0.10 -> 3.1.0
• Patch version change
– 向下相容,只修正bug
– Ex. Rails 3.1.0 -> 3.1.1
22. Semantic Versioning
• 例外: Major version 0為早期開發
– 0.0.1, 0.0.2, 0.9.4 什麼都可能不相容
• 更多細節請見 http://semver.org/
– Pre-release
– Tag name
– Semantic versioning v2.0.0-rc1
• See also: Apache APR Version Numbering
29. Bundler
Ensure you are using right gems
在Shell中執行:
$ bunlde exec ruby your_app.rb
或是在程式啟始點:
require "rubygems"
require "bundler/setup"
建議:所有的Ruby專案都可以使用Bundler
38. Carton
Carton is a new command to manage Perl
module dependencies for your applications.
Like gem bundler for Ruby, Carton solves the
issue of "upgrading CPAN modules broke my
code" by allowing you to lock and freeze
dependencies. Carton makes it easy to
manage and reproduce module installations
on any environments.