postgres-copy 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +37 -37
- data/VERSION +1 -1
- data/lib/postgres-copy/active_record.rb +1 -1
- data/postgres-copy.gemspec +8 -14
- data/spec/fixtures/reserved_word_model.rb +5 -0
- data/spec/fixtures/reserved_words.csv +2 -0
- data/spec/pg_copy_from_spec.rb +5 -0
- data/spec/spec_helper.rb +4 -1
- metadata +37 -82
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,12 +2,12 @@ GEM
|
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
4
|
abstract (1.0.0)
|
5
|
-
actionmailer (3.0.
|
6
|
-
actionpack (= 3.0.
|
5
|
+
actionmailer (3.0.7)
|
6
|
+
actionpack (= 3.0.7)
|
7
7
|
mail (~> 2.2.15)
|
8
|
-
actionpack (3.0.
|
9
|
-
activemodel (= 3.0.
|
10
|
-
activesupport (= 3.0.
|
8
|
+
actionpack (3.0.7)
|
9
|
+
activemodel (= 3.0.7)
|
10
|
+
activesupport (= 3.0.7)
|
11
11
|
builder (~> 2.1.2)
|
12
12
|
erubis (~> 2.6.6)
|
13
13
|
i18n (~> 0.5.0)
|
@@ -15,64 +15,64 @@ GEM
|
|
15
15
|
rack-mount (~> 0.6.14)
|
16
16
|
rack-test (~> 0.5.7)
|
17
17
|
tzinfo (~> 0.3.23)
|
18
|
-
activemodel (3.0.
|
19
|
-
activesupport (= 3.0.
|
18
|
+
activemodel (3.0.7)
|
19
|
+
activesupport (= 3.0.7)
|
20
20
|
builder (~> 2.1.2)
|
21
21
|
i18n (~> 0.5.0)
|
22
|
-
activerecord (3.0.
|
23
|
-
activemodel (= 3.0.
|
24
|
-
activesupport (= 3.0.
|
22
|
+
activerecord (3.0.7)
|
23
|
+
activemodel (= 3.0.7)
|
24
|
+
activesupport (= 3.0.7)
|
25
25
|
arel (~> 2.0.2)
|
26
26
|
tzinfo (~> 0.3.23)
|
27
|
-
activeresource (3.0.
|
28
|
-
activemodel (= 3.0.
|
29
|
-
activesupport (= 3.0.
|
30
|
-
activesupport (3.0.
|
31
|
-
arel (2.0.
|
27
|
+
activeresource (3.0.7)
|
28
|
+
activemodel (= 3.0.7)
|
29
|
+
activesupport (= 3.0.7)
|
30
|
+
activesupport (3.0.7)
|
31
|
+
arel (2.0.10)
|
32
32
|
builder (2.1.2)
|
33
33
|
diff-lcs (1.1.2)
|
34
34
|
erubis (2.6.6)
|
35
35
|
abstract (>= 1.0.0)
|
36
36
|
i18n (0.5.0)
|
37
|
-
mail (2.2.
|
37
|
+
mail (2.2.19)
|
38
38
|
activesupport (>= 2.3.6)
|
39
39
|
i18n (>= 0.4.0)
|
40
40
|
mime-types (~> 1.16)
|
41
41
|
treetop (~> 1.4.8)
|
42
42
|
mime-types (1.16)
|
43
|
-
pg (0.
|
43
|
+
pg (0.11.0)
|
44
44
|
polyglot (0.3.1)
|
45
|
-
rack (1.2.
|
45
|
+
rack (1.2.3)
|
46
46
|
rack-mount (0.6.14)
|
47
47
|
rack (>= 1.0.0)
|
48
48
|
rack-test (0.5.7)
|
49
49
|
rack (>= 1.0)
|
50
|
-
rails (3.0.
|
51
|
-
actionmailer (= 3.0.
|
52
|
-
actionpack (= 3.0.
|
53
|
-
activerecord (= 3.0.
|
54
|
-
activeresource (= 3.0.
|
55
|
-
activesupport (= 3.0.
|
50
|
+
rails (3.0.7)
|
51
|
+
actionmailer (= 3.0.7)
|
52
|
+
actionpack (= 3.0.7)
|
53
|
+
activerecord (= 3.0.7)
|
54
|
+
activeresource (= 3.0.7)
|
55
|
+
activesupport (= 3.0.7)
|
56
56
|
bundler (~> 1.0)
|
57
|
-
railties (= 3.0.
|
58
|
-
railties (3.0.
|
59
|
-
actionpack (= 3.0.
|
60
|
-
activesupport (= 3.0.
|
57
|
+
railties (= 3.0.7)
|
58
|
+
railties (3.0.7)
|
59
|
+
actionpack (= 3.0.7)
|
60
|
+
activesupport (= 3.0.7)
|
61
61
|
rake (>= 0.8.7)
|
62
62
|
thor (~> 0.14.4)
|
63
|
-
rake (0.
|
64
|
-
rspec (2.
|
65
|
-
rspec-core (~> 2.
|
66
|
-
rspec-expectations (~> 2.
|
67
|
-
rspec-mocks (~> 2.
|
68
|
-
rspec-core (2.
|
69
|
-
rspec-expectations (2.
|
63
|
+
rake (0.9.0)
|
64
|
+
rspec (2.6.0)
|
65
|
+
rspec-core (~> 2.6.0)
|
66
|
+
rspec-expectations (~> 2.6.0)
|
67
|
+
rspec-mocks (~> 2.6.0)
|
68
|
+
rspec-core (2.6.3)
|
69
|
+
rspec-expectations (2.6.0)
|
70
70
|
diff-lcs (~> 1.1.2)
|
71
|
-
rspec-mocks (2.
|
71
|
+
rspec-mocks (2.6.0)
|
72
72
|
thor (0.14.6)
|
73
73
|
treetop (1.4.9)
|
74
74
|
polyglot (>= 0.3.1)
|
75
|
-
tzinfo (0.3.
|
75
|
+
tzinfo (0.3.27)
|
76
76
|
|
77
77
|
PLATFORMS
|
78
78
|
ruby
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.4
|
@@ -27,7 +27,7 @@ module ActiveRecord
|
|
27
27
|
line = io.gets
|
28
28
|
columns_list = options[:columns] || line.strip.split(options[:delimiter])
|
29
29
|
columns_list = columns_list.map{|c| options[:map][c.to_s] } if options[:map]
|
30
|
-
connection.execute
|
30
|
+
connection.execute %{COPY #{quoted_table_name} ("#{columns_list.join('","')}") FROM STDIN WITH DELIMITER '#{options[:delimiter]}' CSV}
|
31
31
|
while line = io.gets do
|
32
32
|
next if line.strip.size == 0
|
33
33
|
if block_given?
|
data/postgres-copy.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{postgres-copy}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Diogo Biazus"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-05-26}
|
13
13
|
s.description = %q{Now you can use the super fast COPY for import/export data directly from your AR models.}
|
14
14
|
s.email = %q{diogob@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -30,6 +30,8 @@ Gem::Specification.new do |s|
|
|
30
30
|
"lib/postgres-copy/zip_responder.rb",
|
31
31
|
"postgres-copy.gemspec",
|
32
32
|
"spec/fixtures/extra_field.rb",
|
33
|
+
"spec/fixtures/reserved_word_model.rb",
|
34
|
+
"spec/fixtures/reserved_words.csv",
|
33
35
|
"spec/fixtures/semicolon_with_different_header.csv",
|
34
36
|
"spec/fixtures/semicolon_with_header.csv",
|
35
37
|
"spec/fixtures/tab_only_data.csv",
|
@@ -46,25 +48,17 @@ Gem::Specification.new do |s|
|
|
46
48
|
]
|
47
49
|
s.homepage = %q{http://github.com/diogob/postgres-copy}
|
48
50
|
s.require_paths = ["lib"]
|
49
|
-
s.rubygems_version = %q{1.
|
51
|
+
s.rubygems_version = %q{1.7.2}
|
50
52
|
s.summary = %q{Put COPY command functionality in ActiveRecord's model class}
|
51
|
-
s.test_files = [
|
52
|
-
"spec/fixtures/extra_field.rb",
|
53
|
-
"spec/fixtures/test_model.rb",
|
54
|
-
"spec/pg_copy_from_spec.rb",
|
55
|
-
"spec/pg_copy_to_spec.rb",
|
56
|
-
"spec/spec_helper.rb"
|
57
|
-
]
|
58
53
|
|
59
54
|
if s.respond_to? :specification_version then
|
60
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
61
55
|
s.specification_version = 3
|
62
56
|
|
63
57
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
64
58
|
s.add_runtime_dependency(%q<pg>, [">= 0"])
|
65
59
|
s.add_runtime_dependency(%q<activerecord>, [">= 0"])
|
66
60
|
s.add_runtime_dependency(%q<rails>, [">= 0"])
|
67
|
-
s.add_runtime_dependency(%q<rake>, ["
|
61
|
+
s.add_runtime_dependency(%q<rake>, ["= 0.8.7"])
|
68
62
|
s.add_runtime_dependency(%q<rspec>, ["~> 2.5"])
|
69
63
|
s.add_runtime_dependency(%q<rspec-core>, ["~> 2.5"])
|
70
64
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
@@ -73,7 +67,7 @@ Gem::Specification.new do |s|
|
|
73
67
|
s.add_dependency(%q<pg>, [">= 0"])
|
74
68
|
s.add_dependency(%q<activerecord>, [">= 0"])
|
75
69
|
s.add_dependency(%q<rails>, [">= 0"])
|
76
|
-
s.add_dependency(%q<rake>, ["
|
70
|
+
s.add_dependency(%q<rake>, ["= 0.8.7"])
|
77
71
|
s.add_dependency(%q<rspec>, ["~> 2.5"])
|
78
72
|
s.add_dependency(%q<rspec-core>, ["~> 2.5"])
|
79
73
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
@@ -83,7 +77,7 @@ Gem::Specification.new do |s|
|
|
83
77
|
s.add_dependency(%q<pg>, [">= 0"])
|
84
78
|
s.add_dependency(%q<activerecord>, [">= 0"])
|
85
79
|
s.add_dependency(%q<rails>, [">= 0"])
|
86
|
-
s.add_dependency(%q<rake>, ["
|
80
|
+
s.add_dependency(%q<rake>, ["= 0.8.7"])
|
87
81
|
s.add_dependency(%q<rspec>, ["~> 2.5"])
|
88
82
|
s.add_dependency(%q<rspec-core>, ["~> 2.5"])
|
89
83
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
data/spec/pg_copy_from_spec.rb
CHANGED
@@ -74,5 +74,10 @@ describe "COPY FROM" do
|
|
74
74
|
end.should raise_error
|
75
75
|
TestModel.order(:id).all.map{|r| r.attributes}.should == []
|
76
76
|
end
|
77
|
+
|
78
|
+
it "should copy from even when table fields need identifier quoting" do
|
79
|
+
ReservedWordModel.pg_copy_from File.expand_path('spec/fixtures/reserved_words.csv')
|
80
|
+
ReservedWordModel.order(:id).all.map{|r| r.attributes}.should == [{"group"=>"group name", "id"=>1, "select"=>"test select"}]
|
81
|
+
end
|
77
82
|
end
|
78
83
|
|
data/spec/spec_helper.rb
CHANGED
@@ -2,6 +2,7 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
2
2
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
3
|
require 'fixtures/test_model'
|
4
4
|
require 'fixtures/extra_field'
|
5
|
+
require 'fixtures/reserved_word_model'
|
5
6
|
require 'rspec'
|
6
7
|
require 'rspec/autorun'
|
7
8
|
|
@@ -19,11 +20,13 @@ RSpec.configure do |config|
|
|
19
20
|
SET client_min_messages TO warning;
|
20
21
|
DROP TABLE IF EXISTS test_models;
|
21
22
|
DROP TABLE IF EXISTS extra_fields;
|
23
|
+
DROP TABLE IF EXISTS reserved_word_models;
|
22
24
|
CREATE TABLE test_models (id serial PRIMARY KEY, data text);
|
25
|
+
CREATE TABLE reserved_word_models (id serial PRIMARY KEY, "select" text, "group" text);
|
23
26
|
CREATE TABLE extra_fields (id serial PRIMARY KEY, data text, created_at timestamp, updated_at timestamp);
|
24
27
|
}
|
25
28
|
rescue Exception => e
|
26
|
-
puts "
|
29
|
+
puts "Exception: #{e}"
|
27
30
|
ActiveRecord::Base.establish_connection(
|
28
31
|
:adapter => "postgresql",
|
29
32
|
:host => "localhost",
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postgres-copy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 3
|
10
|
-
version: 0.3.3
|
4
|
+
prerelease:
|
5
|
+
version: 0.3.4
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Diogo Biazus
|
@@ -15,127 +10,96 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
13
|
+
date: 2011-05-26 00:00:00 Z
|
20
14
|
dependencies:
|
21
15
|
- !ruby/object:Gem::Dependency
|
22
|
-
type: :runtime
|
23
|
-
prerelease: false
|
24
16
|
name: pg
|
25
|
-
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
18
|
none: false
|
27
19
|
requirements:
|
28
20
|
- - ">="
|
29
21
|
- !ruby/object:Gem::Version
|
30
|
-
hash: 3
|
31
|
-
segments:
|
32
|
-
- 0
|
33
22
|
version: "0"
|
34
|
-
requirement: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
23
|
type: :runtime
|
37
24
|
prerelease: false
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
38
27
|
name: activerecord
|
39
|
-
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
29
|
none: false
|
41
30
|
requirements:
|
42
31
|
- - ">="
|
43
32
|
- !ruby/object:Gem::Version
|
44
|
-
hash: 3
|
45
|
-
segments:
|
46
|
-
- 0
|
47
33
|
version: "0"
|
48
|
-
requirement: *id002
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
34
|
type: :runtime
|
51
35
|
prerelease: false
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
52
38
|
name: rails
|
53
|
-
|
39
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
40
|
none: false
|
55
41
|
requirements:
|
56
42
|
- - ">="
|
57
43
|
- !ruby/object:Gem::Version
|
58
|
-
hash: 3
|
59
|
-
segments:
|
60
|
-
- 0
|
61
44
|
version: "0"
|
62
|
-
requirement: *id003
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
45
|
type: :runtime
|
65
46
|
prerelease: false
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
66
49
|
name: rake
|
67
|
-
|
50
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
68
51
|
none: false
|
69
52
|
requirements:
|
70
|
-
- - "
|
53
|
+
- - "="
|
71
54
|
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
segments:
|
74
|
-
- 0
|
75
|
-
version: "0"
|
76
|
-
requirement: *id004
|
77
|
-
- !ruby/object:Gem::Dependency
|
55
|
+
version: 0.8.7
|
78
56
|
type: :runtime
|
79
57
|
prerelease: false
|
58
|
+
version_requirements: *id004
|
59
|
+
- !ruby/object:Gem::Dependency
|
80
60
|
name: rspec
|
81
|
-
|
61
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
82
62
|
none: false
|
83
63
|
requirements:
|
84
64
|
- - ~>
|
85
65
|
- !ruby/object:Gem::Version
|
86
|
-
hash: 9
|
87
|
-
segments:
|
88
|
-
- 2
|
89
|
-
- 5
|
90
66
|
version: "2.5"
|
91
|
-
requirement: *id005
|
92
|
-
- !ruby/object:Gem::Dependency
|
93
67
|
type: :runtime
|
94
68
|
prerelease: false
|
69
|
+
version_requirements: *id005
|
70
|
+
- !ruby/object:Gem::Dependency
|
95
71
|
name: rspec-core
|
96
|
-
|
72
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
97
73
|
none: false
|
98
74
|
requirements:
|
99
75
|
- - ~>
|
100
76
|
- !ruby/object:Gem::Version
|
101
|
-
hash: 9
|
102
|
-
segments:
|
103
|
-
- 2
|
104
|
-
- 5
|
105
77
|
version: "2.5"
|
106
|
-
|
107
|
-
- !ruby/object:Gem::Dependency
|
108
|
-
type: :development
|
78
|
+
type: :runtime
|
109
79
|
prerelease: false
|
80
|
+
version_requirements: *id006
|
81
|
+
- !ruby/object:Gem::Dependency
|
110
82
|
name: rspec
|
111
|
-
|
83
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
112
84
|
none: false
|
113
85
|
requirements:
|
114
86
|
- - ">="
|
115
87
|
- !ruby/object:Gem::Version
|
116
|
-
hash: 13
|
117
|
-
segments:
|
118
|
-
- 1
|
119
|
-
- 2
|
120
|
-
- 9
|
121
88
|
version: 1.2.9
|
122
|
-
|
123
|
-
- !ruby/object:Gem::Dependency
|
124
|
-
type: :runtime
|
89
|
+
type: :development
|
125
90
|
prerelease: false
|
91
|
+
version_requirements: *id007
|
92
|
+
- !ruby/object:Gem::Dependency
|
126
93
|
name: activerecord
|
127
|
-
|
94
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
128
95
|
none: false
|
129
96
|
requirements:
|
130
97
|
- - ">="
|
131
98
|
- !ruby/object:Gem::Version
|
132
|
-
hash: 7
|
133
|
-
segments:
|
134
|
-
- 3
|
135
|
-
- 0
|
136
|
-
- 0
|
137
99
|
version: 3.0.0
|
138
|
-
|
100
|
+
type: :runtime
|
101
|
+
prerelease: false
|
102
|
+
version_requirements: *id008
|
139
103
|
description: Now you can use the super fast COPY for import/export data directly from your AR models.
|
140
104
|
email: diogob@gmail.com
|
141
105
|
executables: []
|
@@ -159,6 +123,8 @@ files:
|
|
159
123
|
- lib/postgres-copy/zip_responder.rb
|
160
124
|
- postgres-copy.gemspec
|
161
125
|
- spec/fixtures/extra_field.rb
|
126
|
+
- spec/fixtures/reserved_word_model.rb
|
127
|
+
- spec/fixtures/reserved_words.csv
|
162
128
|
- spec/fixtures/semicolon_with_different_header.csv
|
163
129
|
- spec/fixtures/semicolon_with_header.csv
|
164
130
|
- spec/fixtures/tab_only_data.csv
|
@@ -172,7 +138,6 @@ files:
|
|
172
138
|
- spec/pg_copy_to_spec.rb
|
173
139
|
- spec/spec.opts
|
174
140
|
- spec/spec_helper.rb
|
175
|
-
has_rdoc: true
|
176
141
|
homepage: http://github.com/diogob/postgres-copy
|
177
142
|
licenses: []
|
178
143
|
|
@@ -186,29 +151,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
186
151
|
requirements:
|
187
152
|
- - ">="
|
188
153
|
- !ruby/object:Gem::Version
|
189
|
-
hash: 3
|
190
|
-
segments:
|
191
|
-
- 0
|
192
154
|
version: "0"
|
193
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
156
|
none: false
|
195
157
|
requirements:
|
196
158
|
- - ">="
|
197
159
|
- !ruby/object:Gem::Version
|
198
|
-
hash: 3
|
199
|
-
segments:
|
200
|
-
- 0
|
201
160
|
version: "0"
|
202
161
|
requirements: []
|
203
162
|
|
204
163
|
rubyforge_project:
|
205
|
-
rubygems_version: 1.
|
164
|
+
rubygems_version: 1.7.2
|
206
165
|
signing_key:
|
207
166
|
specification_version: 3
|
208
167
|
summary: Put COPY command functionality in ActiveRecord's model class
|
209
|
-
test_files:
|
210
|
-
|
211
|
-
- spec/fixtures/test_model.rb
|
212
|
-
- spec/pg_copy_from_spec.rb
|
213
|
-
- spec/pg_copy_to_spec.rb
|
214
|
-
- spec/spec_helper.rb
|
168
|
+
test_files: []
|
169
|
+
|