remote_files 2.2.0 → 2.2.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: b0fe1c19ed8b77ca6633a84ea57261292acd19c9
4
- data.tar.gz: 2ab28b49c94ad696ecc5be416d3272e5df4d29e1
3
+ metadata.gz: 7bdd6a2996936339581664a79c8258c779f3b8f5
4
+ data.tar.gz: 71736655623982c8fa949a8a3b4a9b0ac8ecf151
5
5
  SHA512:
6
- metadata.gz: 922ffa3a10fe9223974962749eb4838a6af5cc7f3208a79e01ee381ee1fe7c951cc1baad1fddca503d717bbb8e2d3cb0f9630ba03f6ba2c5ccbbcf0081043531
7
- data.tar.gz: 081b58ec458091d42f16ac328e2d5fc1e29d5da33d4a1d72f58badaaa5176ec5cf4f121634b40811af36f8dffb1fc030b7099b25bca546c5f226a67dfbb77575
6
+ metadata.gz: a5fa60188f842e9f88acee6708dd2e445e93a1fd1529d29137c3d229b0ce7a41e4b178d437074e842c94e90408022fbb932f3a031b38aae317c61f659dd15126
7
+ data.tar.gz: e98f60b4c50a47a7173f7de996708d29bba301ba881950a06f30930268a7ab9f891090b1be50a4b483d36bb61990bf73e8e01c7e308377efd4679fb02fad3230
@@ -42,6 +42,10 @@ module RemoteFiles
42
42
  raise "You need to implement #{self.class.name}:#url_matcher"
43
43
  end
44
44
 
45
+ def read_only?
46
+ options[:read_only] == true
47
+ end
48
+
45
49
  def file_from_url(url, options = {})
46
50
  matched = url_matcher.match(url)
47
51
 
@@ -54,6 +54,8 @@ module RemoteFiles
54
54
  store = (options[:class] || FogStore).new(store_identifier)
55
55
  block.call(store) if block_given?
56
56
 
57
+ store[:read_only] = options[:read_only] if options.key?(:read_only)
58
+
57
59
  if options[:primary]
58
60
  @stores.unshift(store)
59
61
  else
@@ -69,9 +71,18 @@ module RemoteFiles
69
71
 
70
72
  def stores
71
73
  raise "You need to configure add stores to the #{name} RemoteFiles configuration" unless configured?
74
+
72
75
  @stores
73
76
  end
74
77
 
78
+ def read_only_stores
79
+ stores.select {|s| s.read_only?}
80
+ end
81
+
82
+ def read_write_stores
83
+ stores.reject {|s| s.read_only?}
84
+ end
85
+
75
86
  def lookup_store(store_identifier)
76
87
  @stores_map[store_identifier.to_sym]
77
88
  end
@@ -85,7 +96,7 @@ module RemoteFiles
85
96
 
86
97
  exception = nil
87
98
 
88
- stores.each do |store|
99
+ read_write_stores.each do |store|
89
100
  begin
90
101
  stored = store.store!(file)
91
102
  file.stored_in << store.identifier
@@ -115,8 +126,8 @@ module RemoteFiles
115
126
 
116
127
  def delete_now!(file)
117
128
  exceptions = []
118
- file.stored_in.each do |store_identifier|
119
- store = lookup_store(store_identifier)
129
+ stores = file.read_write_stores
130
+ stores.each do |store|
120
131
  begin
121
132
  store.delete!(file.identifier)
122
133
  rescue NotFoundError => e
@@ -124,7 +135,7 @@ module RemoteFiles
124
135
  end
125
136
  end
126
137
 
127
- if exceptions.size == file.stored_in.size # they all failed
138
+ if exceptions.size == stores.size # they all failed
128
139
  raise exceptions.first
129
140
  end
130
141
 
@@ -133,6 +144,8 @@ module RemoteFiles
133
144
 
134
145
  def synchronize!(file)
135
146
  file.missing_stores.each do |store|
147
+ next if store.read_only?
148
+
136
149
  store.store!(file)
137
150
  file.stored_in << store.identifier
138
151
  end
@@ -50,6 +50,10 @@ module RemoteFiles
50
50
  @stored_in.map { |store_id| configuration.lookup_store(store_id) }
51
51
  end
52
52
 
53
+ def read_write_stores
54
+ stores.reject(&:read_only?)
55
+ end
56
+
53
57
  def missing_stores
54
58
  configuration.stores - stores
55
59
  end
@@ -1,3 +1,3 @@
1
1
  module RemoteFiles
2
- VERSION = '2.2.0'
2
+ VERSION = '2.2.1'
3
3
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remote_files
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-04 00:00:00.000000000 Z
11
+ date: 2014-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.15'
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: '1.15'
27
27
  description: A library for uploading files to multiple remote storage backends like
@@ -53,12 +53,12 @@ require_paths:
53
53
  - lib
54
54
  required_ruby_version: !ruby/object:Gem::Requirement
55
55
  requirements:
56
- - - '>='
56
+ - - ">="
57
57
  - !ruby/object:Gem::Version
58
58
  version: '0'
59
59
  required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - '>='
61
+ - - ">="
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
64
  requirements: []
@@ -70,3 +70,4 @@ summary: The purpose of the library is to implement a simple interface for uploa
70
70
  files to multiple backends and to keep the backends in sync, so that your app will
71
71
  keep working when one backend is down.
72
72
  test_files: []
73
+ has_rdoc: