file_manipulator 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/file_manipulator/configuration.rb +4 -0
- data/lib/file_manipulator/merger.rb +9 -3
- data/lib/file_manipulator/splitter.rb +5 -1
- data/lib/file_manipulator/version.rb +1 -1
- data/lib/file_manipulator.rb +4 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13573c2e0b4ce4edac7cd5cd3ed0f1e770ed7f30
|
4
|
+
data.tar.gz: 8508bb824193155998cfb9aacf6881c47e7ff2f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1029af0140c72522a99fd77e04645b59add62fbb2d03276d64270cffdab5b5b4e00dc1642866e53397e4fce00da3470889e8f33ad6573804e0cd6a32c870403c
|
7
|
+
data.tar.gz: 928d65a51a91cc5cb506c6b3227937626daebbd4716ce4ab941dca39419b926f30bcb7ebf4c09e7270be14acf5a38b5c6c0e5a6bc9b4f8e5699976278bda08b5
|
data/Gemfile.lock
CHANGED
@@ -9,7 +9,7 @@ module FileManipulator
|
|
9
9
|
def run
|
10
10
|
string_io = StringIO.new
|
11
11
|
|
12
|
-
Dir.glob("#{config.split_files_directory}/#{
|
12
|
+
Dir.glob("#{config.split_files_directory}/#{prefix}_*").sort.each do |file|
|
13
13
|
string_io.write File.read(file)
|
14
14
|
end
|
15
15
|
|
@@ -17,11 +17,17 @@ module FileManipulator
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def merged_file
|
20
|
-
sample_split_file = Dir.glob("#{config.split_files_directory}/#{
|
20
|
+
sample_split_file = Dir.glob("#{config.split_files_directory}/#{prefix}_*").first
|
21
21
|
basename = File.basename(sample_split_file)
|
22
22
|
extname = File.extname(sample_split_file)
|
23
|
-
basename = basename.sub(/^#{
|
23
|
+
basename = basename.sub(/^#{prefix}_/, '').sub(/#{extname}$/, '').sub(/_\d*$/, '')
|
24
24
|
File.join(config.merged_file_directory, "#{basename}#{extname}")
|
25
25
|
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def prefix
|
30
|
+
config.prefix
|
31
|
+
end
|
26
32
|
end
|
27
33
|
end
|
@@ -41,8 +41,12 @@ module FileManipulator
|
|
41
41
|
|
42
42
|
def output_file_name(index)
|
43
43
|
output_file_basename = sprintf("#{basename}_%0#{number_of_digits}d", index)
|
44
|
-
output_file_basename = "#{
|
44
|
+
output_file_basename = "#{prefix}_#{output_file_basename}" unless prefix == ''
|
45
45
|
extname == '' ? output_file_basename : "#{output_file_basename}.#{extname}"
|
46
46
|
end
|
47
|
+
|
48
|
+
def prefix
|
49
|
+
config.prefix
|
50
|
+
end
|
47
51
|
end
|
48
52
|
end
|
data/lib/file_manipulator.rb
CHANGED
@@ -9,8 +9,10 @@ module FileManipulator
|
|
9
9
|
|
10
10
|
def configure
|
11
11
|
yield(@configuration ||= Configuration.new)
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
configuration.directories.each do |directory|
|
14
|
+
FileUtils.mkdir_p(directory)
|
15
|
+
end
|
14
16
|
end
|
15
17
|
|
16
18
|
def merge
|