forked from CWDG/cwdg.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev_ruby_setup.haml
More file actions
297 lines (231 loc) · 13.1 KB
/
Copy pathdev_ruby_setup.haml
File metadata and controls
297 lines (231 loc) · 13.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
!!!
%html
%head
%title <CWDG/> Web Ninjas Unite
%link(href="favicon.ico" rel="icon" type="image/x-icon")
%link(href="css/screen.css" media="screen, projection" rel="stylesheet" type="text/css")
%link(href="css/print.css" media="print" rel="stylesheet" type="text/css")
/[if lt IE 8]
<link href="css/ie.css" media="screen, projection" rel="stylesheet" type="text/css" />
%body.bp
#header
%ul.relevant-links
%li.last
%a.button{:target => "blank", :href => "http://groups.google.com/group/cwdgosu"} Mailing List Archives
%li
%a.button{:target => "blank", :href => "http://www.twitter.com/cwdgosu"} Twitter
%li
%a.button{:target => "blank", :href => "http://www.facebook.com/groups/cwdgosu/"} Facebook
%li
%a.button{:target => "blank", :href => "https://github.com/CWDG"} GitHub
%li
%a.button{:target => "blank", :href => "irc.html"} Chat on IRC
%li.first
%a.button{:target => "blank", :href => "http://go.osu.edu/cwdglist"} Join the Mailing List
%a.banner{href: '/'}
%h1
%span.tag <
Collegiate Web Developers Group
%span.slash /
%span.tag >
#container
#content
.section.goal
%h2 Your Mission
.content
:markdown
This guide will show you how to setup your computer to follow along
with all the CWDG sessions. Everything we use here will be used again
countless times during the course of your web development career.
The goal for tonight is to run a simple web server and publish the code
to the internet.
.section.rvm
%h2 1. Setup the Ruby Version Manager
.content
:markdown
First we will install RVM. This is a program which does some basic
path manipulation to ensure you are using the correct version of ruby.
It is recommended that you simply follow the
[Installation Instructions](https://rvm.io/rvm/install/) on the
[main RVM website](https://rvm.io/). The project is quite well documented
in both *how* to use RVM and also *why*.
**Apple Users** take note! Make sure you look into the
[Special Instructions](https://rvm.io/os/osx/) for your computers.
If you are a audio/video person, you can check out the
[RVM Screencast](http://screencasts.org/episodes/how-to-use-rvm),
but your milage may vary.
I also recommend you run `rvm requirements` and make sure all the required
libraries are installed correctly. This will prevent problems down the
road and add a few optional, but wonderful features to ruby.
Once RVM is installed, I recommend you close all your terminal windows.
Reopening your terminal, you can check to make sure that rvm is working.
> `rvm list`
If the command works, you may see something similar to
> rvm rubies
>
> =* ruby-1.9.3-p194 [ i686 ]
>
> # => - current
> # =* - current && default
> # * - default
You may not have any "rubies installed". I recommend that you then run:
> `rvm install ruby-1.9.3`
While this is doing it's thing (it will take a while), you can move
onto steps 2 through 4.
.section.git
%h2 2. Install Git
.content
:markdown
We also want to make sure we can save our work permanently. We will use the
version control system [Git](http://git-scm.com/ "Git Source Control Manager").
**Linux Users**: Your favorite package manager will have a package for git.
You have my word as the anonymous narrator of this guide.
> For example, *Ubuntu Users* will use the command `sudo apt-get install git`.
**Apple Users**:
You have a couple of options. If you are using Homebrew, use `brew install git`.
If you have no idea what Homebrew is, you can simply
[Download Git](http://git-scm.com/download/mac) from their
[website](http://git-scm.com/ "Git Source Control Manager").
If you get lost, Github provides
[detailed instructions](https://help.github.com/articles/set-up-git)
that are much better than mine.
.section.github
%h2 3. Signup for a Github Account
.content
:markdown
We want somewhere to put our code. As we are learning, we will be making our
code [open source](https://en.wikipedia.org/wiki/Open-source_software). This
is fantastic because we can learn from each other.
We can also use [Github](https://github.com/) for *free*!
Go [Sign Up](https://github.com/signup/free) now.
Github has [fantastic documentation](https://help.github.com/) detailing how
to use Git and take advantage of their services. You can explore this yourself now.
We will also begin covering git in more detail later this semester. Very useful
tool to know how to use. *+1 Marketable Skill*.
.section.ssh-keys
%h2 4. Setup SSH Keys
.content
:markdown
In order to use git from your terminal, you will need to setup some authentication
keys. Github uses SSH keys to authenticate users attempting to push code to
a repository (save code).
They have a [awesome guide](https://help.github.com/articles/generating-ssh-keys)
for this. It is even tailored to your favorite operating system!
When generating your keyfiles, any options in [brackets] are default options.
I recommend you leave the filename of the keys to be their default (id_rsa).
You know you've got it *working correctly* if you are able to run the command
> `ssh -T git@github.com`
and see the output
> `Hi *USERNAME*! You've successfully authenticated, but GitHub does not
> provide shell access.`
When you get this working, you know you're doing great.
.section.sinatra
%h2 5. Install Sinatra
.content
:markdown
Now that you have RVM with ruby-1.9.3 installed, we can start using ruby. You are
going to run the command
> gem install sinatra
This will install the [Sinatra Web Framework](http://sinatrarb.com/). It will be
our tool of choice for the next few weeks as we explore web development.
.section.sinatra
%h2 6. Create Your First Website
.content
:markdown
Now we get to ***CREATE***! Create your first website!
The plan: We are going to create a project directory, a server file, a
documentation file. We'll then see our creation run in our browser.
Finally we'll push the results to Github.
Open your terminal and open a [text editor](#text-editors). Run:
> mkdir -p ~/cwdg_projects/hello_sinatra
> cd ~/cwdg_projects/hello_sinatra
Copy the following text into your text editor and save the file as `hi.rb`:
> require 'sinatra'
>
> get '/hi' do
> "Hello World!"
> end
This is going to create a page that just says "Hello World".
Now you will start the server by running:
> ruby hi.rb
It should output something similar to `Listening on 0.0.0.0:4567`.
You can look at this page by pointing your browser at
[http://localhost:4567](http://localhost:4567). You should get an error page
from Sinatra ("Sinatra doesn't know this ditty").
Now go to [http://localhost:4567/hi](http://localhost:4567/hi). You should
see "Hello World!" in your browser.
***VICTORY!***
.section.push
%h2 7. Push to Github
.content
:markdown
Now we need to save this success for posterity.
[Create a New Repo on Github](https://github.com/new). Name it
`hello_sinatra` or whatever you like. Check "public" and hit "create repository".
Now we'll follow the directions on the next page.
With your text editor, save a file called README.md in this directory with the text:
> A basic Sinatra app.
In your terminal, run:
> git init
> git add hi.rb
> git add README.md
> git commit -m "Basic Sinatra App"
> git remote add origin git@github.com:YOUR_USERNAME/hello_sinatra.git
> git push -u origin master
Make sure you used your own Github username. *YOUR_USERNAME* is a placeholder.
Replace it with whatever your real username is. You can check the
[example I created](https://github.com/saterus/hello_sinatra) if you like.
Check the Github page again. You should see your code saved to Github now!
***MISSION ACCOMPLISHED!***
Everything is setup. Next week we will build on the work you did here. You can
read up on [Ruby](http://www.ruby-lang.org/en/),
[Git](http://git-scm.com/book/en/Getting-Started),
[Github](https://help.github.com/), [Sinatra](http://www.sinatrarb.com/), or
[Web Development](https://en.wikipedia.org/wiki/Web_development) in the meantime.
.section.faq
%h2 FAQ
.content
:markdown
- **What do you mean by "run this command"?**
- In your terminal application, type or paste the code snippet and hit enter.
- **I'm typing my password, but nothing shows up.**
- Don't worry! It is still working, it is just hiding your password from
anyone who might be standing behind you. When you are finished, just hit enter.
- **Zlib isn't installed?**
- We noticed that some people using Ubuntu had issues installing Sinatra because
of a missing dependency. Follow [these instructions](https://rvm.io/packages/zlib/)
in order to get your gem installs to work.
- **I was installing XYZ, it says it failed. What should I do?**
- Try thinking of your problem in its general terms, then typing them into Google.
If you have a specific error message, try that.
[Stack Overflow](http://stackoverflow.com/) is a pretty good resource for
common problems.
- **Which text editor should I use?**
- It doesn't really matter. If someone tells you to use Emacs or Vim, they mean
well, but are likely just going to confuse you. You might want to try
[Gedit](http://projects.gnome.org/gedit/) or
[Sublime Text 2](http://www.sublimetext.com/2).
- **I'm stuck.**
- Step 1: *Don't Give Up!*
- You probably ran into a problem someone else is having. Please feel free to
send an email out with a detailed description of your problem. Someone will
likely be able to help. You should include what operating system you are using,
and which steps have been completed successfully.
- **I found an error/typo/omission in this guide.**
- Please email [cwdgosu@gmail.com](mailto:cwdgosu@gmail.com) with your keen
observation. If you feel really adventurous, you can [submit a pull request
with a fix or improvement](https://github.com/CWDG/cwdg.github.com).
.section.why
%h2 But why are we installing XYZ program?
.content
:markdown
There are many options for how to create web applications. We have chosen a few
technologies to use so everyone is using similar software. We think the benefits
of this will become apparent as people begin creating their own projects. Our
club members will become experts in these tools capable of actually helping each
other.
If you have questions about specific technology choices, please feel free to email
the mailing list or [cwdgosu@gmail.com](mailto:cwdgosu@gmail.com).
#footer
:markdown
Email [cwdgosu@gmail.com](mailto:cwdgosu@gmail.com) for more information.