Code Monkey home page Code Monkey logo

ruby-kickstart's Introduction

Welcome to RubyKickstart!

RubyKickstart is an interactive guide to learning the Ruby programming language.

The material here follows along with the videos, but it's not necessary to watch them to get the benefits. And get the source code with notes and challenges.

How it works

RubyKickstart is downloaded onto your computer as a folder full of files and folders. It consists of six sessions, all of which have common features:

Videos

Each session has a video where I go through the notes with some friends I made this material for. Watch your way through the video and follow along with the material on your computer.

Notes

Each session has a set of notes files, which are just simple Ruby programs that are heavily commented to walk through the material of that session. This is the material that we go through for each session.

Examples

Existence of examples is intermittent. They are full Ruby programs that demonstrate the material taught in the notes. You can run them on your own and modify them to experiment with the ideas they demonstrate.

Quizzes

Each session has an associated quiz available on the website. The quizzes test that you understood the material for the session.

Challenges

Challenges are found in each session. They provide fun programming exercises for you to work through, so you have something to work on that utilizes the session's information. Challenges are taken from a few different places. Several are taken from different books that I have enjoyed, including the third edition of Absolute Java by Walter Savitch, which is probably my favourite CS book (for beginners), it was exceptionally well done, and one was taken from Learn to Program by Chris Pine, a book to teach programming to absolute beginners, using Ruby. The rest were spawned out of my own brain, or from real world situations that I have found myself in.

Solved & Specs

Along with challenges, each session provides solutions to its challenges and a suite of automated tests you can use to test the correctness of your solutions.

Cheatsheets

Although not part of the sessions, RubyKickstart has a number of cheatsheets which contain all the syntax for various topics. Some of the material in the cheatsheets is not covered in the notes or examples for sessions, so make sure you check out the cheatsheets before diving into the challenges.

Sessions

  • 1
    • Introduction
    • Arithmetic
    • Logic
    • String
    • Basic IO
  • 2
    • Arrays
    • Basic Classes
    • Singleton Classes
  • 3
    • Symbols
    • Hashes
    • Blocks / Procs
    • Method Parameters
  • 4
    • Boolean Return Values
    • Introspection / Reflection
    • Ranges
    • Simple File IO
    • Inheritance
    • Exceptions
  • 5
    • Modules
    • Regular Expressions
    • Ruby gems
  • 6
    • The Web
    • Sinatra
    • ERB
    • Rack
    • Git
    • Heroku

What you'll need to use it

To use RubyKickstart, you'll need several tools:

  • Ruby the happy programming language :)
  • Rake version 0.8.7+ see if you have it by typing "gem list" at the command line, we use it to apply the tests
  • RSpec version 2.0+ currently we use this for testing
  • git lets you download our changes without overwriting your work. Good installation instructions at (http://help.github.com/git-installation-redirect)
  • A text editor Our Recommendations:
    • Windows: SciTE should come with the one click installer
    • Linux: SciTE also works great on linux :)
    • Mac: TextMate costs $50 but can be used by a beginner, and yet is powerful, has a community, and can be customized to meet your needs

Age

This is several years old now, but I updated it to RSpec 3 and cleaned it up a lot in December 2014. Everything should still work fine and be applicable.

There is now a Gemfile in the root, you can ignore it, it's mostly for letting me know what versions I last checked it against.

The website is down now b/c Heroku changed since I made this. I'll hopefully get it up again, but IDK how much work it's going to take, so it might not happen.

ruby-kickstart's People

Contributors

dependabot[bot] avatar joshcheek avatar marioribeiro avatar olegsliusar avatar wikimatze avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruby-kickstart's Issues

Session 1 Notes: 19-nil.rb maybe explain | and {}?

Going through the tutorial right now, I am confused as to what the {...} and the |number|mean in these two lines:

array.find { |number| number * 2 == 10 } # => 5
array.find { |number| number * 2 == 11 } # => nil

Could not find an explanation in earlier notes so I had to look them up. Figured it out in the end on my own, but it would be nice if a note covered this.

rake 1:7 total confusion

The solution takes value of current_char to the string indexes from [0..n] then puts the value of the current_char if current_char is "r". So how does it ends up with the correct answer. And also what does setting the value of add_next to 'false' accomplishes. Removing it gives an error, setting it to true comes up with an additional '0' th index character. I am clueless and now kind of bashing my head for 3 hours straight. Can you please elaborate a little, that would be great. I am just a new seedling in the world of coding.

Your lessons are briliant

That said I was wondering why you chose solutions and tests that only your briliance could come up with. Shouldn't we have some simple things first? I don't have a clue from the tests so I end up cheating and looking at your solves. Have you seen https://github.com/alexch/learn_ruby? I thank you for the excellence of your efforts. Sorry I was in such a bad mood.

rake 2:2 fail

Hi Josh,
thanks for making these lessons, I'm almost done with session two and enjoying it a lot :).

I was running the rspec on exercise 2 from session 2 (rake 2:2) and it keeps on failing.
I've also tried it with the solution provided by you (solved folder), same result.

This is the result that I am getting:

$ rake 2:2
(in /Users/sandagolcea/Projects/ruby/kickstart)
ruby -c '/Users/sandagolcea/Projects/ruby/kickstart/session2/challenge/2_input_output_control.rb'
Syntax OK
rspec -cr '/Users/sandagolcea/Projects/ruby/kickstart/session2/challenge/2_input_output_control.rb' -r enumerator '/Users/sandagolcea/Projects/ruby/kickstart/session2/spec/2.rb' --fail-fast
F

Failures:

  1. hi_hi_goodbye should immediately quit if the first submission is bye
    Failure/Error: (!!output[BYE_REGEX]).should be_true
    expected true to respond to true?

    ./session2/spec/2.rb:35:in `hi_hi_goodbye_tester'

    ./session2/spec/2.rb:41:in`block (2 levels) in <top (required)>'

Deprecation Warnings:

Using should from rspec-expectations' old :should syntax without explicitly enabling the syntax is deprecated. Use the new :expect syntax or explicitly enable :should instead. Called from /Users/sandagolcea/Projects/ruby/kickstart/session2/spec/2.rb:34:in `hi_hi_goodbye_tester'.

If you need more of the backtrace for any of these deprecations to
identify where to make the necessary changes, you can configure
config.raise_errors_for_deprecations!, and it will turn the
deprecation warnings into errors, giving you the full backtrace.

1 deprecation warning total

Finished in 0.00485 seconds (files took 0.1046 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./session2/spec/2.rb:40 # hi_hi_goodbye should immediately quit if the first submission is bye
rake aborted!
Command failed with status (1): [rspec -cr '/Users/sandagolcea/Projects/rub...]
/Users/sandagolcea/Projects/ruby/kickstart/Rakefile:67:in run_spec' /Users/sandagolcea/Projects/ruby/kickstart/Rakefile:93:inblock (4 levels) in <top (required)>'
/Users/sandagolcea/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in eval' /Users/sandagolcea/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in

'
Tasks: TOP => 2:2
(See full trace by running task with --trace)

Do you know what's wrong with it? :)

Install - Rake and RSpec

Hello,
I recently installed ruby (through rubyinstaller.org for windows 10) which is a version 2.1.7 as of today (december 2015) and by typing "gem list" in the terminal I see that there is already rake installed (v 10.1.0). Probably a basic and stupid question but when looking at the challenge folder in session 1, in the file 1_arithmetic.rb, it is indicated "fill out the method below then test tho see if you did them correctly with $ rake 1:1" >> I am not sure to understand how to test my code using rake.
Typing rake 1:1 in the terminal doesn't make sense I suppose but still I tried and got a "rake aborted!" message. Could you please let me know how should I do this?
Thanks in advance!
Btw, I just discovered these courses and thank you very much for putting these together and making it free!

Hi Josh. This isn't really an issue just a message.

I am in the process of creating rdocs for ruby-kickstart. Before I try to send a pull request I would just like you to take a look at it and see if I should. I could then just drop it into a branch if you like. My repo is ruby-kickstart-4-rdoc but I'm not done yet.
I'll push what I have so far maybe before days end.
Thanks. No hurry.

Still working on the mardown stuff Josh but I have something.

K! First of what you can do as what I am doing, go get practicing ruby articles here on github.
Practicing Ruby journal.
http://github.com/elm-city-craftworks/practicing-ruby-manuscripts
That has the code I'm using to do this with.

Next is your option. In Rakefile

filecontent = Kramdown::Document.new(filecontent, :coderay_line_numbers => nil, template: "#{__dir__}/templates/default.html.erb")

I chose to not include line numbers. Your choice though.
If you want line numbers then just remove the nil hash.
My Rackefile now is:

require "kramdown"
require "coderay"
require "fileutils"

MARKDOWN_FILES = Dir.glob("#{__dir__}/articles/**/*.md")

task default: :html_files

desc "Generate HTML files from markdown articles"
task :html_files do
  MARKDOWN_FILES.each do |markdown_file|
    html_path = markdown_file.sub("/articles/", "/articles-html/").sub(/\.md$/, ".html")
    puts "Generating #{html_path}"
    FileUtils.mkdir_p(File.dirname(html_path))
    File.open(html_path, "w") do |html_file|
      filecontent = File.read(markdown_file)
      filecontent = filecontent.gsub("\`\`\`", "~~~")
      filecontent = Kramdown::Document.new(filecontent, template: "#{__dir__}/templates/default.html.erb")
      html_file.write(filecontent.to_html)
    end
  end
end

desc "Delete all generated HTML files"
task :clean do
  FileUtils.rm_rf("#{__dir__}/articles-html")
end


ALL_FILES = Dir.glob("#{__dir__}/articles/**/*")
desc "make md files from ruby files"
task :make_and_add_ruby_tags_to_files do
  ALL_FILES.each do |file|
    if !File.directory?(file)
      File.open(file, "r") do |f|
        content = File.read(f)        
        content = "```ruby\n" + content + "```"
        path = f.path
        markdown_file_name = path << ".md"      
        File.open(markdown_file_name, "w") {|f| f.write(content) }          
      end
      File.delete(file)
      p file  
    end        
  end            
end

It's not 100% because of image files but you only have one right?
I deleted it before generating any html files.
http://myrackapps.herokuapp.com/htdocs/ruby-kickstart-master/session6/notes/09-static-files-and-bundler/public/dependencies.png
But added it back in after.

So you see we need some further tasks to do that so there won't be one manual manipulation like this and for future uses.

I would suggest you give a commented name to all these files so that they show up in the converted files. Maybe you know better than I how we could just take the Rakefile and do it. We have the file names after all. But I'm just glade I don't have to do this manually now. What a relief. ;-)

I've really learned a lot from guys like you, Gregory, github folks in general and all the other ones that I know from the web.

Error in LRTHW exercise 17 i dont understand

In the exercise, the comment on line 5 says that we can consolidate lines 6 and 7 into one line, which I have attempted to do in my code so that it reads as such:
`from_file, to_file = ARGV

puts "Copying from #{from_file} to #{to_file}"

in_file = open(from_file).read

puts "The input file is #{in_file.length} bytes long"

puts "Does the output file exist? #{File.exist?(to_file)}"
puts "Ready, hit RETURN to continue, CTRL-C to abort"
$stdin.gets

out_file = open(to_file, 'w')
out_file.write(in_file)

puts "Alright, all done"

out_file.close
in_file.close`

However when I run thi I get the error "ex17.rb:21:in <main>': undefined method close' for "This is a test file.\n":String (NoMethodError)
Did you mean? clone"

I can only assume the reason for this error is something to do with the way I typed in_file = open(from_file).read. Can anyone confirm this and if so how do I write this on a single line

Spec in session2/challenge/13_classes_iterating_sorting.rb seems incorrect

Under Example at Line 32 the spec says

Blog.new Date.parse("2007-01-02"), lissa, "Going dancing!" # we'll call this blog2

Blog.new Date.parse("2006-01-02"), lissa, "For the last time, fuck facebook >.<" # we'll call this blog3

Blog.new Date.parse("2010-01-02"), lissa, "Got a new job, cuz I'm pretty much the best ^_^" # we'll call this blog4

lissa.blogs # => [ blog1 , blog4 , blog2 , blog3 ]

However, calling Blog.new directly and not via lissa.add_blog will not add blog2, blog3 and blog4 to lissa.blogs, will it?

Additionally (negligible, but here it goes), it seems like you want an attribute 'blogs' for User class and not a method, there is no mention of 'entry' method for Blog class except in examples and there is no mention of add_blog returning the added blog except when a rake test fails.

Looking at the test cases I managed to figure out what was expected and complete the challenge. However, I just wanted to raise it back to you in case anything I have raised is correct and in case you are planning on making updates to ruby-kickstart in the future.

Thank you for the brilliant tutorial. I have learnt a lot from it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.