Class: Textus::Manifest
- Inherits:
-
Object
show all
- Defined in:
- lib/textus/manifest.rb,
lib/textus/manifest/entry.rb,
lib/textus/manifest/rules.rb,
lib/textus/manifest/schema.rb,
lib/textus/manifest/resolver.rb,
lib/textus/manifest/entry/base.rb,
lib/textus/manifest/entry/leaf.rb,
lib/textus/manifest/role_kinds.rb,
lib/textus/manifest/entry/intake.rb,
lib/textus/manifest/entry/nested.rb,
lib/textus/manifest/entry/parser.rb,
lib/textus/manifest/entry/derived.rb,
lib/textus/manifest/entry/validators.rb,
lib/textus/manifest/entry/validators/events.rb,
lib/textus/manifest/entry/validators/inject_boot.rb,
lib/textus/manifest/entry/validators/publish_each.rb,
lib/textus/manifest/entry/validators/format_matrix.rb,
lib/textus/manifest/entry/validators/index_filename.rb
Defined Under Namespace
Modules: RoleKinds, Schema
Classes: Entry, Resolver, Rules
Constant Summary
collapse
- AUDIT_DEFAULTS =
{ max_size: 10_485_760, keep: 5 }.freeze
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(root, raw) ⇒ Manifest
Returns a new instance of Manifest.
Instance Attribute Details
#entries ⇒ Object
Returns the value of attribute entries.
8
9
10
|
# File 'lib/textus/manifest.rb', line 8
def entries
@entries
end
|
#raw ⇒ Object
Returns the value of attribute raw.
8
9
10
|
# File 'lib/textus/manifest.rb', line 8
def raw
@raw
end
|
#root ⇒ Object
Returns the value of attribute root.
8
9
10
|
# File 'lib/textus/manifest.rb', line 8
def root
@root
end
|
Class Method Details
.load(root) ⇒ Object
69
70
71
72
73
74
75
76
|
# File 'lib/textus/manifest.rb', line 69
def self.load(root)
manifest_path = File.join(root, "manifest.yaml")
raise IoError.new("manifest not found: #{manifest_path}") unless File.exist?(manifest_path)
raw = YAML.safe_load_file(manifest_path, aliases: false)
check_version!(raw, manifest_path)
new(root, raw)
end
|
.parse(yaml_text, root: ".") ⇒ Object
63
64
65
66
67
|
# File 'lib/textus/manifest.rb', line 63
def self.parse(yaml_text, root: ".")
raw = YAML.safe_load(yaml_text, aliases: false)
check_version!(raw, "<string>")
new(root, raw)
end
|
Instance Method Details
#audit_config ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/textus/manifest.rb', line 35
def audit_config
raw = @raw["audit"] || {}
{
max_size: raw["max_size"] || AUDIT_DEFAULTS[:max_size],
keep: raw["keep"] || AUDIT_DEFAULTS[:keep],
}
end
|
#permission_for(zone_name) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/textus/manifest.rb', line 25
def permission_for(zone_name)
Textus::Domain::Permission.new(
zone: zone_name,
write_policy: zone_writers(zone_name),
read_policy: zone_readers[zone_name] || :all,
)
end
|
#resolver ⇒ Object
111
112
113
|
# File 'lib/textus/manifest.rb', line 111
def resolver
@resolver ||= Resolver.new(self)
end
|
#role_kind(name) ⇒ Object
47
48
49
|
# File 'lib/textus/manifest.rb', line 47
def role_kind(name)
role_mapping[name]
end
|
#role_mapping ⇒ Object
43
44
45
|
# File 'lib/textus/manifest.rb', line 43
def role_mapping
@role_mapping ||= RoleKinds.resolve(@raw["roles"])
end
|
#roles_with_kind(kind) ⇒ Object
51
52
53
|
# File 'lib/textus/manifest.rb', line 51
def roles_with_kind(kind)
role_mapping.each_with_object([]) { |(name, k), acc| acc << name if k == kind }
end
|
#rules ⇒ Object
103
104
105
|
# File 'lib/textus/manifest.rb', line 103
def rules
@rules ||= Textus::Manifest::Rules.parse(@raw["rules"] || [])
end
|
#rules_for(key) ⇒ Object
107
108
109
|
# File 'lib/textus/manifest.rb', line 107
def rules_for(key)
rules.for(key)
end
|
#validate_key!(key) ⇒ Object
115
116
117
118
119
|
# File 'lib/textus/manifest.rb', line 115
def validate_key!(key)
raise UsageError.new("empty key") if key.nil? || key.empty?
Key::Grammar.validate!(key)
end
|
#zone_kinds(zone_name) ⇒ Object
55
56
57
58
59
60
61
|
# File 'lib/textus/manifest.rb', line 55
def zone_kinds(zone_name)
@zone_kinds_cache ||= {}
@zone_kinds_cache[zone_name] ||= zone_writers(zone_name).each_with_object(Set.new) do |w, acc|
k = role_kind(w)
acc << k if k
end.freeze
end
|
#zone_readers ⇒ Object
14
15
16
17
18
19
|
# File 'lib/textus/manifest.rb', line 14
def zone_readers
@zone_readers ||= Array(@raw["zones"]).to_h do |z|
rp = z["read_policy"]
[z["name"], rp.nil? ? :all : Array(rp)]
end
end
|
#zone_writers(zone_name) ⇒ Object
21
22
23
|
# File 'lib/textus/manifest.rb', line 21
def zone_writers(zone_name)
zones[zone_name] or raise UsageError.new("undeclared zone '#{zone_name}'")
end
|
#zones ⇒ Object
10
11
12
|
# File 'lib/textus/manifest.rb', line 10
def zones
@zones ||= Array(@raw["zones"]).to_h { |z| [z["name"], Array(z["write_policy"])] }
end
|