aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert2017-05-02 22:10:31 +0200
committerRobert2017-05-02 22:10:31 +0200
commite89703a1646711ea2387e6058765aa3c6b953971 (patch)
tree77a2fb1bc960587e17bb48409b89ee4d5b0d4f88
parentcd8b08325558f6339e953b69fa64fa58a90bf3f2 (diff)
downloadchouette-core-e89703a1646711ea2387e6058765aa3c6b953971.tar.bz2
more duplicates of Range#intersection removed and range_ext required instead
-rw-r--r--app/models/calendar.rb1
-rw-r--r--app/models/referential_metadata.rb9
-rw-r--r--config/application.rb2
-rw-r--r--lib/range_ext.rb1
-rw-r--r--spec/lib/range_ext_spec.rb1
5 files changed, 5 insertions, 9 deletions
diff --git a/app/models/calendar.rb b/app/models/calendar.rb
index 4890540b9..cd945a67f 100644
--- a/app/models/calendar.rb
+++ b/app/models/calendar.rb
@@ -1,3 +1,4 @@
+require 'range_ext'
class Calendar < ActiveRecord::Base
belongs_to :organisation
has_many :time_tables
diff --git a/app/models/referential_metadata.rb b/app/models/referential_metadata.rb
index 3ec8398e0..357465c63 100644
--- a/app/models/referential_metadata.rb
+++ b/app/models/referential_metadata.rb
@@ -1,4 +1,5 @@
require 'activeattr_ext.rb'
+require 'range_ext'
class ReferentialMetadata < ActiveRecord::Base
belongs_to :referential, touch: true
@@ -160,11 +161,3 @@ class ReferentialMetadata < ActiveRecord::Base
end
end
end
-
-class Range
- def intersection(other)
- return nil if (self.max < other.begin or other.max < self.begin)
- [self.begin, other.begin].max..[self.max, other.max].min
- end
- alias_method :&, :intersection
-end
diff --git a/config/application.rb b/config/application.rb
index 06f931765..8606a3156 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -14,7 +14,7 @@ module ChouetteIhm
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
- config.autoload_paths += %W(#{config.root}/lib)
+ config.autoload_paths << config.root.join("lib")
# custom exception pages
config.exceptions_app = self.routes
diff --git a/lib/range_ext.rb b/lib/range_ext.rb
index 729cd1092..f1df5e70d 100644
--- a/lib/range_ext.rb
+++ b/lib/range_ext.rb
@@ -1,4 +1,5 @@
class Range
+
def intersection(other)
return nil if (self.max < other.min or other.max < self.min)
[self.min, other.min].max..[self.max, other.max].min
diff --git a/spec/lib/range_ext_spec.rb b/spec/lib/range_ext_spec.rb
index 0e2365b5e..9c44608b9 100644
--- a/spec/lib/range_ext_spec.rb
+++ b/spec/lib/range_ext_spec.rb
@@ -1,3 +1,4 @@
+require 'range_ext'
RSpec.describe Range do
context "intersection" do
it "is nil (sic) for two distinct ranges" do