Permalink
Browse files

Whitespace cleanup throught remaining code

  • Loading branch information...
1 parent a771178 commit 5674c694a4ad54c806669e82dc4ffd4565cf4013 @forrest forrest committed Oct 29, 2012
View
@@ -1,6 +1,6 @@
require 'rspec/core/rake_task'
require File.dirname(__FILE__) + '/lib/ice_cube/version'
-
+
task :build => :test do
system "gem build ice_cube.gemspec"
end
@@ -12,7 +12,7 @@ task :release => :build do
# push the gem
system "gem push ice_cube-#{IceCube::VERSION}.gem"
end
-
+
RSpec::Core::RakeTask.new(:test) do |t|
t.pattern = 'spec/**/*_spec.rb'
fail_on_error = true # be explicit
View
@@ -1,8 +1,8 @@
require File.dirname(__FILE__) + '/lib/ice_cube/version'
spec = Gem::Specification.new do |s|
-
- s.name = 'ice_cube'
+
+ s.name = 'ice_cube'
s.author = 'John Crepezzi'
s.add_development_dependency('rspec')
s.add_development_dependency('active_support', '>= 3.0.0')
@@ -1,7 +1,7 @@
module IceCube
class HashBuilder
-
+
def initialize(rule = nil)
@hash = { :validations => {}, :rule_type => rule.class.name }
end
@@ -41,8 +41,8 @@ def register_formatter(type, &formatter)
class << self
NUMBER_SUFFIX = ['th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th']
- SPECIAL_SUFFIX = { 11 => 'th', 12 => 'th', 13 => 'th', 14 => 'th' }
-
+ SPECIAL_SUFFIX = { 11 => 'th', 12 => 'th', 13 => 'th', 14 => 'th' }
+
# influenced by ActiveSupport's to_sentence
def sentence(array)
case array.length
@@ -63,12 +63,12 @@ def nice_number(number)
else
suffix = SPECIAL_SUFFIX.include?(number) ?
SPECIAL_SUFFIX[number] : NUMBER_SUFFIX[number.abs % 10]
- number.to_s << suffix
+ number.to_s << suffix
end
end
end
-
+
end
end
@@ -1,7 +1,7 @@
module IceCube
class SecondlyRule < ValidatedRule
-
+
include Validations::SecondlyInterval
def initialize(interval = 1)
View
@@ -314,7 +314,7 @@ def self.from_hash(original_hash, options = {})
schedule = IceCube::Schedule.new TimeUtil.deserialize_time(data[:start_date])
schedule.duration = data[:duration] if data[:duration]
schedule.end_time = TimeUtil.deserialize_time(data[:end_time]) if data[:end_time]
- data[:rrules] && data[:rrules].each { |h| schedule.rrule(IceCube::Rule.from_hash(h)) }
+ data[:rrules] && data[:rrules].each { |h| schedule.rrule(IceCube::Rule.from_hash(h)) }
data[:exrules] && data[:exrules].each { |h| schedule.exrule(IceCube::Rule.from_hash(h)) }
data[:rtimes] && data[:rtimes].each do |t|
schedule.add_recurrence_time TimeUtil.deserialize_time(t)
@@ -45,7 +45,7 @@ def build_ical(builder)
end
StringBuilder.register_formatter(:count) do |segments|
- count = segments.first
+ count = segments.first
"#{count} #{count == 1 ? 'time' : 'times'}"
end
@@ -3,7 +3,7 @@
module IceCube
module Validations::Day
-
+
def day(*days)
days.each do |day|
day = TimeUtil.symbol_to_day(day) if day.is_a?(Symbol)
@@ -42,7 +42,7 @@ def dst_adjust?
def validate(time, schedule)
start_time = schedule.start_time
- sec = (time.to_i - time.to_i % ONE_HOUR) -
+ sec = (time.to_i - time.to_i % ONE_HOUR) -
(start_time.to_i - start_time.to_i % ONE_HOUR)
hours = sec / ONE_HOUR
unless hours % interval == 0
@@ -23,11 +23,11 @@ def validate_day_lock(time, schedule)
# If this number is positive, then follow our normal procedure
if start > 0
return start >= time.day ? start - time.day : days_in_this_month - time.day + start
- end
+ end
# If the number is negative, and it resolved against the current month
# puts it in the future, just return the difference
days_in_this_month = TimeUtil.days_in_month(time)
- start_one = days_in_this_month + start + 1
+ start_one = days_in_this_month + start + 1
if start_one >= time.day
return start_one - time.day
end
@@ -45,7 +45,7 @@ def validate(time, schedule)
st = schedule.start_time
start_date = Date.new(st.year, st.month, st.day)
weeks = (
- (date - TimeUtil.normalize_weekday(date.wday, week_start)) -
+ (date - TimeUtil.normalize_weekday(date.wday, week_start)) -
(start_date - TimeUtil.normalize_weekday(start_date.wday, week_start))
) / 7
unless weeks % interval == 0
View
@@ -3,8 +3,8 @@
:rrules:
- :rule_type: IceCube::MinutelyRule
:interval: 60
- :until: !!null
- :count: !!null
+ :until: !!null
+ :count: !!null
:validations:
:day:
- 4
@@ -18,4 +18,4 @@
:rdates: []
:exdates: []
:duration: 3600
-:end_time: !!null
+:end_time: !!null
View
@@ -13,7 +13,7 @@
dates.each do |date|
date.utc?.should_not == true
date.hour.should == 5
- end
+ end
end
# DST in 2010 is November 7th at 2am
@@ -27,9 +27,9 @@
dates.each do |date|
date.utc?.should_not == true
date.hour.should == 5
- end
+ end
end
-
+
it 'cross a daylight savings time boundary with a recurrence rule in local time' do
start_date = Time.local(2010, 3, 14, 5, 0, 0)
schedule = IceCube::Schedule.new(start_date)
@@ -55,7 +55,7 @@
distance_in_hours += 2
end
end
-
+
it 'every 30 minutes over a daylight savings time boundary, checking interval' do
start_date = Time.local(2010, 11, 6, 23, 0, 0)
schedule = IceCube::Schedule.new(start_date)
@@ -68,7 +68,7 @@
distance_in_minutes += 30
end
end
-
+
it 'every 120 seconds over a daylight savings time boundary, checking interval' do
start_date = Time.local(2010, 11, 6, 23, 50, 0)
schedule = IceCube::Schedule.new(start_date)
@@ -81,7 +81,7 @@
distance_in_seconds += 120
end
end
-
+
it 'every other day over a daylight savings time boundary, checking hour/min/sec' do
start_date = Time.local(2010, 11, 6, 20, 0, 0)
schedule = IceCube::Schedule.new(start_date)
@@ -94,7 +94,7 @@
d.sec.should == start_date.sec
end
end
-
+
it 'every other month over a daylight savings time boundary, checking day/hour/min/sec' do
start_date = Time.local(2010, 11, 6, 20, 0, 0)
schedule = IceCube::Schedule.new(start_date)
@@ -108,7 +108,7 @@
d.sec.should == start_date.sec
end
end
-
+
it 'every other year over a daylight savings time boundary, checking day/hour/min/sec' do
start_date = Time.local(2010, 11, 6, 20, 0, 0)
schedule = IceCube::Schedule.new(start_date)
@@ -123,7 +123,7 @@
d.sec.should == start_date.sec
end
end
-
+
it 'LOCAL - has an until date on a rule that is over a DST from the start date' do
start_date = Time.local(2010, 3, 13, 5, 0, 0)
end_date = Time.local(2010, 3, 15, 5, 0, 0)
@@ -159,7 +159,7 @@
#make sure we end on the proper time
schedule.all_occurrences.last.should == end_date
end
-
+
it 'LOCAL - has an end date on a rule that is over a DST from the start date' do
start_date = Time.local(2010, 3, 13, 5, 0, 0)
end_date = Time.local(2010, 3, 15, 5, 0, 0)
@@ -262,5 +262,5 @@
schedule.add_recurrence_rule IceCube::Rule.yearly.month_of_year(:april).day_of_month(10)
schedule.first(3).should == [Time.local(2010, 4, 10, 12, 0, 0), Time.local(2011, 4, 10, 12, 0, 0), Time.local(2012, 4, 10, 12, 0, 0)]
end
-
+
end
@@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe IceCube::MonthlyRule, 'occurs_on?' do
-
+
it 'should produce the correct number of days for @interval = 1' do
start_date = DAY
schedule = IceCube::Schedule.new(start_date)
@@ -40,7 +40,7 @@
#check assumption (month 1 monday) (month 2 monday)
schedule.occurrences(start_date + 50 * IceCube::ONE_DAY).size.should == 2
end
-
+
it 'should produce the correct number of days for @interval = 1 with only the last mondays' do
start_date = Time.utc(2010, 1, 1)
schedule = IceCube::Schedule.new(start_date)
@@ -5,7 +5,7 @@
it 'should consider recurrence dates properly in find_occurreces - github issue 43' do
s = IceCube::Schedule.new(Time.local(2011,10,1, 18, 25))
s.add_recurrence_date(Time.local(2011,12,3,15,0,0))
- s.add_recurrence_date(Time.local(2011,12,3,10,0,0))
+ s.add_recurrence_date(Time.local(2011,12,3,10,0,0))
s.add_recurrence_date(Time.local(2011,12,4,10,0,0))
s.occurs_at?(Time.local(2011,12,3,15,0,0)).should be_true
end
@@ -179,7 +179,7 @@
it 'should return false if conflict is not present and single recurrence and time originally specified as DateTime' do
date = DateTime.new(2020,9,21,11,30,0)
- start_time = date.to_time
+ start_time = date.to_time
schedule1 = IceCube::Schedule.new(start_time, :duration => IceCube::ONE_HOUR)
schedule1.add_recurrence_time(start_time)
schedule2 = IceCube::Schedule.new(start_time + IceCube::ONE_HOUR, :duration => IceCube::ONE_HOUR)
@@ -274,7 +274,7 @@
describe :start_date= do
it 'should modify start date in rrule_occurrence_heads when changed' do
- schedule = Schedule.new (Time.now - 1000)
+ schedule = Schedule.new(Time.now - 1000)
schedule.rrule Rule.daily
schedule.start_date = (start_date = Time.now)
(Time.now - schedule.first).should be < 100
View
@@ -6,37 +6,37 @@
IceCube::Rule.secondly.to_s.should == 'Secondly'
IceCube::Rule.secondly(2).to_s.should == 'Every 2 seconds'
end
-
+
it 'should have a useful base to_s representation for a minutely rule' do
IceCube::Rule.minutely.to_s.should == 'Minutely'
IceCube::Rule.minutely(2).to_s.should == 'Every 2 minutes'
end
-
+
it 'should have a useful base to_s representation for a hourly rule' do
IceCube::Rule.hourly.to_s.should == 'Hourly'
IceCube::Rule.hourly(2).to_s.should == 'Every 2 hours'
end
-
+
it 'should have a useful base to_s representation for a daily rule' do
IceCube::Rule.daily.to_s.should == 'Daily'
IceCube::Rule.daily(2).to_s.should == 'Every 2 days'
end
-
+
it 'should have a useful base to_s representation for a weekly rule' do
IceCube::Rule.weekly.to_s.should == 'Weekly'
IceCube::Rule.weekly(2).to_s.should == 'Every 2 weeks'
end
-
+
it 'should have a useful base to_s representation for a monthly rule' do
IceCube::Rule.monthly.to_s.should == 'Monthly'
IceCube::Rule.monthly(2).to_s.should == 'Every 2 months'
end
-
+
it 'should have a useful base to_s representation for a yearly rule' do
IceCube::Rule.yearly.to_s.should == 'Yearly'
IceCube::Rule.yearly(2).to_s.should == 'Every 2 years'
end
-
+
it 'should work with various sentence types properly' do
IceCube::Rule.weekly.to_s.should == 'Weekly'
IceCube::Rule.weekly.day(:monday).to_s.should == 'Weekly on Mondays'
@@ -77,7 +77,7 @@
schedule.add_recurrence_date Time.local(2010, 3, 20)
schedule.to_s.should == "March 20, 2010"
end
-
+
it 'should work with additional dates' do
schedule = IceCube::Schedule.new Time.local(2010, 3, 20)
schedule.add_recurrence_date Time.local(2010, 3, 20)
@@ -98,7 +98,7 @@
schedule.add_recurrence_date Time.local(2010, 3, 20)
schedule.to_s.should == 'March 20, 2010'
end
-
+
it 'should work with rules and dates' do
schedule = IceCube::Schedule.new Time.local(2010, 3, 20)
schedule.add_recurrence_date Time.local(2010, 3, 20)
@@ -166,7 +166,7 @@
schedule.rrule IceCube::Rule.weekly.until(Time.local(2012, 2, 3))
schedule.to_s.should == 'Weekly until February 3, 2012'
end
-
+
it 'should be able to reflect count' do
schedule = IceCube::Schedule.new(Time.now)
schedule.add_recurrence_rule IceCube::Rule.weekly.count(1)
Oops, something went wrong.

0 comments on commit 5674c69

Please sign in to comment.