posix-fileutils 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGQxOWVmNGUwZGVmOTM4MWMxYmNiMmNmY2VkMGFhZGUxZTNkNWNiMQ==
4
+ NTIxZTMwZDhhODYwMTk3Y2E4YWViNmY2ZmIxNWVhNDQ2Y2NlZWIyMg==
5
5
  data.tar.gz: !binary |-
6
- NjRhY2UzOGFkY2U3MTUyZTc3YjQ1MTZlYTM5MTkwMjE0MDc1NWIzNA==
6
+ MGFlNjhjMjZmZDFjMjc4ZmY0ODc3M2I5OWVlODFjMzRiMmU1NjM1Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2UxNWMzZmIxNWY3MjlmOTFjYjgwNmE5ZjE0ZjdhZDkyY2RjZDQzOTNmM2Rk
10
- OWU4YWZlYzMzZmRlNmViMmY0MDFhM2U0OTlhYzA2YzE1ZmM0NTNiODcyNzUy
11
- MTcxMzQwOWMyMThlY2JhNTM4NWZkNTBlMGRiOGY5NTU3MGRkOWQ=
9
+ YTIxNzZlMzAwNDI1YjQ4OGNkNmNiMDkxNTEzZGZhMjRiOWY1N2RlNjg4M2Uy
10
+ ZGE1NDQ1YzkxNzExZWFhZDkxYTE4ZGI2MTc1NGJjY2U4OWM3ZTgwYWM5NmNl
11
+ YTc1ZmExN2U1MmFhMjQwOWFlMDQyODEzZWM3YjY5NDRhODdlNDY=
12
12
  data.tar.gz: !binary |-
13
- YWIyYzRkMThjOGU1NTVhNTliYTkzNWY2MzZhODljNjZiZjZmNTZiNjk4OGIy
14
- YmVlMjRkZDNjZDJmNzYwODBiZmY2NzRmZTIzNDFhNmE4YjVmYTg1NGMxZTJi
15
- NTc2YzEzNjRkMDQ2OTlmYmUyNjRmZDIxNzMwNmQ0ZDVhMGU3YzM=
13
+ Y2VjZDU5ZjI2OTBiZTAyM2Y1NGNiODFjM2Q5ZjFkZjVhYmZiNzYyNDVhMjQw
14
+ OGM4YTU1OTBiN2Q1N2Y0Mzk0ZWM3MWRhOTkwYzhlMWY0YTQ2OTQ1Njk1ZTkw
15
+ MDdiZDM4Zjk0ZjgwZGU4MGRkMDc1NzY1MGJkM2UzYWM4NTZlMGQ=
@@ -3,6 +3,7 @@ require 'pathname'
3
3
  require 'set'
4
4
  require 'digest'
5
5
 
6
+
6
7
  class Object
7
8
  def a?
8
9
  Enumerable === self
@@ -15,7 +16,7 @@ class Array
15
16
  end
16
17
  end
17
18
 
18
- module FileUtils
19
+ module Fs
19
20
  $fudeopt = [].to_set
20
21
  @popts = {
21
22
  :cp => [:T,:a,:v,:r].to_set,
@@ -27,7 +28,7 @@ module FileUtils
27
28
  :dsync => [:v, ].to_set,
28
29
  }
29
30
 
30
- def parse_cp_args src, dst, *opts
31
+ def self.parse_cp_args src, dst, *opts
31
32
  raise ArgumentError unless !dst.a?
32
33
 
33
34
  dst = Pathname.new dst.to_s unless dst.kind_of? Pathname
@@ -67,9 +68,8 @@ module FileUtils
67
68
 
68
69
  [src, dst, opts]
69
70
  end
70
- module_function :parse_cp_args
71
71
 
72
- def cp src, dst, *opts
72
+ def self.cp src, dst, *opts
73
73
  opts = opts.to_set
74
74
 
75
75
  src, dst, opts = parse_cp_args src, dst, *opts
@@ -78,22 +78,23 @@ module FileUtils
78
78
 
79
79
  Kernel.system "cp #{opts.to_s}#{src.to_s} #{dst.to_s}"
80
80
  end
81
- module_function :cp
82
81
 
83
- def dsync src, dst, *opts
82
+ def self.dsync src, dst, *opts
84
83
  src, dst, opts = parse_cp_args src, dst, *opts
85
84
 
86
85
  opts = opts.to_set
87
86
 
88
87
  raise ArgumentError unless src.directory? && dst.directory?
89
88
 
90
- Dir["#{dst.to_s}/**/{*,.*}"].each do |file|
91
- file = Pathname.new file
92
- next unless file.exist?
89
+ if opts.included? :d
90
+ Dir["#{dst.to_s}/**/{*,.*}"].each do |file|
91
+ file = Pathname.new file
92
+ next unless file.exist?
93
93
 
94
- srcfile = src + file.relative_path_from(dst)
94
+ srcfile = src + file.relative_path_from(dst)
95
95
 
96
- (rm file, *(opts&@popts[:rm]) or return false) unless srcfile.exist?
96
+ (rm file, *(opts&@popts[:rm]) or return false) unless srcfile.exist?
97
+ end
97
98
  end
98
99
 
99
100
  Dir["#{src.to_s}/**/{*,.*}"].each do |file|
@@ -111,18 +112,16 @@ module FileUtils
111
112
 
112
113
  true
113
114
  end
114
- module_function :dsync
115
115
 
116
- def mv src, dst, *opts
116
+ def self.mv src, dst, *opts
117
117
  opts = opts.to_set
118
118
 
119
119
  src, dst, opts = parse_cp_args src, dst, *opts
120
120
 
121
121
  Kernel.system "mv #{opts.to_s}#{src.to_s} #{dst.to_s}"
122
122
  end
123
- module_function :mv
124
123
 
125
- def parse_list_args list, *opts
124
+ def self.parse_list_args list, *opts
126
125
  if list.a?
127
126
  return true if list.count == 0
128
127
 
@@ -156,9 +155,8 @@ module FileUtils
156
155
 
157
156
  [list, opts]
158
157
  end
159
- module_function :parse_list_args
160
158
 
161
- def rm list, *opts
159
+ def self.rm list, *opts
162
160
  opts = opts.to_set
163
161
 
164
162
  list, opts = parse_list_args list, *opts
@@ -168,9 +166,8 @@ module FileUtils
168
166
 
169
167
  Kernel.system "rm #{opts.to_s}#{list.to_s}"
170
168
  end
171
- module_function :rm
172
169
 
173
- def mkdir list, *opts
170
+ def self.mkdir list, *opts
174
171
  opts = opts.to_set
175
172
 
176
173
  list, opts = parse_list_args list, *opts
@@ -187,9 +184,8 @@ module FileUtils
187
184
 
188
185
  Kernel.system "mkdir #{opts.to_s}#{list.to_s}"
189
186
  end
190
- module_function :mkdir
191
187
 
192
- def touch list, *opts
188
+ def self.touch list, *opts
193
189
  opts = opts.to_set
194
190
 
195
191
  list, opts = parse_list_args list, *opts
@@ -197,11 +193,8 @@ module FileUtils
197
193
 
198
194
  Kernel.system "touch #{opts.to_s}#{list.to_s}"
199
195
  end
200
- module_function :touch
201
-
202
- alias_method :_cd, :cd
203
196
 
204
- def cd list, *opts
197
+ def self.cd list, *opts
205
198
  opts = opts.to_set
206
199
 
207
200
  list, opts = parse_list_args list, *opts
@@ -211,18 +204,16 @@ module FileUtils
211
204
 
212
205
  return false unless list.directory?
213
206
 
214
- _cd list.to_s, opts.include?(:v) ? {:verbose => true} : {:verbose => false}
207
+ FileUtils.cd list.to_s, opts.include?(:v) ? {:verbose => true} : {:verbose => false}
215
208
 
216
209
  true
217
210
  end
218
- module_function :cd
219
211
 
220
- def pwd
212
+ def self.pwd
221
213
  Pathname.new(`pwd`.chomp)
222
214
  end
223
- module_function :pwd
224
215
 
225
- end # module FileUtils
216
+ end # module Fs
226
217
 
227
218
  # vim: sw=2 sts=2 ts=8:
228
219
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: posix-fileutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - A. Levenkov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-20 00:00:00.000000000 Z
11
+ date: 2015-03-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: FileUtils library
14
14
  email: artem@levenkov.org