diff options
| -rw-r--r-- | Gemfile.lock | 10 | ||||
| -rw-r--r-- | app/exporters/chouette/hub/company_exporter.rb | 35 | ||||
| -rw-r--r-- | app/exporters/chouette/hub/connection_link_exporter.rb | 2 | ||||
| -rw-r--r-- | app/exporters/chouette/hub/exporter.rb | 16 | ||||
| -rw-r--r-- | app/exporters/chouette/hub/network_exporter.rb | 35 | ||||
| -rw-r--r-- | app/views/api/hub/reseau/show.hub.erb | 1 | ||||
| -rw-r--r-- | app/views/api/hub/transporteur/show.hub.erb | 1 | ||||
| -rw-r--r-- | config/locales/exports.yml | 4 | ||||
| -rw-r--r-- | db/schema.rb | 4 | 
9 files changed, 92 insertions, 16 deletions
| diff --git a/Gemfile.lock b/Gemfile.lock index 277d100c6..cb5c574b8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,10 +1,10 @@  GIT    remote: https://github.com/afimb/ninoxe.git -  revision: ee6f1f77974f2b6912ab63c7e3239249cf6e235e +  revision: c70e52ef6cd42b6f38f0ea8e26963972bf67fa45    branch: sismo    specs: -    ninoxe (1.0.1) -      activerecord (>= 3.1.3, < 4.0) +    ninoxe (1.1.0) +      activerecord (~> 3.2)        acts_as_list (>= 0.1.6)        acts_as_tree (>= 1.1.0)        foreigner (= 1.6.0) @@ -53,10 +53,10 @@ GEM        i18n (~> 0.6, >= 0.6.4)        multi_json (~> 1.0)      acts_as_list (0.1.6) -    acts_as_tree (1.6.1) -      activerecord (>= 3.0.0)      acts_as_tree-1.8 (1.1.0)        activerecord (>= 3.0.0) +    acts_as_tree (2.0.0) +      activerecord (>= 3.0.0)      addressable (2.3.5)      arel (3.0.3)      bcrypt-ruby (3.0.1) diff --git a/app/exporters/chouette/hub/company_exporter.rb b/app/exporters/chouette/hub/company_exporter.rb new file mode 100644 index 000000000..eb530d6d4 --- /dev/null +++ b/app/exporters/chouette/hub/company_exporter.rb @@ -0,0 +1,35 @@ +class Chouette::Hub::CompanyExporter +  include ERB::Util +  attr_accessor :company, :directory, :template +   +  def initialize(company, directory) +    @company = company +    @directory = directory +    @template = File.open('app/views/api/hub/transporteur/show.hub.erb' ){ |f| f.read } +  end +   +  def render() +    ERB.new(@template).result(binding) +  end +   +  def hub_name +    "/TRANSPORTEUR.TXT" +  end +   +  def self.save( companies, directory, hub_export) +    companies.each do |company| +      self.new( company, directory).tap do |specific_exporter| +        specific_exporter.save +      end +    end +    hub_export.log_messages.create( :severity => "ok", :key => "EXPORT|COMPANY_COUNT", :arguments => {"0" => companies.size}) +  end +   +  def save +    File.open(directory + hub_name , "a") do |f| +      f.write("TRANSPORTEUR\n") if f.size == 0 +      f.write(render) +    end if company.present? +  end +end + diff --git a/app/exporters/chouette/hub/connection_link_exporter.rb b/app/exporters/chouette/hub/connection_link_exporter.rb index b3be19396..793da52bd 100644 --- a/app/exporters/chouette/hub/connection_link_exporter.rb +++ b/app/exporters/chouette/hub/connection_link_exporter.rb @@ -1,4 +1,4 @@ -class Chouette::Hub::Connection_LinkExporter +class Chouette::Hub::ConnectionLinkExporter    include ERB::Util    attr_accessor :connection_link, :directory, :template diff --git a/app/exporters/chouette/hub/exporter.rb b/app/exporters/chouette/hub/exporter.rb index 4b846fee0..5f1a1508f 100644 --- a/app/exporters/chouette/hub/exporter.rb +++ b/app/exporters/chouette/hub/exporter.rb @@ -118,7 +118,7 @@ class Chouette::Hub::Exporter          Chouette::Hub::CommercialStopAreaExporter.save(commercial_stop_areas, temp_dir, hub_export)          Chouette::Hub::PhysicalStopAreaExporter.save(physical_stop_areas, temp_dir, hub_export) -        connection_links = Chouette::ConnectionLink.where( "deprture_id IN (?) AND arrival_id IN (?)", (physical_stop_areas.map(&:id) + commercial_stop_areas.map(&:id)), (physical_stop_areas.map(&:id) + commercial_stop_areas.map(&:id)) ) +        connection_links = Chouette::ConnectionLink.where( "departure_id IN (?) AND arrival_id IN (?)", (physical_stop_areas.map(&:id) + commercial_stop_areas.map(&:id)), (physical_stop_areas.map(&:id) + commercial_stop_areas.map(&:id)) )          Chouette::Hub::ConnectionLinkExporter.save(connection_links, temp_dir, hub_export) @@ -130,15 +130,19 @@ class Chouette::Hub::Exporter          if lines_exportable?            Chouette::Hub::LineExporter.save(@lines, temp_dir, hub_export) +          networks = Chouette::Network.where( :id => @lines.map(&:network_id)) +          companies = Chouette::Network.where( :id => @lines.map(&:company_id)) +          Chouette::Hub::NetworkExporter.save(networks, temp_dir, hub_export) +          Chouette::Hub::CompanyExporter.save(companies, temp_dir, hub_export)          else            log_overflow_warning(Chouette::Line)          end -        if routes_exportable? -          #Chouette::Hub::RouteExporter.save( routes, temp_dir, hub_export) -        else -          log_overflow_warning(Chouette::Route) if lines_exportable? -        end +        #if routes_exportable? +        #  Chouette::Hub::RouteExporter.save( routes, temp_dir, hub_export) +        #else +        #  log_overflow_warning(Chouette::Route) if lines_exportable? +        #end          # if too many lines          # there may be too many stop_areas diff --git a/app/exporters/chouette/hub/network_exporter.rb b/app/exporters/chouette/hub/network_exporter.rb new file mode 100644 index 000000000..d59cd5fd3 --- /dev/null +++ b/app/exporters/chouette/hub/network_exporter.rb @@ -0,0 +1,35 @@ +class Chouette::Hub::NetworkExporter +  include ERB::Util +  attr_accessor :network, :directory, :template +   +  def initialize(network, directory) +    @network = network +    @directory = directory +    @template = File.open('app/views/api/hub/reseau/show.hub.erb' ){ |f| f.read } +  end +   +  def render() +    ERB.new(@template).result(binding) +  end +   +  def hub_name +    "/RESEAU.TXT" +  end +   +  def self.save( networks, directory, hub_export) +    networks.each do |network| +      self.new( network, directory).tap do |specific_exporter| +        specific_exporter.save +      end +    end +    hub_export.log_messages.create( :severity => "ok", :key => "EXPORT|NETWORK_COUNT", :arguments => {"0" => networks.size}) +  end +   +  def save +    File.open(directory + hub_name , "a") do |f| +      f.write("RESEAU\n") if f.size == 0 +      f.write(render) +    end if network.present? +  end +end + diff --git a/app/views/api/hub/reseau/show.hub.erb b/app/views/api/hub/reseau/show.hub.erb new file mode 100644 index 000000000..25f24dc6d --- /dev/null +++ b/app/views/api/hub/reseau/show.hub.erb @@ -0,0 +1 @@ +<%= @network.id %>;<%= @network.name %>;<%= @network.registration_number %> diff --git a/app/views/api/hub/transporteur/show.hub.erb b/app/views/api/hub/transporteur/show.hub.erb new file mode 100644 index 000000000..3f175b053 --- /dev/null +++ b/app/views/api/hub/transporteur/show.hub.erb @@ -0,0 +1 @@ +<%= @company.id %>;<%= @company.name %>;<%= @company.registration_number %> diff --git a/config/locales/exports.yml b/config/locales/exports.yml index 539e0d23d..d1a8e1c62 100644 --- a/config/locales/exports.yml +++ b/config/locales/exports.yml @@ -39,6 +39,8 @@ en:        VEHICLE_JOURNEY_AT_STOP_COUNT: "Vehicle journey At Stop count : %{0}"        PHYSICAL_STOP_AREA_COUNT: "Physical Stop Areas count : %{0}"        COMMERCIAL_STOP_AREA_COUNT: "Logical Stop Areas count : %{0}" +      NETWORK_COUNT: "Networks count : %{0}" +      COMPANY_COUNT: "Companies count : %{0}"        EXPORT: "%{0} Export"        EXPORTED_LINE: "Line %{0} (%{1}) exported"        EMPTY_LINE: "Line without valid vehicle journey : not exported" @@ -146,6 +148,8 @@ fr:        VEHICLE_JOURNEY_AT_STOP_COUNT: "Nombre d'horaires : %{0}"        PHYSICAL_STOP_AREA_COUNT: "Nombre d'arrêts physiques : %{0}"        COMMERCIAL_STOP_AREA_COUNT: "Nombre d'arrêts logiques : %{0}" +      NETWORK_COUNT: "Nombre de réseaux : %{0}" +      COMPANY_COUNT: "Nombre de transporteurs : %{0}"        EXPORT: "Export %{0}"        EXPORTED_LINE: "Ligne %{0} (%{1}) exportée"        EMPTY_LINE: "Ligne sans course valide : non exportée" diff --git a/db/schema.rb b/db/schema.rb index 1d3d2aa24..343ccdceb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,11 +11,7 @@  #  # It's strongly recommended to check this file into your version control system. -<<<<<<< HEAD  ActiveRecord::Schema.define(:version => 20140626081658) do -======= -ActiveRecord::Schema.define(:version => 20140618072859) do ->>>>>>> tad_pmr    create_table "access_links", :force => true do |t|      t.integer  "access_point_id",                        :limit => 8 | 
