New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URI.regexp 書き直し #355
URI.regexp 書き直し #355
Conversation
Ruby 2.2 の頃より URI.regexp は obsolete のようです。 https://docs.ruby-lang.org/ja/2.2.0/class/URI.html#S_REGEXP
@@ -89,7 +89,7 @@ def self.get_novel_section_save_dir(archive_path) | |||
# | |||
def self.get_target_type(target) | |||
case target | |||
when URI.regexp | |||
when /^[Hh][Tt][Tt][Pp][Ss]?:\/\// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[RuboCop] Use %r
around regular expression. (see on Sider)
Rule | Severity |
---|---|
Style/RegexpLiteral |
convention |
References:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@topstone
確かにこの場所に関してだけは http:// か https:// で始まってるかを確認すればいいですね
%r!¥Ahttps?://!i
でいい気もしますけど
(動作確認はしてない)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
私が出す PRs は「とりあえずこれで修正されるように見えるよ」というものなので、よりよい表記があったらそちらに直して下さい。(正規表現は、自分が GAWK の頃から使っているものしか覚えていないので…。)
ここの修正については、rubocop --safe-auto-correct
で自動修正されるように見えます。なお、rubocop の bug っぽいものを見つけたので、自動修正もあまりあてにしてはいけなそうです。
すみません、rubocop 通っていませんでした。一旦 close して、また後日 PR 出します。 |
現状報告です。
|
ほお〜 |
Ruby 2.7では動かないと注釈しているにも関わらず、2.7 で動かないと不具合報告してくる人が現れてきてしまったので、 |
とりあえず、narou.gemspec の中で 私の手元で勝手に (上記の形の) narou-3.4.9.gem を build して Ruby 2.7 で導入しようとしたら、ちゃんと …と私が書いているうちに、narou 3.5.0 化が進んでいましたね。失礼しました。 |
というエラーがでてしまったのですが、という報告がくるだけに一票 narou 3.5.0 を gem push したのでご確認ください |
narou 3.5.0 ありがとうございます。 rubocop に出した bug report は、patch が作られて master に取り込まれましたが、rubocop 0.80.0 には間に合わなかったようです。 次回 rubocop が release されたら、よければ |
続き : #360 |
Ruby 2.2 の頃より
URI.regexp
は obsolete のようです。一応現状でも動きますが、いずれ単なる obsolete から error になるのではないかと思います。とりあえず downloader.rb だけ書き直し、RSpec が all green になることを確認しました。他にも以下の2か所に残っています (手を付けていません)。
data.gsub!(URI.regexp(%w(http https))) do |match|
if url =~ URI.regexp