Class: RDoc::Parser::ChangeLog::Git::LogEntry

Inherits:
Struct show all
Defined in:
lib/rdoc/parser/changelog.rb

Constant Summary collapse

HEADING_LEVEL =
3

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

#as_json, json_create, #pretty_print_cycle, #to_json

Constructor Details

#initialize(base, commit, author, email, date, contents) ⇒ LogEntry

Returns a new instance of LogEntry.



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/rdoc/parser/changelog.rb', line 273

def initialize(base, commit, author, email, date, contents)
  case contents
  when String
    contents = RDoc::Markdown.parse(contents).parts.each do |body|
      case body
      when RDoc::Markup::Heading
        body.level += HEADING_LEVEL + 1
      end
    end
    case first = contents[0]
    when RDoc::Markup::Paragraph
      contents[0] = RDoc::Markup::Heading.new(HEADING_LEVEL + 1, first.text)
    end
  end
  super
end

Instance Attribute Details

#authorObject

Returns the value of attribute author

Returns:

  • (Object)

    the current value of author



270
271
272
# File 'lib/rdoc/parser/changelog.rb', line 270

def author
  @author
end

#baseObject

Returns the value of attribute base

Returns:

  • (Object)

    the current value of base



270
271
272
# File 'lib/rdoc/parser/changelog.rb', line 270

def base
  @base
end

#commitObject

Returns the value of attribute commit

Returns:

  • (Object)

    the current value of commit



270
271
272
# File 'lib/rdoc/parser/changelog.rb', line 270

def commit
  @commit
end

#contentsObject

Returns the value of attribute contents

Returns:

  • (Object)

    the current value of contents



270
271
272
# File 'lib/rdoc/parser/changelog.rb', line 270

def contents
  @contents
end

#dateObject

Returns the value of attribute date

Returns:

  • (Object)

    the current value of date



270
271
272
# File 'lib/rdoc/parser/changelog.rb', line 270

def date
  @date
end

#emailObject

Returns the value of attribute email

Returns:

  • (Object)

    the current value of email



270
271
272
# File 'lib/rdoc/parser/changelog.rb', line 270

def email
  @email
end

Instance Method Details

#accept(visitor) ⇒ Object



313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/rdoc/parser/changelog.rb', line 313

def accept visitor
  visitor.accept_heading self
  begin
    if visitor.respond_to?(:code_object=)
      code_object = visitor.code_object
      visitor.code_object = self
    end
    contents.each do |body|
      body.accept visitor
    end
  ensure
    if visitor.respond_to?(:code_object)
      visitor.code_object = code_object
    end
  end
end

#arefObject



294
295
296
# File 'lib/rdoc/parser/changelog.rb', line 294

def aref
  "label-#{commit}"
end

#label(context = nil) ⇒ Object



298
299
300
# File 'lib/rdoc/parser/changelog.rb', line 298

def label context = nil
  aref
end

#levelObject



290
291
292
# File 'lib/rdoc/parser/changelog.rb', line 290

def level
  HEADING_LEVEL
end

#pretty_print(q) ⇒ Object

:nodoc:



330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/rdoc/parser/changelog.rb', line 330

def pretty_print q # :nodoc:
  q.group(2, '[log_entry: ', ']') do
    q.text commit
    q.text ','
    q.breakable
    q.group(2, '[date: ', ']') { q.text date }
    q.text ','
    q.breakable
    q.group(2, '[author: ', ']') { q.text author }
    q.text ','
    q.breakable
    q.group(2, '[email: ', ']') { q.text email }
    q.text ','
    q.breakable
    q.pp contents
  end
end

#textObject



302
303
304
305
306
307
308
309
310
311
# File 'lib/rdoc/parser/changelog.rb', line 302

def text
  case base
  when nil
    "#{date}"
  when /%s/
    "{#{date}}[#{base % commit}]"
  else
    "{#{date}}[#{base}#{commit}]"
  end + " {#{author}}[mailto:#{email}]"
end