Check-in [8f076a2392]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Consolidate filename+dirname lowercasing, switch to regex (FNM_EXTGLOB absent in Ruby 1.9.x). |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
8f076a2392d3e63370caec87810a0476 |
| User & Date: | mario 2014-12-30 12:34:23 |
Context
|
2014-12-30
| ||
| 12:35 | Permit staging_path rebuilding (set to nil on .cleanup), and provide :mkdir and :mkdirname creation in staging_path(subdir). check-in: 11502e1206 user: mario tags: trunk | |
| 12:34 | Consolidate filename+dirname lowercasing, switch to regex (FNM_EXTGLOB absent in Ruby 1.9.x). check-in: 8f076a2392 user: mario tags: trunk | |
|
2014-12-29
| ||
| 17:15 | Add trivial approach to filename lowercasing. (Useful for .phar packages.) check-in: 6c3683bcaa user: mario tags: trunk | |
Changes
Changes to lib/fpm/package/filter_lcase.rb.
1 2 3 4 5 6 | # api: fpm # title: Lowercase filenames # description: Changes filenames and directories to lowercase in the packaging process # type: rewrite # category: filter | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # api: fpm # title: Lowercase filenames # description: Changes filenames and directories to lowercase in the packaging process # type: rewrite # category: filter # version: 0.2 # license: MITL # # Lowercase input filenames and directories. Filenames according to # specified extension list, or all files per `=*` parameter. # # Usage: # -u lcase=c:php:rb |
| ︙ | ︙ | |||
24 25 26 27 28 29 30 | # rename uppercase filenames and directories class FPM::Package::Filter_lcase < FPM::Package # rewrite filenames def update(opts) | < | < < | < < < < < < < < < < < < < < < | > > | | | > > | > | > > > > > > > > > < < > | | < > | < | | | | | | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# rename uppercase filenames and directories
class FPM::Package::Filter_lcase < FPM::Package
# rewrite filenames
def update(opts)
# prepare file search pattern
if opts.empty?
exts = /^\.$/
elsif opts.include? "*"
exts = //
else
exts = /^ .+ \. (?: #{opts.join('|')} ) $/ix
end
# traverse directory tree
walk(staging_path, exts)
end # def update
# Level-wise trough directories, so no further need to care about already lowercased dirnames
def walk(dir, exts)
::Dir.chdir(dir) do
::Dir.glob("*").each do
|fn|
if File.directory?(fn)
walk(lcase(fn), exts)
elsif File.file?(fn)
lcase(fn) if fn =~ exts
end
end
end
end # walk
# Only rename to lowercase if filename isn't already
def lcase(fn)
down = fn.downcase
unless fn == down
FileUtils.mv(fn, down)
end
return down
end # lcase
end # class
|