|
|
Line 1: |
Line 1: |
| {{Ebuild
| | <nowiki>The repository list seems incomplete. We can either update it and keep it in sync, or we maybe create a reference to http://www.funtoo.org/Category:Repositories such that is updates itself?</nowiki> |
| |Summary=Centralized Ruby extension management system
| |
| |CatPkg=dev-ruby/ruby
| |
| |Maintainer=
| |
| |Homepage=https://www.ruby-lang.org
| |
| }}
| |
| | |
| Ruby is a programming language with its own package management system to extend the language.
| |
| | |
| Rubygems is a package management system to extend the ruby language.
| |
| | |
| Gems are packaged wonky in portage so this page will explain how to work with rubygems rather than fight it. Arch wiki outlines a similar method.
| |
| | |
| https://wiki.archlinux.org/index.php/Ruby#RubyGems
| |
| | |
| Emerge ruby & rubygems:
| |
| <console>###i## emerge ruby rubygems</console>
| |
| | |
| Remove conflicting gems:
| |
| <console>###i## emerge -C dev-ruby/rake dev-ruby/racc dev-ruby/json dev-ruby/rdoc</console>
| |
| | |
| 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>
| |
| | |
| | |
| Fetch gems via rubygems:
| |
| <console>###i## gem install rdoc json rake racc</console>
| |
| | |
| <console>###i## rubygems-update</console>
| |
| | |
| update gem system:
| |
| <console>###i## update_rubygems
| |
| ###i## gem update --system
| |
| ###i## gem pristine --all
| |
| </console>
| |
| | |
| Now you're ready to use gem to manage gems.
| |
| | |
| To add gems to your path:
| |
| {{file|name=$HOME/.bashrc|desc=add gem bin directory to your path|body=
| |
| PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH"
| |
| }}
| |
| | |
| ==ruby on rails==
| |
| <console>###i## gem install rails
| |
| ###i## rails new testproject
| |
| ###i## cd testproject
| |
| ###i## bundle install</console>
| |
| | |
| ==puma==
| |
| puma is a fast web server for ruby on rails.
| |
| | |
| To enable puma in your project:
| |
| {{file|name=$HOME/testproject/Gemfile|desc=add puma gem to your rails application|body=
| |
| gem 'puma'
| |
| }}
| |
| | |
| To pull in puma:
| |
| <console>###i## bundle install</console>
| |
| | |
| {{file|name=$HOME/testproject/config/puma.rb|desc=puma configuration file|body=
| |
| <pre>workers 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</pre>
| |
| }}
| |
| | |
| to start puma:
| |
| <console>###i## bundle exec puma</console>
| |
| or if you added gems bin dir to your path
| |
| <console>###i## puma</console>
| |
| | |
| [[Category:Programming language]]
| |
| | |
| {{EbuildFooter}}
| |