file-timestamp 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/timestamp +18 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmQ0MDRiZGJmMGQ5MWI4OGYyNGVlZjI1YmE2M2E5N2ZiNzYyNzYzMA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzJhYTU3YzEyNmU5NzVkZTk1N2JmNWQ5ZDU1MjJiZTI0NWNiMjlkMg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTJhY2FkZjJjODM2ZWQ1ZDQ1OTJjZDQyNzQyN2M3ODdiZjVjOWYyMmExOTdj
|
10
|
+
YzUzYWU0MDk3MWE4NDgxNjIxYTgxNzRmMTE3YTZmNWJiOTI0NzU2N2Y3MjE4
|
11
|
+
MWJhMDQ5MDljNWQwYTE0MjBmNmJkZDI2N2YzMGU5NzBkNjU0NjY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDkyM2Y3ZmRkZmI1YzdjMTI0M2YxMDFjZTBkYjExZTgzNDhiZDg3MmJhYzgw
|
14
|
+
OWMyNTFhZmQ0YWE2ODhkOWQzZmI0NTA2MTMwMmE2MzJkYjkzMzkyMzA5ZTFi
|
15
|
+
ZjBmMGIwODEwZjQ4ODllZTk1NzRmZDNiNTUxOTEzOTA2NjZkOTI=
|
data/bin/timestamp
CHANGED
@@ -5,9 +5,9 @@ require 'rubygems'
|
|
5
5
|
require 'json'
|
6
6
|
require 'optparse'
|
7
7
|
|
8
|
-
VERSION = "1.
|
8
|
+
VERSION = "1.5"
|
9
9
|
|
10
|
-
def collectFileMtime dir,
|
10
|
+
def collectFileMtime dir, exclude_ext, exclude_dir, include_ext
|
11
11
|
# debugger
|
12
12
|
map = {}
|
13
13
|
full_dir = File.expand_path dir
|
@@ -15,9 +15,9 @@ def collectFileMtime dir, file_ext, exclude_dir
|
|
15
15
|
is_empty = true
|
16
16
|
Dir.foreach "." do |file|
|
17
17
|
if File.directory? file
|
18
|
-
unless exclude_dir.include? file
|
18
|
+
unless exclude_dir.to_s.include? file
|
19
19
|
pwd = Dir.pwd
|
20
|
-
submap = collectFileMtime file,
|
20
|
+
submap = collectFileMtime file, exclude_ext, exclude_dir, include_ext
|
21
21
|
is_empty = false unless submap.nil? or submap.empty?
|
22
22
|
unless submap.nil?
|
23
23
|
map[file] = submap
|
@@ -25,9 +25,12 @@ def collectFileMtime dir, file_ext, exclude_dir
|
|
25
25
|
Dir.chdir pwd
|
26
26
|
end
|
27
27
|
else
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
ext = File.extname file
|
29
|
+
if include_ext.length == 0 or include_ext.to_s.include?(ext)
|
30
|
+
unless exclude_ext.to_s.include? ext
|
31
|
+
map[file] = (File.mtime file).strftime "%Y%m%d%H%M%S"
|
32
|
+
is_empty = false
|
33
|
+
end
|
31
34
|
end
|
32
35
|
end
|
33
36
|
end
|
@@ -38,7 +41,8 @@ end
|
|
38
41
|
option = {
|
39
42
|
:pretty => false,
|
40
43
|
:template => "#output#",
|
41
|
-
:
|
44
|
+
:exclude_ext => [".DS_Store", ".swp"],
|
45
|
+
:include_ext => [],
|
42
46
|
:exclude_dir => [".","..",".svn",".git"]
|
43
47
|
}
|
44
48
|
|
@@ -49,10 +53,11 @@ file-timestamp #{VERSION}
|
|
49
53
|
Usage:
|
50
54
|
timestamp [dir] 按目录树结构输出指定目录下的所有指定类型文件的时间戳JSON,默认输出当前目录
|
51
55
|
EOF
|
52
|
-
opts.on('--
|
56
|
+
opts.on('--pretty', "格式化输出") { option[:pretty] = true }
|
53
57
|
opts.on('--template <template>', '指定模板文本,内容占位符为#output#,如--template ";var json=#output#;"') { |template| option[:template] = template}
|
54
|
-
opts.on("--include x,y,z", Array, "
|
55
|
-
opts.on("--exclude x,y,z", Array, "
|
58
|
+
opts.on("--include-ext x,y,z", Array, "要包含的文件扩展名") { |include_ext| option[:include_ext].concat include_ext }
|
59
|
+
opts.on("--exclude-ext x,y,z", Array, "要排除的文件扩展名") { |exclude_ext| option[:exclude_ext].concat exclude_ext }
|
60
|
+
opts.on("--exclude-dir x,y,z", Array, "要排除的目录,默认--exclude-dir .svn,.git") { |exclude_dir| option[:exclude_dir].concat exclude_dir }
|
56
61
|
opts.on("--seajs", "使用默认的seajs模板"){option[:template] = ";define('timestamp', function(require, exports, module) {\n module.exports =#output#\n});" }
|
57
62
|
opts.on("--version", "显示版本"){option[:version] = true}
|
58
63
|
|
@@ -61,9 +66,9 @@ timestamp [dir] 按目录树结构输出指定目录下的所有指定类型文
|
|
61
66
|
if option[:version]
|
62
67
|
puts VERSION
|
63
68
|
else
|
64
|
-
tree = collectFileMtime(ARGV[0] || ".", option[:
|
69
|
+
tree = collectFileMtime(ARGV[0] || ".", option[:exclude_ext], option[:exclude_dir], option[:include_ext])
|
65
70
|
|
66
|
-
if option[:
|
71
|
+
if option[:pretty]
|
67
72
|
output = JSON.pretty_generate(tree)
|
68
73
|
else
|
69
74
|
output = tree.to_json
|