adamh-asset_library 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/asset_library/asset_module.rb +0 -47
  2. metadata +1 -1
@@ -80,52 +80,5 @@ class AssetLibrary
80
80
  write_cache(format)
81
81
  end
82
82
  end
83
-
84
- private
85
-
86
- def assets_for_pattern(pattern, extra_suffix)
87
- ret = []
88
-
89
- suffix = config[:suffix]
90
- suffix = "#{extra_suffix}.#{suffix}" if extra_suffix
91
-
92
- requested_path = File.join(AssetLibrary.root, config[:base], "#{pattern}.#{suffix}")
93
-
94
- Dir.glob(requested_path).sort.each do |found_file|
95
- found_file = maybe_add_optional_suffix_to_path(found_file)
96
- next if path_contains_extra_dot?(found_file, pattern, extra_suffix)
97
- ret << AssetLibrary::Asset.new(found_file)
98
- end
99
-
100
- ret
101
- end
102
-
103
- def maybe_add_optional_suffix_to_path(path)
104
- if config[:optional_suffix]
105
- basename = path[0..-(config[:suffix].length + 2)]
106
- path_with_suffix = "#{basename}.#{config[:optional_suffix]}.#{config[:suffix]}"
107
- File.exist?(path_with_suffix) ? path_with_suffix : path
108
- else
109
- path
110
- end
111
- end
112
-
113
- def path_contains_extra_dot?(path, requested_file, extra_suffix)
114
- allowed_suffixes = []
115
-
116
- allowed_suffixes << "\\.#{Regexp.quote(extra_suffix.to_s)}" if extra_suffix
117
- allowed_suffixes << "(\\.#{Regexp.quote(config[:optional_suffix].to_s)})?" if config[:optional_suffix]
118
- allowed_suffixes << "\\.#{Regexp.quote(config[:suffix].to_s)}" if config[:suffix]
119
-
120
- basename = File.basename(path)
121
- requested_basename = File.basename(requested_file)
122
-
123
- n_dots = requested_basename.count('.')
124
- basename_regex = (['[^\.]+'] * (n_dots + 1)).join('\.')
125
-
126
- regex = /^#{basename_regex}#{allowed_suffixes.join}$/
127
-
128
- !(basename =~ regex)
129
- end
130
83
  end
131
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adamh-asset_library
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - adamh