Module: Avrolution::CompatibilityBreaksFile
- Defined in:
- lib/avrolution/compatibility_breaks_file.rb
Defined Under Namespace
Classes: DuplicateEntryError
Constant Summary
collapse
- NONE =
'NONE'
Class Method Summary
collapse
Class Method Details
.add(name:, fingerprint:, with_compatibility: NONE, after_compatibility: nil, logger: Avrolution.logger) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/avrolution/compatibility_breaks_file.rb', line 18
def self.add(name:,
fingerprint:,
with_compatibility: NONE,
after_compatibility: nil,
logger: Avrolution.logger)
compatibility_break = Avrolution::CompatibilityBreak.new(
name, fingerprint, with_compatibility, after_compatibility
)
compatibility_break.validate!
compatibility_breaks = load
raise DuplicateEntryError.new([name, fingerprint]) if compatibility_breaks.key?(compatibility_break.key)
line = compatibility_break.line
File.write(path, "#{line}\n", mode: 'a')
logger.info("Added #{line.inspect} to #{path}")
end
|
.load ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/avrolution/compatibility_breaks_file.rb', line 37
def self.load
return {} unless File.exist?(path)
File.read(path).each_line.each_with_object({}) do |line, compatibility_breaks|
next if line.blank? || /^#/ =~ line.strip
compatibility_break = Avrolution::CompatibilityBreak.new(*line.strip.split(' '))
compatibility_break.validate!
raise DuplicateEntryError.new(compatibility_break.key) if compatibility_breaks.key?(compatibility_break.key)
compatibility_breaks[compatibility_break.key] = compatibility_break
end
end
|
.path ⇒ Object
14
15
16
|
# File 'lib/avrolution/compatibility_breaks_file.rb', line 14
def self.path
Avrolution.compatibility_breaks_file
end
|