The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.
Difference between revisions of "Package:Ruby"
Threesixes (talk | contribs) m (add puma init script example) |
m (Changed the command to get the rubygems path since it is deprecated.) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Ebuild | {{Ebuild | ||
|Summary=Centralized Ruby extension management system | |Summary=Centralized Ruby extension management system | ||
|CatPkg=dev- | |CatPkg=dev-lang/ruby | ||
|Homepage=https://www.ruby-lang.org | |Homepage=https://www.ruby-lang.org | ||
}} | }} | ||
Ruby is a programming language with its own package management system to extend the language. | Ruby is a programming language with its own package management system to extend the language. | ||
=== Ruby Ruby's way === | |||
Rubygems is a package management system to extend the ruby language. | Rubygems is a package management system to extend the ruby language. | ||
Gems are packaged | Gems are packaged in portage and those are good for production server application. ruby ruby's way is more friendly on the development of rails side. this will explain how to work with rubygems rather than fight it. [https://wiki.archlinux.org/index.php/Ruby#RubyGems Arch wiki] outlines a similar method. | ||
https://wiki.archlinux.org/index.php/Ruby#RubyGems | |||
Emerge ruby & rubygems: | Emerge ruby & rubygems: | ||
Line 22: | Line 19: | ||
Flush conflicting gems bad specs: | Flush conflicting gems bad specs: | ||
<console>###i## mv /usr/local/lib64/ruby/gems/2.1.0/specifications/ /usr/local/lib64/ruby/gems/2.1.0/specifications.backup</console> | <console>###i## mv /usr/local/lib64/ruby/gems/2.1.0/specifications/ /usr/local/lib64/ruby/gems/2.1.0/specifications.backup</console> | ||
Fetch gems via rubygems: | Fetch gems via rubygems: | ||
Line 39: | Line 35: | ||
To add gems to your path: | To add gems to your path: | ||
{{file|name=$HOME/.bashrc|desc=add gem bin directory to your path|body= | {{file|name=$HOME/.bashrc|desc=add gem bin directory to your path|body= | ||
PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH" | PATH="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin:$PATH" | ||
}} | }} | ||
Line 60: | Line 56: | ||
{{file|name=$HOME/testproject/config/puma.rb|desc=puma configuration file|body= | {{file|name=$HOME/testproject/config/puma.rb|desc=puma configuration file|body= | ||
workers Integer(ENV['PUMA_WORKERS'] {{!}}{{!}} 3) | |||
threads Integer(ENV['MIN_THREADS'] | threads Integer(ENV['MIN_THREADS'] {{!}}{{!}} 1), Integer(ENV['MAX_THREADS'] {{!}}{{!}} 16) | ||
preload_app! | preload_app! | ||
rackup DefaultRackup | rackup DefaultRackup | ||
port ENV['PORT'] | port ENV['PORT'] {{!}}{{!}} 3000 | ||
environment ENV['RACK_ENV'] | environment ENV['RACK_ENV'] {{!}}{{!}} 'development' | ||
on_worker_boot do | on_worker_boot do | ||
# worker specific setup | # worker specific setup | ||
ActiveSupport.on_load(:active_record) do | ActiveSupport.on_load(:active_record) do | ||
config = ActiveRecord::Base.configurations[Rails.env] | config = ActiveRecord::Base.configurations[Rails.env] {{!}}{{!}} | ||
Rails.application.config.database_configuration[Rails.env] | Rails.application.config.database_configuration[Rails.env] | ||
config['pool'] = ENV['MAX_THREADS'] | config['pool'] = ENV['MAX_THREADS'] {{!}}{{!}} 16 | ||
ActiveRecord::Base.establish_connection(config) | ActiveRecord::Base.establish_connection(config) | ||
end | end | ||
end | end | ||
}} | }} | ||
Line 88: | Line 84: | ||
https://gist.github.com/666threesixes666/d8bca7f67439763d3e94 | https://gist.github.com/666threesixes666/d8bca7f67439763d3e94 | ||
== media == | |||
{{#widget:YouTube|playlist=PL1512BD72E7C9FFCA}} | |||
[[Category:Programming language]] | [[Category:Programming language]] | ||
{{EbuildFooter}} | {{EbuildFooter}} |
Latest revision as of 05:01, April 9, 2019
Ruby
We welcome improvements to this page. To edit this page, Create a Funtoo account. Then log in and then click here to edit this page. See our editing guidelines to becoming a wiki-editing pro.
Ruby is a programming language with its own package management system to extend the language.
Ruby Ruby's way
Rubygems is a package management system to extend the ruby language.
Gems are packaged in portage and those are good for production server application. ruby ruby's way is more friendly on the development of rails side. this will explain how to work with rubygems rather than fight it. Arch wiki outlines a similar method.
Emerge ruby & rubygems:
root # emerge ruby rubygems
Remove conflicting gems:
root # emerge -C dev-ruby/rake dev-ruby/racc dev-ruby/json dev-ruby/rdoc
Flush conflicting gems bad specs:
root # mv /usr/local/lib64/ruby/gems/2.1.0/specifications/ /usr/local/lib64/ruby/gems/2.1.0/specifications.backup
Fetch gems via rubygems:
root # gem install rdoc json rake racc
root # rubygems-update
update gem system:
root # update_rubygems root # gem update --system root # gem pristine --all
Now you're ready to use gem to manage gems.
To add gems to your path:
$HOME/.bashrc
- add gem bin directory to your pathPATH="$(ruby -r rubygems -e 'puts Gem.user_dir')/bin:$PATH"
ruby on rails
root # gem install rails root # rails new testproject root # cd testproject root # bundle install
puma
puma is a fast web server for ruby on rails.
To enable puma in your project:
$HOME/testproject/Gemfile
- add puma gem to your rails applicationgem 'puma'
To pull in puma:
root # bundle install
$HOME/testproject/config/puma.rb
- puma configuration fileworkers Integer(ENV['PUMA_WORKERS'] || 3)
threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 16)
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
on_worker_boot do
# worker specific setup
ActiveSupport.on_load(:active_record) do
config = ActiveRecord::Base.configurations[Rails.env] ||
Rails.application.config.database_configuration[Rails.env]
config['pool'] = ENV['MAX_THREADS'] || 16
ActiveRecord::Base.establish_connection(config)
end
end
to start puma:
root # bundle exec puma
or if you added gems bin dir to your path
root # puma
a generic puma init script can be found here
https://gist.github.com/666threesixes666/d8bca7f67439763d3e94
media