class Buildkite::Builder::Manifest::Rule
Constants
- GLOB_OPTIONS
Attributes
exclude[R]
glob[R]
Public Class Methods
new(root, pattern)
click to toggle source
# File lib/buildkite/builder/manifest/rule.rb, line 14 def initialize(root, pattern) @root = Pathname.new(root) @exclude = false @glob = @root if pattern[0] == '!' @exclude = true pattern = pattern[1..-1] end if pattern.start_with?('/') pattern = pattern[1..-1] else @glob = @glob.join('**') end @glob = @glob.join(pattern).to_s end
Public Instance Methods
files()
click to toggle source
# File lib/buildkite/builder/manifest/rule.rb, line 33 def files @files ||= begin matched = Dir.glob(glob, GLOB_OPTIONS) matched.map! { |file| Pathname.new(file) } matched.reject!(&:directory?) matched.map! { |file| file.relative_path_from(Builder.root) } Set.new(matched.sort!) end end
match?(file)
click to toggle source
# File lib/buildkite/builder/manifest/rule.rb, line 43 def match?(file) file = Pathname.new(file) file = @root.join(file) unless file.absolute? File.fnmatch?(glob, file.to_s, GLOB_OPTIONS) end