Class: Vanagon::Patch
- Inherits:
-
Object
- Object
- Vanagon::Patch
- Includes:
- HashableAttributes
- Defined in:
- lib/vanagon/patch.rb,
lib/vanagon/extensions/hashable.rb
Instance Attribute Summary collapse
-
#after ⇒ Object
readonly
Returns the value of attribute after.
-
#assembly_path ⇒ Object
readonly
Returns the value of attribute assembly_path.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#fuzz ⇒ Object
readonly
Returns the value of attribute fuzz.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#origin_path ⇒ Object
readonly
Returns the value of attribute origin_path.
-
#strip ⇒ Object
readonly
Returns the value of attribute strip.
Instance Method Summary collapse
- #cmd(platform) ⇒ Object
-
#initialize(origin_path, component, options) ⇒ Patch
constructor
rubocop:disable Metrics/AbcSize,Metrics/PerceivedComplexity.
Methods included from HashableAttributes
Constructor Details
#initialize(origin_path, component, options) ⇒ Patch
rubocop:disable Metrics/AbcSize,Metrics/PerceivedComplexity
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/vanagon/patch.rb', line 34 def initialize(origin_path, component, ) # rubocop:disable Metrics/AbcSize,Metrics/PerceivedComplexity valid_keys = %i[namespace destination strip fuzz after] bad_keys = .each_key.reject { |k| valid_keys.include? k } unless bad_keys.empty? raise Vanagon::Error, "Bad options in patch initialization: #{bad_keys}." end @origin_path = origin_path @namespace = [:namespace] || component.name @assembly_path = "patches/#{@namespace}/#{File.basename(@origin_path)}" @strip = [:strip] || 1 @fuzz = [:fuzz] || 0 @after = [:after] || 'unpack' unless ['unpack', 'install'].include?(@after) raise Vanagon::Error, 'Only "unpack" or "install" permitted for "after" option.' end @destination = [:destination] || component.dirname end |
Instance Attribute Details
#after ⇒ Object (readonly)
Returns the value of attribute after.
32 33 34 |
# File 'lib/vanagon/patch.rb', line 32 def after @after end |
#assembly_path ⇒ Object (readonly)
Returns the value of attribute assembly_path.
15 16 17 |
# File 'lib/vanagon/patch.rb', line 15 def assembly_path @assembly_path end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
20 21 22 |
# File 'lib/vanagon/patch.rb', line 20 def destination @destination end |
#fuzz ⇒ Object (readonly)
Returns the value of attribute fuzz.
28 29 30 |
# File 'lib/vanagon/patch.rb', line 28 def fuzz @fuzz end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
11 12 13 |
# File 'lib/vanagon/patch.rb', line 11 def namespace @namespace end |
#origin_path ⇒ Object (readonly)
Returns the value of attribute origin_path.
7 8 9 |
# File 'lib/vanagon/patch.rb', line 7 def origin_path @origin_path end |
#strip ⇒ Object (readonly)
Returns the value of attribute strip.
24 25 26 |
# File 'lib/vanagon/patch.rb', line 24 def strip @strip end |
Instance Method Details
#cmd(platform) ⇒ Object
54 55 56 |
# File 'lib/vanagon/patch.rb', line 54 def cmd(platform) return "#{platform.patch} --strip=#{@strip} --fuzz=#{@fuzz} --ignore-whitespace --no-backup-if-mismatch < $(workdir)/#{@assembly_path}" end |