Module: Dictum

Defined in:
lib/dictum.rb,
lib/dictum/version.rb,
lib/dictum/constants.rb,
lib/dictum/documenter.rb,
lib/dictum/html_writer.rb,
lib/dictum/html_helpers.rb,
lib/dictum/markdown_writer.rb

Defined Under Namespace

Classes: Documenter, HtmlHelpers, HtmlWriter, MarkdownWriter

Constant Summary collapse

TEMPFILE_PATH =
"#{Dir.tmpdir}/dictum_temp.json".freeze
VERSION =
'0.0.8'.freeze
MISSING_MESSAGE =
'Dictum error: data not provided.'.freeze

Class Method Summary collapse

Class Method Details

.configObject



60
61
62
# File 'lib/dictum.rb', line 60

def self.config
  @config
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Dictum)

    the object that the method was called on



24
25
26
# File 'lib/dictum.rb', line 24

def self.configure
  yield self
end

.documentObject

Method that will execute tests and then save the results in the selected format



89
90
91
92
93
94
95
96
# File 'lib/dictum.rb', line 89

def self.document
  Dir.mkdir(@config[:output_path]) unless Dir.exist?(@config[:output_path])
  Documenter.instance.reset_data

  system "bundle exec rspec #{@config[:root_path]} --tag dictum" if @config[:test_suite] == :rspec

  save_to_file
end

.endpoint(arguments) ⇒ Object

Method used to create a new endpoint of a resource



74
75
76
# File 'lib/dictum.rb', line 74

def self.endpoint(arguments)
  Documenter.instance.endpoint(arguments)
end

.error_codes(codes_list) ⇒ Object

Method used to add a new error code.

Parameters:

  • codes_list

    is an array of hashes representing the code, message and description



82
83
84
# File 'lib/dictum.rb', line 82

def self.error_codes(codes_list)
  codes_list.each { |error| Documenter.instance.error_code(error) }
end

.header_title=(title) ⇒ Object



52
53
54
# File 'lib/dictum.rb', line 52

def self.header_title=(title)
  @config[:header_title] = title
end

.index_title=(title) ⇒ Object



48
49
50
# File 'lib/dictum.rb', line 48

def self.index_title=(title)
  @config[:index_title] = title
end

.inline_css=(style) ⇒ Object



56
57
58
# File 'lib/dictum.rb', line 56

def self.inline_css=(style)
  @config[:inline_css] = style
end

.output_filename=(file) ⇒ Object



44
45
46
# File 'lib/dictum.rb', line 44

def self.output_filename=(file)
  @config[:output_filename] = file
end

.output_format=(style) ⇒ Object



28
29
30
# File 'lib/dictum.rb', line 28

def self.output_format=(style)
  @config[:output_format] = style
end

.output_path=(folder) ⇒ Object



32
33
34
# File 'lib/dictum.rb', line 32

def self.output_path=(folder)
  @config[:output_path] = folder
end

.resource(arguments) ⇒ Object

Method used to create a new resource



67
68
69
# File 'lib/dictum.rb', line 67

def self.resource(arguments)
  Documenter.instance.resource(arguments)
end

.root_path=(folder) ⇒ Object



36
37
38
# File 'lib/dictum.rb', line 36

def self.root_path=(folder)
  @config[:root_path] = folder
end

.save_to_fileObject



98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/dictum.rb', line 98

def self.save_to_file
  writer = nil
  output_filename = "#{@config[:output_path]}/#{@config[:output_filename]}"

  case @config[:output_format]
  when :markdown
    writer = MarkdownWriter.new(output_filename, TEMPFILE_PATH, @config)
  when :html
    writer = HtmlWriter.new(output_filename, TEMPFILE_PATH, @config)
  end

  writer.write
end

.test_suite=(suite) ⇒ Object



40
41
42
# File 'lib/dictum.rb', line 40

def self.test_suite=(suite)
  @config[:test_suite] = suite
end