Skip to content

Commit 8f4715e

Browse files
committed
fix RuboCop
1 parent d332fa2 commit 8f4715e

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

exe/jekyll-import

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Mercenary.program(:jekyll_import) do |p|
2121
p.action do |args, _|
2222
if args.empty?
2323
Jekyll.logger.error "An importer subcommand is required."
24-
puts p
24+
Jekyll.logger.info p
2525
abort
2626
else
2727
subcommand = args.first

lib/jekyll-import/importers/pebble.rb

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: false
2+
13
module JekyllImport
24
module Importers
35
class Pebble < Importer
@@ -8,34 +10,32 @@ def self.require_deps
810
))
911
end
1012

11-
def self.specify_options(c)
13+
def self.specify_options(c)
1214
c.option "directory", "--directory PATH", "Pebble source directory"
1315
end
1416

1517
def self.process(opts)
16-
options = {
17-
directory: opts.fetch("directory", "")
18-
}
18+
options = { directory => opts.fetch("directory", "") }
1919

2020
FileUtils.mkdir_p("_posts")
2121
FileUtils.mkdir_p("_drafts")
2222

2323
traverse_posts_within(options[:directory]) do |file|
24-
next if file.end_with?('categories.xml')
24+
next if file.end_with?("categories.xml")
25+
2526
process_file(file)
2627
end
2728
end
2829

29-
def self.traverse_posts_within(directory, &block)
30+
def self.traverse_posts_within(directory, &block)
3031
Dir.foreach(directory) do |fd|
3132
path = File.join(directory, fd)
32-
if fd == '.' || fd == '..'
33+
if fd.include?(".") || fd.include?("..")
3334
next
34-
elsif File.directory?(path)
35+
elsif File.directory?(path)
3536
traverse_posts_within(path, &block)
36-
elsif path.end_with?('xml')
37+
elsif path.end_with?("xml")
3738
yield(path) if block_given?
38-
else
3939
end
4040
end
4141
end
@@ -46,17 +46,17 @@ def self.process_file(file)
4646

4747
doc = xml.xpath("blogEntry")
4848

49-
title = kebabize(doc.xpath('title').text).gsub('_', '-')
50-
date = Date.parse(doc.xpath('date').text)
49+
title = kebabize(doc.xpath("title").text).tr("_", "-")
50+
date = Date.parse(doc.xpath("date").text)
5151

5252
directory = "_posts"
53-
name = "#{date.strftime('%Y-%m-%d')}-#{title}"
53+
name = "#{date.strftime("%Y-%m-%d")}-#{title}"
5454

5555
header = {
56-
"layout" => 'post',
57-
"title" => doc.xpath("title").text,
58-
"tags" => doc.xpath("tags").text.split(", "),
59-
"categories" => doc.xpath('category').text.split(', ')
56+
"layout" => "post",
57+
"title" => doc.xpath("title").text,
58+
"tags" => doc.xpath("tags").text.split(", "),
59+
"categories" => doc.xpath("category").text.split(", "),
6060
}
6161
header["render_with_liquid"] = false
6262

@@ -71,17 +71,17 @@ def self.process_file(file)
7171
end
7272

7373
def self.kebabize(string)
74-
kebab = '-'.freeze
75-
string.gsub!(/[^\w\-_]+/, kebab)
74+
kebab = "-".freeze
75+
string.gsub!(%r![^\w\-_]+!, kebab)
7676

7777
unless kebab.nil? || kebab.empty?
7878
if kebab == "-".freeze
79-
re_duplicate_kebab = /-{2,}/
80-
re_leading_trailing_kebab = /^-|-$/
79+
re_duplicate_kebab = %r!-{2,}!
80+
re_leading_trailing_kebab = %r!^-|-$!
8181
else
8282
re_sep = Regexp.escape(kebab)
83-
re_duplicate_kebab = /#{re_sep}{2,}/
84-
re_leading_trailing_kebab = /^#{re_sep}|#{re_sep}$/
83+
re_duplicate_kebab = %r!#{re_sep}{2,}!
84+
re_leading_trailing_kebab = %r!^#{re_sep}|#{re_sep}$!
8585
end
8686
# No more than one of the kebab in a row.
8787
string.gsub!(re_duplicate_kebab, kebab)

0 commit comments

Comments
 (0)