csvql 0.2.5 → 0.3.0

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/csvql.rb +12 -7
  3. data/lib/csvql/version.rb +1 -1
  4. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bed0a5cc8a2105697059068f974285f7759d6740
4
- data.tar.gz: eb9f67e00d7fa495e66898db8ec63a7643db9e1f
3
+ metadata.gz: 537a7e1f20984f0f7f9d51d6974a8be35001da2d
4
+ data.tar.gz: 532cac120267e16efc2855d1f06eb27bff6552a3
5
5
  SHA512:
6
- metadata.gz: da2ed707579ba0a38405396db9844eb39b1a5f60464fdb955940ee8faba65fd35b966d964237321be42bb71802fda8391b990db9e9cb89192b6755de2ca35c6f
7
- data.tar.gz: 34361aedb693e113b7e48ca4a5b3d1048d793ba78dd3fcb8919ce0e7884ca550d5e24afa7c815dcf5ee807b71e3e19b6ea3e4dc4ef9df872369383cae0b65797
6
+ metadata.gz: efcf98bb4591188e64f6d04057d017a3bab2ba39e24717907ab53d6fc09b3739ba9210dc6c81f720ea0bd0fde0eb33c1c19b434ca794857113ab32eff023d4da
7
+ data.tar.gz: 467445d9fa94b4f7b42e6cce0b3b4fbf87a228f003b4858d9efe6d562f75fe2333450257400cc7479a872ccedb899008367e8cbc771f0caff9a05726ea3c7864
data/lib/csvql.rb CHANGED
@@ -19,7 +19,8 @@ module Csvql
19
19
 
20
20
  opt_parser.on("--console", "After all commands are run, open sqlite3 console with this data") {|v| opt.console = v }
21
21
  opt_parser.on("--header", "Treat file as having the first row as a header row") {|v| opt.header = v }
22
- opt_parser.on('--output-dlm="|"', "Output delimiter (|)") {|v| opt.output_dlm = v }
22
+ opt_parser.on('--ifs=","', "Input field separator (,)") {|v| opt.ifs = v }
23
+ opt_parser.on('--ofs="|"', "Output field separator (|)") {|v| opt.ofs = v }
23
24
  opt_parser.on("--save-to=FILE", "If set, sqlite3 db is left on disk at this path") {|v| opt.save_to = v }
24
25
  opt_parser.on("--append", "Append mode (not dropping any tables)") {|v| opt.append = v }
25
26
  opt_parser.on("--skip-comment", "Skip comment lines start with '#'") {|v| opt.skip_comment = v }
@@ -40,10 +41,14 @@ module Csvql
40
41
  else
41
42
  "tbl"
42
43
  end
43
- if opt.output_dlm == 'tab'
44
- opt.output_dlm = "\t"
44
+ if opt.ifs == 'tab'
45
+ opt.ifs = "\t"
45
46
  end
46
- opt.output_dlm ||= "|"
47
+
48
+ if opt.ofs == 'tab'
49
+ opt.ofs = "\t"
50
+ end
51
+ opt.ofs ||= "|"
47
52
 
48
53
  if opt.completion
49
54
  puts opt.compsys('csvql')
@@ -73,7 +78,7 @@ module Csvql
73
78
  schema = File.open(file).read
74
79
  end
75
80
  else
76
- cols = first_line.parse_csv
81
+ cols = first_line.parse_csv(col_sep: opt.ifs)
77
82
  col_name = if opt.header
78
83
  cols
79
84
  else
@@ -93,7 +98,7 @@ module Csvql
93
98
  line = NKF.nkf('-w', line).strip
94
99
  next if line.size == 0
95
100
  next if opt.skip_comment && line.start_with?("#")
96
- row = line.parse_csv
101
+ row = line.parse_csv(col_sep: opt.ifs)
97
102
  row.map!(&:strip) if opt.strip
98
103
  tbl.insert(row, i)
99
104
  end
@@ -109,7 +114,7 @@ module Csvql
109
114
  end
110
115
  end
111
116
 
112
- tbl.exec(sql).each {|row| puts row.join(opt.output_dlm) } if sql
117
+ tbl.exec(sql).each {|row| puts row.join(opt.ofs) } if sql
113
118
  tbl.open_console if opt.console
114
119
  end
115
120
  end
data/lib/csvql/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Csvql
2
- VERSION = "0.2.5"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csvql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - YANO Satoru
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-01 00:00:00.000000000 Z
11
+ date: 2014-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  version: '0'
68
68
  requirements: []
69
69
  rubyforge_project:
70
- rubygems_version: 2.3.0
70
+ rubygems_version: 2.2.2
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: csvql
@@ -75,4 +75,3 @@ test_files:
75
75
  - spec/csvql_spec.rb
76
76
  - spec/sample.csv
77
77
  - spec/spec_helper.rb
78
- has_rdoc: