file_manipulator 0.1.3 → 0.1.4
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/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/file_manipulator/splitter.rb +3 -2
- data/lib/file_manipulator/version.rb +1 -1
- data/lib/file_manipulator.rb +2 -4
- data/lib/generators/file_manipulator/install/install_generator.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cf73f01f9f7accb7a5ae0efbdeae81b45f5585e
|
4
|
+
data.tar.gz: bfab7a86059734d4e10f7e09773e8e2ef37fb560
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf9409138f32306ff18a2c71b2676aadd784c0559e319c24c78e54d2bcc35571170db555a8fb48fb1329884845e82a48f1ac2d29a718ba7258aff6645dbbf0f1
|
7
|
+
data.tar.gz: 7a5170cc444fe9e02272a2ec2cc3c62b59edae04390a31dae660d1f548ed6056ae9214e1dea512ee5d7812e5be278492888d2af132865775d49af278e72346fe
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# FileManipulator
|
2
2
|
|
3
|
-
`FileManipulator` can split a text formatted file and
|
3
|
+
`FileManipulator` can split a text formatted file into multiple files, and recover the original file by merging the splitted files.
|
4
4
|
|
5
5
|
<!-- http://shields.io/ -->
|
6
6
|
[](https://travis-ci.org/gipcompany/file_manipulator)
|
@@ -8,11 +8,12 @@ module FileManipulator
|
|
8
8
|
|
9
9
|
def run
|
10
10
|
index = 0
|
11
|
+
encoding = File.read(file_name).encoding.to_s
|
11
12
|
|
12
13
|
File.open(file_name, 'r') do |input|
|
13
14
|
until input.eof?
|
14
15
|
File.open(File.join(config.split_files_directory, output_file_name(index)), 'w') do |output|
|
15
|
-
output << input.read(config.size)
|
16
|
+
output << input.read(config.size).force_encoding(encoding)
|
16
17
|
end
|
17
18
|
|
18
19
|
index += 1
|
@@ -35,7 +36,7 @@ module FileManipulator
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def number_of_digits
|
38
|
-
@number_of_digits ||= Math.log10(File.size(file_name).to_f / config.size).ceil
|
39
|
+
@number_of_digits ||= Math.log10(File.size(file_name).to_f / config.size).ceil
|
39
40
|
end
|
40
41
|
|
41
42
|
def output_file_name(index)
|
data/lib/file_manipulator.rb
CHANGED
@@ -9,16 +9,14 @@ module FileManipulator
|
|
9
9
|
|
10
10
|
def configure
|
11
11
|
yield(@configuration ||= Configuration.new)
|
12
|
+
FileUtils.mkdir_p(configuration.split_files_directory)
|
13
|
+
FileUtils.mkdir_p(configuration.merged_file_directory)
|
12
14
|
end
|
13
15
|
|
14
16
|
def merge
|
15
17
|
Merger.new.run
|
16
18
|
end
|
17
19
|
|
18
|
-
def reset
|
19
|
-
@configuration = Configuration.new
|
20
|
-
end
|
21
|
-
|
22
20
|
def split
|
23
21
|
Splitter.new.run
|
24
22
|
end
|
@@ -3,7 +3,7 @@ module FileManipulator
|
|
3
3
|
class InstallGenerator < ::Rails::Generators::Base
|
4
4
|
source_root File.expand_path('../templates', __FILE__)
|
5
5
|
|
6
|
-
def
|
6
|
+
def copy_initializer(destination_path = 'config/initializers/file_manipulator.rb')
|
7
7
|
copy_file 'initializer.rb', destination_path
|
8
8
|
end
|
9
9
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file_manipulator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Atsushi Ishida
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|