Skip to content

Commit

Permalink
Merge pull request #1188 from pooza/dev/3.6.11
Browse files Browse the repository at this point in the history
3.6.11
  • Loading branch information
pooza authored Sep 3, 2024
2 parents 4ee8476 + 460496b commit 20bca11
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 37 deletions.
59 changes: 28 additions & 31 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,24 @@ GIT
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.3.4)
activesupport (7.2.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.8)
cgi (0.4.1)
concurrent-ruby (1.3.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
csv (3.3.0)
Expand All @@ -78,11 +79,11 @@ GEM
sax-machine (>= 1.0, < 2)
fileutils (1.7.2)
find (0.2.0)
fugit (1.11.0)
fugit (1.11.1)
et-orbi (~> 1, >= 1.2.11)
raabro (~> 1.4)
http-accept (1.7.0)
http-cookie (1.0.6)
http-cookie (1.0.7)
domain_name (~> 0.5)
httparty (0.22.0)
csv
Expand All @@ -98,9 +99,10 @@ GEM
ice_cube (>= 0.16)
ice_cube (0.17.0)
json (2.7.2)
json-schema (4.3.1)
addressable (>= 2.8)
json-schema (5.0.0)
addressable (~> 2.8)
language_server-protocol (3.17.0.3)
logger (1.6.1)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
Expand All @@ -111,15 +113,14 @@ GEM
net-smtp
mime-types (3.5.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0702)
mime-types-data (3.2024.0820)
mini_mime (1.1.5)
mini_portile2 (2.8.7)
minitest (5.24.1)
minitest (5.25.1)
multi_json (1.15.0)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
mutex_m (0.2.0)
net-imap (0.4.14)
net-imap (0.4.15)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -137,8 +138,8 @@ GEM
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
optparse (0.5.0)
parallel (1.25.1)
parser (3.3.4.0)
parallel (1.26.3)
parser (3.3.4.2)
ast (~> 2.4.1)
racc
power_assert (2.0.3)
Expand All @@ -153,23 +154,20 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.3.4)
strscan
ricecream (0.2.1)
rubocop (1.65.1)
rubocop (1.66.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-ast (>= 1.32.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
rubocop-ast (1.32.2)
parser (>= 3.3.1.0)
rubocop-minitest (0.35.1)
rubocop-minitest (0.36.0)
rubocop (>= 1.61, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-performance (1.21.1)
Expand All @@ -182,19 +180,18 @@ GEM
ruby-progressbar (1.13.0)
rufus-scheduler (3.9.1)
fugit (~> 1.1, >= 1.1.6)
sanitize (6.1.2)
sanitize (6.1.3)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
sax-machine (1.3.2)
securerandom (0.3.1)
sequel (5.83.0)
sequel (5.84.0)
bigdecimal
set (1.1.0)
sqlite3 (2.0.3)
sqlite3 (2.0.4)
mini_portile2 (~> 2.8.0)
sqlite3 (2.0.3-aarch64-linux-gnu)
sqlite3 (2.0.3-x86_64-linux-gnu)
strscan (3.1.0)
sqlite3 (2.0.4-aarch64-linux-gnu)
sqlite3 (2.0.4-x86_64-linux-gnu)
syslog (0.1.2)
test-unit (3.6.2)
power_assert
Expand All @@ -205,12 +202,12 @@ GEM
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
yajl-ruby (1.4.3)
zeitwerk (2.6.17)
zeitwerk (2.6.18)
zlib (3.1.1)

PLATFORMS
aarch64-linux
x86_64-freebsd-13
x86_64-freebsd-14
x86_64-linux

DEPENDENCIES
Expand All @@ -235,4 +232,4 @@ RUBY VERSION
ruby 3.3.4p94

BUNDLED WITH
2.5.16
2.5.18
15 changes: 14 additions & 1 deletion app/lib/tomato_shrieker/source.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'digest/sha1'

module TomatoShrieker
class Source
class Source # rubocop:disable Metrics/ClassLength
include Package

def initialize(params)
Expand Down Expand Up @@ -40,6 +40,15 @@ def disable?
return self['/disable'] == true
end

def sanitize_mode
return :fedi if self['/dest/sanitize'].nil?
return self['/dest/sanitize'].to_sym
end

def fedi_sanitize?
return sanitize_mode == :fedi
end

def mulukhiya?
return self['/dest/mulukhiya/enable'] == true
end
Expand Down Expand Up @@ -245,5 +254,9 @@ def self.classes
def self.create(id)
return all.find {|v| v.id == id}
end

def fedi_sanitize(message)
return fedi_sanitize? ? message.to_s.sanitize_status : message.to_s.sanitize
end
end
end
2 changes: 1 addition & 1 deletion app/lib/tomato_shrieker/source/feed_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def entries(&block)
return enum_for(__method__) unless block
feedjira.entries
.sort_by {|entry| entry.published.to_f}
.each {|entry| entry.title = entry.title&.sanitize_status}
.each {|entry| entry.title = fedi_sanitize(entry.title)}
.each(&block)
end

Expand Down
6 changes: 3 additions & 3 deletions app/lib/tomato_shrieker/source/icalendar_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def create_entry(event)
start_date:,
end_date:,
is_today: today?(start_date, end_date),
title: event.summary&.sanitize,
body: event.description&.sanitize,
location: event.location&.sanitize_status,
title: fedi_sanitize(event.summary),
body: fedi_sanitize(event.description),
location: fedi_sanitize(event.location),
all_day: event.dtstart.is_a?(Icalendar::Values::Date),
}
end
Expand Down
2 changes: 1 addition & 1 deletion config/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ package:
- [email protected]
license: MIT
url: https://github.com/pooza/tomato-shrieker
version: 3.6.10
version: 3.6.11
ruby:
jit: false
scheduler:
Expand Down
12 changes: 12 additions & 0 deletions test/icalencar_source.rb → test/icalendar_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ def test_negative_keyword
end
end

def test_sanitize_mode
IcalendarSource.all.each do |source|
assert(source.sanitize_mode == :fedi || source.sanitize_mode == :html)
end
end

def test_fedi_sanitize?
IcalendarSource.all.each do |source|
assert_kind_of([TrueClass, FalseClass], source.fedi_sanitize?)
end
end

def test_create_entry
source = %{<a href="https://shonenjumpplus.com/episode/17106371859967525169">https://shonenjumpplus.com/episode/17106371859967525169</a><br>感想には是非、以下のタグをどうぞ!<br>#勇者アバン_42話<br>#勇者アバン_11巻 (11巻2話目にあたります)<br><br>#delmulin #更新}
sanitized = %{https://shonenjumpplus.com/episode/17106371859967525169\n感想には是非、以下のタグをどうぞ!\n#勇者アバン_42話\n#勇者アバン_11巻 (11巻2話目にあたります)\n\n#delmulin #更新}
Expand Down

0 comments on commit 20bca11

Please sign in to comment.