Module: Onebox::Mixins::GithubBody::InstanceMethods
- Defined in:
- lib/onebox/mixins/github_body.rb
Constant Summary collapse
- GITHUB_COMMENT_REGEX =
/(<!--.*?-->\r\n)/
- MAX_BODY_LENGTH =
80
Instance Method Summary collapse
Instance Method Details
#compute_body(body) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/onebox/mixins/github_body.rb', line 14 def compute_body(body) body = body.dup excerpt = nil body = (body || '').gsub(GITHUB_COMMENT_REGEX, '') body = body.length > 0 ? body : nil if body && body.length > MAX_BODY_LENGTH excerpt = body[MAX_BODY_LENGTH..body.length].rstrip body = body[0..MAX_BODY_LENGTH - 1] end [body, excerpt] end |