rabbit_file_split 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rabbit_file_split/bytes.rb +17 -1
- data/lib/rabbit_file_split/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f90d06540f2fdf44e0b1fc2c0d727c236ec75427
|
4
|
+
data.tar.gz: dbcfdd50908c93d9fa7a47c062df566e32dfd166
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 139187cc060d09f180ec5245e602426fa1919b5b300accc6c438f85b790cd68e79d0c10a3982c98110b644c88bb8ae2b31b9ce6f5b9f20abc4e696268284fa83
|
7
|
+
data.tar.gz: c702859766c29e895dcab6dfeec493fdd45d5aec3fb54d1c2d07c57d821a3ce254d587b05d48bdeb455769373e3a6d05aaaf001d749e1596f02a72a1b0f2608b
|
@@ -3,10 +3,10 @@ require 'digest/md5'
|
|
3
3
|
module RabbitFileSplit
|
4
4
|
class Bytes
|
5
5
|
|
6
|
+
# GNU utils split.c bytes_split interface
|
6
7
|
# bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize, size_t initial_read, uintmax_t max_files)
|
7
8
|
|
8
9
|
BUFFER_SIZE = 4096
|
9
|
-
|
10
10
|
@file_path = nil
|
11
11
|
@file_base_name = nil
|
12
12
|
@split_file_num = 0
|
@@ -15,6 +15,8 @@ module RabbitFileSplit
|
|
15
15
|
@original_file_size = nil
|
16
16
|
@split_work_time = nil
|
17
17
|
|
18
|
+
# @param [String] file_path target file path
|
19
|
+
# @return [Bytes] RabbitFIleSplit::Bytes instance
|
18
20
|
def initialize(file_path)
|
19
21
|
@file_path = file_path
|
20
22
|
@file_base_name = File::basename(file_path)
|
@@ -22,6 +24,11 @@ module RabbitFileSplit
|
|
22
24
|
@original_file_size = File.size(file_path)
|
23
25
|
end
|
24
26
|
|
27
|
+
# @param [Integer] n_bytes base byte num
|
28
|
+
# @param [String] file_prefix file_prefix. default is original file name
|
29
|
+
# @param [String] dest_file_path generate split file directory
|
30
|
+
# @param [String] buffer_size file buffer size
|
31
|
+
# @return void
|
25
32
|
def split(n_bytes, file_prefix: @file_base_name, dest_file_path: @file_parent_path, buffer_size: BUFFER_SIZE)
|
26
33
|
start_time = Time.now
|
27
34
|
|
@@ -79,8 +86,17 @@ module RabbitFileSplit
|
|
79
86
|
end
|
80
87
|
end
|
81
88
|
|
89
|
+
#@return [Integer] delete file num
|
90
|
+
def delete_all
|
91
|
+
File.delete(*@file_list)
|
92
|
+
end
|
93
|
+
|
82
94
|
private
|
83
95
|
|
96
|
+
#@param [String] dest_file_path
|
97
|
+
#@param [String] file_prefix
|
98
|
+
#@param [Integer] num split file sequence number
|
99
|
+
#@return [String] done split file path
|
84
100
|
def create_split_file_path(dest_file_path, file_prefix, num)
|
85
101
|
file_path = File.join(dest_file_path, file_prefix + '_' + sprintf('%04d', num))
|
86
102
|
@file_list = [] if @file_list.nil?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabbit_file_split
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AKB428
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -81,3 +81,4 @@ signing_key:
|
|
81
81
|
specification_version: 4
|
82
82
|
summary: simple file byte split
|
83
83
|
test_files: []
|
84
|
+
has_rdoc:
|