From d726fbf698682fb4b5659a36f8a667e2604f0bd7 Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 15 Oct 2018 16:54:38 +0200 Subject: [PATCH] =?UTF-8?q?CARTO::SGMAP=20=E2=86=92=20ApiCarto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/{carto/sgmap => api_carto}/api.rb | 2 +- app/lib/{carto/sgmap => api_carto}/cadastre/adapter.rb | 4 ++-- .../sgmap => api_carto}/quartiers_prioritaires/adapter.rb | 4 ++-- app/services/module_api_carto_service.rb | 4 ++-- spec/controllers/users/carte_controller_shared_example.rb | 6 +++--- spec/lib/{carto/sgmap => api_carto}/api_spec.rb | 2 +- .../lib/{carto/sgmap => api_carto}/cadastre/adapter_spec.rb | 2 +- .../quartiers_prioritaires/adapter_spec.rb | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) rename app/lib/{carto/sgmap => api_carto}/api.rb (96%) rename app/lib/{carto/sgmap => api_carto}/cadastre/adapter.rb (79%) rename app/lib/{carto/sgmap => api_carto}/quartiers_prioritaires/adapter.rb (64%) rename spec/lib/{carto/sgmap => api_carto}/api_spec.rb (98%) rename spec/lib/{carto/sgmap => api_carto}/cadastre/adapter_spec.rb (97%) rename spec/lib/{carto/sgmap => api_carto}/quartiers_prioritaires/adapter_spec.rb (95%) diff --git a/app/lib/carto/sgmap/api.rb b/app/lib/api_carto/api.rb similarity index 96% rename from app/lib/carto/sgmap/api.rb rename to app/lib/api_carto/api.rb index 0489068f1..230fed038 100644 --- a/app/lib/carto/sgmap/api.rb +++ b/app/lib/api_carto/api.rb @@ -1,4 +1,4 @@ -class CARTO::SGMAP::API +class ApiCarto::API def initialize end diff --git a/app/lib/carto/sgmap/cadastre/adapter.rb b/app/lib/api_carto/cadastre/adapter.rb similarity index 79% rename from app/lib/carto/sgmap/cadastre/adapter.rb rename to app/lib/api_carto/cadastre/adapter.rb index 494600267..2fa40f4bc 100644 --- a/app/lib/carto/sgmap/cadastre/adapter.rb +++ b/app/lib/api_carto/cadastre/adapter.rb @@ -1,10 +1,10 @@ -class CARTO::SGMAP::Cadastre::Adapter +class ApiCarto::Cadastre::Adapter def initialize(coordinates) @coordinates = GeojsonService.to_json_polygon_for_cadastre(coordinates) end def data_source - @data_source ||= JSON.parse(CARTO::SGMAP::API.search_cadastre(@coordinates), symbolize_names: true) + @data_source ||= JSON.parse(ApiCarto::API.search_cadastre(@coordinates), symbolize_names: true) end def results diff --git a/app/lib/carto/sgmap/quartiers_prioritaires/adapter.rb b/app/lib/api_carto/quartiers_prioritaires/adapter.rb similarity index 64% rename from app/lib/carto/sgmap/quartiers_prioritaires/adapter.rb rename to app/lib/api_carto/quartiers_prioritaires/adapter.rb index ae1b7a762..9d5e62ee1 100644 --- a/app/lib/carto/sgmap/quartiers_prioritaires/adapter.rb +++ b/app/lib/api_carto/quartiers_prioritaires/adapter.rb @@ -1,10 +1,10 @@ -class CARTO::SGMAP::QuartiersPrioritaires::Adapter +class ApiCarto::QuartiersPrioritaires::Adapter def initialize(coordinates) @coordinates = GeojsonService.to_json_polygon_for_qp(coordinates) end def data_source - @data_source ||= JSON.parse(CARTO::SGMAP::API.search_qp(@coordinates), symbolize_names: true) + @data_source ||= JSON.parse(ApiCarto::API.search_qp(@coordinates), symbolize_names: true) end def results diff --git a/app/services/module_api_carto_service.rb b/app/services/module_api_carto_service.rb index 1d94e16e3..d3d920e3b 100644 --- a/app/services/module_api_carto_service.rb +++ b/app/services/module_api_carto_service.rb @@ -25,7 +25,7 @@ class ModuleApiCartoService def self.generate_qp(coordinates) coordinates.flat_map do |coordinate| - CARTO::SGMAP::QuartiersPrioritaires::Adapter.new( + ApiCarto::QuartiersPrioritaires::Adapter.new( coordinate.map { |element| [element['lng'], element['lat']] } ).results end @@ -33,7 +33,7 @@ class ModuleApiCartoService def self.generate_cadastre(coordinates) coordinates.flat_map do |coordinate| - CARTO::SGMAP::Cadastre::Adapter.new( + ApiCarto::Cadastre::Adapter.new( coordinate.map { |element| [element['lng'], element['lat']] } ).results end diff --git a/spec/controllers/users/carte_controller_shared_example.rb b/spec/controllers/users/carte_controller_shared_example.rb index 8538bc0a7..cfdf9e0e7 100644 --- a/spec/controllers/users/carte_controller_shared_example.rb +++ b/spec/controllers/users/carte_controller_shared_example.rb @@ -113,7 +113,7 @@ shared_examples 'carte_controller_spec' do let(:module_api_carto) { create(:module_api_carto, :with_quartiers_prioritaires) } before do - allow_any_instance_of(CARTO::SGMAP::QuartiersPrioritaires::Adapter) + allow_any_instance_of(ApiCarto::QuartiersPrioritaires::Adapter) .to receive(:results) .and_return([{ :code => "QPCODE1234", :nom => "QP de test", :commune => "Paris", :geometry => { :type => "MultiPolygon", :coordinates => [[[[2.38715792094576, 48.8723062632126], [2.38724851642619, 48.8721392348061]]]] } }]) @@ -160,7 +160,7 @@ shared_examples 'carte_controller_spec' do let(:module_api_carto) { create(:module_api_carto, :with_cadastre) } before do - allow_any_instance_of(CARTO::SGMAP::Cadastre::Adapter) + allow_any_instance_of(ApiCarto::Cadastre::Adapter) .to receive(:results) .and_return([{ :surface_intersection => "0.0006", :surface_parcelle => 11252.692583090324, :numero => "0013", :feuille => 1, :section => "CD", :code_dep => "30", :nom_com => "Le Grau-du-Roi", :code_com => "133", :code_arr => "000", :geometry => { :type => "MultiPolygon", :coordinates => [[[[4.134084, 43.5209193], [4.1346615, 43.5212035], [4.1346984, 43.521189], [4.135096, 43.5213848], [4.1350839, 43.5214122], [4.1352697, 43.521505], [4.1356278, 43.5211065], [4.1357402, 43.5207188], [4.1350935, 43.5203936], [4.135002, 43.5204366], [4.1346051, 43.5202412], [4.134584, 43.5202472], [4.1345572, 43.5202551], [4.134356, 43.5203137], [4.1342488, 43.5203448], [4.134084, 43.5209193]]]] } }]) @@ -215,7 +215,7 @@ shared_examples 'carte_controller_spec' do render_views before do - allow_any_instance_of(CARTO::SGMAP::QuartiersPrioritaires::Adapter) + allow_any_instance_of(ApiCarto::QuartiersPrioritaires::Adapter) .to receive(:results) .and_return([{ :code => "QPCODE1234", :geometry => { :type => "MultiPolygon", :coordinates => [[[[2.38715792094576, 48.8723062632126], [2.38724851642619, 48.8721392348061]]]] } }]) diff --git a/spec/lib/carto/sgmap/api_spec.rb b/spec/lib/api_carto/api_spec.rb similarity index 98% rename from spec/lib/carto/sgmap/api_spec.rb rename to spec/lib/api_carto/api_spec.rb index a13a7a571..ad3f11c95 100644 --- a/spec/lib/carto/sgmap/api_spec.rb +++ b/spec/lib/api_carto/api_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe CARTO::SGMAP::API do +describe ApiCarto::API do describe '.search_qp' do subject { described_class.search_qp(geojson) } diff --git a/spec/lib/carto/sgmap/cadastre/adapter_spec.rb b/spec/lib/api_carto/cadastre/adapter_spec.rb similarity index 97% rename from spec/lib/carto/sgmap/cadastre/adapter_spec.rb rename to spec/lib/api_carto/cadastre/adapter_spec.rb index d4e522abd..6ceab2ca9 100644 --- a/spec/lib/carto/sgmap/cadastre/adapter_spec.rb +++ b/spec/lib/api_carto/cadastre/adapter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe CARTO::SGMAP::Cadastre::Adapter do +describe ApiCarto::Cadastre::Adapter do subject { described_class.new(coordinates).results } before do diff --git a/spec/lib/carto/sgmap/quartiers_prioritaires/adapter_spec.rb b/spec/lib/api_carto/quartiers_prioritaires/adapter_spec.rb similarity index 95% rename from spec/lib/carto/sgmap/quartiers_prioritaires/adapter_spec.rb rename to spec/lib/api_carto/quartiers_prioritaires/adapter_spec.rb index e98cc3294..471be4b2b 100644 --- a/spec/lib/carto/sgmap/quartiers_prioritaires/adapter_spec.rb +++ b/spec/lib/api_carto/quartiers_prioritaires/adapter_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe CARTO::SGMAP::QuartiersPrioritaires::Adapter do +describe ApiCarto::QuartiersPrioritaires::Adapter do subject { described_class.new(coordinates).results } before do