Skip to content

Commit

Permalink
Removing require rubygems from sources
Browse files Browse the repository at this point in the history
Removed require rubygems from lib. All samples updated.
Rakefile sets rubygems to RUBYOPT if env variable does not exist.
You can see more info at http://tomayko.com/writings/require-rubygems-antipattern
  • Loading branch information
rogerleite committed May 23, 2012
1 parent fc223c3 commit 8ae09c7
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 23 deletions.
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require "bundler/gem_tasks"
require "rake/testtask"

ENV["RUBYOPT"] = "rubygems" if ENV["RUBYOPT"].nil?

Rake::TestTask.new do |t|
t.libs.push "lib"
t.libs.push "test"
Expand Down
1 change: 0 additions & 1 deletion lib/restfolia.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require "net/http"
require "uri"

require "rubygems"
require "multi_json"

require "restfolia/version"
Expand Down
3 changes: 1 addition & 2 deletions samples/changing_links_parse.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@

# Run this sample from root project:
# $ ruby samples/changing_links_parse.rb
# $ ruby -rubygems samples/changing_links_parse.rb

require "rubygems"
$LOAD_PATH << "lib"
require "restfolia"

Expand Down
4 changes: 2 additions & 2 deletions samples/cookies_options.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

# Run this sample from root project:
# $ ruby samples/cookies_options.rb
# $ ruby -rubygems samples/cookies_options.rb

require "rubygems"
$LOAD_PATH << "lib"
require "restfolia"

# Running https://github.com/rogerleite/simple_api
SERVICE_URL = "http://localhost:9292/recursos/busca"

sample_cookie = "PREF=ID=988f14fa5edd3243:TM=1335470032:LM=1335470032:S=KVBslNbyz6bG0DqU; expires=Sat, 26-Apr-2014 19:53:52 GMT; path=/; domain=.google.com, NID=59=peUyZQuLWQ_0gELr1yDf0FT4ZlT7ZdITNrO5OhkEnAvp_8MZ4TT6pHq7_q_Su-puTw7vGml_Ok6du8fLreGHzfpMs4Qh1v-qBCFYGuCNbzpwN670x5MFbGKy0KUXA3WP; expires=Fri, 26-Oct-2012 19:53:52 GMT; path=/; domain=.google.com; HttpOnly"
Expand Down
4 changes: 2 additions & 2 deletions samples/headers_options.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

# Run this sample from root project:
# $ ruby samples/headers_options.rb
# $ ruby -rubygems samples/headers_options.rb

require "rubygems"
$LOAD_PATH << "lib"
require "restfolia"

# Running https://github.com/rogerleite/simple_api
SERVICE_URL = "http://localhost:9292/recursos/busca"

# accessing headers attribute
Expand Down
16 changes: 6 additions & 10 deletions samples/http_behaviour.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

# Run this sample from root project:
# $ ruby samples/http_behaviour.rb
# $ ruby -rubygems samples/http_behaviour.rb

require "rubygems"
$LOAD_PATH << "lib"
require "restfolia"
require "ostruct"

Restfolia::HTTP.behaviours do

clear #clean all defined behaviours

on(200) do |http_response|
content_type = (http_response["content-type"] =~ /application\/json/)
if !content_type
Expand Down Expand Up @@ -36,17 +36,13 @@
# custom_helper
#end

#helpers do
# def custom_helper
# 'lixo'
# end
#end

end

# Running https://github.com/rogerleite/simple_api
SERVICE_URL = "http://localhost:9292/recursos/busca"

resource = Restfolia.at(SERVICE_URL).get
puts resource.inspect
puts resource.inspect # => #<Restfolia::Resource ...>

Restfolia.at("http://google.com").get
# => "3xx error"
6 changes: 3 additions & 3 deletions samples/using_custom_factory.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

# Run this sample from root project:
# $ ruby samples/using_custom_factory.rb
# $ ruby -rubygems samples/using_custom_factory.rb

require "rubygems"
$LOAD_PATH << "lib"
require "restfolia"
require "ostruct"

# Running https://github.com/rogerleite/simple_api
SERVICE_URL = "http://localhost:9292/recursos/busca"

resource = Restfolia.at(SERVICE_URL).get
puts resource.inspect # => #<Restfolia::Resource ...>
#puts resource.inspect # => #<Restfolia::Resource ...>

# Here you have the "pure" json from response body.
# You can do anything.
Expand Down
6 changes: 3 additions & 3 deletions samples/using_custom_resource.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

# Run this sample from root project:
# $ ruby samples/using_custom_resource.rb
# $ ruby -rubygems samples/using_custom_resource.rb

require "rubygems"
$LOAD_PATH << "lib"
require "restfolia"
require "ostruct"

# Running https://github.com/rogerleite/simple_api
SERVICE_URL = "http://localhost:9292/recursos/busca"

resource = Restfolia.at(SERVICE_URL).get
puts resource.inspect # => #<Restfolia::Resource ...>
#puts resource.inspect # => #<Restfolia::Resource ...>

# Here you have the advantage to use a custom resource
# and the same time you have the recursive lookup at hash
Expand Down

0 comments on commit 8ae09c7

Please sign in to comment.