ice_cube 0.16.4 → 0.17.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 +4 -4
 - data/config/locales/id.yml +134 -0
 - data/lib/ice_cube/builders/hash_builder.rb +1 -5
 - data/lib/ice_cube/builders/ical_builder.rb +13 -15
 - data/lib/ice_cube/builders/string_builder.rb +10 -16
 - data/lib/ice_cube/deprecated.rb +3 -4
 - data/lib/ice_cube/errors/count_exceeded.rb +0 -2
 - data/lib/ice_cube/errors/until_exceeded.rb +0 -2
 - data/lib/ice_cube/flexible_hash.rb +3 -7
 - data/lib/ice_cube/i18n.rb +11 -19
 - data/lib/ice_cube/input_alignment.rb +9 -11
 - data/lib/ice_cube/null_i18n.rb +6 -6
 - data/lib/ice_cube/occurrence.rb +10 -11
 - data/lib/ice_cube/parsers/hash_parser.rb +3 -6
 - data/lib/ice_cube/parsers/ical_parser.rb +39 -38
 - data/lib/ice_cube/parsers/yaml_parser.rb +2 -4
 - data/lib/ice_cube/rule.rb +7 -18
 - data/lib/ice_cube/rules/daily_rule.rb +0 -4
 - data/lib/ice_cube/rules/hourly_rule.rb +0 -4
 - data/lib/ice_cube/rules/minutely_rule.rb +0 -4
 - data/lib/ice_cube/rules/monthly_rule.rb +0 -4
 - data/lib/ice_cube/rules/secondly_rule.rb +0 -4
 - data/lib/ice_cube/rules/weekly_rule.rb +1 -5
 - data/lib/ice_cube/rules/yearly_rule.rb +0 -4
 - data/lib/ice_cube/schedule.rb +32 -40
 - data/lib/ice_cube/single_occurrence_rule.rb +1 -5
 - data/lib/ice_cube/time_util.rb +49 -57
 - data/lib/ice_cube/validated_rule.rb +4 -10
 - data/lib/ice_cube/validations/count.rb +2 -8
 - data/lib/ice_cube/validations/daily_interval.rb +5 -11
 - data/lib/ice_cube/validations/day.rb +7 -13
 - data/lib/ice_cube/validations/day_of_month.rb +4 -10
 - data/lib/ice_cube/validations/day_of_week.rb +10 -13
 - data/lib/ice_cube/validations/day_of_year.rb +6 -12
 - data/lib/ice_cube/validations/fixed_value.rb +9 -15
 - data/lib/ice_cube/validations/hour_of_day.rb +5 -11
 - data/lib/ice_cube/validations/hourly_interval.rb +3 -9
 - data/lib/ice_cube/validations/lock.rb +8 -14
 - data/lib/ice_cube/validations/minute_of_hour.rb +4 -10
 - data/lib/ice_cube/validations/minutely_interval.rb +4 -10
 - data/lib/ice_cube/validations/month_of_year.rb +2 -8
 - data/lib/ice_cube/validations/monthly_interval.rb +4 -10
 - data/lib/ice_cube/validations/schedule_lock.rb +0 -6
 - data/lib/ice_cube/validations/second_of_minute.rb +4 -10
 - data/lib/ice_cube/validations/secondly_interval.rb +2 -8
 - data/lib/ice_cube/validations/until.rb +2 -8
 - data/lib/ice_cube/validations/weekly_interval.rb +5 -11
 - data/lib/ice_cube/validations/yearly_interval.rb +3 -9
 - data/lib/ice_cube/version.rb +1 -3
 - data/lib/ice_cube.rb +51 -51
 - metadata +23 -8
 - data/spec/spec_helper.rb +0 -79
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 114901036ec2c7e42928b961eddcf9f958f9a5f7ea4de4aadcf57e2f33220339
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: '093d42679272a92e0958662949822cf544f24e8fba39dfaa7c1361fa8da1e738'
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8cb959423e6a8d7ae6959b7f2a3fcc38c36e24aed7087037ece993a49fd215d90836c6d3f4ea683b42dc05094e79a5b66632dc8c4bc955a922bb8063dca1616e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: '0238da4a9c76cfbe63be01a61fbac7515bfd0a9bed34ff7fc3932fca0ad3b5a34222c38735baf343712abbc324542a64f7dbebaf76460e82faa970bb92713c15'
         
     | 
| 
         @@ -0,0 +1,134 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            id:
         
     | 
| 
      
 2 
     | 
    
         
            +
              ice_cube:
         
     | 
| 
      
 3 
     | 
    
         
            +
                pieces_connector: ' / '
         
     | 
| 
      
 4 
     | 
    
         
            +
                not: 'kecuali %{target}'
         
     | 
| 
      
 5 
     | 
    
         
            +
                not_on: 'kecuali %{target}'
         
     | 
| 
      
 6 
     | 
    
         
            +
                date:
         
     | 
| 
      
 7 
     | 
    
         
            +
                  formats:
         
     | 
| 
      
 8 
     | 
    
         
            +
                    default: '%e %B %Y'
         
     | 
| 
      
 9 
     | 
    
         
            +
                times:
         
     | 
| 
      
 10 
     | 
    
         
            +
                  other: '%{count} kali'
         
     | 
| 
      
 11 
     | 
    
         
            +
                  one: '%{count} kali'
         
     | 
| 
      
 12 
     | 
    
         
            +
                until: 'sampai %{date}'
         
     | 
| 
      
 13 
     | 
    
         
            +
                days_of_week: '%{segments} %{day}'
         
     | 
| 
      
 14 
     | 
    
         
            +
                days_of_month:
         
     | 
| 
      
 15 
     | 
    
         
            +
                  other: 'hari ke %{segments} dalam satu bulan'
         
     | 
| 
      
 16 
     | 
    
         
            +
                  one: 'hari ke %{segments} dalam satu bulan'
         
     | 
| 
      
 17 
     | 
    
         
            +
                days_of_year:
         
     | 
| 
      
 18 
     | 
    
         
            +
                  other: 'hari ke %{segments} dalam satu tahun'
         
     | 
| 
      
 19 
     | 
    
         
            +
                  one: 'hari ke %{segments} dalam satu tahun'
         
     | 
| 
      
 20 
     | 
    
         
            +
                at_hours_of_the_day:
         
     | 
| 
      
 21 
     | 
    
         
            +
                  other: pada jam %{segments} dalam satu hari
         
     | 
| 
      
 22 
     | 
    
         
            +
                  one: pada jam %{segments} dalam satu hari
         
     | 
| 
      
 23 
     | 
    
         
            +
                on_minutes_of_hour:
         
     | 
| 
      
 24 
     | 
    
         
            +
                  other: pada menit ke %{segments} dalam satu jam
         
     | 
| 
      
 25 
     | 
    
         
            +
                  one: pada menit ke %{segments} dalam satu jam
         
     | 
| 
      
 26 
     | 
    
         
            +
                at_seconds_of_minute:
         
     | 
| 
      
 27 
     | 
    
         
            +
                  other: pada %{segments} detik
         
     | 
| 
      
 28 
     | 
    
         
            +
                  one: pada %{segments} detik
         
     | 
| 
      
 29 
     | 
    
         
            +
                on_seconds_of_minute:
         
     | 
| 
      
 30 
     | 
    
         
            +
                  other: pada detik ke %{segments} dalam satu menit
         
     | 
| 
      
 31 
     | 
    
         
            +
                  one: pada detik ke %{segments} dalam satu menit
         
     | 
| 
      
 32 
     | 
    
         
            +
                each_second:
         
     | 
| 
      
 33 
     | 
    
         
            +
                  one: Setiap detik
         
     | 
| 
      
 34 
     | 
    
         
            +
                  other: Setiap %{count} detik
         
     | 
| 
      
 35 
     | 
    
         
            +
                each_minute:
         
     | 
| 
      
 36 
     | 
    
         
            +
                  one: Setiap menit
         
     | 
| 
      
 37 
     | 
    
         
            +
                  other: Setiap %{count} menit
         
     | 
| 
      
 38 
     | 
    
         
            +
                each_hour:
         
     | 
| 
      
 39 
     | 
    
         
            +
                  one: Setiap jam
         
     | 
| 
      
 40 
     | 
    
         
            +
                  other: Setiap %{count} jam
         
     | 
| 
      
 41 
     | 
    
         
            +
                each_day:
         
     | 
| 
      
 42 
     | 
    
         
            +
                  one: Setiap hari
         
     | 
| 
      
 43 
     | 
    
         
            +
                  other: Setiap %{count} hari
         
     | 
| 
      
 44 
     | 
    
         
            +
                each_week:
         
     | 
| 
      
 45 
     | 
    
         
            +
                  one: Setiap minggu
         
     | 
| 
      
 46 
     | 
    
         
            +
                  other: Setiap %{count} minggu
         
     | 
| 
      
 47 
     | 
    
         
            +
                each_month:
         
     | 
| 
      
 48 
     | 
    
         
            +
                  one: Setiap bulan
         
     | 
| 
      
 49 
     | 
    
         
            +
                  other: Setiap %{count} bulan
         
     | 
| 
      
 50 
     | 
    
         
            +
                each_year:
         
     | 
| 
      
 51 
     | 
    
         
            +
                  one: Setiap tahun
         
     | 
| 
      
 52 
     | 
    
         
            +
                  other: Setiap %{count} tahun
         
     | 
| 
      
 53 
     | 
    
         
            +
                'on': pada %{sentence}
         
     | 
| 
      
 54 
     | 
    
         
            +
                in: 'pada %{target}'
         
     | 
| 
      
 55 
     | 
    
         
            +
                integer:
         
     | 
| 
      
 56 
     | 
    
         
            +
                  negative: '%{ordinal} sampai akhir'
         
     | 
| 
      
 57 
     | 
    
         
            +
                  literal_ordinals:
         
     | 
| 
      
 58 
     | 
    
         
            +
                    1: pertama
         
     | 
| 
      
 59 
     | 
    
         
            +
                    -1: terakhir
         
     | 
| 
      
 60 
     | 
    
         
            +
                    -2: kedua sampai terakhir
         
     | 
| 
      
 61 
     | 
    
         
            +
                  ordinal: '%{number}%{ordinal}'
         
     | 
| 
      
 62 
     | 
    
         
            +
                  ordinals:
         
     | 
| 
      
 63 
     | 
    
         
            +
                    default: 
         
     | 
| 
      
 64 
     | 
    
         
            +
                on_weekends: pada akhir pekan
         
     | 
| 
      
 65 
     | 
    
         
            +
                on_weekdays: pada hari kerja
         
     | 
| 
      
 66 
     | 
    
         
            +
                days_on:
         
     | 
| 
      
 67 
     | 
    
         
            +
                - Hari minggu
         
     | 
| 
      
 68 
     | 
    
         
            +
                - Hari senin
         
     | 
| 
      
 69 
     | 
    
         
            +
                - Hari selasa
         
     | 
| 
      
 70 
     | 
    
         
            +
                - Hari rabu
         
     | 
| 
      
 71 
     | 
    
         
            +
                - Hari kamis
         
     | 
| 
      
 72 
     | 
    
         
            +
                - Hari jumat
         
     | 
| 
      
 73 
     | 
    
         
            +
                - Hari sabtu
         
     | 
| 
      
 74 
     | 
    
         
            +
                on_days: pada %{days}
         
     | 
| 
      
 75 
     | 
    
         
            +
                array:
         
     | 
| 
      
 76 
     | 
    
         
            +
                  last_word_connector: ' dan '
         
     | 
| 
      
 77 
     | 
    
         
            +
                  two_words_connector: ' dan '
         
     | 
| 
      
 78 
     | 
    
         
            +
                  words_connector: ', '
         
     | 
| 
      
 79 
     | 
    
         
            +
                string:
         
     | 
| 
      
 80 
     | 
    
         
            +
                  format:
         
     | 
| 
      
 81 
     | 
    
         
            +
                    day: '%{rest} %{current}'
         
     | 
| 
      
 82 
     | 
    
         
            +
                    day_of_week: '%{rest} %{current}'
         
     | 
| 
      
 83 
     | 
    
         
            +
                    day_of_month: '%{rest} %{current}'
         
     | 
| 
      
 84 
     | 
    
         
            +
                    day_of_year: '%{rest} %{current}'
         
     | 
| 
      
 85 
     | 
    
         
            +
                    hour_of_day: '%{rest} %{current}'
         
     | 
| 
      
 86 
     | 
    
         
            +
                    minute_of_hour: '%{rest} %{current}'
         
     | 
| 
      
 87 
     | 
    
         
            +
                    until: '%{rest} %{current}'
         
     | 
| 
      
 88 
     | 
    
         
            +
                    count: '%{rest} %{current}'
         
     | 
| 
      
 89 
     | 
    
         
            +
                    default: '%{rest} %{current}'
         
     | 
| 
      
 90 
     | 
    
         
            +
              date:
         
     | 
| 
      
 91 
     | 
    
         
            +
                abbr_day_names:
         
     | 
| 
      
 92 
     | 
    
         
            +
                - Min
         
     | 
| 
      
 93 
     | 
    
         
            +
                - Sen
         
     | 
| 
      
 94 
     | 
    
         
            +
                - Sel
         
     | 
| 
      
 95 
     | 
    
         
            +
                - Rab
         
     | 
| 
      
 96 
     | 
    
         
            +
                - Kam
         
     | 
| 
      
 97 
     | 
    
         
            +
                - Jum
         
     | 
| 
      
 98 
     | 
    
         
            +
                - Sab
         
     | 
| 
      
 99 
     | 
    
         
            +
                abbr_month_names:
         
     | 
| 
      
 100 
     | 
    
         
            +
                -
         
     | 
| 
      
 101 
     | 
    
         
            +
                - Jan
         
     | 
| 
      
 102 
     | 
    
         
            +
                - Feb
         
     | 
| 
      
 103 
     | 
    
         
            +
                - Mar
         
     | 
| 
      
 104 
     | 
    
         
            +
                - Apr
         
     | 
| 
      
 105 
     | 
    
         
            +
                - Mei
         
     | 
| 
      
 106 
     | 
    
         
            +
                - Jun
         
     | 
| 
      
 107 
     | 
    
         
            +
                - Jul
         
     | 
| 
      
 108 
     | 
    
         
            +
                - Agu
         
     | 
| 
      
 109 
     | 
    
         
            +
                - Sep
         
     | 
| 
      
 110 
     | 
    
         
            +
                - Okt
         
     | 
| 
      
 111 
     | 
    
         
            +
                - Nov
         
     | 
| 
      
 112 
     | 
    
         
            +
                - Des
         
     | 
| 
      
 113 
     | 
    
         
            +
                day_names:
         
     | 
| 
      
 114 
     | 
    
         
            +
                - Minggu
         
     | 
| 
      
 115 
     | 
    
         
            +
                - Senin
         
     | 
| 
      
 116 
     | 
    
         
            +
                - Selasa
         
     | 
| 
      
 117 
     | 
    
         
            +
                - Rabu
         
     | 
| 
      
 118 
     | 
    
         
            +
                - Kamis
         
     | 
| 
      
 119 
     | 
    
         
            +
                - Jumat
         
     | 
| 
      
 120 
     | 
    
         
            +
                - Sabtu
         
     | 
| 
      
 121 
     | 
    
         
            +
                month_names:
         
     | 
| 
      
 122 
     | 
    
         
            +
                -
         
     | 
| 
      
 123 
     | 
    
         
            +
                - Januari
         
     | 
| 
      
 124 
     | 
    
         
            +
                - Februari
         
     | 
| 
      
 125 
     | 
    
         
            +
                - Maret
         
     | 
| 
      
 126 
     | 
    
         
            +
                - April
         
     | 
| 
      
 127 
     | 
    
         
            +
                - Mei
         
     | 
| 
      
 128 
     | 
    
         
            +
                - Juni
         
     | 
| 
      
 129 
     | 
    
         
            +
                - Juli
         
     | 
| 
      
 130 
     | 
    
         
            +
                - Agustus
         
     | 
| 
      
 131 
     | 
    
         
            +
                - September
         
     | 
| 
      
 132 
     | 
    
         
            +
                - Oktober
         
     | 
| 
      
 133 
     | 
    
         
            +
                - November
         
     | 
| 
      
 134 
     | 
    
         
            +
                - Desember
         
     | 
| 
         @@ -1,9 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module IceCube
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
2 
     | 
    
         
             
              class HashBuilder
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
3 
     | 
    
         
             
                def initialize(rule = nil)
         
     | 
| 
       6 
     | 
    
         
            -
                  @hash = { 
     | 
| 
      
 4 
     | 
    
         
            +
                  @hash = {validations: {}, rule_type: rule.class.name}
         
     | 
| 
       7 
5 
     | 
    
         
             
                end
         
     | 
| 
       8 
6 
     | 
    
         | 
| 
       9 
7 
     | 
    
         
             
                def validations
         
     | 
| 
         @@ -21,7 +19,5 @@ module IceCube 
     | 
|
| 
       21 
19 
     | 
    
         
             
                def to_hash
         
     | 
| 
       22 
20 
     | 
    
         
             
                  @hash
         
     | 
| 
       23 
21 
     | 
    
         
             
                end
         
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
22 
     | 
    
         
             
              end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
23 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,8 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module IceCube
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
2 
     | 
    
         
             
              class IcalBuilder
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
                ICAL_DAYS = ['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA']
         
     | 
| 
      
 3 
     | 
    
         
            +
                ICAL_DAYS = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"]
         
     | 
| 
       6 
4 
     | 
    
         | 
| 
       7 
5 
     | 
    
         
             
                def initialize
         
     | 
| 
       8 
6 
     | 
    
         
             
                  @hash = {}
         
     | 
| 
         @@ -19,41 +17,41 @@ module IceCube 
     | 
|
| 
       19 
17 
     | 
    
         
             
                # Build for a single rule entry
         
     | 
| 
       20 
18 
     | 
    
         
             
                def to_s
         
     | 
| 
       21 
19 
     | 
    
         
             
                  arr = []
         
     | 
| 
       22 
     | 
    
         
            -
                  if freq = @hash.delete( 
     | 
| 
       23 
     | 
    
         
            -
                    arr << "FREQ=#{freq.join( 
     | 
| 
      
 20 
     | 
    
         
            +
                  if (freq = @hash.delete("FREQ"))
         
     | 
| 
      
 21 
     | 
    
         
            +
                    arr << "FREQ=#{freq.join(",")}"
         
     | 
| 
       24 
22 
     | 
    
         
             
                  end
         
     | 
| 
       25 
23 
     | 
    
         
             
                  arr.concat(@hash.map do |key, value|
         
     | 
| 
       26 
24 
     | 
    
         
             
                    if value.is_a?(Array)
         
     | 
| 
       27 
     | 
    
         
            -
                      "#{key}=#{value.join( 
     | 
| 
      
 25 
     | 
    
         
            +
                      "#{key}=#{value.join(",")}"
         
     | 
| 
       28 
26 
     | 
    
         
             
                    end
         
     | 
| 
       29 
27 
     | 
    
         
             
                  end.compact)
         
     | 
| 
       30 
     | 
    
         
            -
                  arr.join( 
     | 
| 
      
 28 
     | 
    
         
            +
                  arr.join(";")
         
     | 
| 
       31 
29 
     | 
    
         
             
                end
         
     | 
| 
       32 
30 
     | 
    
         | 
| 
       33 
31 
     | 
    
         
             
                def self.ical_utc_format(time)
         
     | 
| 
       34 
32 
     | 
    
         
             
                  time = time.dup.utc
         
     | 
| 
       35 
     | 
    
         
            -
                  IceCube::I18n.l(time, format:  
     | 
| 
      
 33 
     | 
    
         
            +
                  IceCube::I18n.l(time, format: "%Y%m%dT%H%M%SZ") # utc time
         
     | 
| 
       36 
34 
     | 
    
         
             
                end
         
     | 
| 
       37 
35 
     | 
    
         | 
| 
       38 
36 
     | 
    
         
             
                def self.ical_format(time, force_utc)
         
     | 
| 
       39 
37 
     | 
    
         
             
                  time = time.dup.utc if force_utc
         
     | 
| 
       40 
38 
     | 
    
         
             
                  if time.utc?
         
     | 
| 
       41 
     | 
    
         
            -
                    ":#{IceCube::I18n.l(time, format:  
     | 
| 
      
 39 
     | 
    
         
            +
                    ":#{IceCube::I18n.l(time, format: "%Y%m%dT%H%M%SZ")}" # utc time
         
     | 
| 
       42 
40 
     | 
    
         
             
                  else
         
     | 
| 
       43 
     | 
    
         
            -
                    ";TZID=#{IceCube::I18n.l(time, format:  
     | 
| 
      
 41 
     | 
    
         
            +
                    ";TZID=#{IceCube::I18n.l(time, format: "%Z:%Y%m%dT%H%M%S")}" # local time specified
         
     | 
| 
       44 
42 
     | 
    
         
             
                  end
         
     | 
| 
       45 
43 
     | 
    
         
             
                end
         
     | 
| 
       46 
44 
     | 
    
         | 
| 
       47 
45 
     | 
    
         
             
                def self.ical_duration(duration)
         
     | 
| 
       48 
     | 
    
         
            -
                  hours = duration / 3600 
     | 
| 
       49 
     | 
    
         
            -
                   
     | 
| 
       50 
     | 
    
         
            -
                   
     | 
| 
      
 46 
     | 
    
         
            +
                  hours = duration / 3600
         
     | 
| 
      
 47 
     | 
    
         
            +
                  duration %= 3600
         
     | 
| 
      
 48 
     | 
    
         
            +
                  minutes = duration / 60
         
     | 
| 
      
 49 
     | 
    
         
            +
                  duration %= 60
         
     | 
| 
      
 50 
     | 
    
         
            +
                  repr = ""
         
     | 
| 
       51 
51 
     | 
    
         
             
                  repr << "#{hours}H" if hours > 0
         
     | 
| 
       52 
52 
     | 
    
         
             
                  repr << "#{minutes}M" if minutes > 0
         
     | 
| 
       53 
53 
     | 
    
         
             
                  repr << "#{duration}S" if duration > 0
         
     | 
| 
       54 
54 
     | 
    
         
             
                  "PT#{repr}"
         
     | 
| 
       55 
55 
     | 
    
         
             
                end
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
56 
     | 
    
         
             
              end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
57 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,7 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module IceCube
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
2 
     | 
    
         
             
              class StringBuilder
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
3 
     | 
    
         
             
                attr_writer :base
         
     | 
| 
       6 
4 
     | 
    
         | 
| 
       7 
5 
     | 
    
         
             
                def initialize
         
     | 
| 
         @@ -13,15 +11,15 @@ module IceCube 
     | 
|
| 
       13 
11 
     | 
    
         
             
                end
         
     | 
| 
       14 
12 
     | 
    
         | 
| 
       15 
13 
     | 
    
         
             
                def to_s
         
     | 
| 
       16 
     | 
    
         
            -
                  string = @base ||  
     | 
| 
      
 14 
     | 
    
         
            +
                  string = @base || ""
         
     | 
| 
       17 
15 
     | 
    
         
             
                  @types.each do |type, segments|
         
     | 
| 
       18 
     | 
    
         
            -
                    if f = self.class.formatter(type)
         
     | 
| 
      
 16 
     | 
    
         
            +
                    if (f = self.class.formatter(type))
         
     | 
| 
       19 
17 
     | 
    
         
             
                      current = f.call(segments)
         
     | 
| 
       20 
18 
     | 
    
         
             
                    else
         
     | 
| 
       21 
19 
     | 
    
         
             
                      next if segments.empty?
         
     | 
| 
       22 
20 
     | 
    
         
             
                      current = self.class.sentence(segments)
         
     | 
| 
       23 
21 
     | 
    
         
             
                    end
         
     | 
| 
       24 
     | 
    
         
            -
                    f = IceCube::I18n.t( 
     | 
| 
      
 22 
     | 
    
         
            +
                    f = IceCube::I18n.t("ice_cube.string.format")[type] ? type : "default"
         
     | 
| 
       25 
23 
     | 
    
         
             
                    string = IceCube::I18n.t("ice_cube.string.format.#{f}", rest: string, current: current)
         
     | 
| 
       26 
24 
     | 
    
         
             
                  end
         
     | 
| 
       27 
25 
     | 
    
         
             
                  string
         
     | 
| 
         @@ -37,14 +35,13 @@ module IceCube 
     | 
|
| 
       37 
35 
     | 
    
         
             
                end
         
     | 
| 
       38 
36 
     | 
    
         | 
| 
       39 
37 
     | 
    
         
             
                module Helpers
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
38 
     | 
    
         
             
                  # influenced by ActiveSupport's to_sentence
         
     | 
| 
       42 
39 
     | 
    
         
             
                  def sentence(array)
         
     | 
| 
       43 
40 
     | 
    
         
             
                    case array.length
         
     | 
| 
       44 
     | 
    
         
            -
                    when 0  
     | 
| 
       45 
     | 
    
         
            -
                    when 1  
     | 
| 
       46 
     | 
    
         
            -
                    when 2  
     | 
| 
       47 
     | 
    
         
            -
                    else 
     | 
| 
      
 41 
     | 
    
         
            +
                    when 0 then ""
         
     | 
| 
      
 42 
     | 
    
         
            +
                    when 1 then array[0].to_s
         
     | 
| 
      
 43 
     | 
    
         
            +
                    when 2 then "#{array[0]}#{IceCube::I18n.t("ice_cube.array.two_words_connector")}#{array[1]}"
         
     | 
| 
      
 44 
     | 
    
         
            +
                    else; "#{array[0...-1].join(IceCube::I18n.t("ice_cube.array.words_connector"))}#{IceCube::I18n.t("ice_cube.array.last_word_connector")}#{array[-1]}"
         
     | 
| 
       48 
45 
     | 
    
         
             
                    end
         
     | 
| 
       49 
46 
     | 
    
         
             
                  end
         
     | 
| 
       50 
47 
     | 
    
         | 
| 
         @@ -53,7 +50,7 @@ module IceCube 
     | 
|
| 
       53 
50 
     | 
    
         
             
                  end
         
     | 
| 
       54 
51 
     | 
    
         | 
| 
       55 
52 
     | 
    
         
             
                  def ordinalize(number)
         
     | 
| 
       56 
     | 
    
         
            -
                    IceCube::I18n.t( 
     | 
| 
      
 53 
     | 
    
         
            +
                    IceCube::I18n.t("ice_cube.integer.ordinal", number: number, ordinal: ordinal(number))
         
     | 
| 
       57 
54 
     | 
    
         
             
                  end
         
     | 
| 
       58 
55 
     | 
    
         | 
| 
       59 
56 
     | 
    
         
             
                  def literal_ordinal(number)
         
     | 
| 
         @@ -63,14 +60,11 @@ module IceCube 
     | 
|
| 
       63 
60 
     | 
    
         
             
                  def ordinal(number)
         
     | 
| 
       64 
61 
     | 
    
         
             
                    ord = IceCube::I18n.t("ice_cube.integer.ordinals")[number] ||
         
     | 
| 
       65 
62 
     | 
    
         
             
                      IceCube::I18n.t("ice_cube.integer.ordinals")[number % 10] ||
         
     | 
| 
       66 
     | 
    
         
            -
                      IceCube::I18n.t( 
     | 
| 
       67 
     | 
    
         
            -
                    number >= 0 ? ord : IceCube::I18n.t("ice_cube.integer.negative", ordinal: ord)
         
     | 
| 
      
 63 
     | 
    
         
            +
                      IceCube::I18n.t("ice_cube.integer.ordinals")[:default]
         
     | 
| 
      
 64 
     | 
    
         
            +
                    (number >= 0) ? ord : IceCube::I18n.t("ice_cube.integer.negative", ordinal: ord)
         
     | 
| 
       68 
65 
     | 
    
         
             
                  end
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
66 
     | 
    
         
             
                end
         
     | 
| 
       71 
67 
     | 
    
         | 
| 
       72 
68 
     | 
    
         
             
                extend Helpers
         
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
69 
     | 
    
         
             
              end
         
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
70 
     | 
    
         
             
            end
         
     | 
    
        data/lib/ice_cube/deprecated.rb
    CHANGED
    
    | 
         @@ -1,13 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module IceCube
         
     | 
| 
       2 
2 
     | 
    
         
             
              module Deprecated
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
3 
     | 
    
         
             
                # Define a deprecated alias for a method
         
     | 
| 
       5 
4 
     | 
    
         
             
                # @param [Symbol] name - name of method to define
         
     | 
| 
       6 
5 
     | 
    
         
             
                # @param [Symbol] replacement - name of method to replace (alias)
         
     | 
| 
       7 
6 
     | 
    
         
             
                def deprecated_alias(name, replacement)
         
     | 
| 
       8 
7 
     | 
    
         
             
                  # Create a wrapped version
         
     | 
| 
       9 
8 
     | 
    
         
             
                  define_method(name) do |*args, &block|
         
     | 
| 
       10 
     | 
    
         
            -
                    warn "IceCube: #{self.class}##{name} is deprecated (use #{replacement})", caller 
     | 
| 
      
 9 
     | 
    
         
            +
                    warn "IceCube: #{self.class}##{name} is deprecated (use #{replacement})", caller(1..1).first
         
     | 
| 
       11 
10 
     | 
    
         
             
                    send replacement, *args, &block
         
     | 
| 
       12 
11 
     | 
    
         
             
                  end
         
     | 
| 
       13 
12 
     | 
    
         
             
                end
         
     | 
| 
         @@ -21,7 +20,7 @@ module IceCube 
     | 
|
| 
       21 
20 
     | 
    
         
             
                  alias_method old_name, name
         
     | 
| 
       22 
21 
     | 
    
         
             
                  # And replace it with a wrapped version
         
     | 
| 
       23 
22 
     | 
    
         
             
                  define_method(name) do |*args, &block|
         
     | 
| 
       24 
     | 
    
         
            -
                    warn "IceCube: #{self.class}##{name} is deprecated (use #{replacement})", caller 
     | 
| 
      
 23 
     | 
    
         
            +
                    warn "IceCube: #{self.class}##{name} is deprecated (use #{replacement})", caller(1..1).first
         
     | 
| 
       25 
24 
     | 
    
         
             
                    send old_name, *args, &block
         
     | 
| 
       26 
25 
     | 
    
         
             
                  end
         
     | 
| 
       27 
26 
     | 
    
         
             
                end
         
     | 
| 
         @@ -29,7 +28,7 @@ module IceCube 
     | 
|
| 
       29 
28 
     | 
    
         
             
                def self.schedule_options(schedule, options)
         
     | 
| 
       30 
29 
     | 
    
         
             
                  if options[:start_date_override]
         
     | 
| 
       31 
30 
     | 
    
         
             
                    warn "IceCube: :start_date_override option is deprecated " \
         
     | 
| 
       32 
     | 
    
         
            -
                         "(use a block: `{|s| s.start_time = override }`)", caller 
     | 
| 
      
 31 
     | 
    
         
            +
                         "(use a block: `{|s| s.start_time = override }`)", caller(1..1).first
         
     | 
| 
       33 
32 
     | 
    
         
             
                    schedule.start_time = options[:start_date_override]
         
     | 
| 
       34 
33 
     | 
    
         
             
                  end
         
     | 
| 
       35 
34 
     | 
    
         
             
                end
         
     | 
| 
         @@ -1,13 +1,11 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require "delegate"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module IceCube
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
4 
     | 
    
         
             
              # Find keys by symbol or string without symbolizing user input
         
     | 
| 
       6 
5 
     | 
    
         
             
              # Due to the serialization format of ice_cube, this limited implementation
         
     | 
| 
       7 
6 
     | 
    
         
             
              # is entirely sufficient
         
     | 
| 
       8 
7 
     | 
    
         | 
| 
       9 
8 
     | 
    
         
             
              class FlexibleHash < SimpleDelegator
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
9 
     | 
    
         
             
                def [](key)
         
     | 
| 
       12 
10 
     | 
    
         
             
                  key = _match_key(key)
         
     | 
| 
       13 
11 
     | 
    
         
             
                  super
         
     | 
| 
         @@ -27,14 +25,12 @@ module IceCube 
     | 
|
| 
       27 
25 
     | 
    
         | 
| 
       28 
26 
     | 
    
         
             
                def _match_key(key)
         
     | 
| 
       29 
27 
     | 
    
         
             
                  return key if __getobj__.has_key? key
         
     | 
| 
       30 
     | 
    
         
            -
                  if  
     | 
| 
      
 28 
     | 
    
         
            +
                  if key.instance_of?(Symbol)
         
     | 
| 
       31 
29 
     | 
    
         
             
                    __getobj__.keys.detect { |k| return k if k == key.to_s }
         
     | 
| 
       32 
     | 
    
         
            -
                  elsif  
     | 
| 
      
 30 
     | 
    
         
            +
                  elsif key.instance_of?(String)
         
     | 
| 
       33 
31 
     | 
    
         
             
                    __getobj__.keys.detect { |k| return k if k.to_s == key }
         
     | 
| 
       34 
32 
     | 
    
         
             
                  end
         
     | 
| 
       35 
33 
     | 
    
         
             
                  key
         
     | 
| 
       36 
34 
     | 
    
         
             
                end
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
35 
     | 
    
         
             
              end
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
36 
     | 
    
         
             
            end
         
     | 
    
        data/lib/ice_cube/i18n.rb
    CHANGED
    
    | 
         @@ -1,23 +1,15 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require "ice_cube/null_i18n"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module IceCube
         
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
                 
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
                 
     | 
| 
       13 
     | 
    
         
            -
                  @backend ||= detect_backend!
         
     | 
| 
       14 
     | 
    
         
            -
                end
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                def self.detect_backend!
         
     | 
| 
       17 
     | 
    
         
            -
                  ::I18n.load_path += Dir[File.join(LOCALES_PATH, '*.yml')]
         
     | 
| 
       18 
     | 
    
         
            -
                  ::I18n
         
     | 
| 
       19 
     | 
    
         
            -
                rescue NameError
         
     | 
| 
       20 
     | 
    
         
            -
                  NullI18n
         
     | 
| 
       21 
     | 
    
         
            -
                end
         
     | 
| 
      
 4 
     | 
    
         
            +
              LOCALES_PATH = File.expand_path(File.join("..", "..", "config", "locales"), __dir__)
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              # rubocop:disable Naming/ConstantName
         
     | 
| 
      
 7 
     | 
    
         
            +
              I18n = begin
         
     | 
| 
      
 8 
     | 
    
         
            +
                require "i18n"
         
     | 
| 
      
 9 
     | 
    
         
            +
                ::I18n.load_path += Dir[File.join(LOCALES_PATH, "*.yml")]
         
     | 
| 
      
 10 
     | 
    
         
            +
                ::I18n
         
     | 
| 
      
 11 
     | 
    
         
            +
              rescue LoadError
         
     | 
| 
      
 12 
     | 
    
         
            +
                NullI18n
         
     | 
| 
       22 
13 
     | 
    
         
             
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
              # rubocop:enable Naming/ConstantName
         
     | 
| 
       23 
15 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,6 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module IceCube
         
     | 
| 
       2 
2 
     | 
    
         
             
              class InputAlignment
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
3 
     | 
    
         
             
                def initialize(rule, value, rule_part)
         
     | 
| 
       5 
4 
     | 
    
         
             
                  @rule = rule
         
     | 
| 
       6 
5 
     | 
    
         
             
                  @value = value
         
     | 
| 
         @@ -9,16 +8,16 @@ module IceCube 
     | 
|
| 
       9 
8 
     | 
    
         | 
| 
       10 
9 
     | 
    
         
             
                attr_reader :rule, :value, :rule_part
         
     | 
| 
       11 
10 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
                def verify(freq, options={}, & 
     | 
| 
      
 11 
     | 
    
         
            +
                def verify(freq, options = {}, &)
         
     | 
| 
       13 
12 
     | 
    
         
             
                  @rule.validations[:interval] or return
         
     | 
| 
       14 
13 
     | 
    
         | 
| 
       15 
14 
     | 
    
         
             
                  case @rule
         
     | 
| 
       16 
15 
     | 
    
         
             
                  when DailyRule
         
     | 
| 
       17 
     | 
    
         
            -
                    verify_wday_alignment(freq, & 
     | 
| 
      
 16 
     | 
    
         
            +
                    verify_wday_alignment(freq, &)
         
     | 
| 
       18 
17 
     | 
    
         
             
                  when MonthlyRule
         
     | 
| 
       19 
     | 
    
         
            -
                    verify_month_alignment(freq, & 
     | 
| 
      
 18 
     | 
    
         
            +
                    verify_month_alignment(freq, &)
         
     | 
| 
       20 
19 
     | 
    
         
             
                  else
         
     | 
| 
       21 
     | 
    
         
            -
                    verify_freq_alignment(freq, & 
     | 
| 
      
 20 
     | 
    
         
            +
                    verify_freq_alignment(freq, &)
         
     | 
| 
       22 
21 
     | 
    
         
             
                  end
         
     | 
| 
       23 
22 
     | 
    
         
             
                end
         
     | 
| 
       24 
23 
     | 
    
         | 
| 
         @@ -34,7 +33,7 @@ module IceCube 
     | 
|
| 
       34 
33 
     | 
    
         | 
| 
       35 
34 
     | 
    
         
             
                def fixed_validations
         
     | 
| 
       36 
35 
     | 
    
         
             
                  @fixed_validations ||= @rule.validations.values.flatten.select { |v|
         
     | 
| 
       37 
     | 
    
         
            -
                    interval_type = (v.type == :wday ? :day : v.type)
         
     | 
| 
      
 36 
     | 
    
         
            +
                    interval_type = ((v.type == :wday) ? :day : v.type)
         
     | 
| 
       38 
37 
     | 
    
         
             
                    v.class < Validations::FixedValue &&
         
     | 
| 
       39 
38 
     | 
    
         
             
                      interval_type == rule.base_interval_validation.type
         
     | 
| 
       40 
39 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -47,13 +46,13 @@ module IceCube 
     | 
|
| 
       47 
46 
     | 
    
         
             
                  alignment = (value - last_validation.value) % interval_validation.interval
         
     | 
| 
       48 
47 
     | 
    
         
             
                  return if alignment.zero?
         
     | 
| 
       49 
48 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
                  validation_values = fixed_validations.map(&:value).join( 
     | 
| 
       51 
     | 
    
         
            -
                  if rule_part == :interval
         
     | 
| 
       52 
     | 
    
         
            -
                     
     | 
| 
      
 49 
     | 
    
         
            +
                  validation_values = fixed_validations.map(&:value).join(", ")
         
     | 
| 
      
 50 
     | 
    
         
            +
                  message = if rule_part == :interval
         
     | 
| 
      
 51 
     | 
    
         
            +
                    "interval(#{value}) " \
         
     | 
| 
       53 
52 
     | 
    
         
             
                              "must be a multiple of " \
         
     | 
| 
       54 
53 
     | 
    
         
             
                              "intervals in #{last_validation.key}(#{validation_values})"
         
     | 
| 
       55 
54 
     | 
    
         
             
                  else
         
     | 
| 
       56 
     | 
    
         
            -
                     
     | 
| 
      
 55 
     | 
    
         
            +
                    "intervals in #{last_validation.key}(#{validation_values}, #{value}) " \
         
     | 
| 
       57 
56 
     | 
    
         
             
                              "must be multiples of " \
         
     | 
| 
       58 
57 
     | 
    
         
             
                              "interval(#{interval_validation.interval})"
         
     | 
| 
       59 
58 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -84,6 +83,5 @@ module IceCube 
     | 
|
| 
       84 
83 
     | 
    
         | 
| 
       85 
84 
     | 
    
         
             
                  yield ArgumentError.new(message)
         
     | 
| 
       86 
85 
     | 
    
         
             
                end
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
86 
     | 
    
         
             
              end
         
     | 
| 
       89 
87 
     | 
    
         
             
            end
         
     | 
    
        data/lib/ice_cube/null_i18n.rb
    CHANGED
    
    | 
         @@ -1,11 +1,11 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require "yaml"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module IceCube
         
     | 
| 
       4 
4 
     | 
    
         
             
              module NullI18n
         
     | 
| 
       5 
5 
     | 
    
         
             
                def self.t(key, options = {})
         
     | 
| 
       6 
     | 
    
         
            -
                  base = key.to_s.split( 
     | 
| 
      
 6 
     | 
    
         
            +
                  base = key.to_s.split(".").reduce(config) { |hash, current_key| hash[current_key] }
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
                  base = base[options[:count] == 1 ? "one" : "other"] if options[:count]
         
     | 
| 
      
 8 
     | 
    
         
            +
                  base = base[(options[:count] == 1) ? "one" : "other"] if options[:count]
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                  case base
         
     | 
| 
       11 
11 
     | 
    
         
             
                  when Hash
         
     | 
| 
         @@ -17,18 +17,18 @@ module IceCube 
     | 
|
| 
       17 
17 
     | 
    
         
             
                      hash[k] = v
         
     | 
| 
       18 
18 
     | 
    
         
             
                    end
         
     | 
| 
       19 
19 
     | 
    
         
             
                  else
         
     | 
| 
       20 
     | 
    
         
            -
                    return base unless base.include?( 
     | 
| 
      
 20 
     | 
    
         
            +
                    return base unless base.include?("%{")
         
     | 
| 
       21 
21 
     | 
    
         
             
                    base % options
         
     | 
| 
       22 
22 
     | 
    
         
             
                  end
         
     | 
| 
       23 
23 
     | 
    
         
             
                end
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                def self.l(date_or_time, options = {})
         
     | 
| 
       26 
26 
     | 
    
         
             
                  return date_or_time.strftime(options[:format]) if options[:format]
         
     | 
| 
       27 
     | 
    
         
            -
                  date_or_time.strftime(t( 
     | 
| 
      
 27 
     | 
    
         
            +
                  date_or_time.strftime(t("ice_cube.date.formats.default"))
         
     | 
| 
       28 
28 
     | 
    
         
             
                end
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
                def self.config
         
     | 
| 
       31 
     | 
    
         
            -
                  @config ||= YAML.load_file(File.join(IceCube::I18n::LOCALES_PATH,  
     | 
| 
      
 31 
     | 
    
         
            +
                  @config ||= YAML.load_file(File.join(IceCube::I18n::LOCALES_PATH, "en.yml"))["en"]
         
     | 
| 
       32 
32 
     | 
    
         
             
                end
         
     | 
| 
       33 
33 
     | 
    
         
             
              end
         
     | 
| 
       34 
34 
     | 
    
         
             
            end
         
     | 
    
        data/lib/ice_cube/occurrence.rb
    CHANGED
    
    | 
         @@ -1,7 +1,6 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            require "delegate"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module IceCube
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
4 
     | 
    
         
             
              # Wraps start_time and end_time in a single concept concerning the duration.
         
     | 
| 
       6 
5 
     | 
    
         
             
              # This delegates to the enclosed start_time so it behaves like a normal Time
         
     | 
| 
       7 
6 
     | 
    
         
             
              # in almost all situations, however:
         
     | 
| 
         @@ -23,14 +22,14 @@ module IceCube 
     | 
|
| 
       23 
22 
     | 
    
         | 
| 
       24 
23 
     | 
    
         
             
                # Report class name as 'Time' to thwart type checking.
         
     | 
| 
       25 
24 
     | 
    
         
             
                def self.name
         
     | 
| 
       26 
     | 
    
         
            -
                   
     | 
| 
      
 25 
     | 
    
         
            +
                  "Time"
         
     | 
| 
       27 
26 
     | 
    
         
             
                end
         
     | 
| 
       28 
27 
     | 
    
         | 
| 
       29 
28 
     | 
    
         
             
                attr_reader :start_time, :end_time
         
     | 
| 
       30 
     | 
    
         
            -
                 
     | 
| 
       31 
     | 
    
         
            -
                 
     | 
| 
      
 29 
     | 
    
         
            +
                alias_method :first, :start_time
         
     | 
| 
      
 30 
     | 
    
         
            +
                alias_method :last, :end_time
         
     | 
| 
       32 
31 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                def initialize(start_time, end_time=nil)
         
     | 
| 
      
 32 
     | 
    
         
            +
                def initialize(start_time, end_time = nil)
         
     | 
| 
       34 
33 
     | 
    
         
             
                  @start_time = start_time
         
     | 
| 
       35 
34 
     | 
    
         
             
                  @end_time = end_time || start_time
         
     | 
| 
       36 
35 
     | 
    
         
             
                  __setobj__ @start_time
         
     | 
| 
         @@ -52,10 +51,10 @@ module IceCube 
     | 
|
| 
       52 
51 
     | 
    
         
             
                def intersects?(other)
         
     | 
| 
       53 
52 
     | 
    
         
             
                  return cover?(other) unless other.is_a?(Occurrence) || other.is_a?(Range)
         
     | 
| 
       54 
53 
     | 
    
         | 
| 
       55 
     | 
    
         
            -
                  this_start 
     | 
| 
       56 
     | 
    
         
            -
                  this_end 
     | 
| 
      
 54 
     | 
    
         
            +
                  this_start = first + 1
         
     | 
| 
      
 55 
     | 
    
         
            +
                  this_end = last # exclude end boundary
         
     | 
| 
       57 
56 
     | 
    
         
             
                  other_start = other.first + 1
         
     | 
| 
       58 
     | 
    
         
            -
                  other_end 
     | 
| 
      
 57 
     | 
    
         
            +
                  other_end = other.last + 1
         
     | 
| 
       59 
58 
     | 
    
         | 
| 
       60 
59 
     | 
    
         
             
                  !(this_end < other_start || this_start > other_end)
         
     | 
| 
       61 
60 
     | 
    
         
             
                end
         
     | 
| 
         @@ -85,13 +84,13 @@ module IceCube 
     | 
|
| 
       85 
84 
     | 
    
         
             
                # Optional format argument (e.g. :long, :short) supports Rails
         
     | 
| 
       86 
85 
     | 
    
         
             
                # time formats and is only used when ActiveSupport is available.
         
     | 
| 
       87 
86 
     | 
    
         
             
                #
         
     | 
| 
       88 
     | 
    
         
            -
                def to_s(format=nil)
         
     | 
| 
      
 87 
     | 
    
         
            +
                def to_s(format = nil)
         
     | 
| 
       89 
88 
     | 
    
         
             
                  if format && to_time.public_method(:to_s).arity != 0
         
     | 
| 
       90 
89 
     | 
    
         
             
                    t0, t1 = start_time.to_s(format), end_time.to_s(format)
         
     | 
| 
       91 
90 
     | 
    
         
             
                  else
         
     | 
| 
       92 
91 
     | 
    
         
             
                    t0, t1 = start_time.to_s, end_time.to_s
         
     | 
| 
       93 
92 
     | 
    
         
             
                  end
         
     | 
| 
       94 
     | 
    
         
            -
                  duration > 0 ? "#{t0} - #{t1}" : t0
         
     | 
| 
      
 93 
     | 
    
         
            +
                  (duration > 0) ? "#{t0} - #{t1}" : t0
         
     | 
| 
       95 
94 
     | 
    
         
             
                end
         
     | 
| 
       96 
95 
     | 
    
         | 
| 
       97 
96 
     | 
    
         
             
                def overnight?
         
     | 
| 
         @@ -1,6 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module IceCube
         
     | 
| 
       2 
2 
     | 
    
         
             
              class HashParser
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
3 
     | 
    
         
             
                attr_reader :hash
         
     | 
| 
       5 
4 
     | 
    
         | 
| 
       6 
5 
     | 
    
         
             
                def initialize(original_hash)
         
     | 
| 
         @@ -26,13 +25,13 @@ module IceCube 
     | 
|
| 
       26 
25 
     | 
    
         
             
                  data = IceCube::FlexibleHash.new(hash.dup)
         
     | 
| 
       27 
26 
     | 
    
         | 
| 
       28 
27 
     | 
    
         
             
                  if (start_date = data.delete(:start_date))
         
     | 
| 
       29 
     | 
    
         
            -
                    warn "IceCube: :start_date is deprecated, please use :start_time at: #{ 
     | 
| 
      
 28 
     | 
    
         
            +
                    warn "IceCube: :start_date is deprecated, please use :start_time at: #{caller(1..1).first}"
         
     | 
| 
       30 
29 
     | 
    
         
             
                    data[:start_time] = start_date
         
     | 
| 
       31 
30 
     | 
    
         
             
                  end
         
     | 
| 
       32 
31 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                  {: 
     | 
| 
      
 32 
     | 
    
         
            +
                  {rdates: :rtimes, exdates: :extimes}.each do |old_key, new_key|
         
     | 
| 
       34 
33 
     | 
    
         
             
                    if (times = data.delete(old_key))
         
     | 
| 
       35 
     | 
    
         
            -
                      warn "IceCube: :#{old_key} is deprecated, please use :#{new_key} at: #{ 
     | 
| 
      
 34 
     | 
    
         
            +
                      warn "IceCube: :#{old_key} is deprecated, please use :#{new_key} at: #{caller(1..1).first}"
         
     | 
| 
       36 
35 
     | 
    
         
             
                      (data[new_key] ||= []).concat times
         
     | 
| 
       37 
36 
     | 
    
         
             
                    end
         
     | 
| 
       38 
37 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -61,7 +60,6 @@ module IceCube 
     | 
|
| 
       61 
60 
     | 
    
         | 
| 
       62 
61 
     | 
    
         
             
                def apply_exrules(schedule, data)
         
     | 
| 
       63 
62 
     | 
    
         
             
                  return unless data[:exrules]
         
     | 
| 
       64 
     | 
    
         
            -
                  warn "IceCube: :exrules is deprecated, and will be removed in a future release. at: #{ caller[0] }"
         
     | 
| 
       65 
63 
     | 
    
         
             
                  data[:exrules].each do |h|
         
     | 
| 
       66 
64 
     | 
    
         
             
                    rrule = h.is_a?(IceCube::Rule) ? h : IceCube::Rule.from_hash(h)
         
     | 
| 
       67 
65 
     | 
    
         | 
| 
         @@ -86,6 +84,5 @@ module IceCube 
     | 
|
| 
       86 
84 
     | 
    
         
             
                def parse_time(time)
         
     | 
| 
       87 
85 
     | 
    
         
             
                  TimeUtil.deserialize_time(time)
         
     | 
| 
       88 
86 
     | 
    
         
             
                end
         
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
87 
     | 
    
         
             
              end
         
     | 
| 
       91 
88 
     | 
    
         
             
            end
         
     |