raigoocal 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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +48 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/raigoocal.rb +30 -0
- data/lib/raigoocal/agenda_model.rb +87 -0
- data/lib/raigoocal/event_loader_model.rb +62 -0
- data/lib/raigoocal/month_model.rb +149 -0
- data/lib/raigoocal/version.rb +3 -0
- data/raigoocal.gemspec +45 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c06e7fd8fb58ab276646c234deba4822186105eabf714ccaf429d90b4c3c952b
|
4
|
+
data.tar.gz: d22b64fab76ad93e51fa2cc4499dfc445f7c733fe22bf93e729f0cf94665374e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2eea50ee8e6a57c6903fc9c6a82b1f103094f977acec500657f52254350f7b374889de3b44b525a37ca9ebefd3d5ca4fa4728dbaac02c3c543ecbcd2fba2d361
|
7
|
+
data.tar.gz: 06a3fdf2a25767cd1a61134b876e72ab693d9974ee4d0037bb9d46e2e4e0351829f0bac8d0dae7f0f3de385778a812d131f826c586ce81b90408a5236588da9f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
raigoocal (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activesupport (5.2.2)
|
10
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
|
+
i18n (>= 0.7, < 2)
|
12
|
+
minitest (~> 5.1)
|
13
|
+
tzinfo (~> 1.1)
|
14
|
+
concurrent-ruby (1.1.4)
|
15
|
+
diff-lcs (1.3)
|
16
|
+
i18n (1.5.2)
|
17
|
+
concurrent-ruby (~> 1.0)
|
18
|
+
minitest (5.11.3)
|
19
|
+
rake (10.5.0)
|
20
|
+
rspec (3.8.0)
|
21
|
+
rspec-core (~> 3.8.0)
|
22
|
+
rspec-expectations (~> 3.8.0)
|
23
|
+
rspec-mocks (~> 3.8.0)
|
24
|
+
rspec-core (3.8.0)
|
25
|
+
rspec-support (~> 3.8.0)
|
26
|
+
rspec-expectations (3.8.2)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.8.0)
|
29
|
+
rspec-mocks (3.8.0)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.8.0)
|
32
|
+
rspec-support (3.8.0)
|
33
|
+
thread_safe (0.3.6)
|
34
|
+
tzinfo (1.2.5)
|
35
|
+
thread_safe (~> 0.1)
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
x64-mingw32
|
39
|
+
|
40
|
+
DEPENDENCIES
|
41
|
+
activesupport (~> 5.0, >= 5.0.0.1)
|
42
|
+
bundler (~> 2.0)
|
43
|
+
raigoocal!
|
44
|
+
rake (~> 10.0)
|
45
|
+
rspec (~> 3.0)
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
2.0.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Andreas Schau
|
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,39 @@
|
|
1
|
+
# Raigoocal
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/raigoocal`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'raigoocal'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install raigoocal
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/raigoocal.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "raigoocal"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/raigoocal.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# require "rubygems"
|
2
|
+
require "active_support/all"
|
3
|
+
|
4
|
+
require "raigoocal/version"
|
5
|
+
require "raigoocal/event_loader_model"
|
6
|
+
require "raigoocal/agenda_model"
|
7
|
+
require "raigoocal/month_model"
|
8
|
+
|
9
|
+
module Raigoocal
|
10
|
+
# class Calendar
|
11
|
+
# attr_reader :configuration
|
12
|
+
# # class Error < StandardError; end
|
13
|
+
# # # Your code goes here...
|
14
|
+
|
15
|
+
# # require "raigoocal/event_loader_model"
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
# def initialize(json_config)
|
22
|
+
# self.configuration = JSON.parse(json_config)
|
23
|
+
# end
|
24
|
+
|
25
|
+
# private
|
26
|
+
|
27
|
+
# attr_writer :configuration
|
28
|
+
# end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "raigoocal/event_loader_model"
|
2
|
+
|
3
|
+
class AgendaModel
|
4
|
+
# Attributes one needs to access from the "outside"
|
5
|
+
attr_reader :display_day_count
|
6
|
+
attr_reader :days_shift_coefficient
|
7
|
+
|
8
|
+
def initialize(json_config)
|
9
|
+
json_parsed = JSON.parse(json_config)
|
10
|
+
self.google_calendar_base_path = json_parsed["calendar"]["google_calendar_api_host_base_path"]
|
11
|
+
self.calendar_id = json_parsed["calendar"]["calendar_id"]
|
12
|
+
self.api_key = json_parsed["calendar"]["api_key"]
|
13
|
+
|
14
|
+
self.display_day_count = json_parsed["agenda"]["display_day_count"].to_i
|
15
|
+
self.days_shift_coefficient = json_parsed["agenda"]["days_shift_coefficient"].to_i
|
16
|
+
|
17
|
+
self.maps_query_host = json_parsed["general"]["maps_query_host"]
|
18
|
+
end
|
19
|
+
|
20
|
+
def agenda_events(from, to, today)
|
21
|
+
EventLoaderModel.get_agenda_events(google_calendar_base_path, calendar_id, api_key, from, to)
|
22
|
+
end
|
23
|
+
|
24
|
+
# best if called in a cached block
|
25
|
+
def get_days_grouped_events(from, to, today)
|
26
|
+
events = agenda_events(from, to, today)
|
27
|
+
|
28
|
+
events.group_by { |event| event.dtstart.to_date }
|
29
|
+
end
|
30
|
+
|
31
|
+
def path(page_host, params = {})
|
32
|
+
URI::HTTP.build( host: page_host, query: { v: 'a' }.merge(params).to_query).to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def before_path(page_host, current_shift_factor)
|
36
|
+
week_shift_path(page_host, current_shift_factor, -1)
|
37
|
+
end
|
38
|
+
def ahead_path(page_host, current_shift_factor)
|
39
|
+
week_shift_path(page_host, current_shift_factor, +1)
|
40
|
+
end
|
41
|
+
def week_shift_path(page_host, current_shift_factor, shift_factor)
|
42
|
+
path(page_host , s: (current_shift_factor.to_i + shift_factor.to_i).to_s)
|
43
|
+
end
|
44
|
+
|
45
|
+
def current_shift_for_agenda(current_shift_factor)
|
46
|
+
current_shift_factor
|
47
|
+
end
|
48
|
+
def current_shift_for_month(current_shift_factor, today_date = Date.today)
|
49
|
+
date_span = (current_end_date(current_shift_factor, today_date) - current_start_date(current_shift_factor, today_date)).to_i
|
50
|
+
midway_date = (current_start_date(current_shift_factor, today_date) + (date_span / 2))
|
51
|
+
|
52
|
+
current_month_shift = ((midway_date.year * 12 + midway_date.month) - (today_date.year * 12 + today_date.month)).to_i
|
53
|
+
|
54
|
+
current_month_shift
|
55
|
+
end
|
56
|
+
|
57
|
+
def current_start_date(current_shift_factor, today_date = Date.today)
|
58
|
+
today_date + (current_shift_factor.to_i * self.days_shift_coefficient).days
|
59
|
+
end
|
60
|
+
def current_end_date(current_shift_factor, today_date = Date.today)
|
61
|
+
today_date + (current_shift_factor.to_i * self.days_shift_coefficient + self.display_day_count).days
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.emphasize_date(check_date, emphasized_date, emphasized, regular)
|
65
|
+
check_date.to_date == emphasized_date.to_date ? emphasized : regular
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.summary_title(event)
|
69
|
+
event.summary.to_s.force_encoding("UTF-8") + "\n" + event.location.to_s.force_encoding("UTF-8") + "\n" + event.description.to_s.force_encoding("UTF-8")
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.address_to_maps_path(address)
|
73
|
+
URI::HTTP.build( host: self.maps_query_host, query: { q: address.force_encoding("UTF-8").gsub(" ", "+") }.to_query).to_s
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
attr_writer :display_day_count
|
79
|
+
attr_writer :days_shift_coefficient
|
80
|
+
|
81
|
+
attr_accessor :calendar_id
|
82
|
+
attr_accessor :api_key
|
83
|
+
|
84
|
+
attr_accessor :google_calendar_base_path
|
85
|
+
attr_accessor :maps_query_host
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
class EventLoaderModel
|
5
|
+
Event ||= Struct.new(:dtstart, :dtend, :summary, :description, :location, :uid)
|
6
|
+
def self.Event(dtstart, dtend, summary, description, location, uid)
|
7
|
+
Event.new(:dtstart, :dtend, :summary, :description, :location, :uid)
|
8
|
+
end
|
9
|
+
|
10
|
+
UpdateInterval ||= 2.hours
|
11
|
+
|
12
|
+
def self.get_agenda_events(google_calendar_base_path, calendar_id, api_key, from, to)
|
13
|
+
events = parse_calendar(google_calendar_base_path, calendar_id, api_key, from, to)
|
14
|
+
spreaded_events = spread_multiday_events(events, from, to)
|
15
|
+
|
16
|
+
sorted_events = (events + spreaded_events.to_a).sort_by do |el|
|
17
|
+
[el.dtstart, el.summary]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.get_month_events(google_calendar_base_path, calendar_id, api_key, from, to)
|
22
|
+
events = parse_calendar(google_calendar_base_path, calendar_id, api_key, from, to)
|
23
|
+
|
24
|
+
sorted_events = (events).sort_by do |el|
|
25
|
+
[el.dtstart, el.summary]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def self.build_google_request_path(google_calendar_base_path, calendar_id, api_key, from, to)
|
32
|
+
google_test_path = "#{google_calendar_base_path}#{calendar_id}/events?key=#{api_key}&singleEvents=true&orderBy=startTime&timeMin=#{CGI.escape(from.to_s)}&timeMax=#{CGI.escape(to.to_s)}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.parse_calendar(google_calendar_base_path, calendar_id, api_key, from, to)
|
36
|
+
|
37
|
+
google_test_path = build_google_request_path(google_calendar_base_path, calendar_id, api_key, from.to_datetime, to.to_datetime)
|
38
|
+
|
39
|
+
requested_events = JSON.parse(Net::HTTP.get(URI.parse(google_test_path)))
|
40
|
+
|
41
|
+
restructured_events = requested_events["items"].map{ |e| e["start"]["dateTime"] != nil ? Event.new(DateTime.parse(e["start"]["dateTime"]), DateTime.parse(e["end"]["dateTime"]), e["summary"], e["description"], e["location"], e["id"]) : Event.new(Date.parse(e["start"]["date"]), Date.parse(e["end"]["date"]), e["summary"], e["description"], e["location"], e["id"]) }
|
42
|
+
|
43
|
+
restructured_events.to_a
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.spread_multiday_events(events, from, to)
|
47
|
+
unspreaded_events = events.select{ |event| (event.dtend - event.dtstart).to_i > 0 }
|
48
|
+
|
49
|
+
unspreaded_events.map do |event|
|
50
|
+
([from, (event.dtstart + 1.day)].max .. [(event.dtend - 1.day), to].min).to_a.map do |date|
|
51
|
+
Event.new.tap do |e|
|
52
|
+
e.dtstart = date
|
53
|
+
e.dtend = event.dtend
|
54
|
+
e.summary = event.summary
|
55
|
+
e.location = event.location
|
56
|
+
e.description = event.description
|
57
|
+
e.uid = event.uid
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end.flatten!
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
class MonthModel
|
2
|
+
# Attributes one needs to access from the "outside"
|
3
|
+
attr_reader :months_view_dates
|
4
|
+
attr_reader :months_grouped_events
|
5
|
+
attr_reader :months_multiday_events
|
6
|
+
|
7
|
+
attr_reader :delta_start_of_weekday_from_sunday
|
8
|
+
attr_reader :summary_teaser_length
|
9
|
+
|
10
|
+
def initialize(json_config)
|
11
|
+
json_parsed = JSON.parse(json_config)
|
12
|
+
|
13
|
+
self.google_calendar_base_path = json_parsed["calendar"]["google_calendar_api_host_base_path"]
|
14
|
+
self.calendar_id = json_parsed["calendar"]["calendar_id"]
|
15
|
+
self.api_key = json_parsed["calendar"]["api_key"]
|
16
|
+
|
17
|
+
self.summary_teaser_length = json_parsed["month"]["summary_teaser_length_in_characters"].to_i
|
18
|
+
self.delta_start_of_weekday_from_sunday = json_parsed["month"]["delta_start_of_weekday_from_sunday"].to_i
|
19
|
+
|
20
|
+
self.maps_query_host = json_parsed["general"]["maps_query_host"]
|
21
|
+
end
|
22
|
+
|
23
|
+
def month_events(from, to)
|
24
|
+
EventLoaderModel.get_month_events(google_calendar_base_path, calendar_id, api_key, from, to)
|
25
|
+
end
|
26
|
+
|
27
|
+
def multiday_events(from, to)
|
28
|
+
events = month_events(from, to)
|
29
|
+
events.select { |event| event.dtstart.instance_of?(Date) }
|
30
|
+
end
|
31
|
+
|
32
|
+
def grouped_events(from, to)
|
33
|
+
events = month_events(from, to)
|
34
|
+
events.select { |event| event.dtstart.instance_of?(DateTime) }.sort_by{ |event| event.dtstart.localtime }.group_by { |event| event.dtstart.to_date }
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.weeks_grouped_multiday_events(months_multiday_events, first_weekday, last_weekday)
|
38
|
+
weeks_events = months_multiday_events.select{ |event| event.dtend > first_weekday && event.dtstart <= last_weekday }
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.find_best_fit_for_day(first_weekday, day, event_heap)
|
42
|
+
best_fit = event_heap.select{ |event| (day == first_weekday ? (event.dtstart <= day && event.dtend >= day) : (event.dtstart == day)) }.sort_by{ |event| [event.dtstart.to_time.to_i, -event.dtend.to_time.to_i] }.first
|
43
|
+
end
|
44
|
+
|
45
|
+
def path(page_host, params = {})
|
46
|
+
URI::HTTP.build( host: page_host, query: { v: 'm' }.merge(params).to_query).to_s
|
47
|
+
end
|
48
|
+
|
49
|
+
def before_path(page_path, current_shift_factor)
|
50
|
+
month_shift_path(page_path, current_shift_factor, -1)
|
51
|
+
end
|
52
|
+
def ahead_path(page_path, current_shift_factor)
|
53
|
+
month_shift_path(page_path, current_shift_factor, 1)
|
54
|
+
end
|
55
|
+
def month_shift_path(page_path, current_shift_factor, shift_factor)
|
56
|
+
path(page_path, s: (current_shift_factor.to_i + shift_factor.to_i).to_s)
|
57
|
+
end
|
58
|
+
|
59
|
+
def current_shift_for_agenda(current_shift_factor)
|
60
|
+
today_date = Date.today
|
61
|
+
current_shift_in_days = (MonthModel.current_month_start(current_shift_factor, today_date) - today_date).to_i
|
62
|
+
|
63
|
+
current_shift_in_days = (MonthModel.current_month_start(current_shift_factor, today_date) + ((MonthModel.current_month_end(current_shift_factor, today_date) - MonthModel.current_month_start(current_shift_factor, today_date)).div 5) - today_date).to_i
|
64
|
+
|
65
|
+
current_shift_factor_for_agenda = (current_shift_in_days.div AgendaModel.days_shift_coefficient)
|
66
|
+
|
67
|
+
current_shift_factor_for_agenda
|
68
|
+
end
|
69
|
+
def current_shift_for_month(current_shift_factor)
|
70
|
+
current_shift_factor
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.emphasize_date(check_date, emphasized_date, emphasized, regular)
|
74
|
+
check_date.to_date == emphasized_date.to_date ? emphasized : regular
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.multiday_event_cutoff(cutoff_start_condition, cutoff_end_condition, cutoff_start_style, cutoff_both_style, cutoff_end_style)
|
78
|
+
if (cutoff_start_condition && cutoff_end_condition)
|
79
|
+
cutoff_both_style
|
80
|
+
elsif (cutoff_start_condition)
|
81
|
+
cutoff_start_style
|
82
|
+
elsif (cutoff_end_condition)
|
83
|
+
cutoff_end_style
|
84
|
+
else
|
85
|
+
''
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.summary_title(event)
|
90
|
+
event.summary.to_s.force_encoding("UTF-8") + "\n" + event.location.to_s.force_encoding("UTF-8") + "\n" + event.description.to_s.force_encoding("UTF-8")
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.address_to_maps_path(address)
|
94
|
+
URI::HTTP.build( host: maps_query_host, query: { q: address.force_encoding("UTF-8").gsub(" ", "+") }.to_query).to_s
|
95
|
+
end
|
96
|
+
|
97
|
+
def weekday_dates(today_date = Date.today)
|
98
|
+
weekdays_dates = []
|
99
|
+
first_day_of_week = today_date - (today_date.wday - self.delta_start_of_weekday_from_sunday)
|
100
|
+
7.times do |day|
|
101
|
+
weekdays_dates += [first_day_of_week + day]
|
102
|
+
end
|
103
|
+
weekdays_dates
|
104
|
+
end
|
105
|
+
|
106
|
+
def months_view_dates(date_month_start, date_month_end)
|
107
|
+
dates_in_month_view = []
|
108
|
+
((date_month_start.wday - self.delta_start_of_weekday_from_sunday) % 7).times do |day|
|
109
|
+
dates_in_month_view = dates_in_month_view + [(date_month_start - (((date_month_start.wday - self.delta_start_of_weekday_from_sunday) % 7) - day))]
|
110
|
+
end
|
111
|
+
|
112
|
+
date_month_end.day.times do |day|
|
113
|
+
dates_in_month_view = dates_in_month_view + [date_month_start + day]
|
114
|
+
end
|
115
|
+
|
116
|
+
(6 - date_month_end.wday + self.delta_start_of_weekday_from_sunday).times do |day|
|
117
|
+
dates_in_month_view = dates_in_month_view + [date_month_end + day + 1]
|
118
|
+
end
|
119
|
+
|
120
|
+
dates_in_month_view
|
121
|
+
end
|
122
|
+
|
123
|
+
def self.weeks_in_months_view_dates(months_view_dates)
|
124
|
+
months_view_dates.length.div 7
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.current_month_start(current_shift_factor, today_date = Date.today)
|
128
|
+
(today_date + (current_shift_factor.to_i).month).beginning_of_month
|
129
|
+
end
|
130
|
+
def self.current_month_end(current_shift_factor, today_date = Date.today)
|
131
|
+
(today_date + (current_shift_factor.to_i).month).end_of_month
|
132
|
+
end
|
133
|
+
|
134
|
+
private
|
135
|
+
|
136
|
+
attr_writer :months_view_dates
|
137
|
+
attr_writer :months_grouped_events
|
138
|
+
attr_writer :months_multiday_events
|
139
|
+
|
140
|
+
attr_writer :delta_start_of_weekday_from_sunday
|
141
|
+
attr_writer :summary_teaser_length
|
142
|
+
|
143
|
+
attr_accessor :calendar_id
|
144
|
+
attr_accessor :api_key
|
145
|
+
|
146
|
+
attr_accessor :google_calendar_base_path
|
147
|
+
attr_accessor :maps_query_host
|
148
|
+
|
149
|
+
end
|
data/raigoocal.gemspec
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "raigoocal/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "raigoocal"
|
8
|
+
spec.version = Raigoocal::VERSION
|
9
|
+
spec.authors = ["Andreas Schau"]
|
10
|
+
spec.email = ["andreas.schau@hicknhack-software.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{This gem provides functionality to handle the loading of event data from a public google calendar via an api key. (Without the need for OAuth.)}
|
13
|
+
spec.description = %q{It does so by offering functions that gather the event data, cache it and structure it in a way that makes it easy to display in an agenda or monthly overview-like style.}
|
14
|
+
spec.homepage = "https://www.hicknhack-software.com/it-events"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
|
22
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
24
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
25
|
+
# else
|
26
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
# "public gem pushes."
|
28
|
+
# end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
40
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
41
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
42
|
+
|
43
|
+
# Library that helps get more functionality that typically comes with rails applications
|
44
|
+
spec.add_development_dependency "activesupport", "~> 5.0", ">= 5.0.0.1"
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: raigoocal
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andreas Schau
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.0'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 5.0.0.1
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '5.0'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 5.0.0.1
|
75
|
+
description: It does so by offering functions that gather the event data, cache it
|
76
|
+
and structure it in a way that makes it easy to display in an agenda or monthly
|
77
|
+
overview-like style.
|
78
|
+
email:
|
79
|
+
- andreas.schau@hicknhack-software.com
|
80
|
+
executables: []
|
81
|
+
extensions: []
|
82
|
+
extra_rdoc_files: []
|
83
|
+
files:
|
84
|
+
- ".gitignore"
|
85
|
+
- ".rspec"
|
86
|
+
- ".travis.yml"
|
87
|
+
- Gemfile
|
88
|
+
- Gemfile.lock
|
89
|
+
- LICENSE.txt
|
90
|
+
- README.md
|
91
|
+
- Rakefile
|
92
|
+
- bin/console
|
93
|
+
- bin/setup
|
94
|
+
- lib/raigoocal.rb
|
95
|
+
- lib/raigoocal/agenda_model.rb
|
96
|
+
- lib/raigoocal/event_loader_model.rb
|
97
|
+
- lib/raigoocal/month_model.rb
|
98
|
+
- lib/raigoocal/version.rb
|
99
|
+
- raigoocal.gemspec
|
100
|
+
homepage: https://www.hicknhack-software.com/it-events
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.7.6
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: This gem provides functionality to handle the loading of event data from
|
124
|
+
a public google calendar via an api key. (Without the need for OAuth.)
|
125
|
+
test_files: []
|