From 55b2b904a1b0263d5ee30adbd0817637134fad19 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Fri, 15 Jul 2016 08:28:59 -0700 Subject: [PATCH] [git] First pass at a clean filter for Alfred workflows --- .gitconfig | 2 ++ bin/clean_alfred_workflow | 13 +++++++++++++ 2 files changed, 15 insertions(+) create mode 100755 bin/clean_alfred_workflow diff --git a/.gitconfig b/.gitconfig index cf07cc8..14ef805 100644 --- a/.gitconfig +++ b/.gitconfig @@ -69,3 +69,5 @@ fetchJobs = 4 [commit] verbose = true +[filter "alfredworkflow"] + clean = clean_alfred_workflow diff --git a/bin/clean_alfred_workflow b/bin/clean_alfred_workflow new file mode 100755 index 0000000..83914cd --- /dev/null +++ b/bin/clean_alfred_workflow @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby + +require 'rexml/document' + +doc = REXML::Document.new(ARGF.read, ignore_whitespace_nodes: :all) +xpath = '//dict/key[text()="variablesdontexport"]/following-sibling::array' +vars = doc.elements[xpath].map(&:text) + +vars.each do |var| + doc.elements["//key[text()='#{var}']/following-sibling::string"].text = '' +end + +doc.write