??云主机低折扣年付还赠送90天?? 广告位招租 - 15元/月全站展示
??伍彩集团官网直营彩票 ??言情小说??
??私有威屁恩(独享/安全/稳定/高速/低价) ??Google Facebook Youtube 科学上网
广告位招租 - 15元/月全站展示 广告位招租 - 15元/月全站展示
Install ruby via RVM

转载   jia_xiaolei   2017-07-10   浏览量:545




1. Install RVM and refer to https://rvm.io/

 -- gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

 -- \curl -sSL https://get.rvm.io | bash -s stable


[[email protected] ~]$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: directory `/home/jiaxiaol/.gnupg' created
gpg: new configuration file `/home/jiaxiaol/.gnupg/gpg.conf' created
gpg: WARNING: options in `/home/jiaxiaol/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/home/jiaxiaol/.gnupg/secring.gpg' created
gpg: keyring `/home/jiaxiaol/.gnupg/pubring.gpg' created
gpg: requesting key D39DC0E3 from hkp server keys.gnupg.net
gpg: requesting key 39499BDB from hkp server keys.gnupg.net
gpg: /home/jiaxiaol/.gnupg/trustdb.gpg: trustdb created
gpg: key D39DC0E3: public key "Michal Papis (RVM signing) <[email protected]>" imported
gpg: key 39499BDB: public key "Piotr Kuczynski <[email protected]>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 2
gpg:               imported: 2  (RSA: 2)
[[email protected] ~]$
[[email protected] ~]$ \curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.2.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.2/1.29.2.tar.gz.asc
gpg: Signature made Thu 22 Jun 2017 04:18:38 PM GMT using RSA key ID BF04FF17
gpg: Good signature from "Michal Papis (RVM signing) <[email protected]>"
gpg:                 aka "Michal Papis <[email protected]>"
gpg:                 aka "[jpeg image of size 5015]"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 409B 6B17 96C2 7546 2A17  0311 3804 BB82 D39D C0E3
     Subkey fingerprint: 62C9 E5F4 DA30 0D94 AC36  166B E206 C29F BF04 FF17
GPG verified '/home/jiaxiaol/.rvm/archives/rvm-1.29.2.tgz'
Installing RVM to /home/jiaxiaol/.rvm/
    Adding rvm PATH line to /home/jiaxiaol/.profile /home/jiaxiaol/.mkshrc /home/jiaxiaol/.bashrc /home/jiaxiaol/.zshrc.
    Adding rvm loading line to /home/jiaxiaol/.profile /home/jiaxiaol/.bash_profile /home/jiaxiaol/.zlogin.
Installation of RVM in /home/jiaxiaol/.rvm/ is almost complete:
  * To start using RVM you need to run `source /home/jiaxiaol/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.
# jiaxiaol,
#
#   Thank you for using RVM!
#   We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.
In case of problems: https://rvm.io/help and https://twitter.com/rvm_io
  * WARNING: You have '~/.profile' file, you might want to load it,
    to do that add the following line to '/home/jiaxiaol/.bash_profile':
      source ~/.profile

2. Check the available version

[[email protected] ~]$ rvm list known




3. Install ruby 2.4.0:

[[email protected] ~]$ rvm install 2.4.0
Searching for binary rubies, this might take some time.
No binary rubies available for: centos/7/x86_64/ruby-2.4.0.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for centos.
Installing requirements for centos.
Installing required packages: libyaml-devel, readline-devel, libffi-devel, sqlite-devel.........
Requirements installation successful.
Installing Ruby from source to: /home/jiaxiaol/.rvm/rubies/ruby-2.4.0, this may take a while depending on your cpu(s)...
ruby-2.4.0 - #downloading ruby-2.4.0, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 11.9M  100 11.9M    0     0  6499k      0  0:00:01  0:00:01 --:--:-- 6499k
ruby-2.4.0 - #extracting ruby-2.4.0 to /home/jiaxiaol/.rvm/src/ruby-2.4.0....
ruby-2.4.0 - #configuring..................................................................
ruby-2.4.0 - #post-configuration..
ruby-2.4.0 - #compiling.................................................................................
ruby-2.4.0 - #installing...........................
ruby-2.4.0 - #making binaries executable..
ruby-2.4.0 - #downloading rubygems-2.6.12
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  749k  100  749k    0     0  2842k      0 --:--:-- --:--:-- --:--:-- 2851k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.4.0 - #extracting rubygems-2.6.12....
ruby-2.4.0 - #removing old rubygems.........
ruby-2.4.0 - #installing rubygems-2.6.12.........................
ruby-2.4.0 - #gemset created /home/jiaxiaol/.rvm/gems/[email protected]
ruby-2.4.0 - #importing gemset /home/jiaxiaol/.rvm/gemsets/global.gems...............................................
ruby-2.4.0 - #generating global wrappers........
ruby-2.4.0 - #gemset created /home/jiaxiaol/.rvm/gems/ruby-2.4.0
ruby-2.4.0 - #importing gemsetfile /home/jiaxiaol/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.4.0 - #generating default wrappers........
ruby-2.4.0 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.4.0 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
[[email protected] ~]$
[[email protected] ~]$ rvm list
rvm rubies
=* ruby-2.4.0 [ x86_64 ]
# => - current
# =* - current && default
#  * - default
[[email protected] ~]$


转载自://blog.51cto.com/jiaxiaolei/1945948



Install ruby via RVM
1.InstallRVMandrefertohttps://rvm.io/&nbsp;--gpg--keyserverhkp://keys.gnupg.net--recv-keys409B6B1796C275462A1703113804BB82D39DC0E37D2BAF1CF37B13E2069D6956105BD0E739499BDB&nbsp;--\curl-sS
ruby 的while
while是一个非常强大的语句,很大程度上可以替换其他判断和循环。1、while代替ifwhile&nbsp;5&nbsp;&gt;&nbsp;3&nbsp;&nbsp;puts&nbsp;"ok"end2、while代替for循环sum&nbsp;=&nbsp;0i&nbsp;=&nbsp;1while&nbsp;i&nbsp;&lt;=&nbsp;5&nbsp;&nbsp;
ruby CGI 获取参数
URL:/cgi-bin/test.cgi?FirstName=Zara&amp;LastName=Ali获取参数#!/usr/bin/rubyrequire&nbsp;'cgi'cgi&nbsp;=&nbsp;CGI.newcgi['FirstName']&nbsp;#&nbsp;=&gt;&nbsp;&nbsp;["Zara"]cgi['LastName']&nbsp;&nbsp;#&
ruby对文件和目录的基本操作
新建目录Dir.mkdir("/tmp/test")FileUtils.mkdir_p("/tmp/test1/test2")&nbsp;#建目录结构新建文件my_file&nbsp;=&nbsp;File.new("/tmp/abc.txt")读文件File.read("/tmp/abc.txt")或File.open("/tmp/abc.txt","r")常用的方法还有File.read
ruby仿awk处理列
取出文本中的第二列直接上代码#!/usr/bin/env&nbsp;ruby#encoding:&nbsp;utf-8filename&nbsp;=&nbsp;ARGV[0]file&nbsp;=&nbsp;File.open(filename)=begin逐列打印=endfile.each_line&nbsp;do&nbsp;|line|&nbsp;&nbsp;myline
ruby的if判断
if判断的基本格式如下:if&nbsp;条件&nbsp;then&nbsp;&nbsp;&nbsp;#then可省略&nbsp;&nbsp;处理end1、判断文件是否存在#!/usr/bin/env&nbsp;rubyif&nbsp;File.exist?("/etc/hosts")&nbsp;&nbsp;print&nbsp;"ok"end加上else#!/usr/bin/env&nb
ruby 遍历文件
ruby遍历文件内容,基本思路是逐行读取逐行打印,也是比较普遍的方法:#!/usr/bin/env&nbsp;ruby#Encoding:utf8file&nbsp;=&nbsp;File.open("/tmp/abc.txt")file.each_line&nbsp;do&nbsp;|line|&nbsp;&nbsp;print&nbsp;lineendfile.close直接写成
Ruby-类
#类与对象class&nbsp;Person&nbsp;&nbsp;def&nbsp;initialize(name,age,sex)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#initialize&nbsp;方法,试用new方法生成新的对象时,该方法会被调用,同时new方法的参数会原封不动的传给该方法,因此初始化对象时需要的处理一般都写在这个方法中&nbsp;
Ruby-方法
#方法def&nbsp;helloworld&nbsp;&nbsp;puts&nbsp;"Hello&nbsp;World!"endhelloworld#带参数的方法def&nbsp;hello(name)&nbsp;&nbsp;puts&nbsp;"Hello&nbsp;#{name}"endhello("World!")hello("Ruby")#带可变长参数的方法
Ruby-条件判断
=begin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;条件判断语句包括if语句,unless语句,case语句,=end#if&nbsp;语句=beginif&nbsp;条件&nbsp;then&nbsp;&nbsp;处理1elsif&nbsp;条件2&nbsp;then&nbsp;&nbsp;处理2else&nbsp;&nbsp;处理3end