dir-to-xml 0.7.0 → 0.7.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/dir-to-xml.rb +22 -10
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67285bd12d04cbdcb410beec66b61b67f4af7a73
|
4
|
+
data.tar.gz: 018b47d9893f558ee6087dfd24f1f769c8700c1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f544cd8687ad522eff3da13cd0f0624dc234bd2fd47b0a212b121a7e710206dfa1420093cc188150d6f35f3d04131a46b297602ca4ed200327ed2c5fa31ce619
|
7
|
+
data.tar.gz: e91b07753b2f31e912b3b5a384a6863848bf02058bd3c5aac4b6e8e43a67f419599cc81ec9fc817ccfb51cf1ca3bea9a6e0efcaa3dde7f60e42b18848417a9dd
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/dir-to-xml.rb
CHANGED
@@ -9,8 +9,11 @@ class DirToXML
|
|
9
9
|
|
10
10
|
|
11
11
|
def initialize(path= '.', recursive: false)
|
12
|
+
|
12
13
|
super()
|
13
|
-
|
14
|
+
|
15
|
+
@path = path
|
16
|
+
|
14
17
|
old_path = Dir.pwd
|
15
18
|
raise "Directory not found." unless File.exists? path
|
16
19
|
Dir.chdir path
|
@@ -24,9 +27,9 @@ class DirToXML
|
|
24
27
|
name: x,
|
25
28
|
type: File::ftype(x),
|
26
29
|
ext: File.extname(x),
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
ctime: File::ctime(x),
|
31
|
+
mtime: File::mtime(x),
|
32
|
+
atime: File::atime(x)
|
30
33
|
}
|
31
34
|
|
32
35
|
end
|
@@ -50,13 +53,19 @@ class DirToXML
|
|
50
53
|
self
|
51
54
|
end
|
52
55
|
|
56
|
+
def find_by_filename(s)
|
57
|
+
@dx.all.find {|item| item.name == s}
|
58
|
+
end
|
59
|
+
|
60
|
+
alias find_by_file find_by_filename
|
61
|
+
|
53
62
|
def last_modified(ext=nil)
|
54
63
|
|
55
64
|
if ext and ext != '*' then
|
56
65
|
@object = @h.select{|x| x[:ext][/#{ext}/] or x[:type] == 'directory'}
|
57
66
|
end
|
58
67
|
|
59
|
-
a = sort_by :
|
68
|
+
a = sort_by :mtime
|
60
69
|
a2 = a.reject {|x| x[:name] == 'dir.xml'}
|
61
70
|
|
62
71
|
lm = a2[-1]
|
@@ -68,6 +77,10 @@ class DirToXML
|
|
68
77
|
end
|
69
78
|
end
|
70
79
|
|
80
|
+
def save()
|
81
|
+
@dx.save File.join(@path, 'dir.xml')
|
82
|
+
end
|
83
|
+
|
71
84
|
def select_by_ext(ext)
|
72
85
|
|
73
86
|
@object = ext != '*' ? @h.select{|x| x[:ext][/#{ext}/]} : @h
|
@@ -75,14 +88,13 @@ class DirToXML
|
|
75
88
|
end
|
76
89
|
|
77
90
|
def sort_by(sym)
|
78
|
-
procs = [[:
|
79
|
-
.sort_by{|x| x[:last_modified]}}]]
|
91
|
+
procs = [[:mtime, lambda{|obj| obj.sort_by{|x| x[:mtime]}}]]
|
80
92
|
proc1 = procs.assoc(sym).last
|
81
93
|
proc1.call(@object)
|
82
94
|
end
|
83
95
|
|
84
96
|
def sort_by_last_modified()
|
85
|
-
sort_by :
|
97
|
+
sort_by :mtime
|
86
98
|
end
|
87
99
|
|
88
100
|
alias sort_by_lastmodified sort_by_last_modified
|
@@ -104,8 +116,8 @@ class DirToXML
|
|
104
116
|
def dxify(a)
|
105
117
|
|
106
118
|
dx = Dynarex.new 'directory[title,file_path]/file(name, ' + \
|
107
|
-
'type, ext,
|
108
|
-
|
119
|
+
'type, ext, ctime, mtime, atime, description, owner, ' + \
|
120
|
+
'group, permissions)'
|
109
121
|
|
110
122
|
dx.title = 'Index of ' + File.basename(Dir.pwd)
|
111
123
|
dx.file_path = Dir.pwd
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|