carrierwave-postgresql 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +23 -34
- data/lib/carrierwave/storage/postgresql_lo.rb +1 -0
- metadata +31 -60
- data/.document +0 -5
- data/.rspec +0 -2
- data/.travis.yml +0 -6
- data/Gemfile +0 -17
- data/Gemfile.lock +0 -85
- data/VERSION +0 -1
- data/carrierwave-postgresql.gemspec +0 -76
- data/spec/fixtures/test.jpg +0 -1
- data/spec/spec_helper.rb +0 -12
- data/spec/storage/file_spec.rb +0 -54
- data/spec/storage/postgresql_lo_spec.rb +0 -45
- data/spec/support/active_record.rb +0 -22
- data/spec/support/mock_files.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2921d3af4cc2e44b25dfea7f76fce3c0c9594fb0
|
4
|
+
data.tar.gz: f86a5aeb45ac8ac21416e9ae67a6747d041fa4a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5193d5dddc37bade3bb8ad0dcd147b341ecf6c1c62aba847e1f02a68a094e8c8338561d22954c79d036637572ea36940b4604235557da0480665b09ef1debc3
|
7
|
+
data.tar.gz: 70f52d6c331169ccd8020980cc247c2f3d8b2402946315e861e19133ea63e7831a8756301f314a72021627b9b65e758778675c3d5ffd764d285519af6de6bf3f
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# carrierwave-postgresql [![Build Status](https://secure.travis-ci.org/diogob/carrierwave-postgresql.png)](http://travis-ci.org/diogob/carrierwave-postgresql)
|
1
|
+
# carrierwave-postgresql [![Build Status](https://secure.travis-ci.org/diogob/carrierwave-postgresql.png)](http://travis-ci.org/diogob/carrierwave-postgresql)[![Code Climate](https://codeclimate.com/github/diogob/carrierwave-postgresql.png)](https://codeclimate.com/github/diogob/carrierwave-postgresql)
|
2
2
|
|
3
3
|
This gem adds to [CarrierWave](https://github.com/jnicklas/carrierwave/) a storage facility which will use the PostgreSQL's oid datatype to reference a large object residing in the databse. It supports up to 2GB files, though it's better suited for smaller ones. Makes life easier for fast prototyping and put all your data in the same place, allows one backup for all your data and file storage in heroku servers.
|
4
4
|
|
data/Rakefile
CHANGED
@@ -1,30 +1,29 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require '
|
4
|
-
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
5
7
|
begin
|
6
|
-
|
7
|
-
rescue
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
11
13
|
end
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
gem.license = "MIT"
|
21
|
-
gem.summary = %Q{Use PostgreSQL large objects (AKA BLOBs) to store your files inside the database}
|
22
|
-
gem.description = %Q{This gem adds to carrierwave a storage facility which will use the PostgreSQL's oid datatype to reference a large object residing in the databse. It supports up to 2GB files, though it's better suited for smaller ones. Makes life easier for fast prototyping and put all your data in the same place, allows one backup for all your data and file storage in heroku servers.}
|
23
|
-
gem.email = "diogo@biazus.me"
|
24
|
-
gem.authors = ["Diogo Biazus"]
|
25
|
-
# dependencies defined in Gemfile
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'PostgresqlLoStreamer'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
26
21
|
end
|
27
|
-
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
28
27
|
|
29
28
|
require 'rspec/core'
|
30
29
|
require 'rspec/core/rake_task'
|
@@ -38,13 +37,3 @@ RSpec::Core::RakeTask.new(:rcov) do |spec|
|
|
38
37
|
end
|
39
38
|
|
40
39
|
task :default => :spec
|
41
|
-
|
42
|
-
require 'rdoc/task'
|
43
|
-
Rake::RDocTask.new do |rdoc|
|
44
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
-
|
46
|
-
rdoc.rdoc_dir = 'rdoc'
|
47
|
-
rdoc.title = "carrierwave-postgresql #{version}"
|
48
|
-
rdoc.rdoc_files.include('README*')
|
49
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-postgresql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diogo Biazus
|
@@ -14,134 +14,105 @@ dependencies:
|
|
14
14
|
name: carrierwave
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
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
26
|
version: '0'
|
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
|
-
version:
|
33
|
+
version: 4.0.1
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 4.0.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pg
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
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
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 2.11.0
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rdoc
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '3.12'
|
61
|
+
version: '0'
|
76
62
|
type: :development
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|
80
|
-
- -
|
66
|
+
- - ">="
|
81
67
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
68
|
+
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: bundler
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
86
72
|
requirements:
|
87
|
-
- -
|
73
|
+
- - ">="
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
75
|
+
version: '0'
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
|
-
- -
|
80
|
+
- - ">="
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
82
|
+
version: '0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
84
|
+
name: rake
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
|
-
- -
|
87
|
+
- - ">="
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
89
|
+
version: '0'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
|
-
- -
|
94
|
+
- - ">="
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
96
|
+
version: '0'
|
111
97
|
description: This gem adds to carrierwave a storage facility which will use the PostgreSQL's
|
112
98
|
oid datatype to reference a large object residing in the databse. It supports up
|
113
99
|
to 2GB files, though it's better suited for smaller ones. Makes life easier for
|
114
100
|
fast prototyping and put all your data in the same place, allows one backup for
|
115
101
|
all your data and file storage in heroku servers.
|
116
|
-
email:
|
102
|
+
email:
|
103
|
+
- diogo@biazus.me
|
117
104
|
executables: []
|
118
105
|
extensions: []
|
119
|
-
extra_rdoc_files:
|
120
|
-
- LICENSE.txt
|
121
|
-
- README.md
|
106
|
+
extra_rdoc_files: []
|
122
107
|
files:
|
123
|
-
- .document
|
124
|
-
- .rspec
|
125
|
-
- .travis.yml
|
126
|
-
- Gemfile
|
127
|
-
- Gemfile.lock
|
128
108
|
- LICENSE.txt
|
129
109
|
- README.md
|
130
110
|
- Rakefile
|
131
|
-
- VERSION
|
132
|
-
- carrierwave-postgresql.gemspec
|
133
111
|
- lib/carrierwave-postgresql.rb
|
134
112
|
- lib/carrierwave/postgresql.rb
|
135
113
|
- lib/carrierwave/storage/postgresql_lo.rb
|
136
|
-
|
137
|
-
|
138
|
-
- spec/storage/file_spec.rb
|
139
|
-
- spec/storage/postgresql_lo_spec.rb
|
140
|
-
- spec/support/active_record.rb
|
141
|
-
- spec/support/mock_files.rb
|
142
|
-
homepage: http://diogob.github.com/carrierwave-postgresql/
|
143
|
-
licenses:
|
144
|
-
- MIT
|
114
|
+
homepage: https://github.com/diogob/carrierwave-postgresql
|
115
|
+
licenses: []
|
145
116
|
metadata: {}
|
146
117
|
post_install_message:
|
147
118
|
rdoc_options: []
|
@@ -149,18 +120,18 @@ require_paths:
|
|
149
120
|
- lib
|
150
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|
151
122
|
requirements:
|
152
|
-
- -
|
123
|
+
- - ">="
|
153
124
|
- !ruby/object:Gem::Version
|
154
125
|
version: '0'
|
155
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
127
|
requirements:
|
157
|
-
- -
|
128
|
+
- - ">="
|
158
129
|
- !ruby/object:Gem::Version
|
159
130
|
version: '0'
|
160
131
|
requirements: []
|
161
132
|
rubyforge_project:
|
162
|
-
rubygems_version: 2.0
|
133
|
+
rubygems_version: 2.2.0
|
163
134
|
signing_key:
|
164
135
|
specification_version: 4
|
165
|
-
summary:
|
136
|
+
summary: Carrierwave storing files in a PostgreSQL database
|
166
137
|
test_files: []
|
data/.document
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
5
|
-
|
6
|
-
# Add dependencies to develop your gem here.
|
7
|
-
# Include everything needed to run rake, tests, features, etc.
|
8
|
-
gem 'carrierwave'
|
9
|
-
|
10
|
-
group :development do
|
11
|
-
gem "activerecord", "~> 3.2.8"
|
12
|
-
gem "pg"
|
13
|
-
gem "rspec", "~> 2.11.0"
|
14
|
-
gem "rdoc", "~> 3.12"
|
15
|
-
gem "bundler", "~> 1.3.0"
|
16
|
-
gem "jeweler", "~> 1.8.4"
|
17
|
-
end
|
data/Gemfile.lock
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
activemodel (3.2.14)
|
5
|
-
activesupport (= 3.2.14)
|
6
|
-
builder (~> 3.0.0)
|
7
|
-
activerecord (3.2.14)
|
8
|
-
activemodel (= 3.2.14)
|
9
|
-
activesupport (= 3.2.14)
|
10
|
-
arel (~> 3.0.2)
|
11
|
-
tzinfo (~> 0.3.29)
|
12
|
-
activesupport (3.2.14)
|
13
|
-
i18n (~> 0.6, >= 0.6.4)
|
14
|
-
multi_json (~> 1.0)
|
15
|
-
addressable (2.3.5)
|
16
|
-
arel (3.0.2)
|
17
|
-
builder (3.0.4)
|
18
|
-
carrierwave (0.9.0)
|
19
|
-
activemodel (>= 3.2.0)
|
20
|
-
activesupport (>= 3.2.0)
|
21
|
-
json (>= 1.7)
|
22
|
-
diff-lcs (1.1.3)
|
23
|
-
faraday (0.8.8)
|
24
|
-
multipart-post (~> 1.2.0)
|
25
|
-
git (1.2.5)
|
26
|
-
github_api (0.10.1)
|
27
|
-
addressable
|
28
|
-
faraday (~> 0.8.1)
|
29
|
-
hashie (>= 1.2)
|
30
|
-
multi_json (~> 1.4)
|
31
|
-
nokogiri (~> 1.5.2)
|
32
|
-
oauth2
|
33
|
-
hashie (2.0.5)
|
34
|
-
highline (1.6.19)
|
35
|
-
httpauth (0.2.0)
|
36
|
-
i18n (0.6.4)
|
37
|
-
jeweler (1.8.6)
|
38
|
-
builder
|
39
|
-
bundler (~> 1.0)
|
40
|
-
git (>= 1.2.5)
|
41
|
-
github_api (= 0.10.1)
|
42
|
-
highline (>= 1.6.15)
|
43
|
-
nokogiri (= 1.5.10)
|
44
|
-
rake
|
45
|
-
rdoc
|
46
|
-
json (1.8.0)
|
47
|
-
jwt (0.1.8)
|
48
|
-
multi_json (>= 1.5)
|
49
|
-
multi_json (1.7.7)
|
50
|
-
multi_xml (0.5.4)
|
51
|
-
multipart-post (1.2.0)
|
52
|
-
nokogiri (1.5.10)
|
53
|
-
oauth2 (0.9.2)
|
54
|
-
faraday (~> 0.8)
|
55
|
-
httpauth (~> 0.2)
|
56
|
-
jwt (~> 0.1.4)
|
57
|
-
multi_json (~> 1.0)
|
58
|
-
multi_xml (~> 0.5)
|
59
|
-
rack (~> 1.2)
|
60
|
-
pg (0.16.0)
|
61
|
-
rack (1.5.2)
|
62
|
-
rake (10.1.0)
|
63
|
-
rdoc (3.12.2)
|
64
|
-
json (~> 1.4)
|
65
|
-
rspec (2.11.0)
|
66
|
-
rspec-core (~> 2.11.0)
|
67
|
-
rspec-expectations (~> 2.11.0)
|
68
|
-
rspec-mocks (~> 2.11.0)
|
69
|
-
rspec-core (2.11.1)
|
70
|
-
rspec-expectations (2.11.3)
|
71
|
-
diff-lcs (~> 1.1.3)
|
72
|
-
rspec-mocks (2.11.3)
|
73
|
-
tzinfo (0.3.37)
|
74
|
-
|
75
|
-
PLATFORMS
|
76
|
-
ruby
|
77
|
-
|
78
|
-
DEPENDENCIES
|
79
|
-
activerecord (~> 3.2.8)
|
80
|
-
bundler (~> 1.3.0)
|
81
|
-
carrierwave
|
82
|
-
jeweler (~> 1.8.4)
|
83
|
-
pg
|
84
|
-
rdoc (~> 3.12)
|
85
|
-
rspec (~> 2.11.0)
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.2
|
@@ -1,76 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = "carrierwave-postgresql"
|
8
|
-
s.version = "0.1.2"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Diogo Biazus"]
|
12
|
-
s.date = "2013-11-19"
|
13
|
-
s.description = "This gem adds to carrierwave a storage facility which will use the PostgreSQL's oid datatype to reference a large object residing in the databse. It supports up to 2GB files, though it's better suited for smaller ones. Makes life easier for fast prototyping and put all your data in the same place, allows one backup for all your data and file storage in heroku servers."
|
14
|
-
s.email = "diogo@biazus.me"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE.txt",
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".rspec",
|
22
|
-
".travis.yml",
|
23
|
-
"Gemfile",
|
24
|
-
"Gemfile.lock",
|
25
|
-
"LICENSE.txt",
|
26
|
-
"README.md",
|
27
|
-
"Rakefile",
|
28
|
-
"VERSION",
|
29
|
-
"carrierwave-postgresql.gemspec",
|
30
|
-
"lib/carrierwave-postgresql.rb",
|
31
|
-
"lib/carrierwave/postgresql.rb",
|
32
|
-
"lib/carrierwave/storage/postgresql_lo.rb",
|
33
|
-
"spec/fixtures/test.jpg",
|
34
|
-
"spec/spec_helper.rb",
|
35
|
-
"spec/storage/file_spec.rb",
|
36
|
-
"spec/storage/postgresql_lo_spec.rb",
|
37
|
-
"spec/support/active_record.rb",
|
38
|
-
"spec/support/mock_files.rb"
|
39
|
-
]
|
40
|
-
s.homepage = "http://diogob.github.com/carrierwave-postgresql/"
|
41
|
-
s.licenses = ["MIT"]
|
42
|
-
s.require_paths = ["lib"]
|
43
|
-
s.rubygems_version = "2.0.7"
|
44
|
-
s.summary = "Use PostgreSQL large objects (AKA BLOBs) to store your files inside the database"
|
45
|
-
|
46
|
-
if s.respond_to? :specification_version then
|
47
|
-
s.specification_version = 4
|
48
|
-
|
49
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
-
s.add_runtime_dependency(%q<carrierwave>, [">= 0"])
|
51
|
-
s.add_development_dependency(%q<activerecord>, ["~> 3.2.8"])
|
52
|
-
s.add_development_dependency(%q<pg>, [">= 0"])
|
53
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.11.0"])
|
54
|
-
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
55
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.3.0"])
|
56
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
57
|
-
else
|
58
|
-
s.add_dependency(%q<carrierwave>, [">= 0"])
|
59
|
-
s.add_dependency(%q<activerecord>, ["~> 3.2.8"])
|
60
|
-
s.add_dependency(%q<pg>, [">= 0"])
|
61
|
-
s.add_dependency(%q<rspec>, ["~> 2.11.0"])
|
62
|
-
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
63
|
-
s.add_dependency(%q<bundler>, ["~> 1.3.0"])
|
64
|
-
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
65
|
-
end
|
66
|
-
else
|
67
|
-
s.add_dependency(%q<carrierwave>, [">= 0"])
|
68
|
-
s.add_dependency(%q<activerecord>, ["~> 3.2.8"])
|
69
|
-
s.add_dependency(%q<pg>, [">= 0"])
|
70
|
-
s.add_dependency(%q<rspec>, ["~> 2.11.0"])
|
71
|
-
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
72
|
-
s.add_dependency(%q<bundler>, ["~> 1.3.0"])
|
73
|
-
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
data/spec/fixtures/test.jpg
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
this is stuff
|
data/spec/spec_helper.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
-
require 'rspec'
|
4
|
-
require 'carrierwave-postgresql'
|
5
|
-
require 'tempfile'
|
6
|
-
|
7
|
-
require 'carrierwave'
|
8
|
-
|
9
|
-
# Requires supporting files with custom matchers and macros, etc,
|
10
|
-
# in ./support/ and its subdirectories.
|
11
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
12
|
-
|
data/spec/storage/file_spec.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe CarrierWave::Storage::PostgresqlLo::File do
|
4
|
-
let(:test_model){ Test.new }
|
5
|
-
let(:uploader){ mock('an uploader', :model => test_model, :identifier => 0, :mounted_as => :file) }
|
6
|
-
let(:file){ CarrierWave::Storage::PostgresqlLo::File.new(uploader) }
|
7
|
-
let(:tempfile){ stub_tempfile('test.jpg', 'application/xml') }
|
8
|
-
|
9
|
-
describe "#delete" do
|
10
|
-
before do
|
11
|
-
file.connection.should_receive(:lo_unlink).with(0)
|
12
|
-
end
|
13
|
-
it("should delete the file using the lo interface"){ file.delete }
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#url" do
|
17
|
-
subject{ file.url }
|
18
|
-
it{ should == "/test_file/0" }
|
19
|
-
|
20
|
-
context "on a namespaced model" do
|
21
|
-
let(:test_model){ Namespace::Test.new }
|
22
|
-
it{ should == "/namespace_test_file/0" }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#write" do
|
27
|
-
before do
|
28
|
-
file.connection.should_receive(:lo_open).with(0, ::PG::INV_WRITE).and_return(2)
|
29
|
-
file.connection.should_receive(:lo_close).with(2)
|
30
|
-
file.connection.should_receive(:lo_write).with(2, "this is stuff").and_return(42)
|
31
|
-
end
|
32
|
-
it("should write the file using the lo interface"){ file.write(tempfile).should == 42 }
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "#file_length" do
|
36
|
-
before do
|
37
|
-
file.connection.should_receive(:lo_open).with(0).and_return(1)
|
38
|
-
file.connection.should_receive(:lo_close).with(1)
|
39
|
-
file.connection.should_receive(:lo_lseek).with(1, 0, 2).and_return(42)
|
40
|
-
end
|
41
|
-
it("should return the file size"){ file.file_length.should == 42 }
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "#read" do
|
45
|
-
before do
|
46
|
-
file.connection.should_receive(:lo_open).with(0).and_return(1)
|
47
|
-
file.connection.should_receive(:lo_close).with(1)
|
48
|
-
file.should_receive(:file_length).and_return(42)
|
49
|
-
file.connection.should_receive(:lo_read).with(1, 42).and_return('file content')
|
50
|
-
end
|
51
|
-
|
52
|
-
it("should read the file using the lo interface"){ file.read.should == 'file content' }
|
53
|
-
end
|
54
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe CarrierWave::Storage::PostgresqlLo do
|
4
|
-
let(:storage){ CarrierWave::Storage::PostgresqlLo.new(uploader) }
|
5
|
-
let(:file){ stub_tempfile('test.jpg', 'application/xml') }
|
6
|
-
let(:test_model){ Test.new }
|
7
|
-
|
8
|
-
describe "#retrieve!" do
|
9
|
-
context "when we do not have it mounted" do
|
10
|
-
let(:uploader){ mock('an uploader', :model => nil) }
|
11
|
-
it("should raise error if not mounted"){ ->{ storage.store!(file) }.should raise_error("This uploader must be mounted in an ActiveRecord model to work") }
|
12
|
-
end
|
13
|
-
|
14
|
-
context "when we have it mounted" do
|
15
|
-
let(:uploader){ mock('an uploader', :model => test_model, :mounted_as => :file) }
|
16
|
-
let(:lo){ storage.store!(file) }
|
17
|
-
before do
|
18
|
-
uploader.stub(:identifier) do
|
19
|
-
storage.identifier
|
20
|
-
end
|
21
|
-
end
|
22
|
-
subject{ storage.retrieve! lo.identifier }
|
23
|
-
its(:read){ should == "this is stuff" }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "#store!" do
|
28
|
-
context "when we do not have it mounted" do
|
29
|
-
let(:uploader){ mock('an uploader', :model => nil) }
|
30
|
-
it("should raise error if not mounted"){ ->{ storage.store!(file) }.should raise_error("This uploader must be mounted in an ActiveRecord model to work") }
|
31
|
-
end
|
32
|
-
|
33
|
-
context "when we have it mounted" do
|
34
|
-
let(:uploader){ mock('an uploader', :model => test_model, :mounted_as => :file) }
|
35
|
-
let(:lo){ storage.store!(file) }
|
36
|
-
before do
|
37
|
-
uploader.stub(:identifier) do
|
38
|
-
storage.identifier
|
39
|
-
end
|
40
|
-
end
|
41
|
-
subject{ lo }
|
42
|
-
its(:read){ should == "this is stuff" }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'active_record'
|
2
|
-
|
3
|
-
RSpec.configure do |config|
|
4
|
-
config.before(:suite) do
|
5
|
-
ActiveRecord::Base.establish_connection(
|
6
|
-
:adapter => 'postgresql',
|
7
|
-
:database => 'carrierwave_test',
|
8
|
-
:username => 'postgres',
|
9
|
-
:password => 'password',
|
10
|
-
:host => 'localhost')
|
11
|
-
ActiveRecord::Base.connection.execute "DROP TABLE IF EXISTS tests;"
|
12
|
-
ActiveRecord::Base.connection.execute "CREATE TABLE tests (file oid);"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class Test < ActiveRecord::Base
|
17
|
-
end
|
18
|
-
|
19
|
-
module Namespace
|
20
|
-
class Test < ActiveRecord::Base
|
21
|
-
end
|
22
|
-
end
|
data/spec/support/mock_files.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
module CarrierWave
|
2
|
-
module Test
|
3
|
-
module MockFiles
|
4
|
-
def file_path( *paths )
|
5
|
-
File.expand_path(File.join(File.dirname(__FILE__), '../fixtures', *paths))
|
6
|
-
end
|
7
|
-
|
8
|
-
def stub_file(filename, mime_type=nil, fake_name=nil)
|
9
|
-
f = File.open(file_path(filename))
|
10
|
-
return f
|
11
|
-
end
|
12
|
-
|
13
|
-
def stub_tempfile(filename, mime_type=nil, fake_name=nil)
|
14
|
-
raise "#{file_path(filename)} file does not exist" unless File.exist?(file_path(filename))
|
15
|
-
|
16
|
-
t = Tempfile.new(filename)
|
17
|
-
FileUtils.copy_file(file_path(filename), t.path)
|
18
|
-
|
19
|
-
t.stub!(:local_path => "",
|
20
|
-
:original_filename => filename || fake_name,
|
21
|
-
:content_type => mime_type)
|
22
|
-
|
23
|
-
return t
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
RSpec.configure do |config|
|
30
|
-
config.include CarrierWave::Test::MockFiles
|
31
|
-
end
|
32
|
-
|