class Jekyll::Commands::RenameArgParser

Public Instance Methods

basename() click to toggle source
# File lib/jekyll/commands/rename.rb, line 59
def basename
  @basename ||= File.basename(current_path)
end
current_path() click to toggle source
# File lib/jekyll/commands/rename.rb, line 47
def current_path
  @current_path ||= args[0]
end
date() click to toggle source
# File lib/jekyll/commands/rename.rb, line 71
def date
  @date ||= if options["now"]
              Time.now
            elsif options["date"]
              Date.parse(options["date"])
            end
end
date_from_filename() click to toggle source
# File lib/jekyll/commands/rename.rb, line 79
def date_from_filename
  Date.parse(Regexp.last_match(1)) if basename =~ Jekyll::Document::DATE_FILENAME_MATCHER
end
dirname() click to toggle source
# File lib/jekyll/commands/rename.rb, line 55
def dirname
  @dirname ||= File.dirname(current_path)
end
draft?() click to toggle source
# File lib/jekyll/commands/rename.rb, line 87
def draft?
  dirname == "_drafts"
end
path() click to toggle source
# File lib/jekyll/commands/rename.rb, line 51
def path
  File.join(source, current_path).sub(%r!\A/!, "")
end
post?() click to toggle source
# File lib/jekyll/commands/rename.rb, line 83
def post?
  dirname == "_posts"
end
title() click to toggle source
# File lib/jekyll/commands/rename.rb, line 63
def title
  @title ||= args.drop(1).join(" ")
end
touch?() click to toggle source
# File lib/jekyll/commands/rename.rb, line 67
def touch?
  !!options["date"] || options["now"]
end
validate!() click to toggle source
# File lib/jekyll/commands/rename.rb, line 39
def validate!
  raise ArgumentError, "You must specify current path and the new title." if args.length < 2

  if options.values_at("date", "now").compact.length > 1
    raise ArgumentError, "You can only specify one of --date DATE or --now."
  end
end