Module: Flux::CLI::Review::ReviewBody

Defined in:
lib/flux/cli/review.rb

Class Method Summary collapse

Class Method Details

.from_markdown(md) ⇒ Object



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/flux/cli/review.rb', line 197

def self.from_markdown(md)
  if (md || '').include?(signoff)
    _, branch_name, story_url, iter = md.
      gsub(signoff, '').
      split(/### [^\n]+/).map(&:strip)

    if iter
      _, iterations = iter.split('*').map(&:strip)

      iterations = Array(iterations)
    else
      iterations = []
    end
  else
    branch_name = nil
    story_url   = "http://mojotech.com"
    iterations  = []
  end

  {:branch_name => branch_name,
   :story_url   => story_url,
   :iterations  => iterations}
end

.signoffObject



246
247
248
# File 'lib/flux/cli/review.rb', line 246

def self.signoff
  "*Your friendly neighborhood Flux*"
end

.to_markdown(data) ⇒ Object



221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/flux/cli/review.rb', line 221

def self.to_markdown(data)
  tmpl = <<MARKDOWN
### Branch

#{data[:branch_name]}

### Story

#{data[:story_url]}

MARKDOWN

  if data[:iterations].empty?
    tmpl << signoff << "\n"
  else
    tmpl << <<ITERATIONS
### Prior Versions

#{"* " + data[:iterations].join("\n* ") + "\n"}

#{signoff}
ITERATIONS
  end
end