Skip to content

Commit

Permalink
Appease newest Rubocop (#71)
Browse files Browse the repository at this point in the history
Merge pull request 71
  • Loading branch information
jekyllbot committed Jul 11, 2018
1 parent d95e21d commit 82f2da8
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 60 deletions.
4 changes: 0 additions & 4 deletions .rubocop.yml
Expand Up @@ -27,10 +27,6 @@ Metrics/BlockLength:
Exclude:
- spec/**/*

Style/IndentHeredoc:
Exclude:
- spec/**/*

Style/GlobalVars:
Exclude:
- spec/spec_helper.rb
2 changes: 1 addition & 1 deletion jekyll-compose.gemspec
Expand Up @@ -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
52 changes: 28 additions & 24 deletions 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
34 changes: 19 additions & 15 deletions 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
1 change: 1 addition & 0 deletions lib/jekyll-compose/file_mover.rb
Expand Up @@ -44,6 +44,7 @@ def move_file
end

private

def from
movement.from
end
Expand Down
32 changes: 16 additions & 16 deletions spec/file_info_spec.rb
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down

0 comments on commit 82f2da8

Please sign in to comment.