fxn-unmac 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -14,6 +14,7 @@ Options:
14
14
  -r, --keep-dsstore Do not delete ".DS_Store" files
15
15
  -d, --keep-apple-double Do not delete "._*" ghost files
16
16
  -o, --keep-apple-double-orphans Delete "._foo.txt" only if "foo.txt" exists
17
+ -i, --keep-custom-folder-icons Delete custom folder icons
17
18
 
18
19
  Description:
19
20
  When a Mac copies files to volumes that have a different file system it adds
@@ -48,6 +49,8 @@ What's deleted:
48
49
  * For each file "foo.txt", its resource fork and some additional stuff
49
50
  are stored in an accompaining ghost file called "._foo.txt". The pattern
50
51
  is to prepend "._" to the original file name.
52
+
53
+ * If a folder has a custom icon you get a file Icon^M (that's a hard CR).
51
54
 
52
55
  Some stuff is only found in the root folder of volumes, unmac looks for them
53
56
  in any directory you pass as argument, but not on their subdirectories.
data/bin/unmac CHANGED
@@ -22,6 +22,7 @@ Options:
22
22
  -r, --keep-dsstore Do not delete ".DS_Store" files
23
23
  -d, --keep-apple-double Do not delete "._*" ghost files
24
24
  -o, --keep-apple-double-orphans Delete "._foo.txt" only if "foo.txt" exists
25
+ -i, --keep-custom-folder-icons Delete custom folder icons
25
26
 
26
27
  Description:
27
28
  When a Mac copies files to volumes that have a different file system it adds
@@ -56,6 +57,8 @@ What's deleted:
56
57
  * For each file "foo.txt", its resource fork and some additional stuff
57
58
  are stored in an accompaining ghost file called "._foo.txt". The pattern
58
59
  is to prepend "._" to the original file name.
60
+
61
+ * If a folder has a custom icon you get a file Icon^M (that's a hard CR).
59
62
 
60
63
  Some stuff is only found in the root folder of volumes, unmac looks for them
61
64
  in any directory you pass as argument, but not on their subdirectories.
@@ -73,6 +76,7 @@ opts = GetoptLong.new(
73
76
  ['--keep-dsstore', '-r', GetoptLong::NO_ARGUMENT],
74
77
  ['--keep-apple-double', '-d', GetoptLong::NO_ARGUMENT],
75
78
  ['--keep-apple-double-orphans', '-o', GetoptLong::NO_ARGUMENT],
79
+ ['--keep-custom-folder-icons', '-i', GetoptLong::NO_ARGUMENT],
76
80
  ['--test', GetoptLong::NO_ARGUMENT]
77
81
  )
78
82
 
data/lib/unmacer.rb CHANGED
@@ -10,13 +10,15 @@ class Unmacer
10
10
  :keep_macosx,
11
11
  :keep_dsstore,
12
12
  :keep_apple_double,
13
- :keep_apple_double_orphans
13
+ :keep_apple_double_orphans,
14
+ :keep_custom_folder_icons
14
15
 
15
16
  SPOTLIGHT = '.Spotlight-V100'
16
17
  FSEVENTS = '.fseventsd'
17
18
  TRASHES = '.Trashes'
18
19
  MACOSX = '__MACOSX'
19
20
  DSSTORE = '.DS_Store'
21
+ ICON = "Icon\cM"
20
22
 
21
23
  def initialize
22
24
  self.verbose = false
@@ -28,6 +30,7 @@ class Unmacer
28
30
  self.keep_dsstore = false
29
31
  self.keep_apple_double = false
30
32
  self.keep_apple_double_orphans = false
33
+ self.keep_custom_folder_icons = false
31
34
  end
32
35
 
33
36
  def unmac!(dirnames)
@@ -65,6 +68,7 @@ private
65
68
  delete_macosx(dirname) unless keep_macosx
66
69
  delete_dsstore(dirname) unless keep_dsstore
67
70
  delete_apple_double(dirname) unless keep_apple_double
71
+ delete_custom_folder_icon(dirname) unless keep_custom_folder_icons
68
72
  end
69
73
 
70
74
  def delete(parent, file_or_directory)
@@ -149,4 +153,8 @@ private
149
153
  delete(dirname, basename)
150
154
  end
151
155
  end
156
+
157
+ def delete_custom_folder_icon(dirname)
158
+ delete(dirname, ICON)
159
+ end
152
160
  end
data/test/test_unmac.rb CHANGED
@@ -25,6 +25,7 @@ class TestUnmac < Test::Unit::TestCase
25
25
  assert !unmacer.keep_dsstore
26
26
  assert !unmacer.keep_apple_double
27
27
  assert !unmacer.keep_apple_double_orphans
28
+ assert !unmacer.keep_custom_folder_icons
28
29
  assert_equal %w(dummy), ARGV
29
30
  end
30
31
 
@@ -40,6 +41,7 @@ class TestUnmac < Test::Unit::TestCase
40
41
  assert !unmacer.keep_dsstore
41
42
  assert !unmacer.keep_apple_double
42
43
  assert !unmacer.keep_apple_double_orphans
44
+ assert !unmacer.keep_custom_folder_icons
43
45
  assert_equal %w(dummy), ARGV
44
46
  end
45
47
  end
@@ -56,6 +58,7 @@ class TestUnmac < Test::Unit::TestCase
56
58
  assert !unmacer.keep_dsstore
57
59
  assert !unmacer.keep_apple_double
58
60
  assert !unmacer.keep_apple_double_orphans
61
+ assert !unmacer.keep_custom_folder_icons
59
62
  assert_equal %w(dummy), ARGV
60
63
  end
61
64
  end
@@ -72,6 +75,7 @@ class TestUnmac < Test::Unit::TestCase
72
75
  assert !unmacer.keep_dsstore
73
76
  assert !unmacer.keep_apple_double
74
77
  assert !unmacer.keep_apple_double_orphans
78
+ assert !unmacer.keep_custom_folder_icons
75
79
  assert_equal %w(dummy), ARGV
76
80
  end
77
81
  end
@@ -88,6 +92,7 @@ class TestUnmac < Test::Unit::TestCase
88
92
  assert !unmacer.keep_dsstore
89
93
  assert !unmacer.keep_apple_double
90
94
  assert !unmacer.keep_apple_double_orphans
95
+ assert !unmacer.keep_custom_folder_icons
91
96
  assert_equal %w(dummy), ARGV
92
97
  end
93
98
  end
@@ -104,6 +109,7 @@ class TestUnmac < Test::Unit::TestCase
104
109
  assert !unmacer.keep_dsstore
105
110
  assert !unmacer.keep_apple_double
106
111
  assert !unmacer.keep_apple_double_orphans
112
+ assert !unmacer.keep_custom_folder_icons
107
113
  assert_equal %w(dummy), ARGV
108
114
  end
109
115
  end
@@ -120,6 +126,7 @@ class TestUnmac < Test::Unit::TestCase
120
126
  assert !unmacer.keep_dsstore
121
127
  assert !unmacer.keep_apple_double
122
128
  assert !unmacer.keep_apple_double_orphans
129
+ assert !unmacer.keep_custom_folder_icons
123
130
  assert_equal %w(dummy), ARGV
124
131
  end
125
132
  end
@@ -136,6 +143,7 @@ class TestUnmac < Test::Unit::TestCase
136
143
  assert unmacer.keep_dsstore
137
144
  assert !unmacer.keep_apple_double
138
145
  assert !unmacer.keep_apple_double_orphans
146
+ assert !unmacer.keep_custom_folder_icons
139
147
  assert_equal %w(dummy), ARGV
140
148
  end
141
149
  end
@@ -152,6 +160,7 @@ class TestUnmac < Test::Unit::TestCase
152
160
  assert !unmacer.keep_dsstore
153
161
  assert unmacer.keep_apple_double
154
162
  assert !unmacer.keep_apple_double_orphans
163
+ assert !unmacer.keep_custom_folder_icons
155
164
  assert_equal %w(dummy), ARGV
156
165
  end
157
166
  end
@@ -168,12 +177,30 @@ class TestUnmac < Test::Unit::TestCase
168
177
  assert !unmacer.keep_dsstore
169
178
  assert !unmacer.keep_apple_double
170
179
  assert unmacer.keep_apple_double_orphans
180
+ assert !unmacer.keep_custom_folder_icons
181
+ assert_equal %w(dummy), ARGV
182
+ end
183
+ end
184
+
185
+ def test_custom_folder_icons
186
+ for opt in ['--keep-custom-folder-icons', '-i']
187
+ unmacer = call_unmac(opt, 'dummy')
188
+ assert !unmacer.verbose
189
+ assert !unmacer.pretend
190
+ assert !unmacer.keep_spotlight
191
+ assert !unmacer.keep_fsevents
192
+ assert !unmacer.keep_trashes
193
+ assert !unmacer.keep_macosx
194
+ assert !unmacer.keep_dsstore
195
+ assert !unmacer.keep_apple_double
196
+ assert !unmacer.keep_apple_double_orphans
197
+ assert unmacer.keep_custom_folder_icons
171
198
  assert_equal %w(dummy), ARGV
172
199
  end
173
200
  end
174
201
 
175
202
  def test_mix_1
176
- unmacer = call_unmac(*%w(-v -f -m -d dummy))
203
+ unmacer = call_unmac(*%w(-v -f -m -d -i dummy))
177
204
  assert unmacer.verbose
178
205
  assert !unmacer.pretend
179
206
  assert !unmacer.keep_spotlight
@@ -183,6 +210,7 @@ class TestUnmac < Test::Unit::TestCase
183
210
  assert !unmacer.keep_dsstore
184
211
  assert unmacer.keep_apple_double
185
212
  assert !unmacer.keep_apple_double_orphans
213
+ assert unmacer.keep_custom_folder_icons
186
214
  assert_equal %w(dummy), ARGV
187
215
  end
188
216
 
@@ -197,6 +225,7 @@ class TestUnmac < Test::Unit::TestCase
197
225
  assert unmacer.keep_dsstore
198
226
  assert !unmacer.keep_apple_double
199
227
  assert unmacer.keep_apple_double_orphans
228
+ assert !unmacer.keep_custom_folder_icons
200
229
  assert_equal %w(dummy), ARGV
201
230
  end
202
231
 
data/test/test_unmacer.rb CHANGED
@@ -190,6 +190,19 @@ class TestUnmacer < Test::Unit::TestCase
190
190
  assert_equal %w(._foo.txt), read_struct
191
191
  end
192
192
 
193
+ def test_custom_folder_icons
194
+ create_struct([], Unmacer::ICON)
195
+ unmac!
196
+ assert read_struct.empty?
197
+ end
198
+
199
+ def test_keep_custom_folder_icons
200
+ create_struct([], Unmacer::ICON)
201
+ @unmacer.keep_custom_folder_icons = true
202
+ unmac!
203
+ assert_equal [Unmacer::ICON], read_struct
204
+ end
205
+
193
206
  def test_a_handful_of_files
194
207
  dummy = 'dummy'
195
208
  dummy2 = File.join(dummy, 'dummy2')
@@ -208,6 +221,8 @@ class TestUnmacer < Test::Unit::TestCase
208
221
  File.join(dummy2, Unmacer::DSSTORE),
209
222
  File.join(dummy, Unmacer::MACOSX),
210
223
  File.join(dummy2, Unmacer::MACOSX),
224
+ File.join(dummy, Unmacer::ICON),
225
+ File.join(dummy2, Unmacer::ICON),
211
226
  'foo.txt',
212
227
  '._foo.txt',
213
228
  ghost,
data/unmac.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'unmac'
3
- spec.version = '0.4'
3
+ spec.version = '0.5'
4
4
  spec.summary = 'Delete spurious Mac files under a directory or volume'
5
5
  spec.homepage = 'http://github.com/fxn/unmac/tree/master'
6
6
  spec.executables = %w(unmac)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fxn-unmac
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.4"
4
+ version: "0.5"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xavier Noria