Class: Bootprint::Diff
- Inherits:
-
Object
- Object
- Bootprint::Diff
- Defined in:
- lib/bootprint/diff.rb
Defined Under Namespace
Classes: Change
Constant Summary collapse
- IGNORED_PATHS =
%w[generated_at bootprint_version environment.name].freeze
Instance Attribute Summary collapse
-
#allowed_paths ⇒ Object
readonly
Returns the value of attribute allowed_paths.
-
#local ⇒ Object
readonly
Returns the value of attribute local.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #allowed?(path) ⇒ Boolean
- #changes ⇒ Object
-
#initialize(local, target, allowed_paths: []) ⇒ Diff
constructor
A new instance of Diff.
Constructor Details
#initialize(local, target, allowed_paths: []) ⇒ Diff
Returns a new instance of Diff.
15 16 17 18 19 |
# File 'lib/bootprint/diff.rb', line 15 def initialize(local, target, allowed_paths: []) @local = local.is_a?(Snapshot) ? local.data : local @target = target.is_a?(Snapshot) ? target.data : target @allowed_paths = allowed_paths end |
Instance Attribute Details
#allowed_paths ⇒ Object (readonly)
Returns the value of attribute allowed_paths.
13 14 15 |
# File 'lib/bootprint/diff.rb', line 13 def allowed_paths @allowed_paths end |
#local ⇒ Object (readonly)
Returns the value of attribute local.
13 14 15 |
# File 'lib/bootprint/diff.rb', line 13 def local @local end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
13 14 15 |
# File 'lib/bootprint/diff.rb', line 13 def target @target end |
Instance Method Details
#allowed?(path) ⇒ Boolean
25 26 27 |
# File 'lib/bootprint/diff.rb', line 25 def allowed?(path) allowed_paths.any? { |pattern| File.fnmatch?(pattern, path, File::FNM_PATHNAME | File::FNM_EXTGLOB) } end |
#changes ⇒ Object
21 22 23 |
# File 'lib/bootprint/diff.rb', line 21 def changes @changes ||= compare(local, target).reject { |change| ignored?(change.path) } end |