dir-to-xml 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/dir-to-xml.rb +12 -19
- data.tar.gz.sig +0 -0
- metadata +2 -2
- 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: d902a0b07e4b77dc9d9ad7122a4e84186a6e5c09
|
4
|
+
data.tar.gz: b9271f1ca9b93c64da56180ec9e018609f1b204f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6e2869f2e12fc0570535f20986f41aba36f5cb918e3afe8bc72914c273bf82186d81c917503fcb55bfb7c952b6d5b1682d07b7b2bb65aa635f710ced38ed874
|
7
|
+
data.tar.gz: 1660b3c78c97d666228f28013ed2e10b168a20daf774b5ff5e2597d9c2194592d83493c049a26adf2e96fcd815bd803d8923fd6660346941e148e33e59ca5769
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/dir-to-xml.rb
CHANGED
@@ -8,18 +8,17 @@ require 'dynarex'
|
|
8
8
|
class DirToXML
|
9
9
|
|
10
10
|
|
11
|
-
def initialize(path= '.', recursive: false)
|
11
|
+
def initialize(path= '.', recursive: false, index: 'dir.xml')
|
12
12
|
|
13
13
|
super()
|
14
14
|
|
15
|
-
@path = path
|
15
|
+
@path, @index, @recursive = path, index, recursive
|
16
16
|
|
17
|
-
old_path = Dir.pwd
|
18
17
|
raise "Directory not found." unless File.exists? path
|
19
|
-
Dir.chdir path
|
20
18
|
|
21
|
-
a = Dir.glob("*").sort
|
22
|
-
|
19
|
+
a = Dir.glob(File.join(path, "*")).map{|x| File.basename(x) }.sort
|
20
|
+
|
21
|
+
a.delete index
|
23
22
|
|
24
23
|
a2 = a.inject([]) do |r, x|
|
25
24
|
|
@@ -34,17 +33,12 @@ class DirToXML
|
|
34
33
|
|
35
34
|
end
|
36
35
|
|
37
|
-
command = File.exists?(
|
36
|
+
command = File.exists?(index) ? :refresh : :dxify
|
38
37
|
|
39
38
|
@dx = self.method(command).call a2
|
40
|
-
|
41
|
-
Dir.chdir old_path
|
42
|
-
|
43
|
-
@h = @dx.to_h
|
44
|
-
@object = @h
|
45
39
|
|
46
|
-
@
|
47
|
-
@
|
40
|
+
@h = @dx.to_h
|
41
|
+
@object = @h
|
48
42
|
|
49
43
|
end
|
50
44
|
|
@@ -66,9 +60,8 @@ class DirToXML
|
|
66
60
|
end
|
67
61
|
|
68
62
|
a = sort_by :mtime
|
69
|
-
a2 = a.reject {|x| x[:name] == 'dir.xml'}
|
70
63
|
|
71
|
-
lm =
|
64
|
+
lm = a[-1]
|
72
65
|
|
73
66
|
if @recursive and lm[:type] == 'directory' then
|
74
67
|
return [lm, DirToXML.new(File.join(@path, lm[:name])).last_modified]
|
@@ -78,7 +71,7 @@ class DirToXML
|
|
78
71
|
end
|
79
72
|
|
80
73
|
def save()
|
81
|
-
@dx.save File.join(@path,
|
74
|
+
@dx.save File.join(@path, @index)
|
82
75
|
end
|
83
76
|
|
84
77
|
def select_by_ext(ext)
|
@@ -123,7 +116,7 @@ class DirToXML
|
|
123
116
|
dx.file_path = Dir.pwd
|
124
117
|
|
125
118
|
dx.import a
|
126
|
-
dx.save
|
119
|
+
dx.save @index
|
127
120
|
|
128
121
|
return dx
|
129
122
|
|
@@ -131,7 +124,7 @@ class DirToXML
|
|
131
124
|
|
132
125
|
def refresh(cur_files)
|
133
126
|
|
134
|
-
dx = Dynarex.new
|
127
|
+
dx = Dynarex.new @index
|
135
128
|
|
136
129
|
prev_files = dx.to_a
|
137
130
|
|
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: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
iqgRYucyTfq3VLTy6wrGN2HJj8unXh4JIFjyEvR3yvcCYl6IaHxuDfgoDfBI6MeQ
|
32
32
|
Em7HctRLQorltw==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-12-
|
34
|
+
date: 2015-12-19 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: dynarex
|
metadata.gz.sig
CHANGED
Binary file
|