class Pliny::Commands::Generator::Schema
Public Class Methods
Source
# File lib/pliny/commands/generator/schema.rb, line 7 def initialize(*) super @warned_legacy = false end
Calls superclass method
Pliny::Commands::Generator::Base::new
Public Instance Methods
Source
# File lib/pliny/commands/generator/schema.rb, line 12 def create warn_legacy if legacy? schema = schema_yaml_path(field_name) write_file(schema) do Prmd.init(name.singularize, yaml: true) end display "created schema file #{schema}" end
Source
# File lib/pliny/commands/generator/schema.rb, line 31 def legacy? File.exist?("./docs/schema.json") || File.directory?("./docs/schema/schemata") end
Source
# File lib/pliny/commands/generator/schema.rb, line 49 def meta_path if legacy? "./docs/schema/meta.json" else "./schema/meta.json" end end
Source
# File lib/pliny/commands/generator/schema.rb, line 22 def rebuild warn_legacy if legacy? write_file(schema_json_path) do Prmd.combine(schemata_path, meta: meta_path) end display "rebuilt #{schema_json_path}" end
Source
# File lib/pliny/commands/generator/schema.rb, line 65 def schema_base Pathname.new("./schema") end
Source
# File lib/pliny/commands/generator/schema.rb, line 41 def schema_json_path if legacy? "./docs/schema.json" else "./schema/schema.json" end end
Source
# File lib/pliny/commands/generator/schema.rb, line 69 def schema_yaml_path(field_name) File.join(schemata_path, "#{field_name}.yaml") end
Source
# File lib/pliny/commands/generator/schema.rb, line 57 def schemata_path if legacy? "./docs/schema/schemata" else "./schema/schemata" end end
Source
# File lib/pliny/commands/generator/schema.rb, line 35 def warn_legacy return if @warned_legacy display "WARNING: Using legacy schema layout under docs/. To use new layout under schema/, run `mkdir -p schema && git mv docs/schema.json docs/schema/meta.* docs/schema/schemata schema` then check for remaining schema-related files under docs/." @warned_legacy = true end