9 rbenv rbenv ruby 9.1 rbenv rbenv rbenv ruby ruby-build ruby 9.2 rbenv macos.bash_profile ~/.bash_profile ~/.bash_profile.bak $ touch ~/.bash_profile $ cp -f ~/.bash_profile ~/.bash_profile.bak ~/.bash_profile 51
9 rbenv $ cp -f ~/.bash_profile.bak ~/.bash_profile $ brew install rbenv ruby-build $ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile $ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile $ source ~/.bash_profile echo Ubuntu.bashrc ~/.bashrc ~/.bashrc.bak $ touch ~/.bashrc $ cp -f ~/.bashrc ~/.bashrc.bak ~/.bashrc $ cp -f ~/.bashrc.bak ~/.bashrc $ sudo apt-get update $ sudo apt-get -y install build-essential $ sudo apt-get -y install git zlib1g-dev libssl-dev libreadline-dev $ sudo apt-get -y install libxml2-dev libxslt-dev libsqlite3-dev 52
9.3 rbenv $ git clone git://github.com/sstephenson/rbenv.git ~/.rbenv $ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc $ echo 'eval "$(rbenv init -)"' >> ~/.bashrc $ source ~/.bashrc $ mkdir -p ~/.rbenv/plugins $ cd ~/.rbenv/plugins $ git clone git://github.com/sstephenson/ruby-build.git echo apt-get rbenv ruby-build ruby rbenv ruby-build 9.3 rbenv ruby ruby $ rbenv install --list 2.4.1 2017 4 5 : ruby-build ruby ruby-build ruby-build 53
9 rbenv $ cd ~/.rbenv/plugins/ruby-build $ git pull rbenv install --list ruby ruby-build ruby 2.4.1 ruby $ rbenv install 2.4.1 ruby ruby $ rbenv versions * system (set by /Users/kuroda/.rbenv/version) 2.4.1 * system ruby 54
9.3 rbenv ruby ruby rbenv shell local global shell ruby 2.4.1 $ rbenv shell 2.4.1 $ ruby -v OS 1 macos 2 Ubuntu ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin15] ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux] p0 ruby rbenv shell 55
9 rbenv $ rbenv shell --unset : RBENV_VERSION rbenv shell RBENV_VERSION ruby rbenv shell local ruby 2.4.1 $ rbenv local 2.4.1.ruby-version ruby.ruby-version projects x y projects.ruby-version 2.3.3 x y ruby 2.3.3 y 2.4.1 ruby y rbenv local 2.4.1 2.4.1.ruby-version y 2.4.1 ruby shell local.ruby-version RBENV_VERSION 56
9.4 rbenv global ruby 2.4.1 $ rbenv global 2.4.1 ~/.rbenv/ version ruby global.ruby-version shell > local > global rbenv global $ rbenv global system ruby 9.4 rbenv Mac macos rbenv $ rbenv --version 2017 4 5 57
9 rbenv rbenv 1.1.0 rbenv $ brew update $ brew upgrade rbenv ruby-build $ cd ~/.rbenv/plugins/ruby-build $ git pull Ubuntu rbenv $ rbenv --version 2017 4 5 rbenv 1.1.0-2-g4f8925a rbenv $ cd ~/.rbenv $ git pull $ cd plugins/ruby-build $ git pull 58
20 React JavaScrip React React Webpacker Rails 20.1 React React Facebook JavaScript 2013 2015 DOM virtual DOM JSX JSX JavaScript JSX React.render( <p>hello, world!</p>, document.getelementbyid('message') ); JavaScript 2 HTML <p>hello, world!</p> JSX 143
20 React React Redux JavaScript Web state 20.2 React 19 AirBoy React $ cd ~/projects $ cp -r air_boy air_boy_react $ cd air_boy_react $ rails webpacker:install:react package.json react node_modules React 2017 4 React 15.4.2 app/javascript/packs top_react.jsx JSX JavaScript 20.3 React React JavaScript JSX 144
20.3 React $ rails g controller top counter create route invoke create invoke create app/controllers/top_controller.rb get 'top/counter' erb app/assets/javascripts/top.coffee scss app/assets/stylesheets/top.scss JSX app/javascript/packs counter.jsx app/javascript/packs/counter.jsx 1 import React from 'react' 2 import ReactDOM from 'react-dom' 3 4 class Counter extends React.Component { 5 constructor(props) { 6 super(props) 7 this.state = { counter: 0 } 8 this.increment = this.increment.bind(this) 9 } 10 11 increment() { 12 this.setstate({ counter: this.state.counter + 1 }) 13 } 14 15 render() { 16 return <div> 17 <div>counter = {this.state.counter}</div> 18 <button onclick={this.increment}>click me!</button> 19 </div> 20 } 21 } 145
20 React 22 23 document.addeventlistener('domcontentloaded', () => { 24 ReactDOM.render( 25 <Counter />, 26 document.getelementbyid('counter') 27 ) 28 }) webpack-watcher $ bin/webpack-watcher 20.1 20.1 webpack-watcher 146
20.3 React webpack-dev-server $ cd ~/projects/air_boy_react $ bin/webpack-dev-server 20.2 20.2 webpack-dev-server HTML Web app/views/top counter.html.erb 147
20 React app/views/top/counter.html.erb 1 - <h1>top#counter</h1> 2 - <p>find me in app/views/top/counter.html.erb</p> 1 + <div id="counter"></div> 2 + <%= javascript_pack_tag "counter" %> Rails Rails $ cd ~/projects/air_boy_react $ rails s http://localhost:3000/top/counter 20.3 148
20.3 React 20.3 Click me! Counter = 1 149