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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd5585380e2974fa41d2cc45e6e7984f5395da49
4
- data.tar.gz: 636b45606a6c0e7ad43e914f56ca8bd996672403
3
+ metadata.gz: 931c661fa298a72aa5a2cb96a3aabbd1281a0704
4
+ data.tar.gz: 6d33c05e6684f1c401a5c7b363813a579a57d5ac
5
5
  SHA512:
6
- metadata.gz: bf8fbb49d296092ba1dfff6a6a0e5d9c2c1868a5efb7b758b972cbd1dbf288f3776e86939465457bd390faac4c04d08cfde95fe8b9533b880ef0eeaf821028f6
7
- data.tar.gz: bf83b635d97bfb2ddcc4e4b51ed9231817138bc57489af579986acc84c0f0bdb8cfa5f5b326c94c5d245d704c566aead96101b055024bfced8e0905ab329a539
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 totwine localisation.txt converted.csv
26
+ twineCSV tocsv localisation.txt converted.csv
27
27
  ```
28
28
 
29
- You have to proide at least the input file. When omitting the output file the filename is created based on the inputs filename.
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 tocsv converted.csv localisation_new.txt
34
+ twineCSV totwine converted.csv localisation.txt
35
35
  ```
36
36
 
37
- You have to proide at least the input file. When omitting the output file the filename is created based on the inputs filename.
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, '1.0.0'
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
@@ -1,3 +1,3 @@
1
1
  module TwineCSV
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
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
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-03 00:00:00.000000000 Z
11
+ date: 2017-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander