module Mumukit::Sync::Store::Github::Schema
Schema
definition explanation
-
name: the name of the field
-
kind: the type of the field: metadata, special, file or transient.
* metadata fields are those that are small and fit into the metadata.yml when exported to git * special fields are those are essentials and not part of any file, like the id or name when exported to git * transient fields are not exported to git * file fields are large fields that are exported to git within their own file.
-
reverse: the name of the field in the model. By default, it is assumed to be the same of name, but can be overridden with this option
-
default: the default value of the field
-
extension: the file extension. It only applies to file kinds. It can be a plain extension or one of the following special extensions:
* test: the extension of the test framework * code: the normal extension for the language
Public Instance Methods
defaults()
click to toggle source
# File lib/mumukit/sync/store/github/schema.rb, line 19 def defaults fields.map { |it| [it.reverse_name, it.default] }.to_h.compact end
fields()
click to toggle source
# File lib/mumukit/sync/store/github/schema.rb, line 43 def fields @field ||= fields_schema.map { |it| new_field(it) } end
file_fields()
click to toggle source
# File lib/mumukit/sync/store/github/schema.rb, line 31 def file_fields fields.select { |it| it.kind == :file } end
file_patterns()
click to toggle source
# File lib/mumukit/sync/store/github/schema.rb, line 35 def file_patterns file_fields.map(&:get_file_pattern) + fixed_file_patterns end
fixed_file_patterns()
click to toggle source
# File lib/mumukit/sync/store/github/schema.rb, line 39 def fixed_file_patterns [] end
metadata_fields()
click to toggle source
# File lib/mumukit/sync/store/github/schema.rb, line 23 def metadata_fields fields.select { |it| it.kind == :metadata } end
name()
click to toggle source
# File lib/mumukit/sync/store/github/schema.rb, line 61 def name with { |it| it&.dig(:name) } end
simple_fields()
click to toggle source
# File lib/mumukit/sync/store/github/schema.rb, line 27 def simple_fields fields.select { |it| [:special, :file].include? it.kind } end
slice(json)
click to toggle source
# File lib/mumukit/sync/store/github/schema.rb, line 47 def slice(json) json.slice(*fields.map(&:reverse_name)) end
with(&block)
click to toggle source
# File lib/mumukit/sync/store/github/schema.rb, line 65 def with(&block) struct to: block, from: proc { |it| File.read(it) } end
yaml_hash()
click to toggle source
# File lib/mumukit/sync/store/github/schema.rb, line 51 def yaml_hash struct to: proc(&:to_yaml), from: proc { |path| YAML.load_file(path) } end
yaml_list(key)
click to toggle source
# File lib/mumukit/sync/store/github/schema.rb, line 56 def yaml_list(key) struct to: proc { |it| {key => it.map(&:stringify_keys)}.to_yaml }, from: proc { |path| YAML.load_file(path).try { |it| it[key] } } end
Private Instance Methods
new_field(it)
click to toggle source
# File lib/mumukit/sync/store/github/schema.rb, line 71 def new_field(it) Field.new(it) end