dir-to-xml 0.7.4 → 0.8.0
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 +27 -13
- 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: 30753497dc3cb89192e2b16e2830a26ce5fef29c
|
4
|
+
data.tar.gz: fce05e271fa0d471391284a2218ca863e21135f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6790149b80e859dcd6486c79266a940be2d87eea37d076bf6008842d0a7e42ebe362f5a4bc3fcd45c9b92e858f9aac4915401190521fdf7f97469aab8e7e3d5d
|
7
|
+
data.tar.gz: 48f055d6452018949ddcc81ee853ea4bf9e2c233397f8d03ec2d69dd74c2bc4c6f57728f81d36d4303da4341e8c8ac2621183d339a2ff0df0677f66787dfd67f
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/dir-to-xml.rb
CHANGED
@@ -7,7 +7,8 @@ require 'dynarex'
|
|
7
7
|
|
8
8
|
class DirToXML
|
9
9
|
|
10
|
-
|
10
|
+
attr_reader :dx
|
11
|
+
|
11
12
|
def initialize(path= '.', recursive: false, index: 'dir.xml')
|
12
13
|
|
13
14
|
super()
|
@@ -35,20 +36,27 @@ class DirToXML
|
|
35
36
|
|
36
37
|
end
|
37
38
|
|
38
|
-
command = File.exists?(index) ? :refresh : :dxify
|
39
|
+
command = File.exists?(File.join(path, index)) ? :refresh : :dxify
|
39
40
|
|
40
41
|
@dx = self.method(command).call a2
|
41
42
|
|
42
|
-
@
|
43
|
-
@object = @
|
43
|
+
@a = @dx.to_a
|
44
|
+
@object = @a
|
44
45
|
|
45
46
|
end
|
46
47
|
|
47
|
-
def
|
48
|
-
|
48
|
+
def filter_by(pattern=/.*/, type: nil)
|
49
|
+
|
50
|
+
@object = @a.select do |x|
|
51
|
+
|
52
|
+
pattern_match = x[:name] =~ pattern
|
53
|
+
type_match = type ? x[:type] == type.to_s : true
|
54
|
+
|
55
|
+
end
|
56
|
+
|
49
57
|
self
|
50
58
|
end
|
51
|
-
|
59
|
+
|
52
60
|
def find_by_filename(s)
|
53
61
|
@dx.all.find {|item| item.name == s}
|
54
62
|
end
|
@@ -58,7 +66,7 @@ class DirToXML
|
|
58
66
|
def last_modified(ext=nil)
|
59
67
|
|
60
68
|
if ext and ext != '*' then
|
61
|
-
@object = @
|
69
|
+
@object = @a.select{|x| x[:ext][/#{ext}/] or x[:type] == 'directory'}
|
62
70
|
end
|
63
71
|
|
64
72
|
a = sort_by :mtime
|
@@ -78,7 +86,7 @@ class DirToXML
|
|
78
86
|
|
79
87
|
def select_by_ext(ext)
|
80
88
|
|
81
|
-
@object = ext != '*' ? @
|
89
|
+
@object = ext != '*' ? @a.select{|x| x[:ext][/#{ext}/]} : @a
|
82
90
|
self
|
83
91
|
end
|
84
92
|
|
@@ -94,8 +102,12 @@ class DirToXML
|
|
94
102
|
|
95
103
|
alias sort_by_lastmodified sort_by_last_modified
|
96
104
|
|
97
|
-
def
|
98
|
-
@object || @
|
105
|
+
def to_a
|
106
|
+
@object || @a
|
107
|
+
end
|
108
|
+
|
109
|
+
def to_h()
|
110
|
+
self.to_a.inject({}){|r,x| r.merge(x[:name] => x)}
|
99
111
|
end
|
100
112
|
|
101
113
|
def to_xml(options=nil)
|
@@ -120,19 +132,21 @@ class DirToXML
|
|
120
132
|
dx.import a
|
121
133
|
|
122
134
|
dx.save File.join(@path, @index)
|
123
|
-
|
135
|
+
|
124
136
|
return dx
|
125
137
|
|
126
138
|
end
|
127
139
|
|
128
140
|
def refresh(cur_files)
|
129
141
|
|
130
|
-
dx = Dynarex.new @index
|
142
|
+
dx = Dynarex.new File.join(@path, @index)
|
131
143
|
|
132
144
|
prev_files = dx.to_a
|
133
145
|
|
134
146
|
cur_files.each do |x|
|
147
|
+
|
135
148
|
file = prev_files.find {|item| item[:name] == x[:name] }
|
149
|
+
|
136
150
|
x[:description] = file[:description] if file and file[:description]
|
137
151
|
end
|
138
152
|
|
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: 0.8.0
|
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-25 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: dynarex
|
metadata.gz.sig
CHANGED
Binary file
|