Class: Jekyll::Commands::RenameArgParser
Instance Attribute Summary
#args, #config, #options
Instance Method Summary
collapse
#force?, #initialize, #layout, #source, #timestamp_format, #type
Instance Method Details
#basename ⇒ Object
59
60
61
|
# File 'lib/jekyll/commands/rename.rb', line 59
def basename
@basename ||= File.basename(current_path)
end
|
#current_path ⇒ Object
47
48
49
|
# File 'lib/jekyll/commands/rename.rb', line 47
def current_path
@current_path ||= args[0]
end
|
#date ⇒ Object
71
72
73
74
75
76
77
|
# 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 ⇒ Object
79
80
81
|
# 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 ⇒ Object
55
56
57
|
# File 'lib/jekyll/commands/rename.rb', line 55
def dirname
@dirname ||= File.dirname(current_path)
end
|
#draft? ⇒ Boolean
87
88
89
|
# File 'lib/jekyll/commands/rename.rb', line 87
def draft?
dirname == "_drafts"
end
|
#path ⇒ Object
51
52
53
|
# File 'lib/jekyll/commands/rename.rb', line 51
def path
File.join(source, current_path).sub(%r!\A/!, "")
end
|
#post? ⇒ Boolean
83
84
85
|
# File 'lib/jekyll/commands/rename.rb', line 83
def post?
dirname == "_posts"
end
|
#title ⇒ Object
63
64
65
|
# File 'lib/jekyll/commands/rename.rb', line 63
def title
@title ||= args.drop(1).join(" ")
end
|
#touch? ⇒ Boolean
67
68
69
|
# File 'lib/jekyll/commands/rename.rb', line 67
def touch?
!!options["date"] || options["now"]
end
|
#validate! ⇒ Object
39
40
41
42
43
44
45
|
# 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
|