dir-to-xml 0.7.0 → 0.7.1

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: 7fa7c3734845467a3d98751753c039b7fe4aadcf
4
- data.tar.gz: 291e33ee74d2bac3a424d9872fb00adea0c3de1f
3
+ metadata.gz: 67285bd12d04cbdcb410beec66b61b67f4af7a73
4
+ data.tar.gz: 018b47d9893f558ee6087dfd24f1f769c8700c1f
5
5
  SHA512:
6
- metadata.gz: a75b46bf2769935e624aa30b7c32aff05c491fb7ef80a11813b037b8d70c23b4e7d323666bd469ee935d8dbd0d003540c018f54e1de0f67a1492321ba1e9d298
7
- data.tar.gz: 9d4e8ee319557c9a880768721b7b53f9a2c31f9411cda7757829bc0931f8dc4f22deacb1a043ecf708945d73fb407504180dbbdad573767ffad59167acaa44af
6
+ metadata.gz: f544cd8687ad522eff3da13cd0f0624dc234bd2fd47b0a212b121a7e710206dfa1420093cc188150d6f35f3d04131a46b297602ca4ed200327ed2c5fa31ce619
7
+ data.tar.gz: e91b07753b2f31e912b3b5a384a6863848bf02058bd3c5aac4b6e8e43a67f419599cc81ec9fc817ccfb51cf1ca3bea9a6e0efcaa3dde7f60e42b18848417a9dd
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -9,8 +9,11 @@ class DirToXML
9
9
 
10
10
 
11
11
  def initialize(path= '.', recursive: false)
12
+
12
13
  super()
13
-
14
+
15
+ @path = path
16
+
14
17
  old_path = Dir.pwd
15
18
  raise "Directory not found." unless File.exists? path
16
19
  Dir.chdir path
@@ -24,9 +27,9 @@ class DirToXML
24
27
  name: x,
25
28
  type: File::ftype(x),
26
29
  ext: File.extname(x),
27
- created: File::ctime(x),
28
- last_modified: File::mtime(x),
29
- last_accessed: File::atime(x)
30
+ ctime: File::ctime(x),
31
+ mtime: File::mtime(x),
32
+ atime: File::atime(x)
30
33
  }
31
34
 
32
35
  end
@@ -50,13 +53,19 @@ class DirToXML
50
53
  self
51
54
  end
52
55
 
56
+ def find_by_filename(s)
57
+ @dx.all.find {|item| item.name == s}
58
+ end
59
+
60
+ alias find_by_file find_by_filename
61
+
53
62
  def last_modified(ext=nil)
54
63
 
55
64
  if ext and ext != '*' then
56
65
  @object = @h.select{|x| x[:ext][/#{ext}/] or x[:type] == 'directory'}
57
66
  end
58
67
 
59
- a = sort_by :last_modified
68
+ a = sort_by :mtime
60
69
  a2 = a.reject {|x| x[:name] == 'dir.xml'}
61
70
 
62
71
  lm = a2[-1]
@@ -68,6 +77,10 @@ class DirToXML
68
77
  end
69
78
  end
70
79
 
80
+ def save()
81
+ @dx.save File.join(@path, 'dir.xml')
82
+ end
83
+
71
84
  def select_by_ext(ext)
72
85
 
73
86
  @object = ext != '*' ? @h.select{|x| x[:ext][/#{ext}/]} : @h
@@ -75,14 +88,13 @@ class DirToXML
75
88
  end
76
89
 
77
90
  def sort_by(sym)
78
- procs = [[:last_modified, lambda{|obj| obj\
79
- .sort_by{|x| x[:last_modified]}}]]
91
+ procs = [[:mtime, lambda{|obj| obj.sort_by{|x| x[:mtime]}}]]
80
92
  proc1 = procs.assoc(sym).last
81
93
  proc1.call(@object)
82
94
  end
83
95
 
84
96
  def sort_by_last_modified()
85
- sort_by :last_modified
97
+ sort_by :mtime
86
98
  end
87
99
 
88
100
  alias sort_by_lastmodified sort_by_last_modified
@@ -104,8 +116,8 @@ class DirToXML
104
116
  def dxify(a)
105
117
 
106
118
  dx = Dynarex.new 'directory[title,file_path]/file(name, ' + \
107
- 'type, ext, created, last_modified, last_accessed,' + \
108
- ' description, owner, group, permissions)'
119
+ 'type, ext, ctime, mtime, atime, description, owner, ' + \
120
+ 'group, permissions)'
109
121
 
110
122
  dx.title = 'Index of ' + File.basename(Dir.pwd)
111
123
  dx.file_path = Dir.pwd
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.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file