postgres-copy 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Gemfile.lock +70 -9
- data/Rakefile +4 -14
- data/VERSION +1 -1
- data/lib/postgres-copy/active_record.rb +1 -1
- data/postgres-copy.gemspec +52 -35
- data/spec/fixtures/tab_with_two_lines.csv +3 -0
- data/spec/pg_copy_from_spec.rb +8 -0
- data/spec/spec_helper.rb +3 -3
- metadata +103 -17
- data/.gitignore +0 -21
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,21 +1,78 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.6)
|
6
|
+
actionpack (= 3.0.6)
|
7
|
+
mail (~> 2.2.15)
|
8
|
+
actionpack (3.0.6)
|
9
|
+
activemodel (= 3.0.6)
|
10
|
+
activesupport (= 3.0.6)
|
6
11
|
builder (~> 2.1.2)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.5.0)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.14)
|
16
|
+
rack-test (~> 0.5.7)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.6)
|
19
|
+
activesupport (= 3.0.6)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.5.0)
|
22
|
+
activerecord (3.0.6)
|
23
|
+
activemodel (= 3.0.6)
|
24
|
+
activesupport (= 3.0.6)
|
11
25
|
arel (~> 2.0.2)
|
12
26
|
tzinfo (~> 0.3.23)
|
13
|
-
|
14
|
-
|
27
|
+
activeresource (3.0.6)
|
28
|
+
activemodel (= 3.0.6)
|
29
|
+
activesupport (= 3.0.6)
|
30
|
+
activesupport (3.0.6)
|
31
|
+
arel (2.0.9)
|
15
32
|
builder (2.1.2)
|
33
|
+
diff-lcs (1.1.2)
|
34
|
+
erubis (2.6.6)
|
35
|
+
abstract (>= 1.0.0)
|
16
36
|
i18n (0.5.0)
|
37
|
+
mail (2.2.15)
|
38
|
+
activesupport (>= 2.3.6)
|
39
|
+
i18n (>= 0.4.0)
|
40
|
+
mime-types (~> 1.16)
|
41
|
+
treetop (~> 1.4.8)
|
42
|
+
mime-types (1.16)
|
17
43
|
pg (0.10.1)
|
18
|
-
|
44
|
+
polyglot (0.3.1)
|
45
|
+
rack (1.2.2)
|
46
|
+
rack-mount (0.6.14)
|
47
|
+
rack (>= 1.0.0)
|
48
|
+
rack-test (0.5.7)
|
49
|
+
rack (>= 1.0)
|
50
|
+
rails (3.0.6)
|
51
|
+
actionmailer (= 3.0.6)
|
52
|
+
actionpack (= 3.0.6)
|
53
|
+
activerecord (= 3.0.6)
|
54
|
+
activeresource (= 3.0.6)
|
55
|
+
activesupport (= 3.0.6)
|
56
|
+
bundler (~> 1.0)
|
57
|
+
railties (= 3.0.6)
|
58
|
+
railties (3.0.6)
|
59
|
+
actionpack (= 3.0.6)
|
60
|
+
activesupport (= 3.0.6)
|
61
|
+
rake (>= 0.8.7)
|
62
|
+
thor (~> 0.14.4)
|
63
|
+
rake (0.8.7)
|
64
|
+
rspec (2.5.0)
|
65
|
+
rspec-core (~> 2.5.0)
|
66
|
+
rspec-expectations (~> 2.5.0)
|
67
|
+
rspec-mocks (~> 2.5.0)
|
68
|
+
rspec-core (2.5.1)
|
69
|
+
rspec-expectations (2.5.0)
|
70
|
+
diff-lcs (~> 1.1.2)
|
71
|
+
rspec-mocks (2.5.0)
|
72
|
+
thor (0.14.6)
|
73
|
+
treetop (1.4.9)
|
74
|
+
polyglot (>= 0.3.1)
|
75
|
+
tzinfo (0.3.26)
|
19
76
|
|
20
77
|
PLATFORMS
|
21
78
|
ruby
|
@@ -23,3 +80,7 @@ PLATFORMS
|
|
23
80
|
DEPENDENCIES
|
24
81
|
activerecord
|
25
82
|
pg
|
83
|
+
rails
|
84
|
+
rake
|
85
|
+
rspec (~> 2.5)
|
86
|
+
rspec-core (~> 2.5)
|
data/Rakefile
CHANGED
@@ -19,26 +19,16 @@ rescue LoadError
|
|
19
19
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
20
|
end
|
21
21
|
|
22
|
-
require
|
23
|
-
|
24
|
-
spec.
|
25
|
-
spec.
|
22
|
+
require "rspec/core/rake_task" # RSpec 2.0
|
23
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
24
|
+
spec.pattern = 'spec/*_spec.rb'
|
25
|
+
spec.rspec_opts = ["--backtrace", "--color", "--format progress", "-r ./spec/spec_helper.rb"]
|
26
26
|
end
|
27
|
-
|
28
|
-
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
-
spec.libs << 'lib' << 'spec'
|
30
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
-
spec.rcov = true
|
32
|
-
end
|
33
|
-
|
34
|
-
task :spec => :check_dependencies
|
35
|
-
|
36
27
|
task :default => :spec
|
37
28
|
|
38
29
|
require 'rake/rdoctask'
|
39
30
|
Rake::RDocTask.new do |rdoc|
|
40
31
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
-
|
42
32
|
rdoc.rdoc_dir = 'rdoc'
|
43
33
|
rdoc.title = "activerecord-postgres-copy #{version}"
|
44
34
|
rdoc.rdoc_files.include('README*')
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
data/postgres-copy.gemspec
CHANGED
@@ -1,60 +1,59 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
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.3"
|
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-04-11}
|
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 = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"lib/postgres-copy.rb",
|
28
|
+
"lib/postgres-copy/active_record.rb",
|
29
|
+
"lib/postgres-copy/csv_responder.rb",
|
30
|
+
"lib/postgres-copy/zip_responder.rb",
|
31
|
+
"postgres-copy.gemspec",
|
32
|
+
"spec/fixtures/extra_field.rb",
|
33
|
+
"spec/fixtures/semicolon_with_different_header.csv",
|
34
|
+
"spec/fixtures/semicolon_with_header.csv",
|
35
|
+
"spec/fixtures/tab_only_data.csv",
|
36
|
+
"spec/fixtures/tab_with_different_header.csv",
|
37
|
+
"spec/fixtures/tab_with_error.csv",
|
38
|
+
"spec/fixtures/tab_with_extra_line.csv",
|
39
|
+
"spec/fixtures/tab_with_header.csv",
|
40
|
+
"spec/fixtures/tab_with_two_lines.csv",
|
41
|
+
"spec/fixtures/test_model.rb",
|
42
|
+
"spec/pg_copy_from_spec.rb",
|
43
|
+
"spec/pg_copy_to_spec.rb",
|
44
|
+
"spec/spec.opts",
|
45
|
+
"spec/spec_helper.rb"
|
46
46
|
]
|
47
47
|
s.homepage = %q{http://github.com/diogob/postgres-copy}
|
48
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
49
48
|
s.require_paths = ["lib"]
|
50
49
|
s.rubygems_version = %q{1.3.7}
|
51
50
|
s.summary = %q{Put COPY command functionality in ActiveRecord's model class}
|
52
51
|
s.test_files = [
|
53
|
-
"spec/
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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"
|
58
57
|
]
|
59
58
|
|
60
59
|
if s.respond_to? :specification_version then
|
@@ -62,13 +61,31 @@ Gem::Specification.new do |s|
|
|
62
61
|
s.specification_version = 3
|
63
62
|
|
64
63
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
64
|
+
s.add_runtime_dependency(%q<pg>, [">= 0"])
|
65
|
+
s.add_runtime_dependency(%q<activerecord>, [">= 0"])
|
66
|
+
s.add_runtime_dependency(%q<rails>, [">= 0"])
|
67
|
+
s.add_runtime_dependency(%q<rake>, [">= 0"])
|
68
|
+
s.add_runtime_dependency(%q<rspec>, ["~> 2.5"])
|
69
|
+
s.add_runtime_dependency(%q<rspec-core>, ["~> 2.5"])
|
65
70
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
66
71
|
s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0"])
|
67
72
|
else
|
73
|
+
s.add_dependency(%q<pg>, [">= 0"])
|
74
|
+
s.add_dependency(%q<activerecord>, [">= 0"])
|
75
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
76
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
77
|
+
s.add_dependency(%q<rspec>, ["~> 2.5"])
|
78
|
+
s.add_dependency(%q<rspec-core>, ["~> 2.5"])
|
68
79
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
69
80
|
s.add_dependency(%q<activerecord>, [">= 3.0.0"])
|
70
81
|
end
|
71
82
|
else
|
83
|
+
s.add_dependency(%q<pg>, [">= 0"])
|
84
|
+
s.add_dependency(%q<activerecord>, [">= 0"])
|
85
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
86
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
87
|
+
s.add_dependency(%q<rspec>, ["~> 2.5"])
|
88
|
+
s.add_dependency(%q<rspec-core>, ["~> 2.5"])
|
72
89
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
73
90
|
s.add_dependency(%q<activerecord>, [">= 3.0.0"])
|
74
91
|
end
|
data/spec/pg_copy_from_spec.rb
CHANGED
@@ -35,6 +35,14 @@ describe "COPY FROM" do
|
|
35
35
|
TestModel.order(:id).all.map{|r| r.attributes}.should == [{'id' => 1, 'data' => 'changed this data'}]
|
36
36
|
end
|
37
37
|
|
38
|
+
it "should import 2 lines and allow changes in block" do
|
39
|
+
TestModel.pg_copy_from(File.open(File.expand_path('spec/fixtures/tab_with_two_lines.csv'), 'r')) do |row|
|
40
|
+
row[1] = 'changed this data'
|
41
|
+
end
|
42
|
+
TestModel.order(:id).first.attributes.should == {'id' => 1, 'data' => 'changed this data'}
|
43
|
+
TestModel.count.should == 2
|
44
|
+
end
|
45
|
+
|
38
46
|
it "should be able to copy from using custom set of columns" do
|
39
47
|
TestModel.pg_copy_from(File.open(File.expand_path('spec/fixtures/tab_only_data.csv'), 'r'), :columns => ["data"])
|
40
48
|
TestModel.order(:id).all.map{|r| r.attributes}.should == [{'id' => 1, 'data' => 'test data 1'}]
|
data/spec/spec_helper.rb
CHANGED
@@ -2,10 +2,10 @@ $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 '
|
6
|
-
require '
|
5
|
+
require 'rspec'
|
6
|
+
require 'rspec/autorun'
|
7
7
|
|
8
|
-
|
8
|
+
RSpec.configure do |config|
|
9
9
|
config.before(:suite) do
|
10
10
|
# we create a test database if it does not exist
|
11
11
|
# I do not use database users or password for the tests, using ident authentication instead
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postgres-copy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Diogo Biazus
|
@@ -15,13 +15,100 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-11 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
name: pg
|
25
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
version: "0"
|
34
|
+
requirement: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
name: activerecord
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
requirement: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
name: rails
|
53
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 3
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
requirement: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
type: :runtime
|
65
|
+
prerelease: false
|
66
|
+
name: rake
|
67
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 3
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
requirement: *id004
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
type: :runtime
|
79
|
+
prerelease: false
|
22
80
|
name: rspec
|
81
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ~>
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 9
|
87
|
+
segments:
|
88
|
+
- 2
|
89
|
+
- 5
|
90
|
+
version: "2.5"
|
91
|
+
requirement: *id005
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
type: :runtime
|
94
|
+
prerelease: false
|
95
|
+
name: rspec-core
|
96
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
hash: 9
|
102
|
+
segments:
|
103
|
+
- 2
|
104
|
+
- 5
|
105
|
+
version: "2.5"
|
106
|
+
requirement: *id006
|
107
|
+
- !ruby/object:Gem::Dependency
|
108
|
+
type: :development
|
23
109
|
prerelease: false
|
24
|
-
|
110
|
+
name: rspec
|
111
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
25
112
|
none: false
|
26
113
|
requirements:
|
27
114
|
- - ">="
|
@@ -32,12 +119,12 @@ dependencies:
|
|
32
119
|
- 2
|
33
120
|
- 9
|
34
121
|
version: 1.2.9
|
35
|
-
|
36
|
-
version_requirements: *id001
|
122
|
+
requirement: *id007
|
37
123
|
- !ruby/object:Gem::Dependency
|
38
|
-
|
124
|
+
type: :runtime
|
39
125
|
prerelease: false
|
40
|
-
|
126
|
+
name: activerecord
|
127
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
41
128
|
none: false
|
42
129
|
requirements:
|
43
130
|
- - ">="
|
@@ -48,8 +135,7 @@ dependencies:
|
|
48
135
|
- 0
|
49
136
|
- 0
|
50
137
|
version: 3.0.0
|
51
|
-
|
52
|
-
version_requirements: *id002
|
138
|
+
requirement: *id008
|
53
139
|
description: Now you can use the super fast COPY for import/export data directly from your AR models.
|
54
140
|
email: diogob@gmail.com
|
55
141
|
executables: []
|
@@ -61,7 +147,6 @@ extra_rdoc_files:
|
|
61
147
|
- README.md
|
62
148
|
files:
|
63
149
|
- .document
|
64
|
-
- .gitignore
|
65
150
|
- Gemfile
|
66
151
|
- Gemfile.lock
|
67
152
|
- LICENSE
|
@@ -81,6 +166,7 @@ files:
|
|
81
166
|
- spec/fixtures/tab_with_error.csv
|
82
167
|
- spec/fixtures/tab_with_extra_line.csv
|
83
168
|
- spec/fixtures/tab_with_header.csv
|
169
|
+
- spec/fixtures/tab_with_two_lines.csv
|
84
170
|
- spec/fixtures/test_model.rb
|
85
171
|
- spec/pg_copy_from_spec.rb
|
86
172
|
- spec/pg_copy_to_spec.rb
|
@@ -91,8 +177,8 @@ homepage: http://github.com/diogob/postgres-copy
|
|
91
177
|
licenses: []
|
92
178
|
|
93
179
|
post_install_message:
|
94
|
-
rdoc_options:
|
95
|
-
|
180
|
+
rdoc_options: []
|
181
|
+
|
96
182
|
require_paths:
|
97
183
|
- lib
|
98
184
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -121,8 +207,8 @@ signing_key:
|
|
121
207
|
specification_version: 3
|
122
208
|
summary: Put COPY command functionality in ActiveRecord's model class
|
123
209
|
test_files:
|
124
|
-
- spec/
|
210
|
+
- spec/fixtures/extra_field.rb
|
211
|
+
- spec/fixtures/test_model.rb
|
125
212
|
- spec/pg_copy_from_spec.rb
|
126
213
|
- spec/pg_copy_to_spec.rb
|
127
|
-
- spec/
|
128
|
-
- spec/fixtures/extra_field.rb
|
214
|
+
- spec/spec_helper.rb
|