Skip to content

Commit

Permalink
Fix RuboCop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin Howard committed Apr 4, 2019
1 parent 5b6c112 commit 502bb47
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
24 changes: 10 additions & 14 deletions lib/jekyll-compose/file_mover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,17 @@ def move_file
end

def update_front_matter
# from Jekyll::Convertible.read_yaml
begin
content = File.read(from)
data = Psych.safe_load(content)
if content =~ /\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m
content = $POSTMATCH
data = Psych.safe_load($1)
data = movement.front_matter(data)
File.write(from, "#{Psych.dump(data)}---\n#{content}")
end
rescue SyntaxError => e
puts e
rescue Exception => e
puts e
content = File.read(from)
if content =~ %r!\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)!m
content = $POSTMATCH
match = Regexp.last_match[1] if Regexp.last_match
data = movement.front_matter(Psych.safe_load(match))
File.write(from, "#{Psych.dump(data)}---\n#{content}")
end
rescue SyntaxError => e
Jekyll.logger e
rescue StandardError => e
Jekyll.logger e
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll/commands/publish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def to
end

def front_matter(data)
data.merge({ "date" => params.date.strftime("%Y-%m-%d %H:%M %z") })
data.merge("date" => params.date.strftime("%Y-%m-%d %H:%M %z"))
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll/commands/unpublish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def to
end

def front_matter(data)
data.select{ |x| x != "date" }
data.reject { |x| x == "date" }
end
end

Expand Down

0 comments on commit 502bb47

Please sign in to comment.