file_manipulator 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a021b26713519ceca3325fc379e92005dc01c4a
4
- data.tar.gz: 365b700976dba9afae6eda948ae563d4a6a4f50c
3
+ metadata.gz: 3cf73f01f9f7accb7a5ae0efbdeae81b45f5585e
4
+ data.tar.gz: bfab7a86059734d4e10f7e09773e8e2ef37fb560
5
5
  SHA512:
6
- metadata.gz: 4a9886789d3cc814d9c33491294a75ffef91e0198f385e0845b1051900a19fca17cbaeb3a26087ba63be7ea6f070488f1b67d66073572818144034166d1527c2
7
- data.tar.gz: 6683b2e825e36a55154cfb031465c2d9a5d57685118e561b1abed257f703cf48d4e5a3331c6ee392ca61d5305832c001d95453b8fe40408daece14e499c2ceec
6
+ metadata.gz: bf9409138f32306ff18a2c71b2676aadd784c0559e319c24c78e54d2bcc35571170db555a8fb48fb1329884845e82a48f1ac2d29a718ba7258aff6645dbbf0f1
7
+ data.tar.gz: 7a5170cc444fe9e02272a2ec2cc3c62b59edae04390a31dae660d1f548ed6056ae9214e1dea512ee5d7812e5be278492888d2af132865775d49af278e72346fe
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- file_manipulator (0.1.3)
4
+ file_manipulator (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # FileManipulator
2
2
 
3
- `FileManipulator` can split a text formatted file and merge them to one file.
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
  [![Build Status](https://travis-ci.org/gipcompany/file_manipulator.svg?branch=master_issue_3)](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 + 1
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)
@@ -1,3 +1,3 @@
1
1
  module FileManipulator
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -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 copy_initializer_file(destination_path = 'config/initializers/file_manipulator.rb')
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.3
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-23 00:00:00.000000000 Z
11
+ date: 2016-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler