Skip to content

Instantly share code, notes, and snippets.

@amrnt
Created June 22, 2013 10:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amrnt/5840304 to your computer and use it in GitHub Desktop.
Save amrnt/5840304 to your computer and use it in GitHub Desktop.
Ruby Ramallah - Day II
source "https://rubygems.org/"
gem 'sinatra'
gem 'nokogiri'
ENV['RACK_ENV'] ||= 'development'
require 'bundler/setup'
Bundler.require :default, ENV['RACK_ENV']
require './web_page'
get "/" do
page_title = WebPage.new(params[:url]).title
"The title page for: #{params[:url]} is <b>#{page_title}</b>"
end
require 'open-uri'
class WebPage
def initialize(url)
@page = Nokogiri::HTML(open(url))
end
def title
@page.title
end
end
@amrnt
Copy link
Author

amrnt commented Jun 22, 2013

First install Bundler by:

gem install bundler

Then run

bundle install

Every time you modify Gemfile make sure to run bundle or bundle install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment