Skip to content

Commit

Permalink
Configuracao do Restfolia
Browse files Browse the repository at this point in the history
  • Loading branch information
Hissao committed Jul 26, 2012
1 parent 5294171 commit 6666017
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 78 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ gem 'rails', '3.2.6'
# Bundle edge Rails instead: # Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git' # gem 'rails', :git => 'git://github.com/rails/rails.git'


gem 'restfulie', '~> 1.0.0' gem 'restfolia', :git => 'http://github.com/rogerleite/restfolia.git'


# Gems used only for assets and not required # Gems used only for assets and not required
# in production environments by default. # in production environments by default.
Expand Down Expand Up @@ -40,12 +40,12 @@ gem 'jquery-rails'


group :development, :test do group :development, :test do
gem 'rspec-rails' gem 'rspec-rails'
gem 'ruby-debug'
end end


group :test do group :test do
gem 'capybara' gem 'capybara'
gem 'vcr' gem 'vcr'
gem 'fakeweb' gem 'fakeweb'
gem 'capybara-mechanize'
gem 'guard-rspec' gem 'guard-rspec'
end end
64 changes: 18 additions & 46 deletions Gemfile.lock
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,10 @@
GIT
remote: http://github.com/rogerleite/restfolia.git
revision: 84609a83c07c82a44e5189ccce1d04e172d68aad
specs:
restfolia (1.0.4)
multi_json (~> 1.0)

GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
Expand Down Expand Up @@ -38,9 +45,6 @@ GEM
rack-test (>= 0.5.4) rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0) selenium-webdriver (~> 2.0)
xpath (~> 0.1.4) xpath (~> 0.1.4)
capybara-mechanize (0.3.0)
capybara (~> 1.1)
mechanize (~> 2.3)
childprocess (0.3.3) childprocess (0.3.3)
ffi (~> 1.0.6) ffi (~> 1.0.6)
coffee-rails (3.2.2) coffee-rails (3.2.2)
Expand All @@ -50,10 +54,9 @@ GEM
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.3.3) coffee-script-source (1.3.3)
columnize (0.3.6)
commonjs (0.2.6) commonjs (0.2.6)
diff-lcs (1.1.3) diff-lcs (1.1.3)
domain_name (0.5.3)
unf (~> 0.0.3)
erubis (2.7.0) erubis (2.7.0)
execjs (1.4.0) execjs (1.4.0)
multi_json (~> 1.0) multi_json (~> 1.0)
Expand All @@ -65,16 +68,12 @@ GEM
guard-rspec (1.1.0) guard-rspec (1.1.0)
guard (>= 1.1) guard (>= 1.1)
hike (1.2.1) hike (1.2.1)
hypertemplate (1.2.2)
json_pure
nokogiri
i18n (0.6.0) i18n (0.6.0)
journey (1.0.4) journey (1.0.4)
jquery-rails (2.0.2) jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0) railties (>= 3.2.0, < 5.0)
thor (~> 0.14) thor (~> 0.14)
json (1.7.3) json (1.7.3)
json_pure (1.7.3)
less (2.2.1) less (2.2.1)
commonjs (~> 0.2.6) commonjs (~> 0.2.6)
less-rails (2.2.3) less-rails (2.2.3)
Expand All @@ -83,6 +82,8 @@ GEM
libv8 (3.3.10.4) libv8 (3.3.10.4)
libwebsocket (0.1.3) libwebsocket (0.1.3)
addressable addressable
linecache (0.46)
rbx-require-relative (> 0.0.4)
listen (0.4.7) listen (0.4.7)
rb-fchange (~> 0.0.5) rb-fchange (~> 0.0.5)
rb-fsevent (~> 0.9.1) rb-fsevent (~> 0.9.1)
Expand All @@ -91,32 +92,13 @@ GEM
i18n (>= 0.4.0) i18n (>= 0.4.0)
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
mechanize (2.5.1)
domain_name (~> 0.5, >= 0.5.1)
mime-types (~> 1.17, >= 1.17.2)
net-http-digest_auth (~> 1.1, >= 1.1.1)
net-http-persistent (~> 2.5, >= 2.5.2)
nokogiri (~> 1.4)
ntlm-http (~> 0.1, >= 0.1.1)
webrobots (~> 0.0, >= 0.0.9)
medie (1.0.0)
actionpack (>= 3.0.0)
activesupport
json_pure
methodize
methodize (0.2.2)
mime-types (1.19) mime-types (1.19)
multi_json (1.3.6) multi_json (1.3.6)
net-http-digest_auth (1.2.1)
net-http-persistent (2.7)
nokogiri (1.5.5) nokogiri (1.5.5)
ntlm-http (0.1.1)
polyglot (0.3.3) polyglot (0.3.3)
rack (1.4.1) rack (1.4.1)
rack-cache (1.2) rack-cache (1.2)
rack (>= 0.4) rack (>= 0.4)
rack-conneg (0.1.5)
rack (>= 1.0)
rack-ssl (1.3.2) rack-ssl (1.3.2)
rack rack
rack-test (0.6.1) rack-test (0.6.1)
Expand All @@ -142,17 +124,9 @@ GEM
rb-fsevent (0.9.1) rb-fsevent (0.9.1)
rb-inotify (0.8.8) rb-inotify (0.8.8)
ffi (>= 0.5.0) ffi (>= 0.5.0)
rbx-require-relative (0.0.9)
rdoc (3.12) rdoc (3.12)
json (~> 1.4) json (~> 1.4)
respondie (0.9.0)
restfulie (1.0.3)
hypertemplate (~> 1.2.0)
json_pure (>= 1.2.4)
medie (~> 1.0.0)
nokogiri (>= 1.4.2)
rack-conneg
respondie (~> 0.9.0)
sqlite3-ruby
rspec (2.10.0) rspec (2.10.0)
rspec-core (~> 2.10.0) rspec-core (~> 2.10.0)
rspec-expectations (~> 2.10.0) rspec-expectations (~> 2.10.0)
Expand All @@ -166,6 +140,11 @@ GEM
activesupport (>= 3.0) activesupport (>= 3.0)
railties (>= 3.0) railties (>= 3.0)
rspec (~> 2.10.0) rspec (~> 2.10.0)
ruby-debug (0.10.4)
columnize (>= 0.1)
ruby-debug-base (~> 0.10.4.0)
ruby-debug-base (0.10.4)
linecache (>= 0.3)
rubyzip (0.9.9) rubyzip (0.9.9)
sass (3.1.20) sass (3.1.20)
sass-rails (3.2.5) sass-rails (3.2.5)
Expand All @@ -181,9 +160,6 @@ GEM
hike (~> 1.2) hike (~> 1.2)
rack (~> 1.0) rack (~> 1.0)
tilt (~> 1.1, != 1.3.0) tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.6)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
therubyracer (0.10.1) therubyracer (0.10.1)
libv8 (~> 3.3.10) libv8 (~> 3.3.10)
thor (0.15.4) thor (0.15.4)
Expand All @@ -200,11 +176,7 @@ GEM
uglifier (1.2.6) uglifier (1.2.6)
execjs (>= 0.3.0) execjs (>= 0.3.0)
multi_json (~> 1.3) multi_json (~> 1.3)
unf (0.0.5)
unf_ext
unf_ext (0.0.5)
vcr (2.2.2) vcr (2.2.2)
webrobots (0.0.13)
xpath (0.1.4) xpath (0.1.4)
nokogiri (~> 1.3) nokogiri (~> 1.3)


Expand All @@ -213,15 +185,15 @@ PLATFORMS


DEPENDENCIES DEPENDENCIES
capybara capybara
capybara-mechanize
coffee-rails (~> 3.2.1) coffee-rails (~> 3.2.1)
fakeweb fakeweb
guard-rspec guard-rspec
jquery-rails jquery-rails
less-rails less-rails
rails (= 3.2.6) rails (= 3.2.6)
restfulie (~> 1.0.0) restfolia!
rspec-rails rspec-rails
ruby-debug
sass-rails (~> 3.2.3) sass-rails (~> 3.2.3)
twitter-bootstrap-rails twitter-bootstrap-rails
uglifier (>= 1.0.3) uglifier (>= 1.0.3)
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/feed_controller_spec.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,7 @@
class FeedController < ApplicationController
def index

@materias = Domain::Materia.all

end
end
2 changes: 1 addition & 1 deletion app/controllers/home_controller.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ class HomeController < ApplicationController
def index def index


@materias = Domain::Materia.all @materias = Domain::Materia.all
debugger
end end
end end
32 changes: 6 additions & 26 deletions app/models/domain/materia.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,36 +1,16 @@
module Domain module Domain
class Materia class Materia
include Restfulie::Client::Base

def initialize(materia)
@materia = materia
end

def get(attribute)
@materia[attribute]
end

def self.entry_point def self.entry_point
"http://#{EDITORIAL_DOMAIN_HOST}/materias/busca" "http://#{EDITORIAL_DOMAIN_HOST}/materias/busca"
end end

def self.resource_name
"materia"
end


def self.all def self.all
result = [] result = []
get!.resource.resultado.each do |item| Restfolia.at(entry_point).get.resultado.each do |item|
result << Materia.new(Restfulie.at(item.id).get.resource) result << Restfolia.at(item.id).get
end end
return result result
end

uses_restfulie do |config|
config.entry_point = entry_point
config.default_headers = {
:get => {'Accept' => 'application/json'}
}
end end


end end
Expand Down
2 changes: 1 addition & 1 deletion app/models/feed.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,3 @@
class Feed class Feed

end end
1 change: 0 additions & 1 deletion app/views/home/index.html.erb
Original file line number Original file line Diff line number Diff line change
@@ -1 +0,0 @@
<p>Hello world</p>
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
# Expands the lines which load the assets # Expands the lines which load the assets
config.assets.debug = true config.assets.debug = true


EDITORIAL_DOMAIN_HOST = "stage.editorial.api.abril.com.br" EDITORIAL_DOMAIN_HOST = "stage.editorial.alexandria.abril.com.br"
end end
42 changes: 42 additions & 0 deletions spec/controllers/home_controller_spec.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'spec_helper'

describe HomeController do
render_views

context "on GET to /feed" do
before do
request.accept = "application/json"
@get_args = [:index]
get *@get_args
end
it "should render JSON" do
response.content_type.should be == "application/json"
end
it_should_behave_like "a cached response"
end

#context "on GET to /concursos/novo_concurso" do
# before do
# request.accept = "application/json"
# @get_args = [:new]
# get *@get_args
# end
# it "should render JSON" do
# response.content_type.should be == "application/json"
# json = JSON.parse response.body
# json.keys.sort.should be == %w[concurso link]
# json["concurso"].should be_kind_of Hash
# json["link"].should be_kind_of Array
#
# json["concurso"]["categorias"].should be_kind_of Array
# json["concurso"]["rotulos_controlados"].should be_kind_of Array
# json["concurso"]["conteudos_relacionados"].should be_kind_of Array
# json["concurso"]["editorias"].should be_kind_of Array
# json["concurso"]["tags"].should be_kind_of Array
#
# json["link"].map{ |l| l["rel"] }.uniq.sort.should be == %w[concursos self]
# end
# it_should_behave_like "a cached response"
#end

end

0 comments on commit 6666017

Please sign in to comment.