Module: ConcursoHub
- Defined in:
- lib/concurso_hub.rb,
lib/concurso_hub/version.rb
Constant Summary collapse
- VERSION =
'0.2.0'
Class Method Summary collapse
- .download(url) ⇒ Object
- .edital(url) ⇒ Object
- .provas(url) ⇒ Object
- .search(estado: nil, nivel: nil, busca: nil, limite: nil, ano: nil, modo: :abertos, with_edital: false, with_provas: false) ⇒ Object
Class Method Details
.download(url) ⇒ Object
64 65 66 |
# File 'lib/concurso_hub.rb', line 64 def self.download(url) Infrastructure::Http::HttpFileDownloader.new.fetch_bytes(url) end |
.edital(url) ⇒ Object
60 61 62 |
# File 'lib/concurso_hub.rb', line 60 def self.edital(url) fetch_edital_hash(url, build_repository) end |
.provas(url) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/concurso_hub.rb', line 68 def self.provas(url) repository = build_repository edital = fetch_edital_hash(url, repository) raise "Nenhuma prova disponÃvel para este concurso." unless edital[:provas_url] fetch_provas_array(edital[:provas_url], repository) end |
.search(estado: nil, nivel: nil, busca: nil, limite: nil, ano: nil, modo: :abertos, with_edital: false, with_provas: false) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/concurso_hub.rb', line 17 def self.search( estado: nil, nivel: nil, busca: nil, limite: nil, ano: nil, modo: :abertos, with_edital: false, with_provas: false ) repository = build_repository presenter = SilentPresenter.new Application::UseCases::ListarConcursos.new( repository: repository, presenter: presenter ).execute( Application::FiltrosConcurso.new( estado: estado, nivel: nivel, busca: busca, limite: limite, ano: ano, modo: modo ) ) raise presenter.erro if presenter.erro concursos = presenter.concursos.map { |c| serialize_concurso(c) } if with_edital || with_provas concursos.each do |c| edital_data = fetch_edital_hash(c[:url], repository) c[:edital] = edital_data if with_provas && edital_data[:provas_url] c[:provas] = fetch_provas_array(edital_data[:provas_url], repository) else c[:provas] = [] if with_provas end end end { concursos: concursos, metadata: presenter. } end |