Ruby: erinevus redaktsioonide vahel

Allikas: Imre kasutab arvutit
Mine navigeerimisribaleMine otsikasti
Resümee puudub
41. rida: 41. rida:
 
===Gem haldus===
 
===Gem haldus===
   
===rakendus===
+
===Gem rakendus===
   
 
<pre>
 
<pre>
57. rida: 57. rida:
 
<p>Your isolated rbenv environment is running a live web server seamlessly!</p>"
 
<p>Your isolated rbenv environment is running a live web server seamlessly!</p>"
 
end
 
end
  +
</pre>
   
  +
Käivitamine
  +
  +
<pre>
 
ruby@ubuntu-2604-01:~/20260605-2$ bundle exec ruby server.rb
 
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
 
== Sinatra (v4.2.1) has taken the stage on 4567 for development with backup from Puma

Redaktsioon: 6. juuni 2026, kell 21:15

Sissejuhatus

Misc

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

Gem haldus

Gem rakendus

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$

Kasulikud lisamaterjalid

  • TODO