activestorage_upyun 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58a87e34575b62aea60678d048e5fcde125277782cc3680ffdf2b39b61f8fb1d
4
- data.tar.gz: 4e6bd359c264c3524d22e24656ab707bf0acffb1c18ad4e57021be7055dc6e54
3
+ metadata.gz: c680c39e020941f01c261047212c41150da91e13b77f15bd1aff293da29e8364
4
+ data.tar.gz: ca532178dacc85e8bcee53c41aa839346e47a7d19ace9653ee54cc8b96af2c41
5
5
  SHA512:
6
- metadata.gz: 18586159b2a651c7e6117dd634a7c5a4b0d803a53545727026631754f36633e2a0f1ab6bcfa3f8554f1a5ef000153831cdc3307f5e564100e5126ecba4076beb
7
- data.tar.gz: e9ec7a546ced43476ae8529a2e80fce5bc743c783961fa495af2a610403c787dcbd0f9fb0ffb06f087065476fdf975787759727f9acedda2dddc1a5a317ab990
6
+ metadata.gz: df0da59f40e289b381facf3c375b8c9cc772c7a9645b5d1a72ae39c0b13cf10d50983ff88c405ee620ac510962d4ce04392cd34be4fbb556334ae6a46df7aed3
7
+ data.tar.gz: 7c1847ea2006b2ce278955ab4e2c20176f2d24053ac0e413a2902120a7118461118b40626825aad873c1f4727fdc34718118e289a07748043f896dc5fece258a
data/README.md CHANGED
@@ -26,5 +26,30 @@ Set up activestorage service:
26
26
  config.active_storage.service = :upyun
27
27
  ```
28
28
 
29
+ Use for image url
30
+
31
+ ```erb
32
+ <%= image_tag @user.avatar.service_url %>
33
+ ```
34
+
35
+ Or add thumb version named `webpw200`
36
+
37
+ ```erb
38
+ <%= image_tag @user.avatar.service_url(params: {process: 'webpw200'}) %>
39
+ ```
40
+
41
+ thumb version use `!` as default identifier, if you want to use `_` as identifier, you can add `identifier` option
42
+
43
+ ```yml
44
+ upyun:
45
+ service: Upyun
46
+ bucket: <%= ENV['UPYUUN_BUCKET'] %>
47
+ operator: <%= ENV['UPYUUN_OPERATOR'] %>
48
+ password: <%= ENV['UPYUUN_PASSWORD'] %>
49
+ host: <%= ENV['UPYUN_HOST'] %>
50
+ folder: <%= ENV['UPYUN_FOLDER'] %>
51
+ identifier: _
52
+ ```
53
+
29
54
  ## License
30
55
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -21,6 +21,7 @@ module ActiveStorage
21
21
  #
22
22
  class Service::UpyunService < Service
23
23
  ENDPOINT = 'http://v0.api.upyun.com'
24
+ IDENTIFIER = '!'
24
25
 
25
26
  attr_reader :upyun, :bucket, :operator, :password, :host, :folder, :upload_options
26
27
 
@@ -71,9 +72,9 @@ module ActiveStorage
71
72
  end
72
73
  end
73
74
 
74
- def url(key, **options)
75
+ def url(key, expires_in:, filename:, content_type:, disposition:, params: {})
75
76
  instrument :url, key: key do |payload|
76
- url = url_for(key)
77
+ url = url_for(key, params: params)
77
78
  payload[:url] = url
78
79
  url
79
80
  end
@@ -116,8 +117,13 @@ module ActiveStorage
116
117
 
117
118
  private
118
119
 
119
- def url_for(key)
120
- [@host, @folder, key].join('/')
120
+ def url_for(key, params: {})
121
+ url = [@host, @folder, key].join('/')
122
+ return url if params.blank?
123
+ process = params.delete(:process)
124
+ identifier = @upload_options[:identifier] || IDENTIFIER
125
+ url = [url, process].join(identifier) if process
126
+ url
121
127
  end
122
128
 
123
129
  def path_for(key)
@@ -1,3 +1,3 @@
1
1
  module ActivestorageUpyun
2
- VERSION = '0.1.1'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activestorage_upyun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - doabit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-20 00:00:00.000000000 Z
11
+ date: 2018-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage