Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ my_calendar_name:
operator: matches # match against regex pattern
val: # array of values also supported
- '/Team A/i'
- field: blocking # blocking (TRANSP) field supported
operator: equals
val: true # true will filter out non-blocking events
alarms: # (optional) create/clear alarms for filtered events
clear_existing: true # (optional) if true, existing alarms will be removed, default: false
triggers: # (optional) triggers for new alarms. Description will be the alarm summary, action is 'DISPLAY'
Expand Down
3 changes: 3 additions & 0 deletions config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ rota:
- field: start_time
operator: equals
val: '09:00'
- field: blocking
operator: equals
val: true
alarms:
clear_existing: true
triggers:
Expand Down
5 changes: 5 additions & 0 deletions lib/ical_filter_proxy/filterable_event_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def end_components
@end_components ||= DateComponents.new(dtend, options[:timezone])
end

# extract and rename TRANSP field to something more obvious
def blocking
raw_event.transp == 'OPAQUE' || raw_event.transp.nil?
end

def method_missing(method_sym, *args, &block)
if method_sym.to_s =~ /(start|end)\_(\w+)/
components = self.send("#{$1}_components")
Expand Down
20 changes: 20 additions & 0 deletions spec/filterable_event_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,24 @@
expect(adapter.end_date).to eq('2017-06-30')
end
end

describe '#blocking' do
it 'returns true if transp is OPAQUE' do
test_event.transp = 'OPAQUE'
adapter = described_class.new(test_event)
expect(adapter.blocking).to be true
end

it 'returns false if transp is TRANSPARENT' do
test_event.transp = 'TRANSPARENT'
adapter = described_class.new(test_event)
expect(adapter.blocking).to be false
end

it 'returns true if transp is nil (default)' do
test_event.transp = nil
adapter = described_class.new(test_event)
expect(adapter.blocking).to be true
end
end
end
Loading