From 4c1cdc8ab8d34852ffa56903b5a6db15fc6b9bfd Mon Sep 17 00:00:00 2001 From: Will Binns Date: Sat, 12 Jan 2019 06:41:41 -0600 Subject: [PATCH] rubocop: Resolve indentation inconsistencies --- .rubocop_todo.yml | 10 ---- _build/txpreview/addlang.rb | 4 +- _contrib/comparelinks.rb | 104 ++++++++++++++++++------------------ _plugins/events.rb | 2 +- 4 files changed, 55 insertions(+), 65 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9404ac8f..dacd1eca 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,16 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 56 -# Cop supports --auto-correct. -# Configuration parameters: IndentationWidth. -Layout/Tab: - Exclude: - - '_build/txpreview/addlang.rb' - - '_contrib/comparelinks.rb' - - '_plugins/events.rb' - - '_plugins/sitemap.rb' - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: AllowInHeredoc. diff --git a/_build/txpreview/addlang.rb b/_build/txpreview/addlang.rb index fdc201b7..9d72dfbf 100644 --- a/_build/txpreview/addlang.rb +++ b/_build/txpreview/addlang.rb @@ -14,8 +14,8 @@ end contents = File.read(PATH + '/_config.yml') if Regexp.new('langsorder:.*?' + "\n" + '- \'' + la + '\'' + "\n", Regexp::MULTILINE).match(contents).nil? - contents.gsub!(Regexp.new("(langsorder:.*?)\n\n", Regexp::MULTILINE), '\1' + "\n" + '- \'' + la + '\'' + "\n\n") - contents.gsub!(Regexp.new("(langs:.*?)\n\n", Regexp::MULTILINE), '\1' + "\n" + ' \'' + la + '\': \'' + la + '\'' + "\n\n") + contents.gsub!(Regexp.new("(langsorder:.*?)\n\n", Regexp::MULTILINE), '\1' + "\n" + '- \'' + la + '\'' + "\n\n") + contents.gsub!(Regexp.new("(langs:.*?)\n\n", Regexp::MULTILINE), '\1' + "\n" + ' \'' + la + '\': \'' + la + '\'' + "\n\n") end File.open(PATH + '/_config.yml', 'w') do |file| diff --git a/_contrib/comparelinks.rb b/_contrib/comparelinks.rb index 5ed20af7..a4318f8c 100644 --- a/_contrib/comparelinks.rb +++ b/_contrib/comparelinks.rb @@ -27,69 +27,69 @@ if !File.exist?('_config.yml') end def fetchlinks() - # Fetch new list of links - links = {} - dirs = Dir.glob(WORKDIR + "/_site/**/*.html").each { |file| - content = File.read(file) - content.scan(/ href *= *"(.*?)"/).each { |link| - link = link[0].to_s.gsub(/^(https?:\/\/(www\.)?bitcoin\.org)?\//, '/') - next if (link.match(/^#|^http:\/\/www.meetup.com\//)) + # Fetch new list of links + links = {} + dirs = Dir.glob(WORKDIR + "/_site/**/*.html").each { |file| + content = File.read(file) + content.scan(/ href *= *"(.*?)"/).each { |link| + link = link[0].to_s.gsub(/^(https?:\/\/(www\.)?bitcoin\.org)?\//, '/') + next if (link.match(/^#|^http:\/\/www.meetup.com\//)) - if (!link.match(/^https?:\/\/|^\/[^\/]|^mailto:/)) - link = File.dirname(file.sub(WORKDIR + '/_site', '')) + '/' + File.basename(link) - end - links[link] = "0" - } - content.scan(/ src *= *"(.*?)"/).each { |link| - link = link[0].to_s.gsub(/^(https?:\/\/(www\.)?bitcoin\.org)?\//, '/') - links[link] = "0" - } - } + if (!link.match(/^https?:\/\/|^\/[^\/]|^mailto:/)) + link = File.dirname(file.sub(WORKDIR + '/_site', '')) + '/' + File.basename(link) + end + links[link] = "0" + } + content.scan(/ src *= *"(.*?)"/).each { |link| + link = link[0].to_s.gsub(/^(https?:\/\/(www\.)?bitcoin\.org)?\//, '/') + links[link] = "0" + } + } - return links + return links end Dir.mktmpdir { |workdir| - WORKDIR = workdir.gsub("\n", '') + WORKDIR = workdir.gsub("\n", '') - # Copy current repository to a temporary directory - `rsync -a ./ "#{WORKDIR}/"` + # Copy current repository to a temporary directory + `rsync -a ./ "#{WORKDIR}/"` - # Build both version of the website and fetch all links - oldlinks = {} - newlinks = {} + # Build both version of the website and fetch all links + oldlinks = {} + newlinks = {} - Dir.chdir(WORKDIR) do - `git checkout #{srcbr}` - `jekyll` - oldlinks = fetchlinks() + Dir.chdir(WORKDIR) do + `git checkout #{srcbr}` + `jekyll` + oldlinks = fetchlinks() - `git checkout #{dstbr}` - `jekyll` - newlinks = fetchlinks() - end + `git checkout #{dstbr}` + `jekyll` + newlinks = fetchlinks() + end - # Find added links, removed links - diffaddlinks = [] - diffrmlinks = [] - newlinks.each { |link, etag| - next if oldlinks.has_key?(link) + # Find added links, removed links + diffaddlinks = [] + diffrmlinks = [] + newlinks.each { |link, etag| + next if oldlinks.has_key?(link) - diffaddlinks.push(link) - } - oldlinks.each { |link, etag| - next if newlinks.has_key?(link) + diffaddlinks.push(link) + } + oldlinks.each { |link, etag| + next if newlinks.has_key?(link) - diffrmlinks.push(link) - } + diffrmlinks.push(link) + } - # Display resulting diff - diff = '' - if diffaddlinks.length > 0 - diff = diff + "## links added\n\n" + diffaddlinks.join("\n") + "\n\n" - end - if diffrmlinks.length > 0 - diff = diff + "## links removed\n\n" + diffrmlinks.join("\n") + "\n\n" - end - print diff + # Display resulting diff + diff = '' + if diffaddlinks.length > 0 + diff = diff + "## links added\n\n" + diffaddlinks.join("\n") + "\n\n" + end + if diffrmlinks.length > 0 + diff = diff + "## links removed\n\n" + diffrmlinks.join("\n") + "\n\n" + end + print diff } diff --git a/_plugins/events.rb b/_plugins/events.rb index 10d8fc6c..1d9391fb 100644 --- a/_plugins/events.rb +++ b/_plugins/events.rb @@ -19,7 +19,7 @@ module Jekyll # Loop in _events.yml YAML.load_file('_events.yml').each do |data| # Skip event if it has started more than five days ago - date = data['date'].to_s.split('-') + date = data['date'].to_s.split('-') next if Time.new.to_i > (Time.new(date[0].to_i, date[1].to_i, date[2].to_i).to_i + 432000) # Get geolocalisation data from Google Maps