Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'origin/deprecated' into develop

  • Loading branch information...
commit d4611bfec8b3bd0581e3fbc62e962ed5fc971c8b 2 parents 5d135c8 + 0a7005c
@seejohnrun authored
View
1  lib/ice_cube.rb
@@ -1,4 +1,5 @@
require 'date'
+require 'ice_cube/deprecated'
# Use psych if we can
begin
View
28 lib/ice_cube/deprecated.rb
@@ -0,0 +1,28 @@
+module Deprecated
+
+ # Define a deprecated alias for a method
+ # @param [Symbol] name - name of method to define
+ # @param [Symbol] replacement - name of method to replace (alias)
+ def deprecated_alias(name, replacement)
+ # Create a wrapped version
+ define_method(name) do |*args, &block|
+ warn "IceCube: ##{name} deprecated (please use ##{replacement})"
+ send replacement, *args, &block
+ end
+ end
+
+ # Deprecate a defined method
+ # @param [Symbol] name - name of deprecated method
+ # @param [Symbol] replacement - name of the desired replacement
+ def deprecated(name, replacement)
+ # Replace old method
+ old_name = :"#{name}_without_deprecation"
+ alias_method old_name, name
+ # And replace it with a wrapped version
+ define_method(name) do |*args, &block|
+ warn "IceCube: ##{name} deprecated (please use ##{replacement})"
+ send old_name, *args, &block
+ end
+ end
+
+end
View
39 lib/ice_cube/schedule.rb
@@ -4,17 +4,20 @@ module IceCube
class Schedule
+ extend ::Deprecated
+
# Get the start time
attr_accessor :start_time
- alias :start_date :start_time
- alias :start_date= :start_time=
+ deprecated_alias :start_date, :start_time
+ deprecated_alias :start_date=, :start_time=
# Get the duration
attr_accessor :duration
# Get the end time
attr_accessor :end_time
- alias :end_date :end_time
+ deprecated_alias :end_date, :end_time
+ deprecated_alias :end_date=, :end_time=
# Create a new schedule
def initialize(start_time = nil, options = {})
@@ -32,8 +35,9 @@ def add_recurrence_time(time)
add_recurrence_rule rule
time
end
- alias :rdate :add_recurrence_time
- alias :add_recurrence_date :add_recurrence_time
+ alias :rtime :add_recurrence_time
+ deprecated_alias :rdate, :rtime
+ deprecated_alias :add_recurrence_date, :add_recurrence_time
# Add an exception time to the schedule
def add_exception_time(time)
@@ -42,8 +46,9 @@ def add_exception_time(time)
add_exception_rule rule
time
end
- alias :exdate :add_exception_time
- alias :add_exception_date :add_exception_time
+ alias :extime :add_exception_time
+ deprecated_alias :exdate, :extime
+ deprecated_alias :add_exception_date, :add_exception_time
# Add a recurrence rule to the schedule
def add_recurrence_rule(rule)
@@ -85,8 +90,9 @@ def exception_rules
def recurrence_times
@all_recurrence_rules.select { |r| r.is_a?(SingleOccurrenceRule) }.map(&:time)
end
- alias :rdates :recurrence_times
- alias :recurrence_dates :recurrence_times
+ alias :rtimes :recurrence_times
+ deprecated_alias :rdates, :rtimes
+ deprecated_alias :recurrence_dates, :recurrence_times
# Remove a recurrence time
def remove_recurrence_time(time)
@@ -96,15 +102,17 @@ def remove_recurrence_time(time)
end
time if found
end
- alias :remove_recurrence_date :remove_recurrence_time
- alias :remove_rdate :remove_recurrence_time
+ alias :remove_rtime :remove_recurrence_time
+ deprecated_alias :remove_recurrence_date, :remove_recurrence_time
+ deprecated_alias :remove_rdate, :remove_rtime
# Get the exception times that are on the schedule
def exception_times
@all_exception_rules.select { |r| r.is_a?(SingleOccurrenceRule) }.map(&:time)
end
- alias :exdates :exception_times
- alias :exception_dates :exception_times
+ alias :extimes :exception_times
+ deprecated_alias :exdates, :extimes
+ deprecated_alias :exception_dates, :exception_times
# Remove an exception time
def remove_exception_time(time)
@@ -114,8 +122,9 @@ def remove_exception_time(time)
end
time if found
end
- alias :remove_exception_date :remove_exception_time
- alias :remove_exdate :remove_exception_time
+ alias :remove_extime :remove_exception_time
+ deprecated_alias :remove_exception_date, :remove_exception_time
+ deprecated_alias :remove_exdate, :remove_extime
# Get all of the occurrences from the start_time up until a
# given Time
View
4 lib/ice_cube/validations/until.rb
@@ -2,11 +2,13 @@ module IceCube
module Validations::Until
+ extend ::Deprecated
+
# accessor
def until_time
@until
end
- alias :until_date :until_time
+ deprecated_alias :until_date, :until_time
def until(time)
@until = time
View
12 spec/spec_helper.rb
@@ -1,13 +1,11 @@
-require File.dirname(__FILE__) + '/../lib/ice_cube'
-
begin
- require 'cover_me'
- # https://github.com/markbates/cover_me/issues/50
- at_exit do
- CoverMe.complete!
- end
+ require 'simplecov'
+ SimpleCov.start
rescue LoadError
+ # okay
end
+require File.dirname(__FILE__) + '/../lib/ice_cube'
+
DAY = Time.utc(2010, 3, 1)
WEDNESDAY = Time.utc(2010, 6, 23, 5, 0, 0)
Please sign in to comment.
Something went wrong with that request. Please try again.