diff --git a/.rubocop.yml b/.rubocop.yml index 3d658ee..d25e249 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -27,10 +27,6 @@ Metrics/BlockLength: Exclude: - spec/**/* -Style/IndentHeredoc: - Exclude: - - spec/**/* - Style/GlobalVars: Exclude: - spec/spec_helper.rb diff --git a/jekyll-compose.gemspec b/jekyll-compose.gemspec index e8442f0..3bdc43e 100644 --- a/jekyll-compose.gemspec +++ b/jekyll-compose.gemspec @@ -25,5 +25,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "bundler", "~> 1.5" spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "rspec", "~> 3.0" - spec.add_development_dependency "rubocop", "~> 0.55" + spec.add_development_dependency "rubocop", "~> 0.57.2" end diff --git a/lib/jekyll-compose/arg_parser.rb b/lib/jekyll-compose/arg_parser.rb index e42ee5c..6e0b3e2 100644 --- a/lib/jekyll-compose/arg_parser.rb +++ b/lib/jekyll-compose/arg_parser.rb @@ -1,34 +1,38 @@ # frozen_string_literal: true -class Jekyll::Compose::ArgParser - attr_reader :args, :options, :config - def initialize(args, options) - @args = args - @options = options - @config = Jekyll.configuration(options) - end +module Jekyll + module Compose + class ArgParser + attr_reader :args, :options, :config + def initialize(args, options) + @args = args + @options = options + @config = Jekyll.configuration(options) + end - def validate! - raise ArgumentError, "You must specify a name." if args.empty? - end + def validate! + raise ArgumentError, "You must specify a name." if args.empty? + end - def type - options["extension"] || Jekyll::Compose::DEFAULT_TYPE - end + def type + options["extension"] || Jekyll::Compose::DEFAULT_TYPE + end - def layout - options["layout"] || Jekyll::Compose::DEFAULT_LAYOUT - end + def layout + options["layout"] || Jekyll::Compose::DEFAULT_LAYOUT + end - def title - args.join " " - end + def title + args.join " " + end - def force? - !!options["force"] - end + def force? + !!options["force"] + end - def source - config["source"].gsub(%r!^#{Regexp.quote(Dir.pwd)}!, "") + def source + config["source"].gsub(%r!^#{Regexp.quote(Dir.pwd)}!, "") + end + end end end diff --git a/lib/jekyll-compose/file_info.rb b/lib/jekyll-compose/file_info.rb index 71fdbb3..974ff94 100644 --- a/lib/jekyll-compose/file_info.rb +++ b/lib/jekyll-compose/file_info.rb @@ -1,22 +1,26 @@ # frozen_string_literal: true -class Jekyll::Compose::FileInfo - attr_reader :params - def initialize(params) - @params = params - end +module Jekyll + module Compose + class FileInfo + attr_reader :params + def initialize(params) + @params = params + end - def file_name - name = Jekyll::Utils.slugify params.title - "#{name}.#{params.type}" - end + def file_name + name = Jekyll::Utils.slugify params.title + "#{name}.#{params.type}" + end - def content(custom_front_matter = {}) - front_matter = YAML.dump({ - "layout" => params.layout, - "title" => params.title, - }.merge(custom_front_matter)) + def content(custom_front_matter = {}) + front_matter = YAML.dump({ + "layout" => params.layout, + "title" => params.title, + }.merge(custom_front_matter)) - front_matter + "---\n" + front_matter + "---\n" + end + end end end diff --git a/lib/jekyll-compose/file_mover.rb b/lib/jekyll-compose/file_mover.rb index 8c28b57..2c26414 100644 --- a/lib/jekyll-compose/file_mover.rb +++ b/lib/jekyll-compose/file_mover.rb @@ -44,6 +44,7 @@ def move_file end private + def from movement.from end diff --git a/spec/file_info_spec.rb b/spec/file_info_spec.rb index f2f7fd9..1fd07b8 100644 --- a/spec/file_info_spec.rb +++ b/spec/file_info_spec.rb @@ -9,11 +9,11 @@ describe "#content" do context "with a title of only words" do let(:expected_result) do - <<-CONTENT.gsub(%r!^\s+!, "") - --- - layout: post - title: A test arg parser - --- + <<~CONTENT + --- + layout: post + title: A test arg parser + --- CONTENT end @@ -32,11 +32,11 @@ context "with a title that includes a colon" do let(:expected_result) do - <<-CONTENT.gsub(%r!^\s+!, "") - --- - layout: post - title: 'A test: arg parser' - --- + <<~CONTENT + --- + layout: post + title: 'A test: arg parser' + --- CONTENT end @@ -55,12 +55,12 @@ context "with custom values" do let(:expected_result) do - <<-CONTENT.gsub(%r!^\s+!, "") - --- - layout: post - title: A test - foo: bar - --- + <<~CONTENT + --- + layout: post + title: A test + foo: bar + --- CONTENT end