almanack 1.2.1 → 1.3.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1134806012a13b60c1ddb18ef4d5e307e0ca00af4fd751f15ba4bbc384b8ef5d
4
- data.tar.gz: 4a22cd08e2bd7c67b612023cb1b6e33cc1cf5ae45e2bab24a41385c40f5a682e
3
+ metadata.gz: cfc9136fa4680e8bd391dca4a764592d27ec9fb41bde609986ccc47c5476306f
4
+ data.tar.gz: 87e47bcb6900fba580099c083e01f09bd3681e4fec89cc4b1a000d114d2f04af
5
5
  SHA512:
6
- metadata.gz: ff81548baa2fe195e492474bf5532bf56f5018a50b0aacd842830cf7a321b2f343bd8a18aeccba5cceb321b5e7ace07a47c4f76f5d74b9117150036558415809
7
- data.tar.gz: 980be5514e9c8a81a92c5a81d209ec17fc339bb282ae81eb5ccdb6f34bf1613f45012bb68d2f3a1613084da0cbb72c937fd00720eaf6d27676869976d8ddbb07
6
+ metadata.gz: e53e216b45cfc1038370d30bbba67e53bc0de9cd59a223b1125a9b77caa1a43a20a2ba4506d22b0edffbe3f0b9c1208c1ffdb4783d5086b4d8594b7faacad7c4
7
+ data.tar.gz: ecb5487daa8ffe180b8e88f92304354d68bcad2373c17bdacc6f2bba5f946954770206c433cca92498dfd607e66b14cd7cc29b7599f159abbc5f9f329d843175
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,13 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- almanack (1.2.1)
4
+ almanack (1.3.0.rc1)
5
5
  activesupport
6
6
  addressable
7
7
  faraday
8
8
  faraday_middleware
9
+ icalendar
10
+ icalendar-recurrence
9
11
  rack-contrib
10
- ri_cal
11
12
  sassc
12
13
  sinatra
13
14
  sinatra-contrib
@@ -41,6 +42,12 @@ GEM
41
42
  hashdiff (1.0.0)
42
43
  i18n (1.7.0)
43
44
  concurrent-ruby (~> 1.0)
45
+ icalendar (2.6.1)
46
+ ice_cube (~> 0.16)
47
+ icalendar-recurrence (1.1.3)
48
+ icalendar (~> 2.0)
49
+ ice_cube (~> 0.16)
50
+ ice_cube (0.16.3)
44
51
  method_source (0.9.2)
45
52
  mini_portile2 (2.4.0)
46
53
  minitest (5.13.0)
@@ -62,7 +69,6 @@ GEM
62
69
  rack-test (1.1.0)
63
70
  rack (>= 1.0, < 3)
64
71
  rake (10.5.0)
65
- ri_cal (0.8.8)
66
72
  rspec (3.9.0)
67
73
  rspec-core (~> 3.9.0)
68
74
  rspec-expectations (~> 3.9.0)
@@ -29,7 +29,8 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency "sinatra"
30
30
  spec.add_dependency "sinatra-contrib"
31
31
  spec.add_dependency "sassc"
32
- spec.add_dependency "ri_cal"
32
+ spec.add_dependency "icalendar"
33
+ spec.add_dependency "icalendar-recurrence"
33
34
  spec.add_dependency "addressable"
34
35
  spec.add_dependency "thor"
35
36
  spec.add_dependency "faraday"
@@ -0,0 +1 @@
1
+ 42e774ae07cdb707781beb8bf467ac386e66e2b89b4ab17b7a67af9c30429da7
@@ -0,0 +1 @@
1
+ af8d056cf0c25db508f57d4fa3c93525d560345092893cf788a0ac2a4f8093229894dd866e7eb0cb60ef8061e4ae789d1bd920dee251f787ee8cd626647f9330
@@ -1,7 +1,8 @@
1
1
  require "pathname"
2
2
  require "forwardable"
3
3
  require "json"
4
- require "ri_cal"
4
+ require "icalendar"
5
+ require "icalendar/recurrence"
5
6
  require "addressable/uri"
6
7
  require "faraday"
7
8
  require "faraday_middleware"
@@ -8,7 +8,21 @@ module Almanack
8
8
  end
9
9
 
10
10
  def events_between(date_range)
11
- occurrences_between(date_range).map(&method(:event_from))
11
+ return enum_for(__method__, date_range).to_a unless block_given?
12
+
13
+ from, to = [date_range.min, date_range.max]
14
+
15
+ each_ical_event do |ical_event|
16
+ if ical_event.rrule.empty?
17
+ if from < ical_event.dtend
18
+ yield event_from(ical_event)
19
+ end
20
+ else
21
+ ical_event.occurrences_between(from, to).each do |occurrence|
22
+ yield event_from(ical_event, occurrence: occurrence)
23
+ end
24
+ end
25
+ end
12
26
  end
13
27
 
14
28
  def serialized_between(date_range)
@@ -21,23 +35,13 @@ module Almanack
21
35
 
22
36
  private
23
37
 
24
- def occurrences_between(date_range, &block)
25
- return enum_for(__method__, date_range) unless block_given?
26
-
27
- query = { starting: date_range.min, before: date_range.max }
28
-
29
- each_event do |ical_event|
30
- ical_event.occurrences(query).each(&block)
31
- end
32
- end
33
-
34
- def event_from(occurrence)
38
+ def event_from(ical_event, occurrence: nil)
35
39
  Event.new(
36
- title: occurrence.summary,
37
- start_time: occurrence.dtstart,
38
- end_time: occurrence.dtend,
39
- description: occurrence.description,
40
- location: occurrence.location
40
+ title: ical_event.summary,
41
+ start_time: occurrence&.start_time || ical_event.dtstart,
42
+ end_time: occurrence&.end_time || ical_event.dtend,
43
+ description: ical_event.description,
44
+ location: ical_event.location
41
45
  )
42
46
  end
43
47
 
@@ -45,13 +49,9 @@ module Almanack
45
49
  io.respond_to?(:read) ? io.read : io
46
50
  end
47
51
 
48
- def entities
49
- RiCal.parse_string(read_io)
50
- end
51
-
52
- def each_event(&block)
53
- entities.each do |entity|
54
- entity.events.each(&block) if entity.respond_to?(:events)
52
+ def each_ical_event(&block)
53
+ Icalendar::Calendar.parse(read_io).each do |calendar|
54
+ calendar.events.each(&block)
55
55
  end
56
56
  end
57
57
  end
@@ -18,7 +18,7 @@ module Almanack
18
18
  private
19
19
 
20
20
  def build!
21
- @ical_event = RiCal.Event
21
+ @ical_event = Icalendar::Event.new
22
22
  set_summary
23
23
  set_start_time
24
24
  set_end_time
@@ -32,7 +32,7 @@ module Almanack
32
32
  end
33
33
 
34
34
  def set_start_time
35
- if event.start_time.is_a?(Date)
35
+ if event.start_time.is_a?(Icalendar::Values::Date)
36
36
  ical_event.dtstart = event.start_time
37
37
  else
38
38
  ical_event.dtstart = event.start_time.utc
@@ -40,7 +40,7 @@ module Almanack
40
40
  end
41
41
 
42
42
  def set_end_time
43
- if event.end_time.is_a?(Date)
43
+ if event.end_time.is_a?(Icalendar::Values::Date)
44
44
  ical_event.dtend = event.end_time
45
45
  else
46
46
  ical_event.dtend = (event.end_time || event.start_time + default_event_duration ).utc
@@ -12,7 +12,7 @@ module Almanack
12
12
  end
13
13
 
14
14
  def to_s
15
- ical.to_s
15
+ ical.to_ical
16
16
  end
17
17
 
18
18
  def self.from(calendar)
@@ -26,8 +26,8 @@ module Almanack
26
26
  end
27
27
 
28
28
  def ical_calendar
29
- events.each_with_object(RiCal.Calendar) do |event, calendar_component|
30
- calendar_component.add_subcomponent ical_event_for(event)
29
+ events.each_with_object(Icalendar::Calendar.new) do |event, calendar|
30
+ calendar.add_event ical_event_for(event)
31
31
  end
32
32
  end
33
33
 
@@ -1,6 +1,6 @@
1
1
  module Almanack
2
2
  CODENAME = "Garlick"
3
- VERSION = "1.2.1"
3
+ VERSION = "1.3.0.rc1"
4
4
  HOMEPAGE = "https://github.com/Aupajo/almanack"
5
5
  ISSUES = "https://github.com/Aupajo/almanack/issues"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: almanack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Nicholls
@@ -79,7 +79,21 @@ dependencies:
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  - !ruby/object:Gem::Dependency
82
- name: ri_cal
82
+ name: icalendar
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :runtime
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: icalendar-recurrence
83
97
  requirement: !ruby/object:Gem::Requirement
84
98
  requirements:
85
99
  - - ">="
@@ -351,6 +365,8 @@ files:
351
365
  - checksums/almanack-1.1.5.gem.sha512
352
366
  - checksums/almanack-1.2.0.gem.sha256
353
367
  - checksums/almanack-1.2.0.gem.sha512
368
+ - checksums/almanack-1.2.1.gem.sha256
369
+ - checksums/almanack-1.2.1.gem.sha512
354
370
  - example.ru
355
371
  - exe/almanack
356
372
  - lib/almanack.rb
@@ -398,9 +414,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
398
414
  version: '0'
399
415
  required_rubygems_version: !ruby/object:Gem::Requirement
400
416
  requirements:
401
- - - ">="
417
+ - - ">"
402
418
  - !ruby/object:Gem::Version
403
- version: '0'
419
+ version: 1.3.1
404
420
  requirements: []
405
421
  rubygems_version: 3.0.3
406
422
  signing_key:
metadata.gz.sig CHANGED
Binary file