zaru 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/zaru.rb +6 -3
- metadata +49 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1dce46aeee751c80d068262090dd9ff1d999c9d3e938c4624b5d46c1b7017533
|
4
|
+
data.tar.gz: dc5e1bd34144d17b88ea6b0d8a60c832cbde857478f9f853fc1b17e5e1ae5d9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fa8e470ff88a19538b88caeb3b108211262c8dacfb23503269d4738339c9ab7a54a6d0d57b0598dc08de7cdbbbe99e0e352f3d394a131359270e4a86c89e230
|
7
|
+
data.tar.gz: 602c8a35db90b7cc934051b69b77382038f93ef3251d62934600b56a82454470ff3a7657c46622823e10b86b5e6567e206841f65a4539001572d0b930a703d9b
|
data/lib/zaru.rb
CHANGED
@@ -10,6 +10,7 @@ class Zaru
|
|
10
10
|
FALLBACK_FILENAME = 'file'
|
11
11
|
|
12
12
|
def initialize(filename, options = {})
|
13
|
+
@fallback = options[:fallback] || FALLBACK_FILENAME
|
13
14
|
@padding = options[:padding] || 0
|
14
15
|
@raw = filename.to_s.freeze
|
15
16
|
end
|
@@ -50,6 +51,8 @@ class Zaru
|
|
50
51
|
|
51
52
|
private
|
52
53
|
|
54
|
+
attr_reader :fallback
|
55
|
+
|
53
56
|
def filter(filename)
|
54
57
|
filename = filter_windows_reserved_names(filename)
|
55
58
|
filename = filter_blank(filename)
|
@@ -57,15 +60,15 @@ class Zaru
|
|
57
60
|
end
|
58
61
|
|
59
62
|
def filter_windows_reserved_names(filename)
|
60
|
-
WINDOWS_RESERVED_NAMES.include?(filename.upcase) ?
|
63
|
+
WINDOWS_RESERVED_NAMES.include?(filename.upcase) ? fallback : filename
|
61
64
|
end
|
62
65
|
|
63
66
|
def filter_blank(filename)
|
64
|
-
filename.empty??
|
67
|
+
filename.empty?? fallback : filename
|
65
68
|
end
|
66
69
|
|
67
70
|
def filter_dot(filename)
|
68
|
-
filename.start_with?('.')? "#{
|
71
|
+
filename.start_with?('.')? "#{fallback}#{filename}" : filename
|
69
72
|
end
|
70
73
|
|
71
74
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zaru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Fuchs
|
@@ -9,7 +9,49 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2017-09-18 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
13
55
|
description: Zaru takes a given filename (a string) and normalizes, filters and truncates
|
14
56
|
it, so it can be safely used as a filename in modern operating systems. Zaru doesn't
|
15
57
|
remove Unicode characters when not necessary.
|
@@ -19,8 +61,9 @@ extensions: []
|
|
19
61
|
extra_rdoc_files: []
|
20
62
|
files:
|
21
63
|
- lib/zaru.rb
|
22
|
-
homepage:
|
23
|
-
licenses:
|
64
|
+
homepage: https://github.com/madrobby/zaru
|
65
|
+
licenses:
|
66
|
+
- MIT
|
24
67
|
metadata: {}
|
25
68
|
post_install_message:
|
26
69
|
rdoc_options: []
|
@@ -30,15 +73,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
30
73
|
requirements:
|
31
74
|
- - ">="
|
32
75
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
76
|
+
version: '1.9'
|
34
77
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
78
|
requirements:
|
36
79
|
- - ">="
|
37
80
|
- !ruby/object:Gem::Version
|
38
81
|
version: '0'
|
39
82
|
requirements: []
|
40
|
-
|
41
|
-
rubygems_version: 2.6.11
|
83
|
+
rubygems_version: 3.0.3.1
|
42
84
|
signing_key:
|
43
85
|
specification_version: 4
|
44
86
|
summary: Filename sanitization for Ruby
|