Module: Prmd
- Defined in:
- lib/prmd/cli.rb,
lib/prmd/link.rb,
lib/prmd/schema.rb,
lib/prmd/cli/doc.rb,
lib/prmd/version.rb,
lib/prmd/cli/base.rb,
lib/prmd/cli/stub.rb,
lib/prmd/template.rb,
lib/prmd/cli/render.rb,
lib/prmd/cli/verify.rb,
lib/prmd/cli/combine.rb,
lib/prmd/cli/generate.rb,
lib/prmd/hash_helpers.rb,
lib/prmd/commands/init.rb,
lib/prmd/core/combiner.rb,
lib/prmd/core/renderer.rb,
lib/prmd/url_generator.rb,
lib/prmd/core/generator.rb,
lib/prmd/rake_tasks/doc.rb,
lib/prmd/commands/render.rb,
lib/prmd/commands/verify.rb,
lib/prmd/rake_tasks/base.rb,
lib/prmd/commands/combine.rb,
lib/prmd/core/schema_hash.rb,
lib/prmd/load_schema_file.rb,
lib/prmd/multi_loader/json.rb,
lib/prmd/multi_loader/toml.rb,
lib/prmd/multi_loader/yajl.rb,
lib/prmd/multi_loader/yaml.rb,
lib/prmd/rake_tasks/verify.rb,
lib/prmd/rake_tasks/combine.rb,
lib/prmd/multi_loader/loader.rb,
lib/prmd/core/reference_localizer.rb,
lib/prmd/url_generators/generators/json.rb,
lib/prmd/url_generators/generators/default.rb
Overview
:nodoc:
Defined Under Namespace
Modules: CLI, Combine, Generate, HashHelpers, MultiLoader, RakeTasks, Render, Verification, Version Classes: Combiner, Generator, Link, ReferenceLocalizer, Renderer, Schema, SchemaHash, Template, UrlGenerator
Constant Summary collapse
- DefaultExamples =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ "boolean" => true, "integer" => 42, "number" => 42.0, "string" => "example", "date-time" => "2015-01-01T12:00:00Z", "email" => "[email protected]", "hostname" => "example.com", "ipv4" => "192.0.2.1", "ipv6" => "2001:DB8::1", "uuid" => "01234567-89ab-cdef-0123-456789abcdef", }
- VERSION =
Version::STRING
Class Method Summary collapse
-
.combine(paths, options = {}) ⇒ Prmd::Schema
Merges all found schema files in the given paths into a single Schema.
-
.init(resource, options = {}) ⇒ String
Generate a schema template.
-
.load_schema_file(filename) ⇒ Object
Attempts to load either a json or yaml file, the type is determined by filename extension.
-
.render(schema, options = {}) ⇒ String
Render provided schema to Markdown.
-
.verify(schema_data, custom_schema: nil) ⇒ Array<String>
Verfies that a given schema is valid.
Class Method Details
.combine(paths, options = {}) ⇒ Prmd::Schema
Merges all found schema files in the given paths into a single Schema
137 138 139 |
# File 'lib/prmd/commands/combine.rb', line 137 def self.combine(paths, = {}) Combine.combine(paths, { faulty_load: false }.merge()) end |
.init(resource, options = {}) ⇒ String
Generate a schema template
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/prmd/commands/init.rb', line 36 def self.init(resource, = {}) gen = Generate.make_generator(template: [:template]) = { resource: nil, parent: nil } if resource parent = nil parent, resource = resource.split('/') if resource.include?('/') [:parent] = parent [:resource] = resource end schema = gen.generate() if [:yaml] schema.to_yaml else schema.to_json end end |
.load_schema_file(filename) ⇒ Object
Attempts to load either a json or yaml file, the type is determined by filename extension.
11 12 13 |
# File 'lib/prmd/load_schema_file.rb', line 11 def self.load_schema_file(filename) Prmd::MultiLoader.load_file(filename) end |
.render(schema, options = {}) ⇒ String
Render provided schema to Markdown
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/prmd/commands/render.rb', line 26 def self.render(schema, = {}) renderer = Prmd::Renderer.new(template: Render.get_template()) doc = '' if [:prepend] doc << [:prepend].map { |path| File.read(path) }.join("\n") << "\n" end doc << renderer.render(schema, ) doc end |
.verify(schema_data, custom_schema: nil) ⇒ Array<String>
Verfies that a given schema is valid
97 98 99 |
# File 'lib/prmd/commands/verify.rb', line 97 def self.verify(schema_data, custom_schema: nil) Verification.verify(schema_data, custom_schema: custom_schema) end |