Class: Shaf::Upgrade::Manifest
- Inherits:
-
Object
- Object
- Shaf::Upgrade::Manifest
- Defined in:
- lib/shaf/upgrade/manifest.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#target_version ⇒ Object
readonly
Returns the value of attribute target_version.
Instance Method Summary collapse
- #additions ⇒ Object
- #drop?(file) ⇒ Boolean
-
#initialize(**params) ⇒ Manifest
constructor
A new instance of Manifest.
- #messages ⇒ Object
- #patches ⇒ Object
- #patches_for(file) ⇒ Object
- #regexps ⇒ Object
- #regexps_for(file) ⇒ Object
- #removals ⇒ Object
- #stats ⇒ Object
- #stats_str ⇒ Object
Constructor Details
#initialize(**params) ⇒ Manifest
Returns a new instance of Manifest.
8 9 10 11 12 13 14 15 16 |
# File 'lib/shaf/upgrade/manifest.rb', line 8 def initialize(**params) @target_version = params[:target_version] @files = {} @files[:patch] = build_patterns(params[:patches]) @files[:add] = params[:add] || {} @files[:drop] = (params[:drop] || []).map { |d| Regexp.new(d) } @files[:regexp] = build_patterns(params[:substitutes]) @files[:messages] = params[:messages] || [] end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
6 7 8 |
# File 'lib/shaf/upgrade/manifest.rb', line 6 def files @files end |
#target_version ⇒ Object (readonly)
Returns the value of attribute target_version.
6 7 8 |
# File 'lib/shaf/upgrade/manifest.rb', line 6 def target_version @target_version end |
Instance Method Details
#additions ⇒ Object
22 23 24 |
# File 'lib/shaf/upgrade/manifest.rb', line 22 def additions files[:add] end |
#drop?(file) ⇒ Boolean
46 47 48 |
# File 'lib/shaf/upgrade/manifest.rb', line 46 def drop?(file) removals.any? { |pattern| file =~ pattern } end |
#messages ⇒ Object
34 35 36 |
# File 'lib/shaf/upgrade/manifest.rb', line 34 def files[:messages] end |
#patches ⇒ Object
18 19 20 |
# File 'lib/shaf/upgrade/manifest.rb', line 18 def patches files[:patch] end |
#patches_for(file) ⇒ Object
38 39 40 |
# File 'lib/shaf/upgrade/manifest.rb', line 38 def patches_for(file) patches.select { |_, pattern| file =~ pattern }.keys end |
#regexps ⇒ Object
30 31 32 |
# File 'lib/shaf/upgrade/manifest.rb', line 30 def regexps files[:regexp] end |
#regexps_for(file) ⇒ Object
42 43 44 |
# File 'lib/shaf/upgrade/manifest.rb', line 42 def regexps_for(file) regexps.select { |_, pattern| file =~ pattern }.keys end |
#removals ⇒ Object
26 27 28 |
# File 'lib/shaf/upgrade/manifest.rb', line 26 def removals files[:drop] end |
#stats ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/shaf/upgrade/manifest.rb', line 50 def stats { additions: additions.size, removals: removals.size, patches: patches.size, regexps: regexps.size, messages: .size } end |
#stats_str ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/shaf/upgrade/manifest.rb', line 60 def stats_str "Add: #{additions.size}, " \ "Del: #{removals.size}, " \ "Patch: #{patches.size}, " \ "Regexp: #{regexps.size}, " \ "Messages: #{.size}" end |