Module: Prmd
- Defined in:
- lib/prmd/cli.rb,
lib/prmd/schema.rb,
lib/prmd/cli/doc.rb,
lib/prmd/version.rb,
lib/prmd/cli/base.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/rake_tasks/verify.rb,
lib/prmd/rake_tasks/combine.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, RakeTasks, Render, Verification, Version Classes: Combiner, Generator, Renderer, Schema, SchemaHash, Template, UrlGenerator
Constant Summary collapse
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) ⇒ 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
97 98 99 |
# File 'lib/prmd/commands/combine.rb', line 97 def self.combine(paths, = {}) Combine.combine(paths, { faulty_load: false }.merge()) end |
.init(resource, options = {}) ⇒ String
Generate a schema template
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/prmd/commands/init.rb', line 24 def self.init(resource, = {}) gen = Generate.make_generator = { 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 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/prmd/load_schema_file.rb', line 11 def self.load_schema_file(filename) extname = File.extname(filename) File.open(filename) do |file| case extname.downcase when '.yaml', '.yml' YAML.load(file.read) when '.json' JSON.load(file.read) else abort "Cannot load schema file #{filename}" \ "(unsupported file extension #{extname})" end end 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) ⇒ Array<String>
Verfies that a given schema is valid
91 92 93 |
# File 'lib/prmd/commands/verify.rb', line 91 def self.verify(schema_data) Verification.verify(schema_data) end |