dir-to-xml 0.7.1 → 0.7.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
  SHA1:
3
- metadata.gz: 67285bd12d04cbdcb410beec66b61b67f4af7a73
4
- data.tar.gz: 018b47d9893f558ee6087dfd24f1f769c8700c1f
3
+ metadata.gz: d902a0b07e4b77dc9d9ad7122a4e84186a6e5c09
4
+ data.tar.gz: b9271f1ca9b93c64da56180ec9e018609f1b204f
5
5
  SHA512:
6
- metadata.gz: f544cd8687ad522eff3da13cd0f0624dc234bd2fd47b0a212b121a7e710206dfa1420093cc188150d6f35f3d04131a46b297602ca4ed200327ed2c5fa31ce619
7
- data.tar.gz: e91b07753b2f31e912b3b5a384a6863848bf02058bd3c5aac4b6e8e43a67f419599cc81ec9fc817ccfb51cf1ca3bea9a6e0efcaa3dde7f60e42b18848417a9dd
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
- a.delete 'dir.xml'
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?('dir.xml') ? :refresh : :dxify
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
- @path = path
47
- @recursive = recursive
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 = a2[-1]
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, 'dir.xml')
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 'dir.xml'
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 'dir.xml'
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.1
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-18 00:00:00.000000000 Z
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