module CrapiDocs

Constants

PARALLEL
SESSION_FILE_PREFIX
TEMPLATE_DIR
VERSION

Attributes

session[R]

Public Class Methods

done() click to toggle source
# File lib/crapidocs.rb, line 45
def done
  handle_parallel if CrapiDocs::PARALLEL
  formatter = Formatter.new(@session)
  write_docs(formatter.to_md)
end
on?() click to toggle source
# File lib/crapidocs.rb, line 41
def on?
  @session.present?
end
purge() click to toggle source
# File lib/crapidocs.rb, line 37
def purge
  @session = nil
end
start(pattern, target = './doc/api.md', tmp = './tmp') click to toggle source
# File lib/crapidocs.rb, line 31
def start(pattern, target = './doc/api.md', tmp = './tmp')
  @session = Session.new(pattern)
  @target = target
  @tmp = tmp
end
version() click to toggle source
# File lib/crapidocs.rb, line 27
def version
  VERSION.join('.')
end

Private Class Methods

handle_parallel() click to toggle source
# File lib/crapidocs.rb, line 53
def handle_parallel
  return write_session unless ParallelTests.first_process?
  ParallelTests.wait_for_other_processes_to_finish
  @session.merge(load_sessions)
end
load_session(file) click to toggle source
# File lib/crapidocs.rb, line 73
def load_session(file)
  data = File.open(file).read
  File.unlink(file)
  Marshal.load(data)
end
load_sessions() click to toggle source
# File lib/crapidocs.rb, line 68
def load_sessions
  glob = "#{@tmp}/#{SESSION_FILE_PREFIX}*"
  Dir[glob].map { |f| load_session(f) }
end
session_file() click to toggle source
# File lib/crapidocs.rb, line 59
def session_file
  test_num = ENV['TEST_ENV_NUMBER'] || '1'
  format('%s/%s%s', @tmp, SESSION_FILE_PREFIX, test_num)
end
write_docs(data) click to toggle source
# File lib/crapidocs.rb, line 79
def write_docs(data)
  write_file(@target, data)
end
write_file(file, data) click to toggle source
# File lib/crapidocs.rb, line 83
def write_file(file, data)
  File.open(file, 'wb') { |f| f.write(data) }
end
write_session() click to toggle source
# File lib/crapidocs.rb, line 64
def write_session
  write_file(session_file, Marshal.dump(@session))
end