class DCCSCR::Whitelist
Class to download the dccscr_whitelist repo and store greylist entries.
Constants
- UPSTREAM_REPO
Attributes
entries[R]
path[R]
repo[R]
Public Class Methods
new(path: nil, repo: nil, clone: true, clone_options: '--depth 1')
click to toggle source
# File lib/dccscr/whitelist.rb, line 16 def initialize(path: nil, repo: nil, clone: true, clone_options: '--depth 1') if path @path = path else @path = Dir.mktmpdir at_exit { FileUtils.remove_entry @path } end if repo @repo = repo else @repo = UPSTREAM_REPO end clone_repo(clone_options) if clone @entries = {} end
Public Instance Methods
[](subpath)
click to toggle source
# File lib/dccscr/whitelist.rb, line 35 def [](subpath) entries[subpath] ||= Entry.new(whitelist: self, subpath: subpath) end
Private Instance Methods
clone_repo(clone_options = '')
click to toggle source
# File lib/dccscr/whitelist.rb, line 55 def clone_repo(clone_options = '') system Shellwords.join [].tap { |cmd| cmd << %w[git clone] cmd << Shellwords.split(clone_options).map { |w| Shellwords.escape(w) } cmd << ['--', Shellwords.escape(@repo), Shellwords.escape(@path)] }.flatten $?.success? || fail('error cloning repo') end