Module: GraphQLDocs::Helpers
Constant Summary collapse
- SLUGIFY_PRETTY_REGEXP =
Regexp.new("[^[:alnum:]._~!$&'()+,;=@]+").freeze
Instance Attribute Summary collapse
-
#templates ⇒ Object
Returns the value of attribute templates.
Instance Method Summary collapse
- #graphql_enum_types ⇒ Object
- #graphql_input_object_types ⇒ Object
- #graphql_interface_types ⇒ Object
- #graphql_mutation_types ⇒ Object
- #graphql_object_types ⇒ Object
- #graphql_scalar_types ⇒ Object
- #graphql_union_types ⇒ Object
- #include(filename, opts = {}) ⇒ Object
- #markdown(string) ⇒ Object
- #slugify(str) ⇒ Object
Instance Attribute Details
#templates ⇒ Object
Returns the value of attribute templates.
5 6 7 |
# File 'lib/graphql-docs/helpers.rb', line 5 def templates @templates end |
Instance Method Details
#graphql_enum_types ⇒ Object
35 36 37 |
# File 'lib/graphql-docs/helpers.rb', line 35 def graphql_enum_types @parsed_schema['enum_types'] end |
#graphql_input_object_types ⇒ Object
43 44 45 |
# File 'lib/graphql-docs/helpers.rb', line 43 def graphql_input_object_types @parsed_schema['input_object_types'] end |
#graphql_interface_types ⇒ Object
31 32 33 |
# File 'lib/graphql-docs/helpers.rb', line 31 def graphql_interface_types @parsed_schema['interface_types'] end |
#graphql_mutation_types ⇒ Object
23 24 25 |
# File 'lib/graphql-docs/helpers.rb', line 23 def graphql_mutation_types @parsed_schema['mutation_types'] end |
#graphql_object_types ⇒ Object
27 28 29 |
# File 'lib/graphql-docs/helpers.rb', line 27 def graphql_object_types @parsed_schema['object_types'] end |
#graphql_scalar_types ⇒ Object
47 48 49 |
# File 'lib/graphql-docs/helpers.rb', line 47 def graphql_scalar_types @parsed_schema['scalar_types'] end |
#graphql_union_types ⇒ Object
39 40 41 |
# File 'lib/graphql-docs/helpers.rb', line 39 def graphql_union_types @parsed_schema['union_types'] end |
#include(filename, opts = {}) ⇒ Object
13 14 15 16 17 |
# File 'lib/graphql-docs/helpers.rb', line 13 def include(filename, opts = {}) template = fetch_include(filename) opts = { base_url: [:base_url] }.merge(opts) template.result(OpenStruct.new(opts.merge(helper_methods)).instance_eval { binding }) end |
#markdown(string) ⇒ Object
19 20 21 |
# File 'lib/graphql-docs/helpers.rb', line 19 def markdown(string) GitHub::Markdown.render(string || 'n/a') end |
#slugify(str) ⇒ Object
7 8 9 10 11 |
# File 'lib/graphql-docs/helpers.rb', line 7 def slugify(str) slug = str.gsub(SLUGIFY_PRETTY_REGEXP, '-') slug.gsub!(%r!^\-|\-$!i, '') slug.downcase end |