csvr 0.2.0 → 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.
- checksums.yaml +4 -4
- data/lib/csvr/cli.rb +16 -0
- data/lib/csvr/sqlitedb.rb +23 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c30f8d1736189d25833a25b9a01a51a15968284f
|
4
|
+
data.tar.gz: 02976b505b2bac0107d1b9230708416f9dbb2bd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 987dc8d5124245ea4392429f9326dac7f64c5a2b33a72e4a9eccdd110235217e340c653830b4f80782aba893b769a896f0e4279797d608cf00b5cfcefa3ca4d6
|
7
|
+
data.tar.gz: 5624105b3868166ef0ba692e518b2c40c1c6806e8700a6c33dc4698696471223968448cca2e578285f7e300dc8d59791a862f944e1560de5cd25fc9c33300688
|
data/lib/csvr/cli.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module CSVR
|
4
|
+
|
5
|
+
class CLI < Thor
|
6
|
+
|
7
|
+
desc "api", "details use of CSVR"
|
8
|
+
def api
|
9
|
+
puts "csvr = CSVR.open('path/to/file')"
|
10
|
+
puts "csvr.create('db_name', 'table_name')"
|
11
|
+
puts "(optional) csvr.headers = ['array','of','custom', 'headers]"
|
12
|
+
puts "(optional) csvr.rows = ['array', 'of' 'strings' 'to' 'parse']"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'sqlite3'
|
2
|
+
|
3
|
+
class Database
|
4
|
+
|
5
|
+
attr_reader :db, :table, :headers, :rows
|
6
|
+
|
7
|
+
def initialize(db, table, headers, rows)
|
8
|
+
@db = db
|
9
|
+
@table = table
|
10
|
+
@headers = headers
|
11
|
+
@rows = rows
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
|
16
|
+
db = SQLite3::Database.open("#{@db}.db")
|
17
|
+
db.execute "CREATE TABLE IF NOT EXISTS #{@table}(#{@headers})"
|
18
|
+
@rows.each { |row| db.execute "INSERT INTO #{@table} #{row}" }
|
19
|
+
|
20
|
+
db.close
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: csvr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Smith
|
@@ -20,8 +20,10 @@ extra_rdoc_files: []
|
|
20
20
|
files:
|
21
21
|
- bin/csvr
|
22
22
|
- lib/csvr.rb
|
23
|
+
- lib/csvr/cli.rb
|
23
24
|
- lib/csvr/format.rb
|
24
25
|
- lib/csvr/parse.rb
|
26
|
+
- lib/csvr/sqlitedb.rb
|
25
27
|
homepage: http://idonthaveone.ca
|
26
28
|
licenses:
|
27
29
|
- MIT
|