dir-to-xml 1.0.1 → 1.0.6
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 +72 -31
- metadata +8 -8
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a24fbbc39d5a5d420a7b67713292409a71aae25b72484c9af7f261af3b1f952f
|
4
|
+
data.tar.gz: 8e33e3dd2579ee7ef0c3c56144b2cc2beecb68784e20c60b73ea1f8bb1adc9fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c45dfed7498b83d0918456d4deb47570cec2f6ab63e27baf0cc26f815927a161a783d3278f6ad5bb421f7d199f9332ea42fd3e9afa10c8ba1c4bd17838785ca6
|
7
|
+
data.tar.gz: 0dc2bdf0cc9483abf4f0ec8fc4f33c48a2d64e9e30cc1b281383c1bb3f9586b7aa4bd5db3459fed4a205e1b9c05954bdaa6629c416f78e357fbe543e4261a154
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/dir-to-xml.rb
CHANGED
@@ -15,6 +15,9 @@ class DirToXML
|
|
15
15
|
|
16
16
|
@debug = debug
|
17
17
|
|
18
|
+
@dx = nil
|
19
|
+
@activity = {new: [], modified: []}
|
20
|
+
|
18
21
|
if x.is_a? DxLite then
|
19
22
|
|
20
23
|
@dx = x
|
@@ -29,15 +32,25 @@ class DirToXML
|
|
29
32
|
@path, @index, @recursive = path, index, recursive
|
30
33
|
|
31
34
|
raise "Directory not found." unless File.exists? path
|
35
|
+
filepath = File.join(path, index)
|
36
|
+
|
37
|
+
|
38
|
+
if File.exists? filepath then
|
32
39
|
|
33
|
-
|
40
|
+
@dx = DxLite.new(File.join(@path, @index), debug: @debug)
|
41
|
+
|
42
|
+
else
|
43
|
+
|
44
|
+
@dx = DxLite.new('directory[title, file_path, last_modified, ' + \
|
45
|
+
'description]/file(name, type, ext, ctime, mtime, atime, ' + \
|
46
|
+
'description, owner, group, permissions)')
|
34
47
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
48
|
+
puts 'before title' if @debug
|
49
|
+
@dx.title = 'Index of ' + File.expand_path(@path)
|
50
|
+
@dx.file_path = File.expand_path(@path)
|
51
|
+
@dx.last_modified = ''
|
52
|
+
|
53
|
+
end
|
41
54
|
|
42
55
|
puts 'before Dir.glob' if @debug
|
43
56
|
|
@@ -64,17 +77,47 @@ class DirToXML
|
|
64
77
|
|
65
78
|
end
|
66
79
|
|
67
|
-
|
80
|
+
# has the directory been modified since last time?
|
81
|
+
#
|
82
|
+
if @dx and @dx.respond_to? :last_modified and \
|
83
|
+
@dx.last_modified.length > 0 then
|
84
|
+
|
85
|
+
puts 'nothing to do' if @debug
|
86
|
+
|
87
|
+
file = a2.max_by {|x| x[:mtime]}
|
68
88
|
|
69
|
-
|
89
|
+
if @debug then
|
90
|
+
puts 'file: ' + file.inspect
|
91
|
+
puts 'd1: ' + Time.parse(@dx.last_modified).inspect
|
92
|
+
puts 'd2: ' + (file[:mtime]).inspect
|
93
|
+
end
|
94
|
+
|
95
|
+
return if Time.parse(@dx.last_modified) >= file[:mtime]
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
puts 'stage 2'
|
100
|
+
|
101
|
+
if @dx and @dx.respond_to? :last_modified then
|
70
102
|
|
71
|
-
|
72
|
-
recent = a2.select {|x| x[:mtime] > t }.map {|x| x[:name]} \
|
73
|
-
- %w(dir.xml dir.json)
|
103
|
+
if @dx.last_modified.length > 0 then
|
74
104
|
|
75
|
-
|
76
|
-
|
77
|
-
|
105
|
+
t = Time.parse(@dx.last_modified)
|
106
|
+
|
107
|
+
# find the most recently modified cur_files
|
108
|
+
recent = a2.select {|x| Time.parse(x[:mtime]) > t }.map {|x| x[:name]} \
|
109
|
+
- %w(dir.xml dir.json)
|
110
|
+
|
111
|
+
# is it a new file or recently modified?
|
112
|
+
new_files = recent - @dx.to_a.map {|x| x[:name]}
|
113
|
+
modified = recent - new_files
|
114
|
+
|
115
|
+
else
|
116
|
+
|
117
|
+
new_files = a2.select {|x| x[:type] == 'file'}.map {|x| x[:name]}
|
118
|
+
modified = []
|
119
|
+
|
120
|
+
end
|
78
121
|
|
79
122
|
@activity = {modified: modified, new: new_files}
|
80
123
|
|
@@ -83,7 +126,10 @@ class DirToXML
|
|
83
126
|
|
84
127
|
command = File.exists?(File.join(path, index)) ? :refresh : :dxify
|
85
128
|
|
86
|
-
|
129
|
+
self.method(command).call a2
|
130
|
+
puts '@dx: ' + @dx.inspect if @debug
|
131
|
+
puts '@dx.last_modified: ' + @dx.last_modified.inspect if @debug
|
132
|
+
|
87
133
|
|
88
134
|
@a = @dx.to_a
|
89
135
|
|
@@ -159,9 +205,15 @@ class DirToXML
|
|
159
205
|
end
|
160
206
|
|
161
207
|
def sort_by(sym)
|
208
|
+
|
209
|
+
puts 'inside sort_by' if @debug
|
162
210
|
procs = [[:mtime, lambda{|obj| obj.sort_by{|x| x[:mtime]}}]]
|
163
211
|
proc1 = procs.assoc(sym).last
|
212
|
+
|
213
|
+
puts '@object: ' + @object.inspect if @debug
|
214
|
+
@object = @a = @dx.to_a if @object.nil?
|
164
215
|
proc1.call(@object)
|
216
|
+
|
165
217
|
end
|
166
218
|
|
167
219
|
def sort_by_last_modified()
|
@@ -192,26 +244,15 @@ class DirToXML
|
|
192
244
|
|
193
245
|
def dxify(a)
|
194
246
|
|
195
|
-
dx =
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
dx.title = 'Index of ' + File.expand_path(@path)
|
200
|
-
dx.file_path = File.expand_path(@path)
|
201
|
-
dx.last_modified = Time.now.to_s
|
202
|
-
|
203
|
-
dx.import a
|
204
|
-
|
205
|
-
dx.save File.join(@path, @index)
|
206
|
-
|
207
|
-
return dx
|
247
|
+
@dx.last_modified = Time.now.to_s if @dx.respond_to? :last_modified
|
248
|
+
@dx.import a
|
249
|
+
@dx.save File.join(@path, @index)
|
208
250
|
|
209
251
|
end
|
210
252
|
|
211
253
|
def refresh(cur_files)
|
212
254
|
|
213
|
-
puts 'inside refresh' if @debug
|
214
|
-
|
255
|
+
puts 'inside refresh' if @debug
|
215
256
|
|
216
257
|
prev_files = @dx.to_a
|
217
258
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dir-to-xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,28 +35,28 @@ cert_chain:
|
|
35
35
|
YSREEphg3phQsU9LV4Dlc2Id4gB3W+//c1Ek6TFieKoVemKMkbtB1lgqsEpTCfwh
|
36
36
|
oNUg84DlSmZ2z9LKagBVAlDy
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2021-01
|
38
|
+
date: 2021-02-01 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: dxlite
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 0.3.0
|
47
44
|
- - "~>"
|
48
45
|
- !ruby/object:Gem::Version
|
49
46
|
version: '0.3'
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.3.2
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 0.3.0
|
57
54
|
- - "~>"
|
58
55
|
- !ruby/object:Gem::Version
|
59
56
|
version: '0.3'
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.3.2
|
60
60
|
description:
|
61
61
|
email: digital.robertson@gmail.com
|
62
62
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|