Top Level Namespace
Defined Under Namespace
Classes: WhiskeyDisk
Instance Method Summary collapse
-
#changed?(path) ⇒ Boolean
have files of interest changed on this deployment?.
- #changes_file_root ⇒ Object
-
#git_changes ⇒ Object
list of changed paths, according to git.
- #git_changes_path ⇒ Object
- #read_git_changes_file ⇒ Object
- #read_rsync_changes_file ⇒ Object
-
#role?(role) ⇒ Boolean
is the current deployment domain in the specified role?.
- #rsync_changes ⇒ Object
- #rsync_changes_path ⇒ Object
Instance Method Details
#changed?(path) ⇒ Boolean
have files of interest changed on this deployment?
9 10 11 12 13 |
# File 'lib/whiskey_disk/helpers.rb', line 9 def changed?(path) return true unless gc = git_changes cleaned = Regexp.escape(path.sub(%r{/+$}, '')) [ gc, rsync_changes ].flatten.compact.any? { |p| p =~ %r<^#{cleaned}(?:$|/)> } end |
#changes_file_root ⇒ Object
39 40 41 42 |
# File 'lib/whiskey_disk/helpers.rb', line 39 def changes_file_root path = IO.popen("git rev-parse --show-toplevel").read path == '' ? Dir.pwd : path.chomp end |
#git_changes ⇒ Object
list of changed paths, according to git
16 17 18 19 20 |
# File 'lib/whiskey_disk/helpers.rb', line 16 def git_changes changes = read_git_changes_file.split("\n").uniq rescue Exception nil end |
#git_changes_path ⇒ Object
44 45 46 |
# File 'lib/whiskey_disk/helpers.rb', line 44 def git_changes_path File.join(changes_file_root, '.whiskey_disk_git_changes') end |
#read_git_changes_file ⇒ Object
31 32 33 |
# File 'lib/whiskey_disk/helpers.rb', line 31 def read_git_changes_file File.read(git_changes_path) end |
#read_rsync_changes_file ⇒ Object
35 36 37 |
# File 'lib/whiskey_disk/helpers.rb', line 35 def read_rsync_changes_file File.read(rsync_changes_path) end |
#role?(role) ⇒ Boolean
is the current deployment domain in the specified role?
3 4 5 6 |
# File 'lib/whiskey_disk/helpers.rb', line 3 def role?(role) return false unless ENV['WD_ROLES'] and ENV['WD_ROLES'] != '' ENV['WD_ROLES'].split(':').include?(role.to_s) end |
#rsync_changes ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/whiskey_disk/helpers.rb', line 22 def rsync_changes changes = read_rsync_changes_file.split("\n") changes.map {|c| c.sub(/^[^ ]* [^ ]* [^ ]* /, '') }. grep(/^[^ ]{9,} /).map {|c| c.sub(/^[^ ]{9,} /, '') }. map {|s| s.sub(%r{/$}, '') } - ['.'] rescue Exception nil end |
#rsync_changes_path ⇒ Object
48 49 50 |
# File 'lib/whiskey_disk/helpers.rb', line 48 def rsync_changes_path File.join(changes_file_root, '.whiskey_disk_rsync_changes') end |