dir-to-xml 1.1.3 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0d019bf13b52e143181d63f55ecb59d4afd6d0528316f8eabc98dad63d7701e
4
- data.tar.gz: 706dfd39b2ec9a414394374736bc390a9fc786243181ccdc65ca4c7b42f16f90
3
+ metadata.gz: 68fb3b092b29f78ba022f7ed82bcb492de8371abcbfbeffb96b68d5dce547838
4
+ data.tar.gz: e30e9f017e10760e9b6df95f56fd3984edf86c6d0f94794b465d5c0de7492dc1
5
5
  SHA512:
6
- metadata.gz: 761c9d38635ad4b9391a8b532713c2c8aa0c3b7e08172d811bf60772135392e4e8fbfc477239083cae926255c005aa689963d03b13aa5965b6a32804f7270067
7
- data.tar.gz: d067ed9b1577125f7bc3b6cf8527531f9ced333a687486e65576307b4462d8ce27f2216042121147d64561e107e5f97d18d82b42a3e6cb4e732ddcbd4f1e9b61
6
+ metadata.gz: eaac7e5cd9fabbd8e36c447fcf1476da286e5d38aa529cf49ef49bb4c92e70f3ec7f826754e4c90efb758d722eb130a13c23274aa8f3f6d021206284e6f1cea1
7
+ data.tar.gz: 6b40bb4b36f1a3873cea22cfd0246952d4d83a1000140f1472f0b75316611d5f8a101b30a04dc96bf663bb13f8eefc7ab5783697ee47f1074a97409fd1093ba4
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/dir-to-xml.rb CHANGED
@@ -31,7 +31,7 @@ require 'dxlite'
31
31
 
32
32
  class DirToXML
33
33
  using ColouredText
34
- include RXFHelperModule
34
+ include RXFReadWriteModule
35
35
 
36
36
  attr_reader :new_files, :deleted_files, :dx, :latest_files, :latest_file
37
37
 
@@ -75,7 +75,11 @@ class DirToXML
75
75
  alias changes activity
76
76
 
77
77
  def directories()
78
- @dx.all.select {|x| x.type == 'directory'}.map(&:name)
78
+
79
+ a = @dx.all
80
+ puts 'inside directories() a: ' + a.inspect if @debug
81
+ a.select {|x| x.type == 'directory'}.map(&:name)
82
+
79
83
  end
80
84
 
81
85
  def find_all_by_ext(s)
@@ -97,8 +101,9 @@ class DirToXML
97
101
  def new_scan()
98
102
 
99
103
  t = Time.now
104
+ puts '_new_scan() @path: ' + @path.inspect if @debug
100
105
  records = scan_dir @path
101
- puts 'new_scan() records: ' + records.inspect if @debug
106
+ puts '_new_scan() records: ' + records.inspect if @debug
102
107
 
103
108
  a = records.map {|x| x[:name]}
104
109
 
@@ -122,37 +127,44 @@ class DirToXML
122
127
 
123
128
  end
124
129
 
125
- # check for newly modified files
126
- # compare the file date with index file last modified date
130
+ # Add any new files
127
131
  #
128
- dtx_last_modified = Time.parse(@dx.last_modified)
132
+ @new_files = a - a2
129
133
 
130
- select_records = records.select do |file|
134
+ if @new_files.any? then
135
+ @dx.import @new_files.map {|filename| getfile_info(filename) }
136
+ end
131
137
 
132
- file[:mtime] > dtx_last_modified or file[:type] == 'directory'
138
+ if (@deleted_files + @new_files).any? then
133
139
 
134
- end
140
+ @dx.last_modified = Time.now.to_s
141
+ @dx.save
135
142
 
136
- puts 'select_records: ' + select_records.inspect if @debug
137
- find_latest(select_records) if select_records.any?
143
+ new_scan()
138
144
 
139
- # Add any new files
140
- #
141
- @new_files = a - a2
145
+ else
142
146
 
143
- if @new_files.any? then
147
+ # check for newly modified files
148
+ # compare the file date with index file last modified date
149
+ #
150
+ dtx_last_modified = Time.parse(@dx.last_modified)
144
151
 
145
- @dx.last_modified = Time.now.to_s
146
- @dx.import @new_files.map {|filename| getfile_info(filename) }
152
+ select_records = records.select do |file|
147
153
 
154
+ file[:mtime] > dtx_last_modified or file[:type] == 'directory'
155
+
156
+ end
157
+
158
+ puts 'select_records: ' + select_records.inspect if @debug
159
+
160
+ find_latest(select_records) if select_records.any?
148
161
  end
149
162
 
150
- @dx.last_modified = Time.now.to_s if @deleted_files.any?
151
163
 
152
164
  else
153
165
 
154
166
  @dx = new_index(records)
155
- find_latest(records)
167
+ find_latest(records) if records.any?
156
168
 
157
169
  end
158
170
 
@@ -166,7 +178,7 @@ class DirToXML
166
178
  t = Time.now
167
179
  puts 'read path: ' + File.join(@path, index).inspect if @Debug
168
180
 
169
- dx = DxLite.new(File.join(@path, index), autosave: true)
181
+ dx = DxLite.new(File.join(@path, index), autosave: false)
170
182
 
171
183
  t2 = Time.now - t
172
184
  puts ("%s read in %.2f seconds" % [@index, t2]).info if @verbose
@@ -186,7 +198,11 @@ class DirToXML
186
198
  @latest_file[:path] = @path
187
199
  puts ':@latest_file: ' + @latest_file.inspect if @debug
188
200
 
201
+ return unless @recursive
202
+
203
+ puts 'before directories()' if @debug
189
204
  dir_list = directories()
205
+ puts 'dir_list: ' + dir_list.inspect if @debug
190
206
 
191
207
  if dir_list.any? then
192
208
 
@@ -194,7 +210,7 @@ class DirToXML
194
210
 
195
211
  puts 'dir: ' + dir.inspect if @debug
196
212
  dtx2 = DirToXML.new(File.join(@path, dir), index: @index,
197
- recursive: true, verbose: false, debug: @debug)
213
+ recursive: @recursive, verbose: false, debug: @debug)
198
214
  [dir, dtx2.latest_file]
199
215
 
200
216
  end.reject {|_,latest| latest.nil? }.sort_by {|_, x| x[:mtime]}.last
@@ -248,7 +264,7 @@ class DirToXML
248
264
  dx.title = 'Index of ' + @path
249
265
  dx.file_path = @path
250
266
  dx.last_modified = Time.now
251
- dx.import records.reverse
267
+ dx.import records.reverse if records.any?
252
268
  dx.save File.join(@path, @index)
253
269
 
254
270
  return dx
data.tar.gz.sig CHANGED
Binary file
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.1.3
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,48 +35,28 @@ cert_chain:
35
35
  m7hEq9GAsvYejQNMhcxlvi+e70d3QiEg+2SVsBHaUGURzv0LjycCOjOaUxQA5swC
36
36
  JKGINad8xoEL7XIDoO6EnBcY
37
37
  -----END CERTIFICATE-----
38
- date: 2022-02-15 00:00:00.000000000 Z
38
+ date: 2022-03-06 00:00:00.000000000 Z
39
39
  dependencies:
40
- - !ruby/object:Gem::Dependency
41
- name: c32
42
- requirement: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 0.3.0
47
- - - "~>"
48
- - !ruby/object:Gem::Version
49
- version: '0.3'
50
- type: :runtime
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: 0.3.0
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '0.3'
60
40
  - !ruby/object:Gem::Dependency
61
41
  name: dxlite
62
42
  requirement: !ruby/object:Gem::Requirement
63
43
  requirements:
64
44
  - - "~>"
65
45
  - !ruby/object:Gem::Version
66
- version: '0.5'
46
+ version: '0.6'
67
47
  - - ">="
68
48
  - !ruby/object:Gem::Version
69
- version: 0.5.2
49
+ version: 0.6.0
70
50
  type: :runtime
71
51
  prerelease: false
72
52
  version_requirements: !ruby/object:Gem::Requirement
73
53
  requirements:
74
54
  - - "~>"
75
55
  - !ruby/object:Gem::Version
76
- version: '0.5'
56
+ version: '0.6'
77
57
  - - ">="
78
58
  - !ruby/object:Gem::Version
79
- version: 0.5.2
59
+ version: 0.6.0
80
60
  description:
81
61
  email: digital.robertson@gmail.com
82
62
  executables: []
@@ -103,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
83
  - !ruby/object:Gem::Version
104
84
  version: '0'
105
85
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.7.10
86
+ rubygems_version: 3.2.22
108
87
  signing_key:
109
88
  specification_version: 4
110
89
  summary: Dir-to-xml saves a directory listing in the Dynarex XML format
metadata.gz.sig CHANGED
@@ -1,5 +1 @@
1
- 38�����������π����8����|�A�4,���觶��b�E�-w��24T&���+N�J>_�
2
- v�l~ot|5a�O��lp���Wk���qA[��1�~�x׿?���L�yܿ'Lx/*.�n��
3
- H��@4�_F�uV�����u��'�U��;k�K��hPw�5�i3��?6��9{�B� ��\�) ��w�Ï�����ԌCo*W���!�_]ty�؉cڻk����]cŽIz�<�શGPZM��.f}��A֜���ܜr�_)Џ��j�2ʬ�r��8��-RL�E�]��&`�����q$�(���� ��i�W� ^GP.�@�<�5�\xy��-�9�/i|T��f
4
- ���b率z1'��
5
- ~�4r.
1
+ ��mQT>Ђ ��H��