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_intro.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
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
59
60
61
62
63
64
65
66
|
# File 'lib/textus/manifest.rb', line 59
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
53
54
55
56
57
|
# File 'lib/textus/manifest.rb', line 53
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
#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
101
102
103
|
# File 'lib/textus/manifest.rb', line 101
def resolver
@resolver ||= Resolver.new(self)
end
|
#role_kind(name) ⇒ Object
37
38
39
|
# File 'lib/textus/manifest.rb', line 37
def role_kind(name)
role_mapping[name]
end
|
#role_mapping ⇒ Object
33
34
35
|
# File 'lib/textus/manifest.rb', line 33
def role_mapping
@role_mapping ||= RoleKinds.resolve(@raw["roles"])
end
|
#roles_with_kind(kind) ⇒ Object
41
42
43
|
# File 'lib/textus/manifest.rb', line 41
def roles_with_kind(kind)
role_mapping.each_with_object([]) { |(name, k), acc| acc << name if k == kind }
end
|
#rules ⇒ Object
93
94
95
|
# File 'lib/textus/manifest.rb', line 93
def rules
@rules ||= Textus::Manifest::Rules.parse(@raw["rules"] || [])
end
|
#rules_for(key) ⇒ Object
97
98
99
|
# File 'lib/textus/manifest.rb', line 97
def rules_for(key)
rules.for(key)
end
|
#validate_key!(key) ⇒ Object
105
106
107
108
109
|
# File 'lib/textus/manifest.rb', line 105
def validate_key!(key)
raise UsageError.new("empty key") if key.nil? || key.empty?
Key::Grammar.validate!(key)
end
|
#zone_kinds(zone_name) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/textus/manifest.rb', line 45
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
|