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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/csvr/cli.rb +16 -0
  3. data/lib/csvr/sqlitedb.rb +23 -0
  4. metadata +3 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b26c74fcc82a0bdb6d9ef88f61b60c8ced0562f8
4
- data.tar.gz: 246386b042b310aafa80cd2367b0857fbbb7414e
3
+ metadata.gz: c30f8d1736189d25833a25b9a01a51a15968284f
4
+ data.tar.gz: 02976b505b2bac0107d1b9230708416f9dbb2bd2
5
5
  SHA512:
6
- metadata.gz: a6c2a0c462e192556e24048954ded3dc1ae406aac41cede33ccd892dafdf71fc3a661d741340e6899fb2c770de89328223116de4664e73443d505d224b801b1e
7
- data.tar.gz: b3563a91ea5f0f6400e87318609aebdad9a661941d96496bae149918b9b613f13aac45a1da627f2de985f42fcf02ebcd3704b228a0a693ad662ce15b333828ed
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.2.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