hebrew_date 1.0.8 → 1.0.9
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/hebrew_date.gemspec +2 -2
- data/lib/hebrew_date.rb +20 -5
- data/lib/support/printing.rb +84 -0
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: caa2551e03b3046a8465f3f4c089aabddaa0fb60
         | 
| 4 | 
            +
              data.tar.gz: c17044991f93ea53302c17aa9c36c920376c9411
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: e17754d8f17a67e26ff377300614df40c5947ffec06c11541272180675cd67314eb3d91f35abca93b0a0e93c6f16ffd9de671648f526d71997624b92e0341d26
         | 
| 7 | 
            +
              data.tar.gz: d1b9fb3ecc905124d0b70d839223fbe374f93d0d37b1effe8017ab8119e4a6a261fdaf3a66abe1c4cb5c81747263ad1391b47c45538b9c1beefecc94f2546979
         | 
    
        data/hebrew_date.gemspec
    CHANGED
    
    | @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            Gem::Specification.new do |s|
         | 
| 2 2 | 
             
              s.name         = 'hebrew_date'
         | 
| 3 3 | 
             
              s.require_paths = %w(. lib)
         | 
| 4 | 
            -
              s.version      = '1.0. | 
| 5 | 
            -
              s.date         = '2014-01- | 
| 4 | 
            +
              s.version      = '1.0.9'
         | 
| 5 | 
            +
              s.date         = '2014-01-31'
         | 
| 6 6 | 
             
              s.summary      = 'Hebrew/Jewish dates, times, and holidays.'
         | 
| 7 7 | 
             
              s.description  = <<-EOF
         | 
| 8 8 | 
             
               hebrew_date is a library designed to provide information about the Jewish
         | 
    
        data/lib/hebrew_date.rb
    CHANGED
    
    | @@ -308,14 +308,29 @@ class HebrewDate < Delegator | |
| 308 308 | 
             
              end
         | 
| 309 309 |  | 
| 310 310 | 
             
              # Get the name of the given Hebrew month.
         | 
| 311 | 
            -
               | 
| 312 | 
            -
             | 
| 313 | 
            -
             | 
| 314 | 
            -
             | 
| 311 | 
            +
              # @param month [Integer]
         | 
| 312 | 
            +
              # @param year [Integer]
         | 
| 313 | 
            +
              # @return [String]
         | 
| 314 | 
            +
              def self.hebrew_month_to_s(month, year=nil)
         | 
| 315 | 
            +
                year ||= HebrewDate.new.hebrew_year
         | 
| 316 | 
            +
                if hebrew_leap_year?(year) && month == 12
         | 
| 317 | 
            +
                  'Adar I'
         | 
| 318 | 
            +
                else
         | 
| 319 | 
            +
                  name = HEBREW_MONTH_NAMES[month - 1]
         | 
| 320 | 
            +
                  if name == 'Teves' && !self.ashkenaz
         | 
| 321 | 
            +
                    name = 'Tevet'
         | 
| 322 | 
            +
                  end
         | 
| 323 | 
            +
                  name
         | 
| 315 324 | 
             
                end
         | 
| 316 | 
            -
                name
         | 
| 317 325 | 
             
              end
         | 
| 318 326 |  | 
| 327 | 
            +
              # @return [Boolean]
         | 
| 328 | 
            +
              def shabbos?
         | 
| 329 | 
            +
                self.saturday?
         | 
| 330 | 
            +
              end
         | 
| 331 | 
            +
             | 
| 332 | 
            +
              alias_method :shabbat?, :shabbos?
         | 
| 333 | 
            +
             | 
| 319 334 | 
             
              # Extend the Date strftime method by replacing Hebrew fields. You can denote
         | 
| 320 335 | 
             
              # Hebrew fields by using the * flag. Also note that ::replace_saturday will
         | 
| 321 336 | 
             
              # replace the %A, %^A, %a and %^a flags with Shabbat/Shabbos.
         | 
| @@ -0,0 +1,84 @@ | |
| 1 | 
            +
            module HebrewDateSupport
         | 
| 2 | 
            +
              module PrintMethods
         | 
| 3 | 
            +
                module ClassMethods
         | 
| 4 | 
            +
                  # Get the name of the given Hebrew month.
         | 
| 5 | 
            +
                  # @param month [Integer] the Hebrew month.
         | 
| 6 | 
            +
                  # @return [String]
         | 
| 7 | 
            +
                  def hebrew_month_to_s(month)
         | 
| 8 | 
            +
                    if hebrew_leap_year?(month) && month == 12
         | 
| 9 | 
            +
                      'Adar I'
         | 
| 10 | 
            +
                    else
         | 
| 11 | 
            +
                      name = HEBREW_MONTH_NAMES[month - 1]
         | 
| 12 | 
            +
                      if name == 'Teves' && !self.ashkenaz
         | 
| 13 | 
            +
                        name = 'Tevet'
         | 
| 14 | 
            +
                      end
         | 
| 15 | 
            +
                      name
         | 
| 16 | 
            +
                    end
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                alias_method :shabbos?, :saturday?
         | 
| 22 | 
            +
                alias_method :shabbat?, :saturday?
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                # Extend the Date strftime method by replacing Hebrew fields. You can denote
         | 
| 25 | 
            +
                # Hebrew fields by using the * flag. Also note that ::replace_saturday will
         | 
| 26 | 
            +
                # replace the %A, %^A, %a and %^a flags with Shabbat/Shabbos.
         | 
| 27 | 
            +
                # Supported flags are:
         | 
| 28 | 
            +
                #  * *Y - Hebrew year
         | 
| 29 | 
            +
                #  * *m - Hebrew month, zero-padded
         | 
| 30 | 
            +
                #  * *_m - Hebrew month, blank-padded
         | 
| 31 | 
            +
                #  * *-m - Hebrew month, no-padded
         | 
| 32 | 
            +
                #  * *B - Hebrew month, full name
         | 
| 33 | 
            +
                #  * *^B - Hebrew month, full name uppercase
         | 
| 34 | 
            +
                #  * *b - Hebrew month, 3 letters
         | 
| 35 | 
            +
                #  * *^b - Hebrew month, 3 letters uppercase
         | 
| 36 | 
            +
                #  * *h - same as %*b
         | 
| 37 | 
            +
                #  * *d - Hebrew day of month, zero-padded
         | 
| 38 | 
            +
                #  * *-d - Hebrew day of month, no-padded
         | 
| 39 | 
            +
                #  * *e - Hebrew day of month, blank-padded
         | 
| 40 | 
            +
                # @param format [String]
         | 
| 41 | 
            +
                # @return [String]
         | 
| 42 | 
            +
                def strftime(format)
         | 
| 43 | 
            +
                  format = format.gsub('*Y', @hebrew_year.to_s)
         | 
| 44 | 
            +
                    .gsub('*m', @hebrew_month.to_s.rjust(2, '0'))
         | 
| 45 | 
            +
                    .gsub('*_m', @hebrew_month.to_s.rjust(2, ' '))
         | 
| 46 | 
            +
                    .gsub('*-m', @hebrew_month.to_s)
         | 
| 47 | 
            +
                    .gsub('*B', hebrew_month_to_s)
         | 
| 48 | 
            +
                    .gsub('*^B', hebrew_month_to_s.upcase)
         | 
| 49 | 
            +
                    .gsub('*b', hebrew_month_to_s[0, 3])
         | 
| 50 | 
            +
                    .gsub('*^b', hebrew_month_to_s[0, 3].upcase)
         | 
| 51 | 
            +
                    .gsub('*h', hebrew_month_to_s[0, 3])
         | 
| 52 | 
            +
                    .gsub('*d', @hebrew_date.to_s.rjust(2, '0'))
         | 
| 53 | 
            +
                    .gsub('*-d', @hebrew_date.to_s)
         | 
| 54 | 
            +
                    .gsub('*e', @hebrew_date.to_s.rjust(2, ' '))
         | 
| 55 | 
            +
                  if HebrewDate.replace_saturday && @hebrew_date.day == 7
         | 
| 56 | 
            +
                    shab_name = HebrewDate.ashkenaz ? 'Shabbos' : 'Shabbat'
         | 
| 57 | 
            +
                    format = format.gsub('%A', shab_name)
         | 
| 58 | 
            +
                      .gsub('%^A', shab_name.upcase)
         | 
| 59 | 
            +
                      .gsub('%a', shab_name[0..2])
         | 
| 60 | 
            +
                      .gsub('%^a', shab_name[0..2].upcase)
         | 
| 61 | 
            +
                  end
         | 
| 62 | 
            +
                  super(format)
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
             | 
| 66 | 
            +
                # @private
         | 
| 67 | 
            +
                HEBREW_MONTH_NAMES = ['Nissan', 'Iyar', 'Sivan', 'Tammuz', 'Av', 'Elul',
         | 
| 68 | 
            +
                                      'Tishrei', 'Cheshvan', 'Kislev', 'Teves', 'Shvat',
         | 
| 69 | 
            +
                                      'Adar', 'Adar II']
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                # @private
         | 
| 72 | 
            +
                def inspect
         | 
| 73 | 
            +
                  strftime('*Y-*-m-*-d (%Y-%-m-%-d)')
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                # Get the name of the current Hebrew month.
         | 
| 77 | 
            +
                # @return [String]
         | 
| 78 | 
            +
                def hebrew_month_to_s
         | 
| 79 | 
            +
                  self.hebrew_month_to_s(@hebrew_month)
         | 
| 80 | 
            +
                end
         | 
| 81 | 
            +
             | 
| 82 | 
            +
             | 
| 83 | 
            +
              end
         | 
| 84 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: hebrew_date
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.9
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Daniel Orner
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014-01- | 
| 11 | 
            +
            date: 2014-01-31 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: yard
         | 
| @@ -75,6 +75,7 @@ files: | |
| 75 75 | 
             
            - lib/hebrew_date.rb
         | 
| 76 76 | 
             
            - lib/support/holidays.rb
         | 
| 77 77 | 
             
            - lib/support/parshiot.rb
         | 
| 78 | 
            +
            - lib/support/printing.rb
         | 
| 78 79 | 
             
            - spec/hebrew_date_spec.rb
         | 
| 79 80 | 
             
            homepage: https://github.com/dorner/hebrew_date
         | 
| 80 81 | 
             
            licenses:
         |