csv2psql 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8e12654e5d07f5a1bb2baa44120d701c52dc5570
4
+ data.tar.gz: 37b7f1d82a61a667b971e2c2f0d5c1bc135b1c13
5
+ SHA512:
6
+ metadata.gz: 67522c3b720cab1215142f0ea1a9e34cd94ade8b20efab614d6fc0c30aecf3bcdd106a85f73bff830444e4b541d5af40a1f1f5d2d6f697a00115492f0f50115b
7
+ data.tar.gz: 9c34f3fe26c109bcca0a7212be2e8e6aa5cdbda0cf6d0af94a69fcdbd9607b37474bed10e59ab19bb53da96ac6162276e5f2e5f024e5c7bc22c03f9abd454144
data/.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+
5
+ $:.push File.expand_path("../lib", __FILE__)
6
+
7
+ require 'csv2psql/version.rb'
8
+
9
+ Gem::Specification.new do |s|
10
+ s.name = 'csv2psql'
11
+ s.version = Csv2Psql::VERSION
12
+ s.summary = 'Tool for converting CSV into SQL statements'
13
+ s.description = 'CSV to SQL conversion tool with user friendly CLI'
14
+ s.authors = [
15
+ 'Tomas Korcak'
16
+ ]
17
+ s.email = 'korczis@gmail.com'
18
+
19
+ s.homepage = 'https://github.com/korczis/csv2psql'
20
+ s.license = 'MIT'
21
+ s.require_paths = ['lib']
22
+
23
+ s.files = `git ls-files`.split("\n")
24
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
25
+
26
+ s.add_dependency 'gli', '~> 2.11', '>= 2.11.0'
27
+ s.add_dependency 'json_pure', '~> 1.8.1'
28
+ s.add_dependency 'multi_json', '~> 1.10.0'
29
+ s.add_dependency 'rake', '~> 10.3', '>= 10.3.2'
30
+ s.add_dependency 'terminal-table', '~> 1.4', '>= 1.4.5'
31
+
32
+ s.add_development_dependency 'coveralls', '~> 0.7', '>= 0.7.0r'
33
+ s.add_development_dependency 'rspec', '~> 3.0', '>= 3.0.0'
34
+ s.add_development_dependency 'rubocop', '~> 0.24', '>= 0.24.0'
35
+ s.add_development_dependency 'simplecov', '~> 0.8', '>= 0.8.2'
36
+ end
data/.gitignore ADDED
@@ -0,0 +1,34 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - ruby-head
6
+ - jruby-19mode
7
+
8
+ script: rake ci
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in json2csv.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Tomas Korcak
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,38 @@
1
+ # csv2psql
2
+
3
+ Tool for transforming CSV into SQL statements for insert or update into DB
4
+
5
+ ## Status
6
+
7
+ [![Gem Version](https://badge.fury.io/rb/csv2psql.svg)](http://badge.fury.io/rb/csv2psql)
8
+ [![Build Status](https://travis-ci.org/korczis/csv2psql.svg?branch=master)](https://travis-ci.org/korczis/csv2psql)
9
+ [![Code Climate](https://codeclimate.com/github/korczis/csv2psql/badges/gpa.svg)](https://codeclimate.com/github/korczis/csv2psql)
10
+ [![Dependency Status](https://gemnasium.com/korczis/csv2psql.svg)](https://gemnasium.com/korczis/csv2psql)
11
+
12
+ ## Getting started
13
+
14
+ ```
15
+ gem install csv2psql
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ **Simple conversion**
21
+
22
+ ```
23
+ csv2psql convert data/sample.csv
24
+ ```
25
+
26
+ ## Contributing to csv2psql
27
+
28
+ - Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
29
+ - Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
30
+ - Fork the project
31
+ - Start a feature/bugfix branch
32
+ - Commit and push until you are happy with your contribution
33
+ - Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
34
+ - Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
35
+
36
+ ## Copyright
37
+
38
+ Copyright (c) 2014 Tomas Korcak. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,59 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'rubygems'
4
+
5
+ require 'bundler/setup'
6
+ require 'bundler/gem_tasks'
7
+
8
+ require 'coveralls/rake/task'
9
+
10
+ require 'rspec/core/rake_task'
11
+
12
+ Coveralls::RakeTask.new
13
+
14
+ RSpec::Core::RakeTask.new(:test)
15
+
16
+ desc 'Run continuous integration test'
17
+ task :ci do
18
+ Rake::Task['test:unit'].invoke
19
+ # unless ENV['TRAVIS'] == 'true' && ENV['TRAVIS_SECURE_ENV_VARS'] == 'false'
20
+ # Rake::Task['test:integration'].invoke
21
+ # end
22
+ Rake::Task['test:cop'].invoke if RUBY_VERSION.start_with?('2.2') == false
23
+ Rake::Task['coveralls:push'].invoke
24
+ end
25
+
26
+ desc 'Run Rubocop'
27
+ task :cop do
28
+ exec 'rubocop lib/'
29
+ end
30
+
31
+ namespace :test do
32
+ desc 'Run unit tests'
33
+ RSpec::Core::RakeTask.new(:unit) do |t|
34
+ t.pattern = 'spec/unit/**/*.rb'
35
+ end
36
+
37
+ desc "Run coding style tests"
38
+ RSpec::Core::RakeTask.new(:cop) do |t|
39
+ # Rake::Task['cop'].invoke
40
+ end
41
+
42
+ task :all => [:unit, :cop]
43
+ end
44
+
45
+ desc 'Get all tasks'
46
+ task :tasklist do
47
+ puts Rake.application.tasks
48
+ end
49
+
50
+ task :usage do
51
+ puts 'No rake task specified, use rake -T to list them'
52
+ # puts "No rake task specified so listing them ..."
53
+ # Rake.application['tasklist'].invoke
54
+ end
55
+ task :default => [:usage]
56
+
57
+ if $0 == __FILE__
58
+ Rake.application['usage'].invoke
59
+ end
data/bin/csv2psql ADDED
@@ -0,0 +1,6 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require_relative '../lib/csv2psql/lib'
4
+ require_relative '../lib/csv2psql/version'
5
+
6
+ require_relative '../lib/csv2psql/cli/cli'
data/data/sample.csv ADDED
@@ -0,0 +1,3 @@
1
+ id,Firstname,Lastname,Address.Street,Address.City,Address.Details.Note
2
+ 12345,Joe,Doe,"#2140 Taylor Street, 94133",San Francisco,Pool available
3
+ 45678,Jack,Plumber,"#111 Sutter St, 94104",San Francisco,Korean Deli near to main entrance
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+
3
+ require 'gli'
4
+ require 'pathname'
5
+ require 'pp'
6
+
7
+ require_relative 'shared'
8
+ require_relative '../version'
9
+
10
+ def launch(argv = ARGV)
11
+ run(argv)
12
+ end
13
+
14
+ include GLI::App
15
+
16
+ program_desc "csv2psql #{Csv2Psql::VERSION}"
17
+
18
+ module Csv2Psql
19
+ # Apollon CLI
20
+ module Cli
21
+ # CLI Application
22
+ class App
23
+ extend Csv2Psql::Cli::Shared
24
+
25
+ cmds = File.absolute_path(File.join(File.dirname(__FILE__), 'cmd'))
26
+ Dir.glob(cmds + '/*.rb').each do |file|
27
+ require file
28
+ end
29
+
30
+ program_desc 'Csv2Psql CLI'
31
+
32
+ def main(argv = ARGV)
33
+ launch(argv)
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ launch
@@ -0,0 +1,7 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'pathname'
4
+
5
+ require_relative 'shared'
6
+
7
+ require_relative 'app'
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ require 'gli'
4
+
5
+ include GLI::App
6
+
7
+ require_relative '../shared'
8
+ require_relative '../../convert/convert'
9
+
10
+ desc 'Convert csv file'
11
+ command :convert do |c|
12
+ c.switch [:h, :header], desc: 'Header row included'
13
+ c.flag [:d, :delimiter], type: String, default_value: ','
14
+
15
+ c.action do |global_options, options, args|
16
+ fail ArgumentError, 'No file to convert specified' if args.empty?
17
+
18
+ opts = {}.merge(global_options).merge(options)
19
+ Csv2Psql::Convert.convert(args, opts)
20
+ end
21
+ end
22
+
23
+ # default_command :convert
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'gli'
4
+
5
+ include GLI::App
6
+
7
+ require_relative '../../version'
8
+
9
+ require_relative '../shared'
10
+
11
+ desc 'Print version info'
12
+ command :version do |c|
13
+ c.action do |_global_options, _options, _args|
14
+ pp Csv2Psql::VERSION
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'gli'
4
+
5
+ module Csv2Psql
6
+ module Cli
7
+ # Shared CLI Stuff
8
+ module Shared
9
+ extend GLI::App
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'csv'
4
+ require 'multi_json'
5
+ require 'pathname'
6
+ require 'pp'
7
+
8
+ require_relative '../version'
9
+
10
+ module Csv2Psql
11
+ # Csv2Psql convert module
12
+ module Convert
13
+ class << self
14
+ def convert(paths, opts = {})
15
+ paths = [paths] unless paths.is_a?(Array)
16
+ paths.each do |path|
17
+ puts "Converting #{path}"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'pathname'
4
+
5
+ base = Pathname(__FILE__).dirname.expand_path
6
+
7
+ res = []
8
+
9
+ Dir.glob(base + '*.rb').each do |file|
10
+ loaded_file = require file
11
+ res << {
12
+ file: file,
13
+ loaded: loaded_file
14
+ }
15
+ end
16
+
17
+ res
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+
3
+ # Csv2Psql module
4
+ module Csv2Psql
5
+ VERSION = '0.0.0'
6
+ end
data/lib/csv2psql.rb ADDED
@@ -0,0 +1,3 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'csv2psql/lib'
@@ -0,0 +1,44 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'simplecov'
4
+ require 'rspec'
5
+ require 'coveralls'
6
+ require 'pathname'
7
+
8
+ Coveralls.wear_merged!
9
+
10
+ # Automagically include all helpers/*_helper.rb
11
+
12
+ base = Pathname(__FILE__).dirname.expand_path
13
+ Dir.glob(base + 'helpers/*_helper.rb').each do |file|
14
+ require file
15
+ end
16
+
17
+ RSpec.configure do |config|
18
+ config.filter_run_excluding :broken => true
19
+
20
+ config.before(:all) do
21
+ # TODO: Fully setup global environment
22
+ end
23
+
24
+ config.after(:all) do
25
+ # TODO: Fully setup global environment
26
+ end
27
+
28
+ config.before(:suite) do
29
+ # TODO: Setup test project
30
+ end
31
+
32
+ config.after(:suite) do
33
+ # TODO: Delete test project
34
+ end
35
+ end
36
+
37
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
38
+ SimpleCov::Formatter::HTMLFormatter,
39
+ Coveralls::SimpleCov::Formatter
40
+ ]
41
+
42
+ SimpleCov.start do
43
+ add_filter 'spec/'
44
+ end
metadata ADDED
@@ -0,0 +1,231 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: csv2psql
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Tomas Korcak
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gli
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.11'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.11.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '2.11'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.11.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: json_pure
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 1.8.1
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 1.8.1
47
+ - !ruby/object:Gem::Dependency
48
+ name: multi_json
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 1.10.0
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 1.10.0
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '10.3'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 10.3.2
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '10.3'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 10.3.2
81
+ - !ruby/object:Gem::Dependency
82
+ name: terminal-table
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '1.4'
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 1.4.5
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '1.4'
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 1.4.5
101
+ - !ruby/object:Gem::Dependency
102
+ name: coveralls
103
+ requirement: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - "~>"
106
+ - !ruby/object:Gem::Version
107
+ version: '0.7'
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 0.7.0r
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.7'
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 0.7.0r
121
+ - !ruby/object:Gem::Dependency
122
+ name: rspec
123
+ requirement: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - "~>"
126
+ - !ruby/object:Gem::Version
127
+ version: '3.0'
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: 3.0.0
131
+ type: :development
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '3.0'
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: 3.0.0
141
+ - !ruby/object:Gem::Dependency
142
+ name: rubocop
143
+ requirement: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - "~>"
146
+ - !ruby/object:Gem::Version
147
+ version: '0.24'
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: 0.24.0
151
+ type: :development
152
+ prerelease: false
153
+ version_requirements: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: '0.24'
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: 0.24.0
161
+ - !ruby/object:Gem::Dependency
162
+ name: simplecov
163
+ requirement: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '0.8'
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: 0.8.2
171
+ type: :development
172
+ prerelease: false
173
+ version_requirements: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - "~>"
176
+ - !ruby/object:Gem::Version
177
+ version: '0.8'
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: 0.8.2
181
+ description: CSV to SQL conversion tool with user friendly CLI
182
+ email: korczis@gmail.com
183
+ executables:
184
+ - csv2psql
185
+ extensions: []
186
+ extra_rdoc_files: []
187
+ files:
188
+ - ".gemspec"
189
+ - ".gitignore"
190
+ - ".travis.yml"
191
+ - Gemfile
192
+ - LICENSE
193
+ - README.md
194
+ - Rakefile
195
+ - bin/csv2psql
196
+ - data/sample.csv
197
+ - lib/csv2psql.rb
198
+ - lib/csv2psql/cli/app.rb
199
+ - lib/csv2psql/cli/cli.rb
200
+ - lib/csv2psql/cli/cmd/convert_cmd.rb
201
+ - lib/csv2psql/cli/cmd/version_cmd.rb
202
+ - lib/csv2psql/cli/shared.rb
203
+ - lib/csv2psql/convert/convert.rb
204
+ - lib/csv2psql/lib.rb
205
+ - lib/csv2psql/version.rb
206
+ - spec/spec_helper.rb
207
+ homepage: https://github.com/korczis/csv2psql
208
+ licenses:
209
+ - MIT
210
+ metadata: {}
211
+ post_install_message:
212
+ rdoc_options: []
213
+ require_paths:
214
+ - lib
215
+ required_ruby_version: !ruby/object:Gem::Requirement
216
+ requirements:
217
+ - - ">="
218
+ - !ruby/object:Gem::Version
219
+ version: '0'
220
+ required_rubygems_version: !ruby/object:Gem::Requirement
221
+ requirements:
222
+ - - ">="
223
+ - !ruby/object:Gem::Version
224
+ version: '0'
225
+ requirements: []
226
+ rubyforge_project:
227
+ rubygems_version: 2.2.2
228
+ signing_key:
229
+ specification_version: 4
230
+ summary: Tool for converting CSV into SQL statements
231
+ test_files: []