Class: Travis::Yaml::Nodes::Node
- Inherits:
-
Object
- Object
- Travis::Yaml::Nodes::Node
show all
- Defined in:
- lib/travis/yaml/nodes/node.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
-
#decrypt(&block) ⇒ Object
-
#decrypted? ⇒ Boolean
-
#deep_verify ⇒ Object
-
#dup ⇒ Object
-
#encrypt(&block) ⇒ Object
-
#encrypted? ⇒ Boolean
-
#error(message, *params) ⇒ Object
-
#errors ⇒ Object
-
#errors? ⇒ Boolean
-
#initialize(parent) {|_self| ... } ⇒ Node
constructor
-
#method_missing(method, *args, &block) ⇒ Object
-
#nested_warning(message, *prefix) ⇒ Object
-
#nested_warnings(*prefix) ⇒ Object
-
#prepare ⇒ Object
-
#respond_to_missing?(method, include_private = false) ⇒ Boolean
-
#serialize(serializer, options = nil) ⇒ Object
-
#to_json(options = nil) ⇒ Object
-
#to_legacy_ruby(options = nil) ⇒ Object
-
#to_ruby(options = nil) ⇒ Object
-
#to_s ⇒ Object
-
#to_yaml(options = nil) ⇒ Object
-
#verify ⇒ Object
-
#verify_language(language) ⇒ Object
-
#visit_child(visitor, value) ⇒ Object
-
#visit_mapping(visitor, value) ⇒ Object
-
#visit_pair(visitor, key, value) ⇒ Object
-
#visit_scalar(visitor, type, value, implicit = true) ⇒ Object
-
#visit_sequence(visitor, value) ⇒ Object
-
#visit_unexpected(visitor, value, message = nil) ⇒ Object
-
#warngings? ⇒ Boolean
-
#warning(message, *params) ⇒ Object
-
#warnings ⇒ Object
-
#with_value(value) ⇒ Object
Constructor Details
#initialize(parent) {|_self| ... } ⇒ Node
Returns a new instance of Node.
9
10
11
12
13
14
|
# File 'lib/travis/yaml/nodes/node.rb', line 9
def initialize(parent)
@nested_warnings = []
@parent = parent
prepare
yield self if block_given?
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
92
93
94
95
|
# File 'lib/travis/yaml/nodes/node.rb', line 92
def method_missing(method, *args, &block)
return super unless __getobj__.respond_to?(method)
__getobj__.public_send(method, *args, &block)
end
|
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
8
9
10
|
# File 'lib/travis/yaml/nodes/node.rb', line 8
def parent
@parent
end
|
Class Method Details
.has_default? ⇒ Boolean
4
5
6
|
# File 'lib/travis/yaml/nodes/node.rb', line 4
def self.has_default?
false
end
|
Instance Method Details
#decrypt(&block) ⇒ Object
101
102
103
|
# File 'lib/travis/yaml/nodes/node.rb', line 101
def decrypt(&block)
each_scalar(SecureString) { |v| v.decrypt(&block) }
end
|
#decrypted? ⇒ Boolean
109
110
111
|
# File 'lib/travis/yaml/nodes/node.rb', line 109
def decrypted?
each_scalar(SecureString).all? { |v| v.decrypted? }
end
|
#deep_verify ⇒ Object
60
61
62
|
# File 'lib/travis/yaml/nodes/node.rb', line 60
def deep_verify
verify
end
|
#dup ⇒ Object
143
144
145
|
# File 'lib/travis/yaml/nodes/node.rb', line 143
def dup
super.dup_values
end
|
#encrypt(&block) ⇒ Object
105
106
107
|
# File 'lib/travis/yaml/nodes/node.rb', line 105
def encrypt(&block)
each_scalar(SecureString) { |v| v.encrypt(&block) }
end
|
#encrypted? ⇒ Boolean
113
114
115
|
# File 'lib/travis/yaml/nodes/node.rb', line 113
def encrypted?
each_scalar(SecureString).all? { |v| v.encrypted? }
end
|
#error(message, *params) ⇒ Object
47
48
49
|
# File 'lib/travis/yaml/nodes/node.rb', line 47
def error(message, *params)
errors << message % params
end
|
#errors ⇒ Object
39
40
41
|
# File 'lib/travis/yaml/nodes/node.rb', line 39
def errors
@errors ||= []
end
|
#errors? ⇒ Boolean
20
21
22
|
# File 'lib/travis/yaml/nodes/node.rb', line 20
def errors?
errors.any?
end
|
#nested_warning(message, *prefix) ⇒ Object
28
29
30
|
# File 'lib/travis/yaml/nodes/node.rb', line 28
def nested_warning(message, *prefix)
@nested_warnings << [prefix, message]
end
|
#nested_warnings(*prefix) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/travis/yaml/nodes/node.rb', line 32
def nested_warnings(*prefix)
messages = errors + warnings
prefixed = messages.map { |warning| [prefix, warning] }
prefixed += @nested_warnings.map { |p, w| [prefix + p, w] }
prefixed
end
|
#prepare ⇒ Object
51
52
|
# File 'lib/travis/yaml/nodes/node.rb', line 51
def prepare
end
|
#respond_to_missing?(method, include_private = false) ⇒ Boolean
88
89
90
|
# File 'lib/travis/yaml/nodes/node.rb', line 88
def respond_to_missing?(method, include_private = false)
__getobj__.respond_to?(method, false)
end
|
#serialize(serializer, options = nil) ⇒ Object
117
118
119
|
# File 'lib/travis/yaml/nodes/node.rb', line 117
def serialize(serializer, options = nil)
Serializer[serializer].serialize(self, options)
end
|
#to_json(options = nil) ⇒ Object
125
126
127
|
# File 'lib/travis/yaml/nodes/node.rb', line 125
def to_json(options = nil)
serialize(:json, options)
end
|
#to_legacy_ruby(options = nil) ⇒ Object
133
134
135
|
# File 'lib/travis/yaml/nodes/node.rb', line 133
def to_legacy_ruby(options = nil)
serialize(:legacy, options)
end
|
#to_ruby(options = nil) ⇒ Object
129
130
131
|
# File 'lib/travis/yaml/nodes/node.rb', line 129
def to_ruby(options = nil)
serialize(:ruby, options)
end
|
#to_s ⇒ Object
97
98
99
|
# File 'lib/travis/yaml/nodes/node.rb', line 97
def to_s
__getobj__.to_s
end
|
#to_yaml(options = nil) ⇒ Object
121
122
123
|
# File 'lib/travis/yaml/nodes/node.rb', line 121
def to_yaml(options = nil)
serialize(:yaml, options)
end
|
#verify ⇒ Object
54
55
|
# File 'lib/travis/yaml/nodes/node.rb', line 54
def verify
end
|
#verify_language(language) ⇒ Object
57
58
|
# File 'lib/travis/yaml/nodes/node.rb', line 57
def verify_language(language)
end
|
#visit_child(visitor, value) ⇒ Object
84
85
86
|
# File 'lib/travis/yaml/nodes/node.rb', line 84
def visit_child(visitor, value)
error("unexpected child")
end
|
#visit_mapping(visitor, value) ⇒ Object
68
69
70
|
# File 'lib/travis/yaml/nodes/node.rb', line 68
def visit_mapping(visitor, value)
error("unexpected mapping")
end
|
#visit_pair(visitor, key, value) ⇒ Object
72
73
74
|
# File 'lib/travis/yaml/nodes/node.rb', line 72
def visit_pair(visitor, key, value)
error("unexpected pair")
end
|
#visit_scalar(visitor, type, value, implicit = true) ⇒ Object
76
77
78
|
# File 'lib/travis/yaml/nodes/node.rb', line 76
def visit_scalar(visitor, type, value, implicit = true)
error("unexpected scalar") unless type == :null
end
|
#visit_sequence(visitor, value) ⇒ Object
80
81
82
|
# File 'lib/travis/yaml/nodes/node.rb', line 80
def visit_sequence(visitor, value)
error("unexpected sequence")
end
|
#visit_unexpected(visitor, value, message = nil) ⇒ Object
64
65
66
|
# File 'lib/travis/yaml/nodes/node.rb', line 64
def visit_unexpected(visitor, value, message = nil)
error(message || "unexpected %p", value)
end
|
#warngings? ⇒ Boolean
16
17
18
|
# File 'lib/travis/yaml/nodes/node.rb', line 16
def warngings?
warnings.any?
end
|
#warning(message, *params) ⇒ Object
43
44
45
|
# File 'lib/travis/yaml/nodes/node.rb', line 43
def warning(message, *params)
warnings << message % params
end
|
#warnings ⇒ Object
24
25
26
|
# File 'lib/travis/yaml/nodes/node.rb', line 24
def warnings
@warnings ||= []
end
|
#with_value(value) ⇒ Object
137
138
139
140
141
|
# File 'lib/travis/yaml/nodes/node.rb', line 137
def with_value(value)
node = dup
node.with_value!(value)
node
end
|