icalendar-upcoming 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2f84dc21c800af622845e4382d41b458ca9ce9c0
4
+ data.tar.gz: 111c45642f22fbb229ff9273ee28273944d4f810
5
+ SHA512:
6
+ metadata.gz: cf4610a7657052cfcb94be250b3bb35c6c6debff70dd09349f1e2115f2210c18542b1828285e8180200429686eda78e010ebb9737f063f48b186598c8d0245fe
7
+ data.tar.gz: 601cd14a048f9ce673f4c2351fc434c8406418128bae234517b4ada30a2bdbf57246decf0001a14425b3a2d409676c3096e6dd6ea48f0328404f5a17cc29d1e8
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ before_install: gem install bundler -v 1.11.2
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in icalendar-upcoming.gemspec
4
+ gemspec
5
+
6
+ gem 'rspec'
7
+ gem 'tzinfo'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Bernard Potocki
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Icalendar::Upcoming
2
+
3
+ Show upcoming events from Icalendar.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'icalendar-upcoming'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install icalendar-upcoming
20
+
21
+ ## Usage
22
+
23
+ On instance of [icalendar](https://github.com/icalendar/icalendar) Calendar:
24
+
25
+ ```ruby
26
+ calendar.upcoming_events() #=> { event: Icalendar::Event, start_time: Date or DateTime, end_time: Date or DateTime }
27
+ ```
28
+
29
+ Available options:
30
+
31
+ - `start_date`: date of first event range. Default: `Date.today`
32
+ - `end_date`: date of last event range. Default: `nil`
33
+ - `num_days`: number of days to calculate end date. Default: `7`
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/imanel/icalendar-upcoming.
38
+
39
+
40
+ ## License
41
+
42
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
43
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'icalendar/upcoming/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "icalendar-upcoming"
8
+ spec.version = Icalendar::Upcoming::VERSION
9
+ spec.authors = ["Bernard Potocki"]
10
+ spec.email = ["bernard.potocki@imanel.org"]
11
+
12
+ spec.summary = %q{Show upcoming events from Icalendar.}
13
+ spec.homepage = "https://github.com/imanel/icalendar-upcoming"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency 'icalendar-recurrence', '~> 1.1'
22
+ end
@@ -0,0 +1 @@
1
+ require_relative './icalendar/upcoming'
@@ -0,0 +1,34 @@
1
+ require "icalendar"
2
+ require "icalendar/recurrence"
3
+ require "icalendar/upcoming/version"
4
+
5
+ module Icalendar
6
+ module Upcoming
7
+ def upcoming_events(num_days: 7, start_date: Date.today, end_date: nil)
8
+ upcoming = []
9
+ end_date ||= start_date + num_days
10
+ list = events.select { |event| !event.occurrences_between(start_date, end_date).empty? }
11
+ list.map do |event|
12
+ event.occurrences_between(start_date, end_date).each do |date|
13
+ if event.dtstart.is_a?(Icalendar::Values::Date)
14
+ starts = date.start_time.to_date
15
+ ends = date.end_time.to_date
16
+ else
17
+ starts = date.start_time.to_datetime
18
+ ends = date.end_time.to_datetime
19
+ end
20
+ upcoming << {
21
+ event: event,
22
+ start_time: starts,
23
+ end_time: ends
24
+ }
25
+ end
26
+ end
27
+ upcoming.sort { |a,b| a[:start_time] <=> b[:start_time] }
28
+ end
29
+ end
30
+
31
+ class Calendar
32
+ include Icalendar::Upcoming
33
+ end
34
+ end
@@ -0,0 +1,5 @@
1
+ module Icalendar
2
+ module Upcoming
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: icalendar-upcoming
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bernard Potocki
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-03-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: icalendar-recurrence
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
27
+ description:
28
+ email:
29
+ - bernard.potocki@imanel.org
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - ".travis.yml"
37
+ - Gemfile
38
+ - LICENSE.txt
39
+ - README.md
40
+ - Rakefile
41
+ - icalendar-upcoming.gemspec
42
+ - lib/icalendar-upcoming.rb
43
+ - lib/icalendar/upcoming.rb
44
+ - lib/icalendar/upcoming/version.rb
45
+ homepage: https://github.com/imanel/icalendar-upcoming
46
+ licenses:
47
+ - MIT
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 2.5.1
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Show upcoming events from Icalendar.
69
+ test_files: []