farmstead 0.0.81 → 0.0.82

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: f51d6712d5808e1d7e0a6ac2aefb73f94321f24b
4
- data.tar.gz: 4d8b42d99e815d2ac6a51e63424009147bab015a
3
+ metadata.gz: 00b654e9c00ebc50dbbcce44940a3577f9e66edc
4
+ data.tar.gz: 8bac8a053968bbaaaa3ccb41d002088815bb2916
5
5
  SHA512:
6
- metadata.gz: 169705c1b8ef8a01abeacab24f981b4155215ebfdcd62001f9dcc05774db0610de17b5edf8a932559b70c199e87887a9bc31712ac0f473a800cf4a90a9b92f8d
7
- data.tar.gz: 298d744acb68c06c838532984c98de9df7ad6a70a4d2f49fdcc1f40d62e4baa2e8505403fb724b92299e66a704d5914a0cdf774894cfc65c4912c2a26a55b157
6
+ metadata.gz: afa1c40fe179f4c2b782a9e3fa68680d06b01b3206ee47087633e57e2000d41a2d77336d1f138238a30889076ac6ef84efa53469696d80dc0be4b732437f74dd
7
+ data.tar.gz: 215d180256368059255083580b2a86cf58873f764d92746358009d514723f758aa271e5bb1d39bc53ac14cc44eb3b8074cff58b9b387443bc4c5740adc0c3489
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- farmstead (0.0.81)
4
+ farmstead (0.0.82)
5
5
  httparty (~> 0.15.6)
6
6
  mechanize (~> 2.7)
7
7
  mysql2 (~> 0.4.10)
@@ -50,7 +50,7 @@ GEM
50
50
  mysql2 (0.4.10)
51
51
  net-http-digest_auth (1.4.1)
52
52
  net-http-persistent (2.9.4)
53
- nokogiri (1.8.1)
53
+ nokogiri (1.8.2)
54
54
  mini_portile2 (~> 2.3.0)
55
55
  ntlm-http (0.1.1)
56
56
  os (1.0.0)
data/lib/farmstead/db.rb CHANGED
@@ -43,21 +43,40 @@ module Farmstead
43
43
  puts ds.all
44
44
  end
45
45
 
46
- # Insert an array of values into a table
47
- def self.insert(table,array)
46
+ def self.insert(table, hash)
48
47
  self.pull_variables
49
- ds = @@DB[table]
50
- ds.insert(array)
48
+ string = "INSERT INTO #{table} ("
49
+ hash.each_with_index do |(key, value), index|
50
+ string = string + key.to_s
51
+ unless index == 1
52
+ string = string + ","
53
+ end
54
+ end
55
+ string = string + ") VALUES ("
56
+ hash.each_with_index do |(key, value), index|
57
+ string = string + "'" + value + "'"
58
+ unless index == 1
59
+ string = string + ","
60
+ end
61
+ end
62
+ string = string + ")"
63
+ puts string
64
+ @@DB.run string
51
65
  end
52
66
 
67
+ # For now keep it simple
53
68
  def self.create_table(table, hash)
54
69
  self.pull_variables
55
- @@DB.create_table? table do
56
- #primary_key(:id) if hash[:primary_key]
57
- String(:name)
58
- String(:type)
59
- String(:module)
70
+ string = "CREATE TABLE IF NOT EXISTS #{table} (id integer primary key, "
71
+ hash.each_with_index do |(key, value), index|
72
+ string = string + key.to_s + " " + value
73
+ unless index == 1
74
+ string = string + ","
75
+ end
60
76
  end
77
+ string = string + ")"
78
+ puts string
79
+ @@DB.run string
61
80
  end
62
81
 
63
82
  # Insert an array of values into a table
@@ -1,3 +1,3 @@
1
1
  module Farmstead
2
- VERSION = "0.0.81"
2
+ VERSION = "0.0.82"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: farmstead
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.81
4
+ version: 0.0.82
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Jenney
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-29 00:00:00.000000000 Z
11
+ date: 2018-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor