timeboss 1.1.4 → 1.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17c22a99ae9b02ecc3f435e99622a075c0a26af2d15f87070aefb1e6c0deb1c4
4
- data.tar.gz: 774b9250575112756f30f9522bd98b36ed017a010cace574407a88b4f3316f98
3
+ metadata.gz: 3299b203ac582ad852fb3411015fb1c8d53ab9b59fbae51f133e79e4750ba912
4
+ data.tar.gz: ae84c4d98f8996519c30b05700f359faca2f66492c78e46f2eda0cf9e2fcc60c
5
5
  SHA512:
6
- metadata.gz: 949de3a932fe24a8c34e8bf9ba89eed605ff6f8148ab5763600a6fb6ec00b822cfc2425b4aebce6982ecc62be43fb037723a264a6543539e626755dc39f1ec04
7
- data.tar.gz: ac0312302c3e89d193bf16354ccf3593e3bed79e6e569b1580d78f82ad40bf663765f950078c86572d3e245f265047b947dbe70c1948b82bb958b205a73542af
6
+ metadata.gz: d2c3e30df4a6256bab1428fb470cbc21f7d44c89747ebd08b390d7b324b010980c2592fbbab3e503c0a21dc20705c03036cd9e68d6c67b844bf372ee19ad9bc0
7
+ data.tar.gz: 79994538d0477b935d1b17887f9e2748f73e59511d84e0dfffb236e0798bc39d1416cecc3e452965a7e96b0ddce156f92771cdeaf73080ca9b6892b1b5ace896
@@ -14,10 +14,10 @@ jobs:
14
14
 
15
15
  steps:
16
16
  - uses: actions/checkout@v2
17
- - name: Set up Ruby 2.6
18
- uses: actions/setup-ruby@v1
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
19
  with:
20
- ruby-version: 2.6.x
20
+ ruby-version: 3.1
21
21
 
22
22
  - name: Publish to RubyGems
23
23
  run: |
@@ -19,15 +19,12 @@ jobs:
19
19
  runs-on: ubuntu-latest
20
20
  strategy:
21
21
  matrix:
22
- ruby-version: ['2.7', '3.0']
22
+ ruby-version: ['2.7', '3.0', '3.1', '3.2']
23
23
 
24
24
  steps:
25
25
  - uses: actions/checkout@v2
26
26
  - name: Set up Ruby
27
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
28
- # change this to (see https://github.com/ruby/setup-ruby#versioning):
29
- # uses: ruby/setup-ruby@v1
30
- uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
27
+ uses: ruby/setup-ruby@v1
31
28
  with:
32
29
  ruby-version: ${{ matrix.ruby-version }}
33
30
  bundler-cache: true # runs 'bundle install' and caches installed gems automatically
@@ -1,8 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "./support/clampable"
4
+
3
5
  module TimeBoss
4
6
  class Calendar
5
7
  class Period
8
+ include Calendar::Support::Clampable
6
9
  attr_reader :begin, :end
7
10
 
8
11
  # @!method start_date
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TimeBoss
4
+ class Calendar
5
+ module Support
6
+ module Clampable
7
+ # Clamp this unit to the range of the provided unit.
8
+ # @return [Period]
9
+ def clamp(unit)
10
+ new_start_date = start_date.clamp(unit.start_date, unit.end_date)
11
+ new_end_date = end_date.clamp(unit.start_date, unit.end_date)
12
+ return unless new_start_date.between?(start_date, end_date) && new_end_date.between?(start_date, end_date)
13
+ calendar.parse("#{new_start_date}..#{new_end_date}")
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -3,6 +3,7 @@
3
3
  require_relative "./navigable"
4
4
  require_relative "./translatable"
5
5
  require_relative "./shiftable"
6
+ require_relative "./clampable"
6
7
  require_relative "./formatter"
7
8
 
8
9
  module TimeBoss
@@ -12,6 +13,7 @@ module TimeBoss
12
13
  include Navigable
13
14
  include Translatable
14
15
  include Shiftable
16
+ include Clampable
15
17
  attr_reader :calendar, :start_date, :end_date
16
18
 
17
19
  UnsupportedUnitError = Class.new(StandardError)
@@ -84,15 +86,6 @@ module TimeBoss
84
86
  @_to_range ||= start_date..end_date
85
87
  end
86
88
 
87
- # Clamp this unit to the range of the provided unit.
88
- # @return [Period]
89
- def clamp(unit)
90
- new_start_date = start_date.clamp(unit.start_date, unit.end_date)
91
- new_end_date = end_date.clamp(unit.start_date, unit.end_date)
92
- return unless new_start_date.between?(start_date, end_date) && new_end_date.between?(start_date, end_date)
93
- calendar.parse("#{new_start_date}..#{new_end_date}")
94
- end
95
-
96
89
  def inspect
97
90
  "#<#{self.class.name} start_date=#{start_date}, end_date=#{end_date}>"
98
91
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TimeBoss
4
- VERSION = "1.1.4"
4
+ VERSION = "1.1.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timeboss
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin McDonald
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-13 00:00:00.000000000 Z
11
+ date: 2023-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -198,6 +198,7 @@ files:
198
198
  - lib/timeboss/calendar/parser.rb
199
199
  - lib/timeboss/calendar/period.rb
200
200
  - lib/timeboss/calendar/quarter.rb
201
+ - lib/timeboss/calendar/support/clampable.rb
201
202
  - lib/timeboss/calendar/support/formatter.rb
202
203
  - lib/timeboss/calendar/support/has_fiscal_weeks.rb
203
204
  - lib/timeboss/calendar/support/has_iso_weeks.rb
@@ -245,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
246
  - !ruby/object:Gem::Version
246
247
  version: '0'
247
248
  requirements: []
248
- rubygems_version: 3.0.3.1
249
+ rubygems_version: 3.3.26
249
250
  signing_key:
250
251
  specification_version: 4
251
252
  summary: Broadcast Calendar navigation in Ruby made simple