Skip to content

Commit

Permalink
Lint with rubocop-jekyll
Browse files Browse the repository at this point in the history
  • Loading branch information
DirtyF committed Jul 24, 2018
1 parent ed78511 commit dd0b1fd
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
5 changes: 3 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
require: rubocop-jekyll
inherit_gem:
jekyll: .rubocop.yml
rubocop-jekyll: .rubocop.yml

AllCops:
TargetRubyVersion: 2.1
TargetRubyVersion: 2.3
Include:
- lib/**/*.rb

Expand Down
4 changes: 2 additions & 2 deletions jekyll-watch.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r!^bin/!) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.required_ruby_version = ">= 2.1.0"
spec.required_ruby_version = ">= 2.3.0"

spec.add_runtime_dependency "listen", "~> 3.0"

Expand All @@ -30,5 +30,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "jekyll", "~> 3.6"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rubocop", "~> 0.57.2"
spec.add_development_dependency "rubocop-jekyll", "~> 0.1.0"
end
2 changes: 1 addition & 1 deletion lib/jekyll-watch/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Jekyll
module Watch
VERSION = "2.0.0".freeze
VERSION = "2.0.0"
end
end
1 change: 0 additions & 1 deletion lib/jekyll/commands/watch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def process(options)
Jekyll.logger.log_level = :error if options["quiet"]
Jekyll::Watcher.watch(options) if options["watch"]
end

end
end
end
10 changes: 2 additions & 8 deletions lib/jekyll/watcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def watch(options, site = nil)
end

private

def build_listener(site, options)
Listen.to(
options["source"],
Expand All @@ -50,14 +51,13 @@ def build_listener(site, options)
)
end

private
def listen_handler(site)
proc do |modified, added, removed|
t = Time.now
c = modified + added + removed
n = c.length
Jekyll.logger.info "Regenerating:",
"#{n} file(s) changed at #{t.strftime("%Y-%m-%d %H:%M:%S")}"
"#{n} file(s) changed at #{t.strftime("%Y-%m-%d %H:%M:%S")}"

c.map { |path| path.sub("#{site.source}/", "") }.each do |file|
Jekyll.logger.info "", file
Expand All @@ -67,19 +67,16 @@ def listen_handler(site)
end
end

private
def custom_excludes(options)
Array(options["exclude"]).map { |e| Jekyll.sanitized_path(options["source"], e) }
end

private
def config_files(options)
%w(yml yaml toml).map do |ext|
Jekyll.sanitized_path(options["source"], "_config.#{ext}")
end
end

private
def to_exclude(options)
[
config_files(options),
Expand All @@ -93,7 +90,6 @@ def to_exclude(options)
# options - A Hash of options passed to the command
#
# Returns a list of relative paths from source that should be ignored
private
def listen_ignore_paths(options)
source = Pathname.new(options["source"]).expand_path
paths = to_exclude(options)
Expand All @@ -114,12 +110,10 @@ def listen_ignore_paths(options)
end.compact + [%r!\.jekyll\-metadata!]
end

private
def sleep_forever
loop { sleep 1000 }
end

private
def process(site, time)
begin
site.process
Expand Down

0 comments on commit dd0b1fd

Please sign in to comment.