postgres-copy 0.8.1 → 0.9.0

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: 9baf34eb526edbec803e3efd7b27dddc3a777a9a
4
- data.tar.gz: 00d5930fb6eb7508e8010c2f0ff6adf4c35995b6
3
+ metadata.gz: 06fb58609cde69655a230014265b1617d26e6b4a
4
+ data.tar.gz: 925c7d2f5b4d0ac68c8ff579dbaacfd0ece9823d
5
5
  SHA512:
6
- metadata.gz: 7abaef90e2d60dc003439a1a8cf3fa2ba2f437f97733d58706ef6bec5cf0a5f08749748b835db18743d1f89939ac44d3fc4ab84082d50ab2c1e414db76e48bec
7
- data.tar.gz: ca0b07437f6181958958db3f1997d37c243505063ee109105a4ab29138bb5bbf564f8ddb27db5446e38d8ecb3f445f3ec99b18401d1aff7e6fb177ac4ed7e0a1
6
+ metadata.gz: 1363641eb2b61078691ad937a0f7dbbc682f8105ea8f7684646e66401ad344658965b1bca5741caecee264b26109e1a7796fce0cb50cdac40880810ca9afb2a8
7
+ data.tar.gz: 356c74bb431c9b6713054b41a6d51b1d4033477729e96c90f1a4b2d876019d586727140bc92d22752cd02553d48c35821d4d0cf3d6ea1dd215a8312bc668f0e1
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- postgres-copy (0.8.1)
4
+ postgres-copy (0.9.0)
5
5
  activerecord (>= 4.0)
6
- pg
6
+ pg (>= 0.17)
7
7
  rails (>= 4.0)
8
8
  responders
9
9
 
@@ -19,9 +19,10 @@ module PostgresCopy
19
19
  raise "You have to choose between exporting to a file or receiving the lines inside a block" if block_given?
20
20
  connection.execute "COPY (#{self.all.to_sql}) TO #{sanitize(path)} WITH #{options_string}"
21
21
  else
22
- connection.execute "COPY (#{self.all.to_sql}) TO STDOUT WITH #{options_string}"
23
- while line = connection.raw_connection.get_copy_data do
24
- yield(line) if block_given?
22
+ connection.raw_connection.copy_data "COPY (#{self.all.to_sql}) TO STDOUT WITH #{options_string}" do
23
+ while line = connection.raw_connection.get_copy_data do
24
+ yield(line) if block_given?
25
+ end
25
26
  end
26
27
  end
27
28
  return self
@@ -67,28 +68,28 @@ module PostgresCopy
67
68
 
68
69
  columns_list = columns_list.map{|c| options[:map][c.to_s] } if options[:map]
69
70
  columns_string = columns_list.size > 0 ? "(\"#{columns_list.join('","')}\")" : ""
70
- connection.execute %{COPY #{table} #{columns_string} FROM STDIN #{options_string}}
71
- if options[:format] == :binary
72
- bytes = 0
73
- begin
74
- while line = io.readpartial(10240)
75
- connection.raw_connection.put_copy_data line
76
- bytes += line.bytesize
71
+ connection.raw_connection.copy_data %{COPY #{table} #{columns_string} FROM STDIN #{options_string}} do
72
+ if options[:format] == :binary
73
+ bytes = 0
74
+ begin
75
+ while line = io.readpartial(10240)
76
+ connection.raw_connection.put_copy_data line
77
+ bytes += line.bytesize
78
+ end
79
+ rescue EOFError
77
80
  end
78
- rescue EOFError
79
- end
80
- else
81
- while line = io.gets do
82
- next if line.strip.size == 0
83
- if block_given?
84
- row = line.strip.split(options[:delimiter])
85
- yield(row)
86
- line = row.join(options[:delimiter]) + "\n"
81
+ else
82
+ while line = io.gets do
83
+ next if line.strip.size == 0
84
+ if block_given?
85
+ row = line.strip.split(options[:delimiter])
86
+ yield(row)
87
+ line = row.join(options[:delimiter]) + "\n"
88
+ end
89
+ connection.raw_connection.put_copy_data line
87
90
  end
88
- connection.raw_connection.put_copy_data line
89
91
  end
90
92
  end
91
- connection.raw_connection.put_copy_end
92
93
  end
93
94
  end
94
95
 
@@ -5,7 +5,7 @@ $:.unshift lib unless $:.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "postgres-copy"
8
- s.version = "0.8.1"
8
+ s.version = "0.9.0"
9
9
 
10
10
  s.platform = Gem::Platform::RUBY
11
11
  s.required_ruby_version = ">= 1.9.3"
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.require_paths = ["lib"]
23
23
  s.summary = "Put COPY command functionality in ActiveRecord's model class"
24
24
 
25
- s.add_dependency "pg"
25
+ s.add_dependency "pg", ">= 0.17"
26
26
  s.add_dependency "activerecord", '>= 4.0'
27
27
  s.add_dependency "rails", '>= 4.0'
28
28
  s.add_dependency "responders"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postgres-copy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diogo Biazus
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.17'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '0.17'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement