Slightly cheating to get myself up and running, but seems a little gentler that way. Also good to have a record of what I'm aiming for
1. Hello, James
Already have Ruby installed (with RVM), so can just create a hello.rb file with puts 'hello world' in it and then run it from the command line with ruby hello.rb. Simple.
To get the name we can either go with:
name = gets.chomp
puts "Hello, #{name}"
which is run as above, but requires entering the name afterwards, or replace the first line with:
name = ARGV[0]
and then run as ruby hello.rb James.
Done.
2. FizzBuzz
Learn a test framework. Also small things about conditionals, I guess. Maybe even the beginnings of a few language conventions.
Test framework is RSpec. Installed with gem install rspec. Requires a 'spec' folder and a 'rspec --init command. Files to be tested need to be required in the specs.
Tests look a little like this:
it 'should return 1 when given 1' do
expect(fizzbuzz(1)).to eq(1)
end
Everything comes out in the command line. Nice and easy. 'Fizzbuzz' is apparently tricky for me to spell consistently, though...
3. Landing Page
So, Sinatra. Starts with installation through a Gemfile and gem 'sinatra'. Gems installed with Bundler. Simplest version is just a file with the following contents:
require 'sinatra'
get '/' do
"Hello World"
end
Server's started with ruby <filename> and "Hello World" is printed to the screen. When you close the server, you get the message "Sinatra has ended his set (crowd applauds)", which is amazing.
So, something more interesting. Set up a simple site that, for Sinatra at least, requires views (with layouts and partials), public stylesheets and helpers. Data for the views comes from the helper and the controller. Not the way you'd actually code the site, but useful set of things I'd like to be able to do. From here on out, I'll just reuse the CSS and most of the HTML, which should make things quicker.
4. Recreate my homepage
Already exists in Sinatra form...
5. Twitter
Already exists in Sinatra form...
May at some point do these in Rails, but for now it's a good base. Onwards.