pg_csv 0.1.7 → 0.1.8

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: 0e7903c3f73583176d0a969c4c6f2f4b9de2db78
4
- data.tar.gz: 7fde910cb1a7639c0b2f3594a15fdadd095546e3
3
+ metadata.gz: 3b49169c6d5e9601a21b8da94f6894c82b86aedc
4
+ data.tar.gz: 5977fc12efe086311c4203ba259b4bb31ad60b9c
5
5
  SHA512:
6
- metadata.gz: c9fe3b47ccea65c02c81cd76b5028306c385985d5c9864a263a598d61a5623b6238e68527653a3a58a0bb45bd5cfa3f4f7022a292056ee74104da0716a738e4a
7
- data.tar.gz: 8c8c3f0e1fbdf77f34fd59e424ae31573e42d090d42141f5bf13a4f77a1f92f0d792f7d9a3561e126f760de952972d682204e1674b14b31b912cddc620cb8322
6
+ metadata.gz: 4d2bc55b716a156cb155216912b09ae920764463142207aad4aa9bbe8d6014a31633213af308273706b4e4ca854b739b61f2f54df30f70b8eaa7d7b70f15253e
7
+ data.tar.gz: b2a33e4e655978b64b9b4bdc7157ccd165ec6f1578a4a29f57dc582c913271be207b0fcf440af097577b700da676ccf09a51befd969c64adab579e23b62cd96f
data/README.md CHANGED
@@ -6,7 +6,7 @@ Fast AR/PostgreSQL csv export. Uses pg function 'copy to csv'. Effective on mill
6
6
  Gemfile:
7
7
  ``` ruby
8
8
  gem 'pg_csv'
9
- ```
9
+ ```
10
10
 
11
11
  Usage:
12
12
  ``` ruby
@@ -59,6 +59,6 @@ end
59
59
 
60
60
  # yield example
61
61
  PgCsv.new(:sql => sql, :type => :yield).export do |row|
62
- puts row
62
+ puts row
63
63
  end
64
64
  ```
@@ -98,31 +98,31 @@ class PgCsv
98
98
  def load_data
99
99
  info "#{query}"
100
100
  raw = connection.raw_connection
101
+ count = 0
101
102
 
102
103
  info "=> query"
103
- q = raw.exec(query)
104
- info "<= query"
105
-
106
- info "=> write data"
107
- if columns_str
108
- yield(@row_proc ? @row_proc[columns_str] : columns_str)
109
- end
104
+ raw.copy_data(query) do
105
+ info "<= query"
110
106
 
111
- count = 0
112
- if @row_proc
113
- while row = raw.get_copy_data()
114
- yield(@row_proc[row])
115
- count += 1
107
+ info "=> write data"
108
+ if columns_str
109
+ yield(@row_proc ? @row_proc[columns_str] : columns_str)
116
110
  end
117
- else
118
- while row = raw.get_copy_data()
119
- yield(row)
120
- count += 1
111
+
112
+ if @row_proc
113
+ while row = raw.get_copy_data()
114
+ yield(@row_proc[row])
115
+ count += 1
116
+ end
117
+ else
118
+ while row = raw.get_copy_data()
119
+ yield(row)
120
+ count += 1
121
+ end
121
122
  end
122
- end
123
- info "<= write data"
123
+ info "<= write data"
124
124
 
125
- q.clear
125
+ end
126
126
  count
127
127
  end
128
128
 
@@ -1,3 +1,3 @@
1
1
  class PgCsv
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -18,10 +18,10 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
  s.license = "MIT"
21
-
22
- s.add_dependency "pg"
21
+
22
+ s.add_dependency "pg", '~> 0.17'
23
23
  s.add_dependency "activerecord"
24
- s.add_development_dependency "rspec"
24
+ s.add_development_dependency "rspec", '<3'
25
25
  s.add_development_dependency "rake"
26
-
27
- end
26
+
27
+ end
@@ -90,14 +90,14 @@ describe PgCsv do
90
90
 
91
91
  describe "using temp file" do
92
92
  it "at least file should return to target and set correct chmod" do
93
- File.exists?(@name).should be_false
93
+ File.exists?(@name).should == false
94
94
  PgCsv.new(:sql => @sql, :temp_file => true, :temp_dir => tmp_dir).export(@name)
95
95
  with_file(@name){|d| d.should == "4,5,6\n1,2,3\n" }
96
96
  sprintf("%o", File.stat(@name).mode).to_i.should >= 100660
97
97
  end
98
98
 
99
99
  it "same with gzip" do
100
- File.exists?(@name).should be_false
100
+ File.exists?(@name).should == false
101
101
  PgCsv.new(:sql => @sql, :temp_file => true, :temp_dir => tmp_dir, :type => :gzip).export(@name)
102
102
  with_gzfile(@name){|d| d.should == "4,5,6\n1,2,3\n" }
103
103
  sprintf("%o", File.stat(@name).mode).to_i.should >= 100660
@@ -106,7 +106,7 @@ describe PgCsv do
106
106
 
107
107
  describe "different types of export" do
108
108
  it "gzip export" do
109
- File.exists?(@name).should be_false
109
+ File.exists?(@name).should == false
110
110
  PgCsv.new(:sql => @sql, :type => :gzip).export(@name)
111
111
  with_gzfile(@name){|d| d.should == "4,5,6\n1,2,3\n" }
112
112
  sprintf("%o", File.stat(@name).mode).to_i.should >= 100660
@@ -144,7 +144,7 @@ describe PgCsv do
144
144
 
145
145
  describe "integration specs" do
146
146
  it "1" do
147
- File.exists?(@name).should be_false
147
+ File.exists?(@name).should == false
148
148
  PgCsv.new(:sql => @sql, :type => :gzip).export(@name, :delimiter => "|", :columns => %w{q w e}, :temp_file => true, :temp_dir => tmp_dir)
149
149
  with_gzfile(@name){|d| d.should == "q|w|e\n4|5|6\n1|2|3\n" }
150
150
  end
@@ -161,7 +161,7 @@ describe PgCsv do
161
161
  end
162
162
 
163
163
  it "gzip with empty content" do
164
- File.exists?(@name).should be_false
164
+ File.exists?(@name).should == false
165
165
  PgCsv.new(:sql => "select a,b,c from tests where a = -1", :type => :gzip).export(@name, :temp_file => true, :temp_dir => tmp_dir)
166
166
  with_gzfile(@name){|d| d.should == "" }
167
167
  end
@@ -28,7 +28,7 @@ def tmp_dir
28
28
  end
29
29
 
30
30
  def with_file(name)
31
- File.exists?(name).should be_true
31
+ File.exists?(name).should == true
32
32
  q = 1
33
33
  File.open(name) do |file|
34
34
  data = file.read
@@ -40,7 +40,7 @@ def with_file(name)
40
40
  end
41
41
 
42
42
  def with_gzfile(name)
43
- File.exist?(name).should be_true
43
+ File.exist?(name).should == true
44
44
  q = 1
45
45
  Zlib::GzipReader.open(name) do |gz|
46
46
  data = gz.read
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Makarchev Konstantin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-23 00:00:00.000000000 Z
11
+ date: 2014-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
15
15
  requirement: !ruby/object:Gem::Requirement
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
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "<"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - "<"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Fast AR/PostgreSQL csv export. Used pg function 'copy to csv'. Effective
@@ -74,7 +74,7 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - .gitignore
77
+ - ".gitignore"
78
78
  - Gemfile
79
79
  - MIT-LICENSE
80
80
  - README.md
@@ -98,17 +98,17 @@ require_paths:
98
98
  - lib
99
99
  required_ruby_version: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - '>='
106
+ - - ">="
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  requirements: []
110
110
  rubyforge_project:
111
- rubygems_version: 2.0.2
111
+ rubygems_version: 2.2.2
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: Fast AR/PostgreSQL csv export. Used pg function 'copy to csv'. Effective