Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appease newest Rubocop #71

Merged
merged 3 commits into from Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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