posix-fileutils 0.0.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 +15 -0
- data/fileutils-test.rb +8 -0
- data/fileutils.rb +82 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZDEyYjk2MmY4ZmY1OTdmYzc0MDcxOThlOTQ5NmU2ZDVhYmZjMTkyNw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NjFiNTRjZGRiZWI3MzRlOWI5ZTE3MjM3OTkwMTNlN2E3MDJkYTg2NQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Y2QzY2MwZDBmNTQwMjRjOGVkNDQ5MjQ5MTJjMzU4NmYxMzZlYTJlYTQ4NGQ5
|
10
|
+
NTg3Yjc3MzZjNTIzMDBkYmJlZmY4N2RmNTM0OWFmN2IyYzJkYzE1YTc3Mzg5
|
11
|
+
ZjgwZjhlNzEyZTZmYWE0MzA5M2U2Yjk1MDhkYjg2NDMzMjRhMmY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OGY4ZTUyYzQyNWEwY2MyZjllYWZmNDZhZDAyZTg0OTUwMDY5Nzc0MTNlNmFk
|
14
|
+
NzEzYmY3ODhlNTM2ZWY3Y2RjOGI5NzI4YjNjZmMwNTA2M2Y1ZTdmZDdmMTQy
|
15
|
+
MjBiMjE0NWZjYjQ3NzMzZjk2MTRmYTBhNzVhNWY0NjNjZDQwOWM=
|
data/fileutils-test.rb
ADDED
data/fileutils.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
module FileUtils
|
2
|
+
def self.ls *args
|
3
|
+
list = args[0]
|
4
|
+
opts = args[1]
|
5
|
+
|
6
|
+
if list.class == Array
|
7
|
+
class << list
|
8
|
+
def to_s
|
9
|
+
join ' '
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
res = `ls #{opts.to_s} #{list.to_s}`.split "\n"
|
15
|
+
|
16
|
+
return res if list.class != Array
|
17
|
+
|
18
|
+
delim = list.map do |i| i << ':' end
|
19
|
+
|
20
|
+
indexes = delim.map do |i| i = res.index i end
|
21
|
+
|
22
|
+
indexes.sort!
|
23
|
+
|
24
|
+
indexes = indexes.drop 1 if indexes[0].zero?
|
25
|
+
|
26
|
+
indexes << -1
|
27
|
+
|
28
|
+
li = 0
|
29
|
+
|
30
|
+
res_map = {}
|
31
|
+
|
32
|
+
indexes.each do |i|
|
33
|
+
path = res[li][0..res[li].length-2]
|
34
|
+
|
35
|
+
res_map[path] = res[li+1..i-1]
|
36
|
+
res_map[path].delete_at -1 if res_map[path][-1].length.zero?
|
37
|
+
li = i
|
38
|
+
end
|
39
|
+
|
40
|
+
return res_map
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.cp dst, src, opt
|
44
|
+
if dst.class == Array
|
45
|
+
raise ArgumentError if dst.count != 1
|
46
|
+
|
47
|
+
class << src
|
48
|
+
def to_s
|
49
|
+
join ' '
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
if src.class == Array
|
55
|
+
raise ArgumentError if dst.count == 0
|
56
|
+
end
|
57
|
+
|
58
|
+
`cp #{src.to_s} #{dst.to_s}`
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.mv dst, src, opt
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.rm files, opt
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.rmdir files, opt
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.ln dst, src, opt
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.unlink files, opt
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.touch files, opt
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
# vim: sw=2 sts=2 ts=8:
|
82
|
+
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: posix-fileutils
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- A. Levenkov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-31 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: FileUtils library
|
14
|
+
email: artem@levenkov.org
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- fileutils.rb
|
20
|
+
- fileutils-test.rb
|
21
|
+
homepage: http://rubygems.org/gems/posix-fileutils
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.0.3
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: FileUtils library
|
45
|
+
test_files: []
|