module Mumukit::Sync::Store::Github::Schema

Schema definition explanation

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