twineCSV 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/bin/twineCSV +2 -1
- data/lib/twineCSV.rb +12 -0
- data/lib/twineCSV/version.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: 931c661fa298a72aa5a2cb96a3aabbd1281a0704
|
4
|
+
data.tar.gz: 6d33c05e6684f1c401a5c7b363813a579a57d5ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 411dc71b07d8c732aefbea6be6dc8f400b319bd01b471928761cdc78b106325e68082372f8bcebe801a68f7aae7856b9c9b6444d8407c79346a992bb73e9e780
|
7
|
+
data.tar.gz: 7acbe2974563842bcc744a01aebbdf7c7dcbe62b59952f901653642929c562044209d92779d49d5490b8af4756d99e6e38358b6c2d17e7405f466942174c215c
|
data/README.md
CHANGED
@@ -23,18 +23,18 @@ This micro gem converts twine formatted txt files to csv and vice versa. The rea
|
|
23
23
|
### Convert to csv
|
24
24
|
|
25
25
|
```
|
26
|
-
twineCSV
|
26
|
+
twineCSV tocsv localisation.txt converted.csv
|
27
27
|
```
|
28
28
|
|
29
|
-
You have to
|
29
|
+
You have to provide at least the input file. When omitting the output file the filename is created based on the inputs filename.
|
30
30
|
|
31
31
|
### Convert to twine file
|
32
32
|
|
33
33
|
```
|
34
|
-
twineCSV
|
34
|
+
twineCSV totwine converted.csv localisation.txt
|
35
35
|
```
|
36
36
|
|
37
|
-
You have to
|
37
|
+
You have to provide at least the input file. When omitting the output file the filename is created based on the inputs filename.
|
38
38
|
|
39
39
|
### Help
|
40
40
|
|
data/bin/twineCSV
CHANGED
@@ -2,9 +2,10 @@
|
|
2
2
|
|
3
3
|
require 'commander/import'
|
4
4
|
require_relative '../lib/twineCSV'
|
5
|
+
require_relative '../lib/twineCSV/version.rb'
|
5
6
|
|
6
7
|
program :name, 'twineCSV'
|
7
|
-
program :version,
|
8
|
+
program :version, TwineCSV::VERSION
|
8
9
|
program :description, 'Converts your twine formatted localisation file to CSV and vice versa'
|
9
10
|
|
10
11
|
command :totwine do |c|
|
data/lib/twineCSV.rb
CHANGED
@@ -46,6 +46,7 @@ module TwineCSV
|
|
46
46
|
|
47
47
|
def self.to_twine input, output
|
48
48
|
abort("The input file must not be nil") if input.nil? or output.nil?
|
49
|
+
check_for_separator(input)
|
49
50
|
|
50
51
|
content = File.open(input, 'r').read
|
51
52
|
lines = content.each_line.to_a.map { |line| line.gsub("\n", '').strip }
|
@@ -69,7 +70,18 @@ module TwineCSV
|
|
69
70
|
File.open(output, 'wb+') { |f|
|
70
71
|
f << result.join("\n")
|
71
72
|
}
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.check_for_separator(input)
|
76
|
+
allowed_separators = [';']
|
77
|
+
|
78
|
+
content = File.open(input, 'r').read
|
79
|
+
lines = content.each_line.to_a.map { |line| line.gsub("\n", '').strip }
|
80
|
+
header_line = lines[0]
|
72
81
|
|
82
|
+
unless header_line.nil?
|
83
|
+
abort('No valid separator was found in the csv. Please use one of the following: ' + allowed_separators.join(' ')) unless allowed_separators.any? { |separator| header_line.include?(separator) }
|
84
|
+
end
|
73
85
|
end
|
74
86
|
|
75
87
|
end
|
data/lib/twineCSV/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twineCSV
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Neidig
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05-
|
11
|
+
date: 2017-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|