prefnerd 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/pn +65 -0
- metadata +51 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5baf52cda97e805d1cc2bfc2f8b0497c1dcaa1b6
|
4
|
+
data.tar.gz: baff97eac5fbf0740b3ab2bf3df665ae8bccd042
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ec978cd2344641e8b5844662691a7768afeb5b958fcf64b0169ad1c92051722f5a0bbfd566503cc66f5cd66cb8155371cf3a4bdb3d66f86be317eb535059287a
|
7
|
+
data.tar.gz: 020ab4bb1272f8f4ad6b1b7b5f863a389cb040a14285387a47dea0fe2067a0673b7ec57d1d7c4581e4dfab31baec25aacd1b23828b183f0dbab6dac42c02ebb4
|
data/bin/pn
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'open3'
|
4
|
+
require 'tempfile'
|
5
|
+
|
6
|
+
PREFERENCES = File.join(ENV['HOME'], 'Library', 'Preferences')
|
7
|
+
PLISTS = File.join(PREFERENCES, '**', '*.plist')
|
8
|
+
|
9
|
+
%w[defaults diff fswatch].each do |dependency|
|
10
|
+
if `which #{dependency}`.length.zero?
|
11
|
+
puts "Missing dependency: #{dependency}"
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def read(plist)
|
17
|
+
# Swallow stderr; it's usually harmless.
|
18
|
+
stdout, stderr, status = Open3.capture3('defaults', 'read', plist)
|
19
|
+
stdout
|
20
|
+
end
|
21
|
+
|
22
|
+
begin
|
23
|
+
# Build up map of known defaults
|
24
|
+
print 'Reading defaults: '
|
25
|
+
DEFAULTS = {}
|
26
|
+
Dir.glob(PLISTS, File::FNM_DOTMATCH).each do |plist|
|
27
|
+
print '.'
|
28
|
+
DEFAULTS[plist] = read(plist)
|
29
|
+
end
|
30
|
+
puts
|
31
|
+
|
32
|
+
# Start monitoring
|
33
|
+
puts 'Monitoring for changes... [hit CTRL-C to exit]'
|
34
|
+
lines = File.popen([
|
35
|
+
'fswatch',
|
36
|
+
'-m',
|
37
|
+
'fsevents_monitor',
|
38
|
+
'-r',
|
39
|
+
ENV['HOME'] + '/Library/Preferences',
|
40
|
+
])
|
41
|
+
while line = lines.readline
|
42
|
+
plist = line.chomp
|
43
|
+
if plist =~ /\.plist\z/
|
44
|
+
new_contents = read(plist)
|
45
|
+
new_file = Tempfile.new('pn')
|
46
|
+
new_file.write(new_contents)
|
47
|
+
new_file.close
|
48
|
+
|
49
|
+
old_contents = DEFAULTS[plist] || ''
|
50
|
+
old_file = Tempfile.new('pn')
|
51
|
+
old_file.write(old_contents)
|
52
|
+
old_file.close
|
53
|
+
|
54
|
+
DEFAULTS[plist] = new_contents
|
55
|
+
|
56
|
+
# Output diff from before to after, but strip meaningless filename header
|
57
|
+
puts plist + ':'
|
58
|
+
puts(File.popen(['diff', '-u', old_file.path, new_file.path]).readlines[2..-1])
|
59
|
+
|
60
|
+
new_file.unlink
|
61
|
+
old_file.unlink
|
62
|
+
end
|
63
|
+
end
|
64
|
+
rescue Interrupt
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: prefnerd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Greg Hurrell
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: "\n Are you an OS X prefnerd? Do you keep a base set of OS X preferences
|
14
|
+
in\n version control to make it easier to set up new machines? Do you want to\n
|
15
|
+
\ know which items are being changed, and to what values, whenever you alter a\n
|
16
|
+
\ setting on OS X? The prefnerd gem contains a simple executable that watches\n
|
17
|
+
\ the defaults database for changes and prints them to your terminal.\n "
|
18
|
+
email:
|
19
|
+
- greg@hurrell.net
|
20
|
+
executables:
|
21
|
+
- pn
|
22
|
+
extensions: []
|
23
|
+
extra_rdoc_files: []
|
24
|
+
files:
|
25
|
+
- bin/pn
|
26
|
+
homepage:
|
27
|
+
licenses:
|
28
|
+
- MIT
|
29
|
+
metadata: {}
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements:
|
45
|
+
- The fswatch executable
|
46
|
+
rubyforge_project:
|
47
|
+
rubygems_version: 2.0.14
|
48
|
+
signing_key:
|
49
|
+
specification_version: 4
|
50
|
+
summary: Monitors the OS X defaults database for changes
|
51
|
+
test_files: []
|