dir-to-xml 0.9.3 → 1.0.2
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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/dir-to-xml.rb +67 -18
- metadata +38 -33
- metadata.gz.sig +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c4612af405a2a24d589028a583d28b3217c7c44db120ad68d015c412efe86b16
|
4
|
+
data.tar.gz: 8d66e4b320b585972be52e6085186858b2fd99dbd369b3d3c0919cc0cd36afa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd2821ac72de327ed54318f5d2ac63c14c184dae26181e6ff38ba455466a067de75dffd48b3749ce5b9ba03ca542d98db4ac94818e929f9e6ce86df43406a4ff
|
7
|
+
data.tar.gz: 48852e32ca730dc65bc3a4363bf87eb8d365742ea20add65ec22adf97e9e80fabf59716cf1cdcea171a234bda6f3dc7dac4ecf994314e26241863b66f3957380
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/dir-to-xml.rb
CHANGED
@@ -2,18 +2,22 @@
|
|
2
2
|
|
3
3
|
# file: dir-to-xml.rb
|
4
4
|
|
5
|
-
require '
|
5
|
+
require 'dxlite'
|
6
6
|
|
7
7
|
|
8
8
|
class DirToXML
|
9
9
|
|
10
|
-
attr_reader :dx
|
10
|
+
attr_reader :dx, :activity
|
11
11
|
|
12
|
-
def initialize(x= '.', recursive: false, index: 'dir.xml')
|
13
|
-
|
12
|
+
def initialize(x= '.', recursive: false, index: 'dir.xml', debug: false)
|
13
|
+
|
14
14
|
super()
|
15
15
|
|
16
|
-
|
16
|
+
@debug = debug
|
17
|
+
|
18
|
+
@dx = nil
|
19
|
+
|
20
|
+
if x.is_a? DxLite then
|
17
21
|
|
18
22
|
@dx = x
|
19
23
|
@a = @dx.to_a
|
@@ -27,9 +31,28 @@ class DirToXML
|
|
27
31
|
@path, @index, @recursive = path, index, recursive
|
28
32
|
|
29
33
|
raise "Directory not found." unless File.exists? path
|
34
|
+
filepath = File.join(path, index)
|
35
|
+
|
36
|
+
|
37
|
+
if File.exists? filepath then
|
38
|
+
|
39
|
+
@dx = DxLite.new(File.join(@path, @index), debug: @debug)
|
40
|
+
|
41
|
+
end
|
30
42
|
|
43
|
+
# has the directory been modified since last time?
|
44
|
+
#
|
45
|
+
if @dx and @dx.respond_to? :last_modified and \
|
46
|
+
@dx.last_modified.length > 0 then
|
47
|
+
|
48
|
+
return if Time.parse(@dx.last_modified) >= \
|
49
|
+
File.mtime(File.expand_path(path))
|
50
|
+
end
|
51
|
+
|
52
|
+
puts 'before Dir.glob' if @debug
|
53
|
+
|
31
54
|
a = Dir.glob(File.join(path, "*")).map{|x| File.basename(x) }.sort
|
32
|
-
|
55
|
+
|
33
56
|
a.delete index
|
34
57
|
|
35
58
|
a2 = a.inject([]) do |r, filename|
|
@@ -50,6 +73,24 @@ class DirToXML
|
|
50
73
|
end
|
51
74
|
|
52
75
|
end
|
76
|
+
|
77
|
+
if @dx and @dx.respond_to? :last_modified \
|
78
|
+
and @dx.last_modified.length > 0 then
|
79
|
+
|
80
|
+
t = Time.parse(@dx.last_modified)
|
81
|
+
|
82
|
+
# find the most recently modified cur_files
|
83
|
+
recent = a2.select {|x| x[:mtime] > t }.map {|x| x[:name]} \
|
84
|
+
- %w(dir.xml dir.json)
|
85
|
+
|
86
|
+
# is it a new file or recently modified?
|
87
|
+
new_files = recent - @dx.to_a.map {|x| x[:name]}
|
88
|
+
modified = recent - new_files
|
89
|
+
|
90
|
+
@activity = {modified: modified, new: new_files}
|
91
|
+
|
92
|
+
end
|
93
|
+
|
53
94
|
|
54
95
|
command = File.exists?(File.join(path, index)) ? :refresh : :dxify
|
55
96
|
|
@@ -82,11 +123,11 @@ class DirToXML
|
|
82
123
|
|
83
124
|
type_match = type ? x[:type] == type.to_s : true
|
84
125
|
ext_match = ext ? x[:ext] == ext.to_s : true
|
85
|
-
|
126
|
+
|
86
127
|
pattern_match and type_match and ext_match
|
87
128
|
|
88
129
|
end
|
89
|
-
|
130
|
+
|
90
131
|
self
|
91
132
|
end
|
92
133
|
|
@@ -117,12 +158,15 @@ class DirToXML
|
|
117
158
|
@dx.save File.join(@path, @index)
|
118
159
|
end
|
119
160
|
|
120
|
-
def select_by_ext(ext)
|
161
|
+
def select_by_ext(ext, &blk)
|
121
162
|
|
122
|
-
@object = ext != '*' ? @a.select{|x| x[:ext][/#{ext}
|
123
|
-
|
163
|
+
@object = ext != '*' ? @a.select{|x| x[:ext][/#{ext}$/]} : @a
|
164
|
+
return if @object.empty?
|
165
|
+
|
166
|
+
dx = DxLite.new
|
124
167
|
dx.import @object
|
125
|
-
DirToXML.new(dx)
|
168
|
+
dtx = DirToXML.new(dx)
|
169
|
+
block_given? ? dtx.dx.all.map(&:name).each(&blk) : dtx
|
126
170
|
end
|
127
171
|
|
128
172
|
def sort_by(sym)
|
@@ -159,13 +203,14 @@ class DirToXML
|
|
159
203
|
|
160
204
|
def dxify(a)
|
161
205
|
|
162
|
-
dx =
|
206
|
+
dx = DxLite.new('directory[title, file_path, last_modified, description]/file(name, ' + \
|
163
207
|
'type, ext, ctime, mtime, atime, description, owner, ' + \
|
164
|
-
'group, permissions)'
|
208
|
+
'group, permissions)')
|
165
209
|
|
166
210
|
dx.title = 'Index of ' + File.expand_path(@path)
|
167
211
|
dx.file_path = File.expand_path(@path)
|
168
|
-
|
212
|
+
dx.last_modified = Time.now.to_s
|
213
|
+
|
169
214
|
dx.import a
|
170
215
|
|
171
216
|
dx.save File.join(@path, @index)
|
@@ -176,14 +221,18 @@ class DirToXML
|
|
176
221
|
|
177
222
|
def refresh(cur_files)
|
178
223
|
|
179
|
-
|
224
|
+
puts 'inside refresh' if @debug
|
225
|
+
|
180
226
|
|
181
|
-
prev_files = dx.to_a
|
227
|
+
prev_files = @dx.to_a
|
228
|
+
|
229
|
+
#puts 'prev_files: ' + prev_files.inspect
|
230
|
+
#puts 'cur_files: ' + cur_files.inspect
|
182
231
|
|
183
232
|
cur_files.each do |x|
|
184
233
|
|
185
234
|
file = prev_files.find {|item| item[:name] == x[:name] }
|
186
|
-
|
235
|
+
#puts 'found : ' + file.inspect if @debug
|
187
236
|
x[:description] = file[:description] if file and file[:description]
|
188
237
|
end
|
189
238
|
|
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: 0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -10,50 +10,55 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
13
|
+
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjEwMTIzMTgwNTQ4WhcN
|
15
|
+
MjIwMTIzMTgwNTQ4WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC3/Li6
|
17
|
+
/b2XI6+wLVA57zxSEu6RtQqu94GlPisH87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
wh0fYGJ2iC/w3rPA78Awm6FNPlGCPjgPIz4mliMicRI/sZmFQvn8+2HYWEzDDOO8
|
33
|
+
zYvUB7rkjDGXYqN1Ft3N6EOuNworOFjUlcPrDFCQHf4UgPjD6Z8WbYkI9c7LWtjc
|
34
|
+
HJCyl/PVyS0Srbl8IPn7JsgUCS7S02KOnVzukQ7PTc1wBlAZ4mNb7N9EOp90GP9a
|
35
|
+
YSREEphg3phQsU9LV4Dlc2Id4gB3W+//c1Ek6TFieKoVemKMkbtB1lgqsEpTCfwh
|
36
|
+
oNUg84DlSmZ2z9LKagBVAlDy
|
32
37
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
38
|
+
date: 2021-01-24 00:00:00.000000000 Z
|
34
39
|
dependencies:
|
35
40
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
41
|
+
name: dxlite
|
37
42
|
requirement: !ruby/object:Gem::Requirement
|
38
43
|
requirements:
|
39
|
-
- - "~>"
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '1.7'
|
42
44
|
- - ">="
|
43
45
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
46
|
+
version: 0.3.0
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.3'
|
45
50
|
type: :runtime
|
46
51
|
prerelease: false
|
47
52
|
version_requirements: !ruby/object:Gem::Requirement
|
48
53
|
requirements:
|
49
|
-
- - "~>"
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: '1.7'
|
52
54
|
- - ">="
|
53
55
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
56
|
+
version: 0.3.0
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0.3'
|
55
60
|
description:
|
56
|
-
email:
|
61
|
+
email: digital.robertson@gmail.com
|
57
62
|
executables: []
|
58
63
|
extensions: []
|
59
64
|
extra_rdoc_files: []
|
@@ -71,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
76
|
requirements:
|
72
77
|
- - ">="
|
73
78
|
- !ruby/object:Gem::Version
|
74
|
-
version: 2.
|
79
|
+
version: 2.5.3
|
75
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
81
|
requirements:
|
77
82
|
- - ">="
|
@@ -79,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
84
|
version: '0'
|
80
85
|
requirements: []
|
81
86
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.7.10
|
83
88
|
signing_key:
|
84
89
|
specification_version: 4
|
85
90
|
summary: Dir-to-xml saves a directory listing in the Dynarex XML format
|
metadata.gz.sig
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
����ʽ{]k$S�d���� �|(I]�;"�~cWu�~��c
|
2
|
+
'�"�</8��Cq�-
|
3
|
+
&iB�ɐ�F٠�?�w3�V�R`�!��פ�@����$MUDp��Dk,�C��"��������z�3����:�-F6�(�'J��+P���a��b}5���"��:�昉aϛ,E�oSX�3����}
|
4
|
+
yd�#��U�>K,��B,ף��]��%$�����s:[��ߙ�?��
|
5
|
+
�3��E�_"�s��v8
|
6
|
+
��>.��u���N���/+�o��.j|wO�9��o\�`�ƨpjs���xϿb���Y}_@��=���~E�� �u\�
|