-
Notifications
You must be signed in to change notification settings - Fork 0
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
Rake task の desc に長文入れると rake --tasks
時に省略されるのはまぁわかるが、 !
を入れるとそこも消される
#100
Comments
# Describes the next rake task. Duplicate descriptions are discarded.
# Descriptions are shown with <code>rake -T</code> (up to the first
# sentence) and <code>rake -D</code> (the entire description).
#
# Example:
# desc "Run the Unit Tests"
# task test: [:build]
# # ... run tests
# end
#
def desc(description) # :doc:
Rake.application.last_description = description
end
なるほど、 # Display the tasks and comments.
def display_tasks_and_comments # :nodoc:
displayable_tasks = tasks.select { |t|
(options.show_all_tasks || t.comment) &&
t.name =~ options.show_task_pattern
}
case options.show_tasks
when :tasks
width = displayable_tasks.map { |t| t.name_with_args.length }.max || 10
if truncate_output?
max_column = terminal_width - name.size - width - 7
else
max_column = nil
end
displayable_tasks.each do |t|
printf("#{name} %-#{width}s # %s\n",
t.name_with_args,
max_column ? truncate(t.comment, max_column) : t.comment)
end
when :describe
displayable_tasks.each do |t|
puts "#{name} #{t.name_with_args}"
comment = t.full_comment || ""
comment.split("\n").each do |line|
puts " #{line}"
end
puts
end
when :lines
displayable_tasks.each do |t|
t.locations.each do |loc|
printf "#{name} %-30s %s\n", t.name_with_args, loc
end
end
else
fail "Unknown show task mode: '#{options.show_tasks}'"
end
end # Full collection of comments. Multiple comments are separated by
# newlines.
def full_comment
transform_comments("\n")
end
# First line (or sentence) of all comments. Multiple comments are
# separated by a "/".
def comment
transform_comments(" / ") { |c| first_sentence(c) }
end
# Get the first sentence in a string. The sentence is terminated
# by the first period, exclamation mark, or the end of the line.
# Decimal points do not count as periods.
def first_sentence(string)
string.split(/(?<=\w)(\.|!)[ \t]|(\.$|!)|\n/).first
end
private :first_sentence なるほどー、若干釈然としないが、 ruby/rake#134 明示的にここで入ったパッチなのか。 で、やっぱ疑問が上がっているみたいだ。ふむー、変更が入った意図としては ruby/rake#106 を直すためだったみたいなのだけど、若干やり方が違うか?しかし、これはまぁ人間の言葉が曖昧というところに落ち着きそうな気がするので、「ちゃんとやれ」と言われたらハイコスト感はあるな・・・ |
rake --tasks
時に省略されるのはまぁわかるが、文字区切り的なのを入れるとそこも消されるrake --tasks
時に省略されるのはまぁわかるが、 !
を入れるとそこも消される
ほぼ https://stackoverflow.com/questions/6479013/i-need-a-regex-to-match-first-sentence-of-the-string のパクリだが、 string.slice(/\A.*?[.!?](?=\s[A-Z]|\s?$)(?!.*\))/).slice(/\A(.*?)[\.]?$/, 1) こんな感じの正規表現だとだいたい大丈夫そうである。が、「怖い」 |
タイトルが全てなのだが、これは仕様なのだろうか
The text was updated successfully, but these errors were encountered: