ninoxe 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/app/models/chouette/access_point.rb +33 -12
- data/app/models/chouette/active_record.rb +1 -1
- data/app/models/chouette/line.rb +2 -0
- data/app/models/chouette/stop_area.rb +41 -3
- data/app/models/chouette/time_table.rb +351 -45
- data/app/models/chouette/time_table_date.rb +5 -5
- data/app/models/chouette/time_table_period.rb +16 -0
- data/app/models/chouette/trident_active_record.rb +27 -3
- data/app/models/chouette/vehicle_journey.rb +1 -1
- data/config/locales/en.yml +1 -0
- data/config/locales/fr.yml +1 -0
- data/db/migrate/20140617131630_add_on_demand_transportation_to_line.rb +5 -0
- data/db/migrate/20140617132236_add_details_to_vehicle_journey.rb +6 -0
- data/db/migrate/20140618071147_fix_column_name.rb +11 -0
- data/db/migrate/20140625143030_add_in_out_to_timetable_date.rb +5 -0
- data/db/migrate/20140626054725_set_in_out_to_timetable_date.rb +8 -0
- data/db/migrate/20140718141703_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +31 -0
- data/db/migrate/20140718141704_add_missing_unique_indices.acts_as_taggable_on_engine.rb +20 -0
- data/db/migrate/20140718141705_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +15 -0
- data/db/migrate/20140718141706_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
- data/db/migrate/20140820060801_add_zip_code_and_city_name_to_stop_area.rb +8 -0
- data/db/migrate/20140820060814_add_zip_code_and_city_name_to_access_point.rb +8 -0
- data/lib/factories/chouette_routes.rb +3 -1
- data/lib/factories/chouette_time_table.rb +2 -2
- data/lib/factories/chouette_vehicle_journey.rb +1 -0
- data/lib/ninoxe/version.rb +1 -1
- data/lib/ninoxe.rb +1 -0
- metadata +117 -118
@@ -25,7 +25,23 @@ class Chouette::TimeTablePeriod < Chouette::ActiveRecord
|
|
25
25
|
errors.add(:period_end,I18n.t("activerecord.errors.models.time_table_period.start_must_be_before_end"))
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
28
29
|
def update_parent
|
29
30
|
time_table.shortcuts_update
|
30
31
|
end
|
32
|
+
|
33
|
+
def copy
|
34
|
+
Chouette::TimeTablePeriod.new(:period_start => self.period_start,:period_end => self.period_end)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Test to see if a period overlap this period
|
38
|
+
def overlap?(p)
|
39
|
+
(p.period_start >= self.period_start && p.period_start <= self.period_end) || (p.period_end >= self.period_start && p.period_end <= self.period_end)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Test to see if a period is included in this period
|
43
|
+
def contains?(p)
|
44
|
+
(p.period_start >= self.period_start && p.period_end <= self.period_end)
|
45
|
+
end
|
46
|
+
|
31
47
|
end
|
@@ -19,12 +19,13 @@ class Chouette::TridentActiveRecord < Chouette::ActiveRecord
|
|
19
19
|
def prepare_auto_columns
|
20
20
|
# logger.info 'calling before_validation'
|
21
21
|
# logger.info 'start before_validation : '+self.objectid.to_s
|
22
|
-
if self.objectid.blank?
|
22
|
+
if self.objectid.nil? || self.objectid.blank?
|
23
23
|
# if empty, generate a pending objectid which will be completed after creation
|
24
24
|
if self.id.nil?
|
25
25
|
self.objectid = "#{prefix}:#{self.class.object_id_key}:__pending_id__#{rand(1000)}"
|
26
26
|
else
|
27
27
|
self.objectid = "#{prefix}:#{self.class.object_id_key}:#{self.id}"
|
28
|
+
fix_uniq_objectid
|
28
29
|
end
|
29
30
|
elsif not self.objectid.include? ':'
|
30
31
|
# if one token : technical token : completed by prefix and key
|
@@ -51,11 +52,25 @@ class Chouette::TridentActiveRecord < Chouette::ActiveRecord
|
|
51
52
|
end
|
52
53
|
end
|
53
54
|
|
55
|
+
def fix_uniq_objectid
|
56
|
+
base_objectid = self.objectid.rpartition(":").first
|
57
|
+
self.objectid = "#{base_objectid}:#{self.id}"
|
58
|
+
if !self.valid?
|
59
|
+
base_objectid="#{self.objectid}_"
|
60
|
+
cnt=1
|
61
|
+
while !self.valid?
|
62
|
+
self.objectid = "#{base_objectid}#{cnt}"
|
63
|
+
cnt += 1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
54
69
|
def build_objectid
|
55
70
|
#logger.info 'start after_create : '+self.objectid
|
56
71
|
if self.objectid.include? ':__pending_id__'
|
57
|
-
|
58
|
-
self.update_attributes( :objectid =>
|
72
|
+
fix_uniq_objectid
|
73
|
+
self.update_attributes( :objectid => self.objectid, :object_version => (self.object_version - 1) )
|
59
74
|
end
|
60
75
|
#logger.info 'end after_create : '+self.objectid
|
61
76
|
end
|
@@ -76,6 +91,15 @@ class Chouette::TridentActiveRecord < Chouette::ActiveRecord
|
|
76
91
|
end
|
77
92
|
end
|
78
93
|
end
|
94
|
+
|
95
|
+
def uniq_objectid
|
96
|
+
i = 0
|
97
|
+
baseobjectid = self.objectid
|
98
|
+
while self.class.exists?(:objectid => self.objectid)
|
99
|
+
i += 1
|
100
|
+
self.objectid = baseobjectid+"_"+i.to_s
|
101
|
+
end
|
102
|
+
end
|
79
103
|
|
80
104
|
def self.model_name
|
81
105
|
ActiveModel::Name.new self, Chouette, self.name.demodulize
|
@@ -6,7 +6,7 @@ class Chouette::VehicleJourney < Chouette::TridentActiveRecord
|
|
6
6
|
attr_accessor :transport_mode_name
|
7
7
|
attr_accessible :route_id, :journey_pattern_id, :time_slot_id, :company_id, :objectid, :object_version, :creation_time, :creator_id, :comment, :status_value
|
8
8
|
attr_accessible :route, :transport_mode,:transport_mode_name, :published_journey_name, :published_journey_identifier, :facility, :vehicle_type_identifier, :number
|
9
|
-
attr_accessible :vehicle_journey_at_stops_attributes, :time_table_tokens, :time_tables
|
9
|
+
attr_accessible :vehicle_journey_at_stops_attributes, :time_table_tokens, :time_tables, :mobility_restricted_suitability, :flexible_service
|
10
10
|
attr_reader :time_table_tokens
|
11
11
|
|
12
12
|
def self.nullable_attributes
|
data/config/locales/en.yml
CHANGED
data/config/locales/fr.yml
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
class FixColumnName < ActiveRecord::Migration
|
2
|
+
def up
|
3
|
+
rename_column :lines, :on_demand_transportation, :flexible_service
|
4
|
+
rename_column :vehicle_journeys, :on_demand_transportation, :flexible_service
|
5
|
+
end
|
6
|
+
|
7
|
+
def down
|
8
|
+
rename_column :lines, :flexible_service, :on_demand_transportation
|
9
|
+
rename_column :vehicle_journeys, :flexible_service, :on_demand_transportation
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# This migration comes from acts_as_taggable_on_engine (originally 1)
|
2
|
+
class ActsAsTaggableOnMigration < ActiveRecord::Migration
|
3
|
+
def self.up
|
4
|
+
create_table :tags do |t|
|
5
|
+
t.string :name
|
6
|
+
end
|
7
|
+
|
8
|
+
create_table :taggings do |t|
|
9
|
+
t.references :tag
|
10
|
+
|
11
|
+
# You should make sure that the column created is
|
12
|
+
# long enough to store the required class names.
|
13
|
+
t.references :taggable, polymorphic: true
|
14
|
+
t.references :tagger, polymorphic: true
|
15
|
+
|
16
|
+
# Limit is created to prevent MySQL error on index
|
17
|
+
# length for MyISAM table type: http://bit.ly/vgW2Ql
|
18
|
+
t.string :context, limit: 128
|
19
|
+
|
20
|
+
t.datetime :created_at
|
21
|
+
end
|
22
|
+
|
23
|
+
add_index :taggings, :tag_id
|
24
|
+
add_index :taggings, [:taggable_id, :taggable_type, :context]
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.down
|
28
|
+
drop_table :taggings
|
29
|
+
drop_table :tags
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This migration comes from acts_as_taggable_on_engine (originally 2)
|
2
|
+
class AddMissingUniqueIndices < ActiveRecord::Migration
|
3
|
+
def self.up
|
4
|
+
add_index :tags, :name, unique: true
|
5
|
+
|
6
|
+
remove_index :taggings, :tag_id
|
7
|
+
remove_index :taggings, [:taggable_id, :taggable_type, :context]
|
8
|
+
add_index :taggings,
|
9
|
+
[:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
|
10
|
+
unique: true, name: 'taggings_idx'
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
remove_index :tags, :name
|
15
|
+
|
16
|
+
remove_index :taggings, name: 'taggings_idx'
|
17
|
+
add_index :taggings, :tag_id
|
18
|
+
add_index :taggings, [:taggable_id, :taggable_type, :context]
|
19
|
+
end
|
20
|
+
end
|
data/db/migrate/20140718141705_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# This migration comes from acts_as_taggable_on_engine (originally 3)
|
2
|
+
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration
|
3
|
+
def self.up
|
4
|
+
add_column :tags, :taggings_count, :integer, default: 0
|
5
|
+
|
6
|
+
ActsAsTaggableOn::Tag.reset_column_information
|
7
|
+
ActsAsTaggableOn::Tag.find_each do |tag|
|
8
|
+
ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
remove_column :tags, :taggings_count
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# This migration comes from acts_as_taggable_on_engine (originally 4)
|
2
|
+
class AddMissingTaggableIndex < ActiveRecord::Migration
|
3
|
+
def self.up
|
4
|
+
add_index :taggings, [:taggable_id, :taggable_type, :context]
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.down
|
8
|
+
remove_index :taggings, [:taggable_id, :taggable_type, :context]
|
9
|
+
end
|
10
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Factory.define :
|
1
|
+
Factory.define :route_common, :class => "Chouette::Route" do |route|
|
2
2
|
route.sequence(:name) { |n| "Route #{n}" }
|
3
3
|
route.sequence(:published_name) { |n| "Long route #{n}" }
|
4
4
|
route.sequence(:number) { |n| "#{n}" }
|
@@ -7,7 +7,9 @@ Factory.define :route, :class => "Chouette::Route" do |route|
|
|
7
7
|
route.sequence(:objectid) { |n| "test:Route:#{n}" }
|
8
8
|
|
9
9
|
route.association :line, :factory => :line
|
10
|
+
end
|
10
11
|
|
12
|
+
Factory.define :route, :class => "Chouette::Route", :parent => :route_common do |route|
|
11
13
|
route.after_create do |r|
|
12
14
|
0.upto(4) do |i|
|
13
15
|
Factory(:stop_point, :position => i, :route => r)
|
@@ -7,9 +7,9 @@ Factory.define :time_table, :class => "Chouette::TimeTable" do |time_table|
|
|
7
7
|
time_table.sequence(:comment) { |n| "Timetable #{n}" }
|
8
8
|
time_table.sequence(:objectid) { |n| "test:Timetable:#{n}" }
|
9
9
|
time_table.sequence(:int_day_types) { (1..7).to_a.map{ |n| 2**(n+1)}.sum }
|
10
|
-
time_table.after_create { |t|
|
10
|
+
time_table.after_create { |t|
|
11
11
|
0.upto(4) do |i|
|
12
|
-
t.dates.create(Factory.attributes_for(:time_table_date, :date => i.days.since.to_date))
|
12
|
+
t.dates.create(Factory.attributes_for(:time_table_date, :date => i.days.since.to_date, :in_out => true))
|
13
13
|
end
|
14
14
|
start_date = Date.today
|
15
15
|
end_date = start_date + 10
|
@@ -1,6 +1,7 @@
|
|
1
1
|
Factory.define :vehicle_journey_common, :class => "Chouette::VehicleJourney" do |v|
|
2
2
|
v.sequence(:objectid) { |n| "test:VehicleJourney:#{n}" }
|
3
3
|
end
|
4
|
+
|
4
5
|
Factory.define :vehicle_journey, :parent => :vehicle_journey_common do |v|
|
5
6
|
v.association :journey_pattern, :factory => :journey_pattern
|
6
7
|
v.after_build do |vj|
|
data/lib/ninoxe/version.rb
CHANGED