kiba-plus 0.1.4 → 0.1.5

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: 6f1a1cdf8bd14192dc38eff8bf739b08291c89f2
4
- data.tar.gz: ccdc4706b15ef09c52c991bb1a3043fbe86d72b6
3
+ metadata.gz: bd0ab521f8e00c7b382e0837b43ac63d46fa04d4
4
+ data.tar.gz: 6a0116b43920b28f6cd4c5f69f108c3d1c554006
5
5
  SHA512:
6
- metadata.gz: b84053566ac09a919756801fd9edc193b06decdafec0d671eda0663a0a4c2ed658581e778c734c77c5afd56e72d0991297b6c76def3bcbab9f628be86d5d0994
7
- data.tar.gz: 95036ece396cbee056b591279baeb05d52d255677d664a83078ffde6a815a2fe61012080bf2822466b2ae77da4069ea025c46cff3f94ccfea75b4c8645e04aed
6
+ metadata.gz: 67cc2a0d8b6c00951bacdfde6b9452a8057a5f7c274aa5e055ae1c0c759becd9bae7b816f380b96bb5483a4683881bd8956242d28792c3d5c28fa1418a690afc
7
+ data.tar.gz: f417fe27d5b199ef50f76e1a1441d7a1a44e41af3bfd92542b6fb4fe3e27dd423b75aa72026de781492924993b0ae867a2b3ff574f3d7235f4995cd465558bc0
@@ -9,12 +9,11 @@ module Kiba::Plus::Destination
9
9
  @options.assert_valid_keys(
10
10
  :connect_url,
11
11
  :schema,
12
- :prepare_name,
13
- :prepare_sql,
12
+ :table_name,
14
13
  :columns
15
14
  )
16
15
  @conn = PG.connect(connect_url)
17
- @conn.exec "SET search_path TO %s" % [ options.fetch(:schema) ] unless options.fetch(:schema).empty?
16
+ @conn.exec "SET search_path TO %s" % [ options[:schema] ] if options[:schema]
18
17
  init
19
18
  end
20
19
 
@@ -43,16 +42,22 @@ module Kiba::Plus::Destination
43
42
  options.fetch(:connect_url)
44
43
  end
45
44
 
45
+ def table_name
46
+ options.fetch(:table_name)
47
+ end
48
+
46
49
  def prepare_name
47
- options.fetch(:prepare_name, self.class.to_s.downcase + "stmt")
50
+ options.fetch(:prepare_name, table_name + "_stmt")
48
51
  end
49
52
 
50
53
  def prepare_sql
51
- options.fetch(:prepare_sql)
54
+ sql = <<-SQL
55
+ INSERT INTO #{table_name} (#{columns.join(', ') }) VALUES (#{columns.each_with_index.map { |_, i| "$#{i + 1}" }.join(', ')});
56
+ SQL
52
57
  end
53
58
 
54
59
  def columns
55
60
  options.fetch(:columns)
56
61
  end
57
62
  end
58
- end
63
+ end
data/lib/kiba/plus/job.rb CHANGED
@@ -18,7 +18,7 @@ module Kiba
18
18
  @client = Mysql2::Client.new(mysql2_connect_hash(connect_url))
19
19
  elsif url.scheme =~ /postgres/i
20
20
  @client = PG.connect(connect_url)
21
- @client.exec "SET search_path TO %s" % [ options.fetch(:schema) ] unless options.fetch(:schema).empty?
21
+ @client.exec "SET search_path TO %s" % [ options[:schema] ] if options[:schema]
22
22
  else
23
23
  raise 'No Imp!'
24
24
  end
@@ -147,4 +147,4 @@ module Kiba
147
147
  end
148
148
  end
149
149
  end
150
- end
150
+ end
@@ -15,7 +15,7 @@ module Kiba
15
15
  :query
16
16
  )
17
17
  @client = PG.connect(connect_url)
18
- @client.exec "SET search_path TO %s" % [ options.fetch(:schema) ] unless options.fetch(:schema).empty?
18
+ @client.exec "SET search_path TO %s" % [ options[:schema] ] if options[:schema]
19
19
  end
20
20
 
21
21
  def each
@@ -37,4 +37,4 @@ module Kiba
37
37
  end
38
38
  end
39
39
  end
40
- end
40
+ end
@@ -1,5 +1,5 @@
1
1
  module Kiba
2
2
  module Plus
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kiba-plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hooopo