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/resolution.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: Schema
Classes: Entry, Resolution, 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
39
40
41
42
43
44
45
46
|
# File 'lib/textus/manifest.rb', line 39
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
33
34
35
36
37
|
# File 'lib/textus/manifest.rb', line 33
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
81
82
83
|
# File 'lib/textus/manifest.rb', line 81
def resolver
@resolver ||= Resolver.new(self)
end
|
#rules ⇒ Object
73
74
75
|
# File 'lib/textus/manifest.rb', line 73
def rules
@rules ||= Textus::Manifest::Rules.parse(@raw["rules"] || [])
end
|
#rules_for(key) ⇒ Object
77
78
79
|
# File 'lib/textus/manifest.rb', line 77
def rules_for(key)
rules.for(key)
end
|
#validate_key!(key) ⇒ Object
85
86
87
88
89
|
# File 'lib/textus/manifest.rb', line 85
def validate_key!(key)
raise UsageError.new("empty key") if key.nil? || key.empty?
Key::Grammar.validate!(key)
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
|