Module: JsonSchemaDocs::Helpers

Included in:
Generator, Parser
Defined in:
lib/json-schema-docs/helpers.rb

Constant Summary collapse

SLUGIFY_PRETTY_REGEXP =
Regexp.new("[^[:alnum:]._~!$&'()+,;=@]+").freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#templatesObject

Returns the value of attribute templates.



7
8
9
# File 'lib/json-schema-docs/helpers.rb', line 7

def templates
  @templates
end

Instance Method Details

#include(filename, opts = {}) ⇒ Object



15
16
17
18
19
# File 'lib/json-schema-docs/helpers.rb', line 15

def include(filename, opts = {})
  template = fetch_include(filename)
  opts = @options.merge(opts)
  template.result(OpenStruct.new(opts.merge(helper_methods)).instance_eval { binding })
end

#slugify(str) ⇒ Object



9
10
11
12
13
# File 'lib/json-schema-docs/helpers.rb', line 9

def slugify(str)
  slug = str.gsub(SLUGIFY_PRETTY_REGEXP, '-')
  slug.gsub!(%r!^\-|\-$!i, '')
  slug.downcase
end