zaru 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/zaru.rb +15 -1
  2. metadata +39 -21
data/lib/zaru.rb CHANGED
@@ -21,7 +21,7 @@ class Zaru
21
21
  # remove characters that aren't allowed cross-OS
22
22
  def sanitize
23
23
  @sanitized ||=
24
- filter_windows_reserved_names(normalize.gsub(CHARACTER_FILTER,''))
24
+ filter(normalize.gsub(CHARACTER_FILTER,''))
25
25
  end
26
26
 
27
27
  # normalize unicode string and cut off at 255 characters
@@ -42,8 +42,22 @@ class Zaru
42
42
 
43
43
  private
44
44
 
45
+ def filter(filename)
46
+ filename = filter_windows_reserved_names(filename)
47
+ filename = filter_blank(filename)
48
+ filename = filter_dot(filename)
49
+ end
50
+
45
51
  def filter_windows_reserved_names(filename)
46
52
  WINDOWS_RESERVED_NAMES.include?(filename.upcase) ? 'file' : filename
47
53
  end
54
+
55
+ def filter_blank(filename)
56
+ filename == '' ? 'file': filename
57
+ end
58
+
59
+ def filter_dot(filename)
60
+ filename.start_with?('.') ? "file#{filename}" : filename
61
+ end
48
62
 
49
63
  end
metadata CHANGED
@@ -1,47 +1,65 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: zaru
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.2
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 3
10
+ version: 0.0.3
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Thomas Fuchs
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2013-02-03 00:00:00.000000000 Z
17
+
18
+ date: 2013-02-05 00:00:00 Z
13
19
  dependencies: []
14
- description: Zaru takes a given filename (a string) and normalizes, filters and truncates
15
- it, so it can be safely used as a filename in modern operating systems. Zaru doesn't
16
- remove Unicode characters when not necessary.
20
+
21
+ description: Zaru takes a given filename (a string) and normalizes, filters and truncates it, so it can be safely used as a filename in modern operating systems. Zaru doesn't remove Unicode characters when not necessary.
17
22
  email: thomas@slash7.com
18
23
  executables: []
24
+
19
25
  extensions: []
26
+
20
27
  extra_rdoc_files: []
21
- files:
28
+
29
+ files:
22
30
  - lib/zaru.rb
23
31
  homepage: http://github.com/madrobby/zaru
24
32
  licenses: []
33
+
25
34
  post_install_message:
26
35
  rdoc_options: []
27
- require_paths:
36
+
37
+ require_paths:
28
38
  - lib
29
- required_ruby_version: !ruby/object:Gem::Requirement
39
+ required_ruby_version: !ruby/object:Gem::Requirement
30
40
  none: false
31
- requirements:
32
- - - ! '>='
33
- - !ruby/object:Gem::Version
34
- version: '0'
35
- required_rubygems_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
49
  none: false
37
- requirements:
38
- - - ! '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
41
57
  requirements: []
58
+
42
59
  rubyforge_project:
43
- rubygems_version: 1.8.23
60
+ rubygems_version: 1.8.24
44
61
  signing_key:
45
62
  specification_version: 3
46
63
  summary: Filename sanitization for Ruby
47
64
  test_files: []
65
+