Module: FileMatcher

Defined in:
app/lib/file_matcher.rb

Class Method Summary collapse

Class Method Details

.case_insensitive_glob_string(str) ⇒ Object



10
11
12
13
14
# File 'app/lib/file_matcher.rb', line 10

def self.case_insensitive_glob_string(str)
  str.chars.map { |char|
    "[#{char.upcase}#{char.downcase}]"
  }.join
end

.common_subfolders ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/lib/file_matcher.rb', line 24

def self.common_subfolders
  {
    "3mf" => file_pattern,
    "fdm" => file_pattern,
    "files" => file_pattern,
    "images" => image_pattern,
    "lychee" => file_pattern,
    "lys" => file_pattern,
    "model" => file_pattern,
    "obj" => file_pattern,
    "parts" => file_pattern,
    "presupported" => file_pattern,
    "resin" => file_pattern,
    "stl" => file_pattern,
    "sup" => file_pattern,
    "supported" => file_pattern,
    "unsupported" => file_pattern
  }
end

.extension_glob(extensions) ⇒ Object



2
3
4
5
6
7
8
# File 'app/lib/file_matcher.rb', line 2

def self.extension_glob(extensions)
  [
    "*.{",
    extensions.map { |ext| case_insensitive_glob_string(ext) }.join(","),
    "}"
  ].join
end

.file_pattern ⇒ Object



20
21
22
# File 'app/lib/file_matcher.rb', line 20

def self.file_pattern
  extension_glob(MediaType.indexable_extensions)
end

.image_pattern ⇒ Object



16
17
18
# File 'app/lib/file_matcher.rb', line 16

def self.image_pattern
  extension_glob(MediaType.image_extensions)
end