master_splitter 1.0.0 → 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d7a1e7298a56c92fc9eb2c6fc64fa91527cfae8
4
- data.tar.gz: be9c96e1c33f54f1f9c8211ab215fddc3bc53ff1
3
+ metadata.gz: 7ff938e1683589dfa9e407dc4ebd8c5b44426fa2
4
+ data.tar.gz: 97a5f462c949934eb44a52a7321dda784fe067ad
5
5
  SHA512:
6
- metadata.gz: 0626cef0959779687722e3ab970b5f8b3e5e0131454dd2225fa61023c01815f56a2c6e1b432b7561cce17ab14e857d21bd918af88c3e01732d4c77d2104b9e05
7
- data.tar.gz: 2c7374a0dc4beef073b05c4463c39139477da9008d9833cb91c4551cb10352f7e03c0ac4e04a15f745c461672883d91c989beebacae35dd0e4d1704be2faa8da
6
+ metadata.gz: 1e28e3e325b49e5238468b5d9aa7833526d4904eb65af709162fb0b011725ace9acee4f5361a4a4bb3ddf7c70e3682c7cb6e5d1573bde365703e2069713c8e17
7
+ data.tar.gz: d0e0d2da2df75355881667a5adc043958d0414a7b048a705937e40b504aa0af06af2f44a1b63cddaa87e334a6cfd184e246dc9b52c3ce8e3650ba2cdf856fe6e
data/README.md CHANGED
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
 
23
23
  You can use executables 'master_join' and 'master_split'.
24
24
  For more imformation just use them with a -h flag.
25
- You can also include it as a library and use if methods
25
+ You can also include it as a library and use it's methods
26
26
  directly, like this:
27
27
 
28
28
  ```ruby
@@ -1,13 +1,17 @@
1
+ ##
2
+ # This gem can take file and splite it in to many slices,
3
+ # or join the slices of a splited file.
4
+ #
5
+ # Authour:: Pouya Gharib Pour
6
+ # License:: p.gharibpour@gmail.com
1
7
  require "master_splitter/version"
2
8
  require "master_splitter/constants"
3
9
  require "master_splitter/joiner"
4
10
  require "master_splitter/splitter"
5
11
 
12
+ ##
13
+ # This module holds everything.
14
+ # It includes 6 methods and 4 constants.
6
15
  module MasterSplitter
7
- ##
8
- # This gem can take file and splite it in to many slices,
9
- # or join the slices of a splited file.
10
- #
11
- # Authour:: Pouya Gharib Pour
12
- # License:: p.gharibpour@gmail.com
16
+
13
17
  end
@@ -1,5 +1,8 @@
1
1
  module MasterSplitter
2
+ # Max size of each read/write from/to files.
2
3
  MAX_CHUNK_SIZE = 1024 * 1024
4
+ # Naming format of a sliced file.
3
5
  STANDARD_SLICE_NAMING_FORMAT = /^(.*)\.(\d{3,})$/i
6
+ # For capturing only name of a file.
4
7
  FILE_NAME_FINDER = /^.*\/(.*)$/i
5
8
  end
@@ -1,17 +1,17 @@
1
1
  module MasterSplitter
2
+ ##
3
+ # With this method you can join a couple of file
4
+ # which their names does not follow the standard format.
5
+ # You can pass it a name for the output file and a directory
6
+ # to store it.
7
+ # Example:
8
+ # >> custom_joiner(["first.pdf", "second.pdf"],
9
+ # output_file_name: "book.pdf", output_dir: "Desktop/")
10
+ # Arguments:
11
+ # slice_names: (Array)
12
+ # options: (Hash)
13
+ #
2
14
  def custom_joiner(slice_names, options={})
3
- ##
4
- # With this method you can join a couple of file
5
- # which their names does not follow the standard format.
6
- # You can pass it a name for the output file and a directory
7
- # to store it.
8
- # Example:
9
- # >> custom_joiner(["first.pdf", "second.pdf"],
10
- # output_file_name: "book.pdf", output_dir: "Desktop/")
11
- # Arguments:
12
- # slice_names: (Array)
13
- # options: (Hash)
14
- #
15
15
  output_dir = options[:output_dir]
16
16
  output_file_name = options[:output_file_name]
17
17
  slice_names.each do |slice_name|
@@ -27,19 +27,19 @@ module MasterSplitter
27
27
  join(output_file_name, slice_names)
28
28
  end
29
29
 
30
+ ##
31
+ # This method joins slices of a splitted file which
32
+ # their names follow the standard format.
33
+ # You just have to pass it the name of the first slice.
34
+ # Remember that all slices must be in the same directory.
35
+ # Example:
36
+ # >> standard_joiner("path/to/first_slice.pdf.001",
37
+ # output_file_name: "book.pdf", output_dir: "Desktop/")
38
+ # Arguments:
39
+ # first_slice_name: (String)
40
+ # options: (Hash)
41
+ #
30
42
  def standard_joiner(first_slice_name, options={})
31
- ##
32
- # This method joins slices of a splitted file which
33
- # their names follow the standard format.
34
- # You just have to pass it the name of the first slice.
35
- # Remember that all slices must be in the same directory.
36
- # Example:
37
- # >> standard_joiner("path/to/first_slice.pdf.001",
38
- # output_file_name: "book.pdf", output_dir: "Desktop/")
39
- # Arguments:
40
- # first_slice_name: (String)
41
- # options: (Hash)
42
- #
43
43
  output_dir = options[:output_dir]
44
44
  output_file_name = options[:output_file_name]
45
45
  slice_names = []
@@ -73,18 +73,18 @@ module MasterSplitter
73
73
  end
74
74
  end #end of standard_joiner
75
75
 
76
+ ##
77
+ # This method does the actual joining of slices.
78
+ # It gets an Array of slice names and name of the
79
+ # output file.
80
+ #
81
+ # Example:
82
+ # >> join("book.pdf", ["book.pdf.001", "book.pdf.002"])
83
+ # Arguments:
84
+ # output_file_name: (String)
85
+ # slice_names: (Array)
86
+ #
76
87
  def join(output_file_name, slice_names)
77
- ##
78
- # This method does the actual joining of slices.
79
- # It gets an Array of slice names and name of the
80
- # output file.
81
- #
82
- # Example:
83
- # >> join("book.pdf", ["book.pdf.001", "book.pdf.002"])
84
- # Arguments:
85
- # output_file_name: (String)
86
- # slice_names: (Array)
87
- #
88
88
  output_file = File.open(output_file_name, 'wb')
89
89
 
90
90
  slice_names.each do |slice_name|
@@ -1,19 +1,20 @@
1
1
  module MasterSplitter
2
+
3
+ ##
4
+ # With this method you can split a file to slices which
5
+ # you can specify size of each slice.
6
+ # Sum of all slice sizes must be equal to the size of the
7
+ # orginal fille.
8
+ # Needless to say, sizes must be in bytes.
9
+ # Example:
10
+ # >> custom_splitter("file.pdf",
11
+ # [1232, 5432], output_dir: "Desktop/")
12
+ # Arguments:
13
+ # source_file_name: (String)
14
+ # slice_sizes: (Array)
15
+ # options: (Hash)
16
+ #
2
17
  def custom_splitter(source_file_name, slice_sizes, options={})
3
- ##
4
- # With this method you can split a file to slices which
5
- # you can specify size of each slice.
6
- # Sum of all slice sizes must be equal to the size of the
7
- # orginal fille.
8
- # Needless to say, sizes must be in bytes.
9
- # Example:
10
- # >> custom_splitter("file.pdf",
11
- # [1232, 5432], output_dir: "Desktop/")
12
- # Arguments:
13
- # source_file_name: (String)
14
- # slice_sizes: (Array)
15
- # options: (Hash)
16
- #
17
18
  slice_names = []
18
19
  output_dir = options[:output_dir]
19
20
  sum_of_sizes = slice_sizes.each(&:+)
@@ -39,19 +40,19 @@ module MasterSplitter
39
40
  split(source_file_name, slice_names, slice_sizes)
40
41
  end #end of custom_splitter
41
42
 
43
+ ##
44
+ # This method splits a given file to a specified
45
+ # number of slices, equally.
46
+ # Example:
47
+ # >> standard_splitter("file.pdf",
48
+ # number_of_slices: 5,
49
+ # output_dir: "Desktop/")
50
+ # Arguments:
51
+ # source_file_name: (String)
52
+ # number_of_slices: (Fixnum)
53
+ # options: (Hash)
54
+ #
42
55
  def standard_splitter(source_file_name, number_of_slices, options={})
43
- ##
44
- # This method splits a given file to a specified
45
- # number of slices, equally.
46
- # Example:
47
- # >> standard_splitter("file.pdf",
48
- # number_of_slices: 5,
49
- # output_dir: "Desktop/")
50
- # Arguments:
51
- # source_file_name: (String)
52
- # number_of_slices: (Fixnum)
53
- # options: (Hash)
54
- #
55
56
  slice_sizes = []
56
57
  slice_names = []
57
58
  output_dir = options[:output_dir]
@@ -79,18 +80,18 @@ module MasterSplitter
79
80
  split(source_file_name, slice_names, slice_sizes)
80
81
  end #end of standard_splitter
81
82
 
83
+ ##
84
+ # This method does the actual splitting of file.
85
+ # It gets the name of the source file and two arrays.
86
+ # One contains names of the slices and the other their sizes.
87
+ # Example:
88
+ # >> split("book.pdf", ["book.pdf.001", "book.pdf.002"], [6456, 6456])
89
+ # Arguments:
90
+ # source_file_name: (String)
91
+ # slice_names: (Array)
92
+ # slice_sizes: (Array)
93
+ #
82
94
  def split(source_file_name, slice_names, slice_sizes)
83
- ##
84
- # This method does the actual splitting of file.
85
- # It gets the name of the source file and two arrays.
86
- # One contains names of the slices and the other their sizes.
87
- # Example:
88
- # >> split("book.pdf", ["book.pdf.001", "book.pdf.002"], [6456, 6456])
89
- # Arguments:
90
- # source_file_name: (String)
91
- # slice_names: (Array)
92
- # slice_sizes: (Array)
93
- #
94
95
  source = File.open(source_file_name, 'rb')
95
96
 
96
97
  slice_names.size.times do |i|
@@ -1,3 +1,4 @@
1
1
  module MasterSplitter
2
- VERSION = "1.0.0"
2
+ # For holding the gems version.
3
+ VERSION = "1.0.1"
3
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: master_splitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pouya Gharib Pour
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-17 00:00:00.000000000 Z
11
+ date: 2015-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  requirements: []
82
82
  rubyforge_project:
83
- rubygems_version: 2.4.4
83
+ rubygems_version: 2.4.5
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: File spliter and joiner.