Rubocop fixes

This commit is contained in:
Nemo 2020-08-17 17:17:24 +05:30
parent b8647994dd
commit c67978fa40
8 changed files with 112 additions and 39 deletions

View File

@ -1,3 +1,5 @@
inherit_from: .rubocop_todo.yml
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-09-17 09:34:31 +0530 using RuboCop version 0.50.0.
@ -14,7 +16,7 @@ Metrics/AbcSize:
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 80
Max: 150
AllowHeredoc: true
AllowURI: true
URISchemes:

65
.rubocop_todo.yml Normal file
View File

@ -0,0 +1,65 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2020-08-17 17:15:37 +0530 using RuboCop version 0.79.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: TreatCommentsAsGroupSeparators, Include.
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
Bundler/OrderedGems:
Exclude:
- 'Gemfile'
# Offense count: 1
# Cop supports --auto-correct.
Layout/EmptyLineAfterMagicComment:
Exclude:
- 'Gemfile'
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 147
# Offense count: 1
Lint/UselessAssignment:
Exclude:
- 'row.rb'
# Offense count: 2
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
Naming/FileName:
Exclude:
- 'wok-reread.rb'
- 'wor-reread.rb'
- 'edgedancer-reread.rb'
- 'oathbringer-reread.rb'
# Offense count: 1
# Configuration parameters: ForbiddenDelimiters.
# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
Naming/HeredocDelimiterNaming:
Exclude:
- 'mythwalker.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'Gemfile'
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 147

View File

@ -1,4 +1,4 @@
# cosmere-books
# cosmere-books ![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/captn3m0/cosmere-books)
![Books in the Cosmere](https://i.imgur.com/NymmBq4.png)

View File

@ -72,7 +72,7 @@ def inside_docker?
File.readlines('/proc/1/sched').each do |line|
return line.strip != 'systemd (1, #threads: 1)'
end
rescue Errno::ENOENT => e
rescue Errno::ENOENT
false
end

View File

@ -10,45 +10,53 @@ FileUtils.mkdir_p('mythwalker')
BASE = 'https://brandonsanderson.com'
links = [
"/warbreaker-prime-mythwalker-prologue/",
"/warbreaker-prime-mythwalker-chapter-one/",
"/warbreaker-prime-mythwalker-chapter-two/",
"/warbreaker-prime-mythwalker-chapter-three/",
"/warbreaker-prime-mythwalker-chapter-four/",
"/warbreaker-prime-mythwalker-chapter-five/",
"/warbreaker-prime-mythwalker-chapter-six/",
"/warbreaker-prime-mythwalker-chapter-seven/",
"/warbreaker-prime-mythwalker-chapter-eight/",
"/warbreaker-prime-mythwalker-chapter-nine/",
"/warbreaker-prime-mythwalker-chapter-ten/",
"/warbreaker-prime-mythwalker-chapter-eleven/",
"/warbreaker-prime-mythwalker-chapter-twelve/",
"/warbreaker-prime-mythwalker-chapter-thirteen/",
"/warbreaker-prime-mythwalker-chapter-fourteen/",
"/warbreaker-prime-mythwalker-chapter-fifteen/",
"/warbreaker-prime-mythwalker-chapter-sixteen/",
"/warbreaker-prime-mythwalker-chapter-seventeen/",
"/warbreaker-prime-mythwalker-chapter-eighteen/",
"/warbreaker-prime-mythwalker-chapter-nineteen/",
"/warbreaker-prime-mythwalker-chapter-twenty/",
"/warbreaker-prime-mythwalker-chapter-twenty-one/",
"/warbreaker-prime-mythwalker-chapter-twenty-two/",
"/warbreaker-deleted-scenes-mab-the-cook/",
'/warbreaker-prime-mythwalker-prologue/',
'/warbreaker-prime-mythwalker-chapter-one/',
'/warbreaker-prime-mythwalker-chapter-two/',
'/warbreaker-prime-mythwalker-chapter-three/',
'/warbreaker-prime-mythwalker-chapter-four/',
'/warbreaker-prime-mythwalker-chapter-five/',
'/warbreaker-prime-mythwalker-chapter-six/',
'/warbreaker-prime-mythwalker-chapter-seven/',
'/warbreaker-prime-mythwalker-chapter-eight/',
'/warbreaker-prime-mythwalker-chapter-nine/',
'/warbreaker-prime-mythwalker-chapter-ten/',
'/warbreaker-prime-mythwalker-chapter-eleven/',
'/warbreaker-prime-mythwalker-chapter-twelve/',
'/warbreaker-prime-mythwalker-chapter-thirteen/',
'/warbreaker-prime-mythwalker-chapter-fourteen/',
'/warbreaker-prime-mythwalker-chapter-fifteen/',
'/warbreaker-prime-mythwalker-chapter-sixteen/',
'/warbreaker-prime-mythwalker-chapter-seventeen/',
'/warbreaker-prime-mythwalker-chapter-eighteen/',
'/warbreaker-prime-mythwalker-chapter-nineteen/',
'/warbreaker-prime-mythwalker-chapter-twenty/',
'/warbreaker-prime-mythwalker-chapter-twenty-one/',
'/warbreaker-prime-mythwalker-chapter-twenty-two/',
'/warbreaker-deleted-scenes-mab-the-cook/'
]
titles = ["Prologue"] + (1..22).map{|x| "Chapter #{x}"} + ["Deleted Scenes: Mab the Cook"]
titles = ['Prologue'] +
(1..22).map { |x| "Chapter #{x}" } +
['Deleted Scenes: Mab the Cook']
episode=1
episode = 1
links.each do |link|
url = BASE + link
puts "Download #{url}"
unless File.exist? "mythwalker/#{episode}.html"
`wget --no-clobber "#{url}" --output-document "mythwalker/#{episode}.html" -o /dev/null`
end
episode+=1
episode += 1
end
html = '<html lang=en><head><title>Warbreaker Prime: Mythwalker</title></head><body>'
html = <<~EOT
<html lang=en>
<head>
<title>Warbreaker Prime: Mythwalker</title>
</head>
<body>
EOT
(1..(links.length)).each do |i|
complete_html = Nokogiri::HTML(open("mythwalker/#{i}.html"))

View File

@ -105,8 +105,7 @@ links = [
'/2019/11/21/oathbringer-reread-chapter-one-hundred-six/',
'/2019/12/05/oathbringer-reread-chapter-one-hundred-and-seven/',
'/2019/12/12/oathbringer-reread-chapter-one-hundred-eight/',
'/2019/12/19/oathbringer-reread-chapter-one-hundred-and-nine/'
'/2020/01/09/oathbringer-reread-chapter-one-hundred-ten/',
'/2019/12/19/oathbringer-reread-chapter-one-hundred-and-nine/',
'/2020/01/09/oathbringer-reread-chapter-one-hundred-ten/',
'/2020/01/23/oathbringer-reread-chapter-one-hundred-and-twelve-one-hundred-and-thirteen-and-venli-interlude/',
'/2020/01/30/oathbringer-reread-rysn-and-teft-interludes-thirteen-and-fourteen/',
@ -115,11 +114,11 @@ links = [
'/2020/02/27/oathbringer-reread-chapter-one-hundred-seventeen/',
'/2020/03/05/oathbringer-reread-chapter-one-hundred-eighteen/',
'/2020/03/12/oathbringer-reread-chapter-one-hundred-nineteen/',
'/2020/03/19/oathbringer-reread-chapter-one-hundred-twenty-part-1/'
'/2020/03/19/oathbringer-reread-chapter-one-hundred-twenty-part-1/',
'/2020/03/26/oathbringer-reread-chapter-one-hundred-twenty-part-two/',
'/2020/04/02/oathbringer-reread-chapter-one-hundred-twenty-one/',
'/2020/04/09/oathbringer-reread-chapter-one-hundred-twenty-two/',
'/2020/04/16/oathbringer-reread-epilogue-and-ars-arcanum/',
'/2020/04/16/oathbringer-reread-epilogue-and-ars-arcanum/'
]
episode = 1

3
row.rb
View File

@ -25,6 +25,7 @@ loop do
day = links.last.split('/')[1]
next_date = Date.new(2020, month.to_i, day.to_i) + 7
break if next_date > Date.today
ending_chapter = [chapter + 2, 32].min
links << "#{next_date.strftime('%m')}/#{next_date.strftime('%d')}/read-rhythm-of-war-by-brandon-sanderson-chapters-#{chapter}-#{ending_chapter}/"
chapter += 3
@ -45,7 +46,7 @@ end
# Now we have all the files
html = ''
for i in 1..(links.length)
(1..(links.length)).each do |i|
page = Nokogiri::HTML(open("row/#{i}.html")).css('.entry-content')
start = ending = false
page.children.each do |e|

View File

@ -16,9 +16,7 @@ episode = 1
links.each do |link|
url = BASE + link
puts "Download #{url}"
unless File.exist? "skyward/#{episode}.html"
`curl --silent "#{url}" --output "skyward/#{episode}.html"`
end
`curl --silent "#{url}" --output "skyward/#{episode}.html"` unless File.exist? "skyward/#{episode}.html"
episode += 1
end