posix-fileutils 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/posix-fileutils/fileutils.rb +131 -133
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTQyMmEwZGMwNDUxY2E0MTc2MjQyNGQ1NDU2ODY2YjBiNGE4NmJhZA==
4
+ OGQxOWVmNGUwZGVmOTM4MWMxYmNiMmNmY2VkMGFhZGUxZTNkNWNiMQ==
5
5
  data.tar.gz: !binary |-
6
- ZmZmNjM3OTRhOTdkNTUyZWRmMmNkZDQ5YmU5MWYyODEyYjkxNjM4Mg==
6
+ NjRhY2UzOGFkY2U3MTUyZTc3YjQ1MTZlYTM5MTkwMjE0MDc1NWIzNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzBkMjg1MDEwOGNlYTg0NDQxNDZkM2I4NDhhNDAxYWVlOWI3YThkNDNmMjBk
10
- NDQxYmRhYTI1ZjAwYTg2MjYyNTU0OGFhMWJhYjY1MDgzMTcxZGU0NjFjNTc2
11
- OWM3YWUwNDRiYjJkZWY1MDM3MmZkNWRmZWRiOTc1NDYzNDc2ZDc=
9
+ N2UxNWMzZmIxNWY3MjlmOTFjYjgwNmE5ZjE0ZjdhZDkyY2RjZDQzOTNmM2Rk
10
+ OWU4YWZlYzMzZmRlNmViMmY0MDFhM2U0OTlhYzA2YzE1ZmM0NTNiODcyNzUy
11
+ MTcxMzQwOWMyMThlY2JhNTM4NWZkNTBlMGRiOGY5NTU3MGRkOWQ=
12
12
  data.tar.gz: !binary |-
13
- MjE5NTgzYzRlMjI1OWU1MjhmMmQyYjkxNzcwOGJiYzMxOGE4ZTBjMGQ2YmIz
14
- ZjVkMTA1NWFjMTQwZTYxOWEzMzU5MzZhNDE1ZjlhYjFjZGMyM2UyMjk4ZjEx
15
- NTBhZDkzM2I3ZGQ2YzViY2Y3OGQxOGMyYzBhY2Y5YmRiNDY4NWM=
13
+ YWIyYzRkMThjOGU1NTVhNTliYTkzNWY2MzZhODljNjZiZjZmNTZiNjk4OGIy
14
+ YmVlMjRkZDNjZDJmNzYwODBiZmY2NzRmZTIzNDFhNmE4YjVmYTg1NGMxZTJi
15
+ NTc2YzEzNjRkMDQ2OTlmYmUyNjRmZDIxNzMwNmQ0ZDVhMGU3YzM=
@@ -27,203 +27,201 @@ module FileUtils
27
27
  :dsync => [:v, ].to_set,
28
28
  }
29
29
 
30
- class << self
31
- def parse_cp_args src, dst, *opts
32
- raise ArgumentError unless !dst.a?
30
+ def parse_cp_args src, dst, *opts
31
+ raise ArgumentError unless !dst.a?
33
32
 
34
- dst = Pathname.new dst.to_s unless dst.kind_of? Pathname
33
+ dst = Pathname.new dst.to_s unless dst.kind_of? Pathname
35
34
 
36
- if src.a?
37
- return true if src.count == 0
35
+ if src.a?
36
+ return true if src.count == 0
38
37
 
39
- raise ArgumentError unless dst.directory?
38
+ raise ArgumentError unless dst.directory?
40
39
 
41
- src.map! do |elem| Pathname.new elem.to_s unless elem.kind_of? Pathname end
40
+ src.map! do |elem| Pathname.new elem.to_s unless elem.kind_of? Pathname end
42
41
 
43
- class << src
44
- def to_s
45
- inject('') do |accu, elem| "#{accu}#{elem.to_s} " end.chomp ' '
46
- end
42
+ class << src
43
+ def to_s
44
+ inject('') do |accu, elem| "#{accu}#{elem.to_s} " end.chomp ' '
47
45
  end
48
- else
49
- src = Pathname.new src.to_s unless src.kind_of? Pathname
50
46
  end
47
+ else
48
+ src = Pathname.new src.to_s unless src.kind_of? Pathname
49
+ end
51
50
 
52
- class << opts
53
- attr_accessor :src
54
- attr_accessor :dst
55
-
56
- def to_s
57
- opts_s = '-f '
51
+ class << opts
52
+ attr_accessor :src
53
+ attr_accessor :dst
58
54
 
59
- [:T, :a, :v, :r].each do |opt|
60
- opts_s << "-#{opt.to_s} " if include?(opt) || $fudeopt.include?(opt)
61
- end
55
+ def to_s
56
+ opts_s = '-f '
62
57
 
63
- opts_s
58
+ [:T, :a, :v, :r].each do |opt|
59
+ opts_s << "-#{opt.to_s} " if include?(opt) || $fudeopt.include?(opt)
64
60
  end
65
- end
66
61
 
67
- opts.src, opts.dst = src, dst
68
-
69
- [src, dst, opts]
62
+ opts_s
63
+ end
70
64
  end
71
- module_function :parse_cp_args
72
65
 
73
- def cp src, dst, *opts
74
- opts = opts.to_set
66
+ opts.src, opts.dst = src, dst
75
67
 
76
- src, dst, opts = parse_cp_args src, dst, *opts
68
+ [src, dst, opts]
69
+ end
70
+ module_function :parse_cp_args
77
71
 
78
- opts << :r if src.a? ? src.inject(false) do |a,p| p.directory? | a end : src.directory?
72
+ def cp src, dst, *opts
73
+ opts = opts.to_set
79
74
 
80
- Kernel.system "cp #{opts.to_s}#{src.to_s} #{dst.to_s}"
81
- end
82
- module_function :cp
75
+ src, dst, opts = parse_cp_args src, dst, *opts
83
76
 
84
- def dsync src, dst, *opts
85
- src, dst, opts = parse_cp_args src, dst, *opts
77
+ opts << :r if src.a? ? src.inject(false) do |a,p| p.directory? | a end : src.directory?
86
78
 
87
- opts = opts.to_set
88
-
89
- raise ArgumentError unless src.directory? && dst.directory?
79
+ Kernel.system "cp #{opts.to_s}#{src.to_s} #{dst.to_s}"
80
+ end
81
+ module_function :cp
90
82
 
91
- Dir["#{dst.to_s}/**/{*,.*}"].each do |file|
92
- file = Pathname.new file
93
- next unless file.exist?
83
+ def dsync src, dst, *opts
84
+ src, dst, opts = parse_cp_args src, dst, *opts
94
85
 
95
- srcfile = src + file.relative_path_from(dst)
86
+ opts = opts.to_set
87
+
88
+ raise ArgumentError unless src.directory? && dst.directory?
96
89
 
97
- (rm file, *(opts&@popts[:rm]) or return false) unless srcfile.exist?
98
- end
99
-
100
- Dir["#{src.to_s}/**/{*,.*}"].each do |file|
101
- file = Pathname.new file
102
- next if file.directory?
90
+ Dir["#{dst.to_s}/**/{*,.*}"].each do |file|
91
+ file = Pathname.new file
92
+ next unless file.exist?
103
93
 
104
- dstfile = dst + file.relative_path_from(src)
94
+ srcfile = src + file.relative_path_from(dst)
105
95
 
106
- (mkdir dstfile.dirname, *((opts+[:p])&@popts[:mkdir]) or return false) unless dstfile.dirname.directory?
96
+ (rm file, *(opts&@popts[:rm]) or return false) unless srcfile.exist?
97
+ end
98
+
99
+ Dir["#{src.to_s}/**/{*,.*}"].each do |file|
100
+ file = Pathname.new file
101
+ next if file.directory?
107
102
 
108
- next if dstfile.file? && Digest::SHA256.file(file) == Digest::SHA256.file(dstfile)
103
+ dstfile = dst + file.relative_path_from(src)
109
104
 
110
- cp file, dstfile, *(opts&@popts[:cp]) or return false
111
- end
105
+ (mkdir dstfile.dirname, *((opts+[:p])&@popts[:mkdir]) or return false) unless dstfile.dirname.directory?
112
106
 
113
- true
107
+ next if dstfile.file? && Digest::SHA256.file(file) == Digest::SHA256.file(dstfile)
108
+
109
+ cp file, dstfile, *(opts&@popts[:cp]) or return false
114
110
  end
115
- module_function :dsync
116
111
 
117
- def mv src, dst, *opts
118
- opts = opts.to_set
112
+ true
113
+ end
114
+ module_function :dsync
115
+
116
+ def mv src, dst, *opts
117
+ opts = opts.to_set
119
118
 
120
- src, dst, opts = parse_cp_args src, dst, *opts
119
+ src, dst, opts = parse_cp_args src, dst, *opts
121
120
 
122
- Kernel.system "mv #{opts.to_s}#{src.to_s} #{dst.to_s}"
123
- end
124
- module_function :mv
121
+ Kernel.system "mv #{opts.to_s}#{src.to_s} #{dst.to_s}"
122
+ end
123
+ module_function :mv
125
124
 
126
- def parse_list_args list, *opts
127
- if list.a?
128
- return true if list.count == 0
125
+ def parse_list_args list, *opts
126
+ if list.a?
127
+ return true if list.count == 0
129
128
 
130
- list.map! do |elem| Pathname.new elem.to_s unless elem.kind_of? Pathname end
129
+ list.map! do |elem| Pathname.new elem.to_s unless elem.kind_of? Pathname end
131
130
 
132
- class << list
133
- def to_s
134
- inject('') do |accu,elem| "#{accu}#{elem.to_s} " end.chomp ' '
135
- end
131
+ class << list
132
+ def to_s
133
+ inject('') do |accu,elem| "#{accu}#{elem.to_s} " end.chomp ' '
136
134
  end
137
- else
138
- list = Pathname.new list.to_s unless list.kind_of? Pathname
139
135
  end
136
+ else
137
+ list = Pathname.new list.to_s unless list.kind_of? Pathname
138
+ end
140
139
 
141
- class << opts
142
- attr_accessor :list
143
- attr_accessor :flags
144
-
145
- def to_s
146
- opts_s = ''
140
+ class << opts
141
+ attr_accessor :list
142
+ attr_accessor :flags
147
143
 
148
- @flags.each do |opt|
149
- opts_s << "-#{opt.to_s} " if include?(opt) || $fudeopt.include?(opt)
150
- end
144
+ def to_s
145
+ opts_s = ''
151
146
 
152
- opts_s
147
+ @flags.each do |opt|
148
+ opts_s << "-#{opt.to_s} " if include?(opt) || $fudeopt.include?(opt)
153
149
  end
150
+
151
+ opts_s
154
152
  end
153
+ end
155
154
 
156
- opts.list = list
155
+ opts.list = list
157
156
 
158
- [list, opts]
159
- end
160
- module_function :parse_list_args
157
+ [list, opts]
158
+ end
159
+ module_function :parse_list_args
161
160
 
162
- def rm list, *opts
163
- opts = opts.to_set
161
+ def rm list, *opts
162
+ opts = opts.to_set
164
163
 
165
- list, opts = parse_list_args list, *opts
166
- opts.flags = [:v, :f, :r]
164
+ list, opts = parse_list_args list, *opts
165
+ opts.flags = [:v, :f, :r]
167
166
 
168
- opts << :r if list.a? ? list.inject(false) do |a,p| p.directory? | a end : list.directory?
167
+ opts << :r if list.a? ? list.inject(false) do |a,p| p.directory? | a end : list.directory?
169
168
 
170
- Kernel.system "rm #{opts.to_s}#{list.to_s}"
171
- end
172
- module_function :rm
169
+ Kernel.system "rm #{opts.to_s}#{list.to_s}"
170
+ end
171
+ module_function :rm
173
172
 
174
- def mkdir list, *opts
175
- opts = opts.to_set
173
+ def mkdir list, *opts
174
+ opts = opts.to_set
176
175
 
177
- list, opts = parse_list_args list, *opts
178
- opts.flags = [:v, :p]
176
+ list, opts = parse_list_args list, *opts
177
+ opts.flags = [:v, :p]
179
178
 
180
- if opts.include? :f
181
- unless list.a?
182
- return true if list.directory?
183
- else
184
- list.select! do |elem| !elem.directory? end
185
- return true if list.empty?
186
- end
179
+ if opts.include? :f
180
+ unless list.a?
181
+ return true if list.directory?
182
+ else
183
+ list.select! do |elem| !elem.directory? end
184
+ return true if list.empty?
187
185
  end
188
-
189
- Kernel.system "mkdir #{opts.to_s}#{list.to_s}"
190
186
  end
191
- module_function :mkdir
192
187
 
193
- def touch list, *opts
194
- opts = opts.to_set
188
+ Kernel.system "mkdir #{opts.to_s}#{list.to_s}"
189
+ end
190
+ module_function :mkdir
195
191
 
196
- list, opts = parse_list_args list, *opts
197
- opts.flags = [:v]
192
+ def touch list, *opts
193
+ opts = opts.to_set
198
194
 
199
- Kernel.system "touch #{opts.to_s}#{list.to_s}"
200
- end
201
- module_function :touch
195
+ list, opts = parse_list_args list, *opts
196
+ opts.flags = [:v]
197
+
198
+ Kernel.system "touch #{opts.to_s}#{list.to_s}"
199
+ end
200
+ module_function :touch
202
201
 
203
- alias_method :_cd, :cd
202
+ alias_method :_cd, :cd
204
203
 
205
- def cd list, *opts
206
- opts = opts.to_set
204
+ def cd list, *opts
205
+ opts = opts.to_set
207
206
 
208
- list, opts = parse_list_args list, *opts
209
- opts.flags = [:v]
207
+ list, opts = parse_list_args list, *opts
208
+ opts.flags = [:v]
210
209
 
211
- raise ArgumentError if list.a?
210
+ raise ArgumentError if list.a?
212
211
 
213
- return false unless list.directory?
212
+ return false unless list.directory?
214
213
 
215
- _cd list.to_s, opts.include?(:v) ? {:verbose => true} : {:verbose => false}
214
+ _cd list.to_s, opts.include?(:v) ? {:verbose => true} : {:verbose => false}
216
215
 
217
- true
218
- end
219
- module_function :cd
216
+ true
217
+ end
218
+ module_function :cd
220
219
 
221
- def pwd
222
- Pathname.new(`pwd`.chomp)
223
- end
224
- module_function :pwd
220
+ def pwd
221
+ Pathname.new(`pwd`.chomp)
222
+ end
223
+ module_function :pwd
225
224
 
226
- end # class << self
227
225
  end # module FileUtils
228
226
 
229
227
  # vim: sw=2 sts=2 ts=8:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posix-fileutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - A. Levenkov