filepicker-rails 1.4.0 → 2.0.0

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: 06d2e91d419884443bd5b5e7b78f3ad18515fde9
4
- data.tar.gz: c0d4ab38baea1c65377d056e8e72f670f2f1bca9
3
+ metadata.gz: 3b84369b54427063911d87d865e6e982912b6536
4
+ data.tar.gz: 1735e9671044f54eaf076b358c5397b41a14e4be
5
5
  SHA512:
6
- metadata.gz: f09dde007e819de987b599b493fc077ed2133aca55bd723c66de7a43f613238b33d7f47fa0acaa0c1b8dd7856c2d61ee5423d62ee4824eccce74fc6394c476f3
7
- data.tar.gz: af1c86fad975850a25696c57155ffb550d0642a59035eb977001bd067001be0125371ebb00c57d51f2eed3d96f6c593bd1b5df5552ce324d4e95c29e41b94898
6
+ metadata.gz: b18582c1c14ba2cbb2f4674d9ca26e12b65f29fe432d743790f486875265a5a6cdcd6e8744de26f82e28f896e874a4f1486ae8972d1dbae48d8deb5c7595b01e
7
+ data.tar.gz: f199fd9c056a9c30203ce25f81cfba3687b4b1261949af4af56e7b95e35b5624f5a8063d53bf4658c6f9299f21056503ac8e17d6d08d0a6e412db1d4a14b07e9
@@ -10,7 +10,7 @@ module FilepickerRails
10
10
  # filepicker_js_include_tag
11
11
  # # => <script src="//api.filepicker.io/v1/filepicker.js"></script>
12
12
  def filepicker_js_include_tag
13
- javascript_include_tag "//api.filepicker.io/v1/filepicker.js"
13
+ javascript_include_tag "//api.filepicker.io/v2/filepicker.js", type: "text/javascript"
14
14
  end
15
15
 
16
16
  # Creates a filepicker field tag, accepts optional `options` hash for configuration.
@@ -179,22 +179,17 @@ module FilepickerRails
179
179
  end
180
180
 
181
181
  def execute
182
- url_with_path = if convert_options.any?
183
- "#{cdn_url}/convert"
184
- else
185
- cdn_url
186
- end
187
-
188
- query_params = all_options.merge(policy_config).to_query
182
+ base_url = url_with_path.split('?').first
183
+ query_params = all_options.to_query
189
184
 
190
- [url_with_path, query_params.presence].compact.join('?')
185
+ [base_url, query_params.presence].compact.join('?')
191
186
  end
192
187
 
193
188
  private
194
189
 
195
190
  attr_reader :url, :options
196
191
 
197
- def all_options
192
+ def valid_options
198
193
  options.select { |option| VALID_OPTIONS.include?(option) }
199
194
  end
200
195
 
@@ -202,8 +197,22 @@ module FilepickerRails
202
197
  options.select { |option| CONVERT_OPTIONS.include?(option) }
203
198
  end
204
199
 
200
+ def all_options
201
+ [original_url_options, valid_options, policy_config].inject(&:merge)
202
+ end
203
+
204
+ def original_url_options
205
+ query_string = url_with_path.split('?')[1]
206
+
207
+ if query_string
208
+ Rack::Utils.parse_nested_query(query_string)
209
+ else
210
+ {}
211
+ end
212
+ end
213
+
205
214
  def cdn_host
206
- ::Rails.application.config.filepicker_rails.cdn_host
215
+ @cdn_host ||= ::Rails.application.config.filepicker_rails.cdn_host
207
216
  end
208
217
 
209
218
  def cdn_url
@@ -218,6 +227,18 @@ module FilepickerRails
218
227
  def policy_config
219
228
  Policy.apply
220
229
  end
230
+
231
+ def url_with_path
232
+ @url_with_path ||= if append_convert_on_url_path?
233
+ "#{cdn_url}/convert"
234
+ else
235
+ cdn_url
236
+ end
237
+ end
238
+
239
+ def append_convert_on_url_path?
240
+ convert_options.any? && !cdn_url.match('/convert')
241
+ end
221
242
  end
222
243
  private_constant :FilepickerImageUrl
223
244
 
@@ -1,4 +1,5 @@
1
1
  module FilepickerRails
2
+ # @private
2
3
  module Tag
3
4
 
4
5
  FILEPICKER_OPTIONS_TO_DASHERIZE = [:button_text, :button_class, :mimetypes,
@@ -1,3 +1,3 @@
1
1
  module FilepickerRails
2
- VERSION = "1.4.0"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filepicker-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Tilford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-07 00:00:00.000000000 Z
11
+ date: 2015-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  version: '0'
175
175
  requirements: []
176
176
  rubyforge_project:
177
- rubygems_version: 2.4.5
177
+ rubygems_version: 2.2.2
178
178
  signing_key:
179
179
  specification_version: 4
180
180
  summary: Makes integrating filepicker.io with rails 4 easy