rabbit_file_split 0.0.4 → 0.0.5
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 +4 -4
- data/README.md +7 -0
- data/bin/split.rb +1 -1
- data/lib/rabbit_file_split/byte_format.rb +17 -0
- data/lib/rabbit_file_split/bytes.rb +4 -3
- data/lib/rabbit_file_split/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50e12adc965739b2df69cfc9888aba3c0d7582c5
|
4
|
+
data.tar.gz: 36a2cc59e688e6b1e132b7e24d5e168f4d5e7326
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7592f5145213b5beada0cc48f4972a3eaaae189df5603d5d745e360b4cc4f7edc09e32c90be3f45294d016cfda9df16017cbbaa6ef949c50e5651ce2608ae619
|
7
|
+
data.tar.gz: a7833f531b2aa46ff028459c8c259a3976ca2f1fa25877ba0fd5615602bae36a8f8e2a77c58b5e146e6cd590b6608863fbe90b16e5e151dbeb9ab281931dbb93
|
data/README.md
CHANGED
@@ -27,6 +27,13 @@ Or install it yourself as:
|
|
27
27
|
split_file_list = RabbitFileSplit::Bytes.new(file_path).split(1048576, file_prefix: 'object', dest_file_path: '/tmp')
|
28
28
|
split_file_list = RabbitFileSplit::Bytes.new(file_path).split(1048576, file_prefix: 'object', dest_file_path: '/tmp', buffer_size: 8096)
|
29
29
|
|
30
|
+
### Support byte Format
|
31
|
+
|
32
|
+
Integer + unit(KB/MB/GB)
|
33
|
+
|
34
|
+
split_file_list = RabbitFileSplit::Bytes.new(file_path).split('1KB') 1024 Byte
|
35
|
+
split_file_list = RabbitFileSplit::Bytes.new(file_path).split('1MB') 1048576 Byte
|
36
|
+
split_file_list = RabbitFileSplit::Bytes.new(file_path).split('1GB') 1073741824 Byte
|
30
37
|
|
31
38
|
## Contributing
|
32
39
|
|
data/bin/split.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
module RabbitFileSplit
|
2
|
+
module ByteFormat
|
3
|
+
|
4
|
+
def to_byte(n_byte)
|
5
|
+
case n_byte
|
6
|
+
when /(\d)KB/ then
|
7
|
+
n_byte.sub(/KB/,'').to_i * 1024
|
8
|
+
when /(\d)MB/ then
|
9
|
+
n_byte.sub(/MB/,'').to_i * 1048576
|
10
|
+
when /(\d)GB/ then
|
11
|
+
n_byte.sub(/GB/,'').to_i * 1073741824
|
12
|
+
else
|
13
|
+
n_byte.to_i
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'digest/md5'
|
2
|
+
require 'rabbit_file_split/byte_format'
|
2
3
|
|
3
4
|
module RabbitFileSplit
|
4
5
|
class Bytes
|
5
|
-
|
6
|
+
include RabbitFileSplit::ByteFormat
|
6
7
|
# GNU utils split.c bytes_split interface
|
7
8
|
# bytes_split (uintmax_t n_bytes, char *buf, size_t bufsize, size_t initial_read, uintmax_t max_files)
|
8
9
|
|
@@ -21,14 +22,14 @@ module RabbitFileSplit
|
|
21
22
|
@original_file_size = File.size(file_path)
|
22
23
|
end
|
23
24
|
|
24
|
-
# @param [
|
25
|
+
# @param [String] n_bytes base byte num or N + byte unit
|
25
26
|
# @param [String] file_prefix file_prefix. default is original file name
|
26
27
|
# @param [String] dest_file_path generate split file directory
|
27
28
|
# @param [String] buffer_size file buffer size
|
28
29
|
# @return void
|
29
30
|
def split(n_bytes, file_prefix: @file_base_name, dest_file_path: @file_parent_path, buffer_size: BUFFER_SIZE)
|
30
31
|
start_time = Time.now
|
31
|
-
|
32
|
+
n_bytes = to_byte(n_bytes)
|
32
33
|
total_readed_byte = 0
|
33
34
|
unit_readed_byte = 0
|
34
35
|
@split_file_num = 1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AKB428
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- Rakefile
|
54
54
|
- bin/split.rb
|
55
55
|
- lib/rabbit_file_split.rb
|
56
|
+
- lib/rabbit_file_split/byte_format.rb
|
56
57
|
- lib/rabbit_file_split/bytes.rb
|
57
58
|
- lib/rabbit_file_split/version.rb
|
58
59
|
- rabbit_file_split.gemspec
|