Ruby
Allikas: Imre kasutab arvutit
Mine navigeerimisribaleMine otsikasti
Sissejuhatus
Ruby paigaldamine tavakasutaja osakond
Käesoleval juhul paigaldatakse Ruby lahendus tavakasutajana, alustatatakse süsteemi ettevalmistamisest
root@ubuntu-2604-01:~# apt-get install build-essential autoconf libssl-dev libyaml-dev zlib1g-dev libffi-dev libgmp-dev rustc
kus
- c kompilaator on vajalik c xxx
Otsustatakse hallata erinevaid ruby keskkondi rbenv lahenduse abil
ruby@ubuntu-2604-01:~$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash
ruby@ubuntu-2604-01:~$ rbenv install -l
ruby@ubuntu-2604-01:~$ rbenv install 3.3.0
==> Downloading ruby-3.3.0.tar.gz...
-> curl -q -fL -o ruby-3.3.0.tar.gz https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.0.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 21.04M 100 21.04M 0 0 11.16M 0 00:01 00:01 11.16M
==> Installing ruby-3.3.0...
-> ./configure "--prefix=$HOME/.rbenv/versions/3.3.0" --enable-shared --with-ext=openssl,psych,+
-> make -j 4
-> make install
==> Installed ruby-3.3.0 to /home/ruby/.rbenv/versions/3.3.0
NOTE: to activate this Ruby version as the new default, run: rbenv global 3.3.0
ruby@ubuntu-2604-01:~$ rbenv global 3.3.0
ruby@ubuntu-2604-01:~$ find . -mmin -1 -ls
393269 4 drwxrwxr-x 15 ruby ruby 4096 Jun 6 15:28 ./.rbenv
413953 4 -rw-rw-r-- 1 ruby ruby 6 Jun 6 15:28 ./.rbenv/version
ruby@ubuntu-2604-01:~$ cat ./.rbenv/version
3.3.0
ruby@ubuntu-2604-01:~$ ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-linux]
ruby@ubuntu-2604-01:~$ which ruby
/home/ruby/.rbenv/shims/ruby
ruby@ubuntu-2604-01:~$ which gem
/home/ruby/.rbenv/shims/gem
ruby@ubuntu-2604-01:~$ tail -n 2 .bashrc
# Added by `rbenv init` on Sat Jun 6 02:42:37 PM UTC 2026
eval "$(~/.rbenv/bin/rbenv init - --no-rehash bash)"
Paigaldatud ruby versioonid
ruby@ubuntu-2604-01:~$ ls -ld .rbenv/versions/* drwxr-xr-x 6 ruby ruby 4096 Jun 6 14:52 .rbenv/versions/3.3.0 drwxr-xr-x 6 ruby ruby 4096 Jun 6 15:45 .rbenv/versions/3.4.9 drwxr-xr-x 6 ruby ruby 4096 Jun 6 15:42 .rbenv/versions/4.0.5 drwxrwxr-x 6 ruby ruby 4096 Jun 6 15:48 .rbenv/versions/truffleruby-34.0.1
Gem haldus
ruby@ubuntu-2604-01:~/20260605-3$ gem source *** NO CONFIGURED SOURCES, DEFAULT SOURCES LISTED BELOW *** https://rubygems.org/
viimase oxidized versiooni esitamine
ruby@ubuntu-2604-01:~$ gem search -r ^oxidized$ *** REMOTE GEMS *** oxidized (0.37.0)
kõigi oxidized versioonide esitamine
ruby@ubuntu-2604-01:~$ gem search -r -a ^oxidized$ *** REMOTE GEMS *** oxidized (0.37.0, 0.36.0, 0.35.0, 0.34.3, 0.34.2, 0.34.1, 0.34.0, 0.33.0, ...)
gem kirjeldus
ruby@ubuntu-2604-01:~$ gem specification net-http summary --- HTTP client api for Ruby.
gem sisu
ruby@ubuntu-2604-01:~$ gem contents oxidized
Sõltuvused
ruby@ubuntu-2604-01:~$ gem dependency oxidized -r
Parem
ruby@ubuntu-2604-01:~/20260605-3$ cat Gemfile source 'https://rubygems.org' gem 'oxidized' ruby@ubuntu-2604-01:~/20260605-3$ bundle check Fetching gem metadata from https://rubygems.org/......... Resolving dependencies... The following gems are missing * oxidized (0.37.0) * bcrypt_pbkdf (1.1.2) * ed25519 (1.4.0) * net-http-digest_auth (1.4.1) * net-ssh (7.3.2) * net-telnet (0.2.0) * psych (5.4.0) * rugged (1.9.0) * semantic_logger (4.18.0) * slop (4.10.1) * syslog (0.4.0) * syslog_protocol (0.9.2) * concurrent-ruby (1.3.6) * timeout (0.6.1) Install missing gems with `bundle install`
Paigaldatud gem nimekiri
ruby@ubuntu-2604-01:~$ ls -ld .rbenv/versions/4.0.5/lib/ruby/gems/4.0.0/gems/* | head -n 5 drwxr-xr-x 4 ruby ruby 4096 Jun 6 15:42 .rbenv/versions/4.0.5/lib/ruby/gems/4.0.0/gems/abbrev-0.1.2 drwxr-xr-x 3 ruby ruby 4096 Jun 6 17:06 .rbenv/versions/4.0.5/lib/ruby/gems/4.0.0/gems/addressable-2.9.0 drwxrwxr-x 4 ruby ruby 4096 Jun 6 16:18 .rbenv/versions/4.0.5/lib/ruby/gems/4.0.0/gems/asetus-0.4.0 drwxr-xr-x 4 ruby ruby 4096 Jun 6 15:42 .rbenv/versions/4.0.5/lib/ruby/gems/4.0.0/gems/base64-0.3.0 drwxr-xr-x 4 ruby ruby 4096 Jun 6 15:42 .rbenv/versions/4.0.5/lib/ruby/gems/4.0.0/gems/benchmark-0.5.0 ...
Tundub, et tarkvara eemaldamine ei ole alati väga lihtne ega selge
ruby@ubuntu-2604-01:~$ bundle config set clean true ruby@ubuntu-2604-01:~$ gem uninstall octokit faraday faraday-net_http sawyer public_suffix addressable json net-http uri ...
Gem rakendus
Paigaldamine algab Gemfile ettavalmistamisest
ruby@ubuntu-2604-01:~/20260605-2$ cat Gemfile source 'https://rubygems.org' gem 'sinatra'
paigaldamine
ruby@ubuntu-2604-01:~/20260605-2$ bundle check ruby@ubuntu-2604-01:~/20260605-2$ bundle install
Paistab, et puuduvad rackup ja puma
ruby@ubuntu-2604-01:~/20260605-2$ bundle add rackup puma Fetching gem metadata from https://rubygems.org/.... Resolving dependencies... Fetching gem metadata from https://rubygems.org/.... Fetching nio4r 2.7.5 Fetching puma 8.0.2 Fetching rackup 2.3.1 Installing rackup 2.3.1 Installing nio4r 2.7.5 with native extensions Installing puma 8.0.2 with native extensions
kusjuures tulemusena on Gemfile sisus kaks rida juures
ruby@ubuntu-2604-01:~/20260605-2$ cat Gemfile source 'https://rubygems.org' gem 'sinatra' gem "rackup", "~> 2.3" gem "puma", "~> 8.0"
serveri ettevalmistamine
ruby@ubuntu-2604-01:~/20260605-2$ cat server.rb # server.rb require 'sinatra' # Tell Sinatra to accept connections from outside your local host loop set :bind, '0.0.0.0' set :port, 4567 # Define the visual landing pad for your web browser get '/' do "<h1>Hello World from Ruby!</h1> <p>Your isolated rbenv environment is running a live web server seamlessly!</p>" end
Käivitamine
ruby@ubuntu-2604-01:~/20260605-2$ bundle exec ruby server.rb
== Sinatra (v4.2.1) has taken the stage on 4567 for development with backup from Puma
Puma starting in single mode...
* Puma version: 8.0.2 ("Into the Arena")
* Ruby version: ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +PRISM [x86_64-linux]
* Min threads: 0
* Max threads: 5
* Environment: development
* PID: 54882
* Listening on http://0.0.0.0:4567
Use Ctrl-C to stop
192.168.10.156 - - [06/Jun/2026:17:18:57 +0000] "GET / HTTP/1.1" 200 114 0.0016
192.168.10.156 - - [06/Jun/2026:17:18:58 +0000] "GET /favicon.ico HTTP/1.1" 404 441 0.0009
192.168.10.156 - - [06/Jun/2026:17:18:58 +0000] "GET / HTTP/1.1" 200 114 0.0006
192.168.10.156 - - [06/Jun/2026:17:18:59 +0000] "GET / HTTP/1.1" 200 114 0.0005
192.168.10.156 - - [06/Jun/2026:17:18:59 +0000] "GET / HTTP/1.1" 200 114 0.0007
192.168.10.156 - - [06/Jun/2026:17:18:59 +0000] "GET / HTTP/1.1" 200 114 0.0008
^C- Gracefully stopping, waiting for requests to finish
=== puma shutdown: 2026-06-06 18:13:59 +0000 ===
- Goodbye!
== Sinatra has ended his set (crowd applauds)
ruby@ubuntu-2604-01:~/20260605-2$
Lokaalne Gem puhverserver
Gemfile
ruby@ubuntu-2604-01:~/gemirro-server$ joe Gemfile source 'https://rubygems.org' gem 'gemirro'
ning
ruby@ubuntu-2604-01:~/gemirro-server$ bundle check Fetching gem metadata from https://rubygems.org/.......... Resolving dependencies... The following gems are missing * gemirro (2.0.0) * builder (3.3.0) * compact_index (0.15.0) * confstruct (1.1.0) * erubis (2.7.0) * httpclient (2.9.0) * parallel (1.28.0) * rubygems-generate_index (1.2.0) * sinatra (3.2.0) * slop (3.6.0) * thin (1.8.2) * hashie (4.1.0) * rack (2.2.23) * rack-protection (3.2.0) * daemons (1.4.1) * eventmachine (1.2.7) Install missing gems with `bundle install` ruby@ubuntu-2604-01:~/gemirro-server$ bundle install
Gem turvalisus
TODO
Gem moodustamine
TODO
Kasulikud lisamaterjalid
- TODO