refile-postgres 0.0.4 → 1.0.1

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: 712efea6017857a480caaf1672ae828389ef21fc
4
- data.tar.gz: d8e138e6289d25977aa4643bf8ac8cbf216317b0
3
+ metadata.gz: f7723e0cc3727c9b97d1fff400a8ba0844c7c661
4
+ data.tar.gz: f3913286722cb4a27c46d1099b9f7a6fc0d7a343
5
5
  SHA512:
6
- metadata.gz: 0f1a41679eee57baa1f760cffcc7b6f873302d5e9122a1bc00709754c63f3b61d0b55bf818552bbd510757184aeaa649e34b9915fca3b06fc8dd028027435227
7
- data.tar.gz: 401e7ba330c7821b641012f09fa48c46e288b3d8ef53e3b6b7663224f493655b8582590f1ea7c5c4c8f2b6d31e78f919fb82ab3e2ef880c62838c8ef3ccf00af
6
+ metadata.gz: c46f8679708f2f6d0b040ad5c4b77e447828f2af382775aa9eb8cc41cd7cc8c3aabcd7d5bb63224659a85c47c9de76d5ab3791daed573ce86875b26dd0b947fa
7
+ data.tar.gz: cb311303267ac2dc99e2d019f1b0ec92cf1c1260e1e2dcb8d0693ec399acaced2368f825d76ff9853b77b342410f8292c9922a56cc31f58552d6f89f69a038e6
data/README.md CHANGED
@@ -33,10 +33,15 @@ Or install it yourself as:
33
33
  ## Usage with Rails
34
34
 
35
35
  Generate migration for table were to store list of attachments.
36
+
36
37
  $ rails g refile:postgres:migration
38
+
37
39
  Run the migrations
40
+
38
41
  $ rake db:migrate
42
+
39
43
  Generate initializer and set Refile::Postgres as `store` backend.
44
+
40
45
  $ rails g refile:postgres:initializer
41
46
 
42
47
  ## Contributing
@@ -6,10 +6,11 @@ module Refile
6
6
  DEFAULT_REGISTRY_TABLE = "refile_attachments"
7
7
  DEFAULT_NAMESPACE = "default"
8
8
  PG_LARGE_OBJECT_TABLE = "pg_largeobject"
9
+ READ_CHUNK_SIZE = 3000
9
10
 
10
11
  def initialize(connection, max_size: nil, namespace: DEFAULT_NAMESPACE, registry_table: DEFAULT_REGISTRY_TABLE)
11
12
  unless connection.is_a?(PG::Connection)
12
- raise ArgumentError.new("First argument should be an instance of PG::Connection. When using ActiveRecord its available in ActiveRecord::Base.connection.raw_connection")
13
+ raise ArgumentError.new("First argument should be an instance of PG::Connection. When using ActiveRecord it is available as ActiveRecord::Base.connection.raw_connection")
13
14
  end
14
15
  @connection = connection
15
16
  @namespace = namespace.to_s
@@ -18,7 +19,7 @@ module Refile
18
19
  @max_size = max_size
19
20
  end
20
21
 
21
- attr_reader :connection, :namespace
22
+ attr_reader :connection, :namespace, :max_size
22
23
 
23
24
  def registry_table
24
25
  unless @registry_table_validated
@@ -36,7 +37,7 @@ module Refile
36
37
  end
37
38
 
38
39
  def upload(uploadable)
39
- Refile.verify_uploadable(uploadable, @max_size)
40
+ Refile.verify_uploadable(uploadable, max_size)
40
41
  oid = connection.lo_creat
41
42
  ensure_in_transaction do
42
43
  begin
@@ -44,7 +45,7 @@ module Refile
44
45
  connection.lo_truncate(handle, 0)
45
46
  buffer = "" # reuse the same buffer
46
47
  until uploadable.eof?
47
- uploadable.read(Refile.read_chunk_size, buffer)
48
+ uploadable.read(READ_CHUNK_SIZE, buffer)
48
49
  connection.lo_write(handle, buffer)
49
50
  end
50
51
  uploadable.close
@@ -106,7 +107,7 @@ module Refile
106
107
  end
107
108
 
108
109
  def clear!(confirm = nil)
109
- raise ArgumentError, "are you sure? this will remove all files in the backend, call as `clear!(:confirm)` if you're sure you want to do this" unless confirm == :confirm
110
+ raise Refile::Confirm unless confirm == :confirm
110
111
  registry_table
111
112
  ensure_in_transaction do
112
113
  connection.exec_params(%{
@@ -1,5 +1,5 @@
1
1
  module Refile
2
2
  module Postgres
3
- VERSION = "0.0.4"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -18,10 +18,12 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "refile"
21
+ spec.add_dependency "refile", "~> 0.5"
22
22
  spec.add_dependency "pg"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "webmock"
25
27
  spec.add_development_dependency "pry"
26
28
  spec.add_development_dependency "pry-stack_explorer"
27
29
  spec.add_development_dependency "rails", "~> 4.1.8"
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: refile-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krists Ozols
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-10 00:00:00.000000000 Z
11
+ date: 2015-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: refile
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '0.5'
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.5'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: pg
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +52,34 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: pry
57
85
  requirement: !ruby/object:Gem::Requirement