qinium 0.4.0 → 0.5.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +16 -1
- data/lib/qinium/config.rb +17 -2
- data/lib/qinium/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bf8940770f06a76b2dd7cbdc666a8f368514247d964ea6130d4a3d31d61f05d8
|
|
4
|
+
data.tar.gz: 9946b505ae6b19c5cda4ca235e596ffcf28fe948495c088382a84e3e818ca701
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 400c37f86d0fd16367e33419b47c5c6476ce3e915409da14d8a1679d1062ba531c7c081708b64580342c21ef28a8af2edcab4048bbffc384ed412ee912a77b88
|
|
7
|
+
data.tar.gz: 878fc9758fc8179270702fd15dee6a07fff4a3976c70dd70a19d81bf50d73082aa6be52f85de77af963d5cbd0c726659adddc51b46012bc964c5df35475c698b
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -14,7 +14,22 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
|
14
14
|
|
|
15
15
|
## Usage
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
### `up_host`(可选)
|
|
18
|
+
|
|
19
|
+
只传**域名**即可(不要带 `http://` / `https://`)。协议由配置里的 **`protocol`** 决定(默认 `:https`;需要走 HTTP 时设 `protocol: :http`)。
|
|
20
|
+
|
|
21
|
+
不传 `up_host` 时,仍通过七牛 UC 解析上传域(与旧版一致)。
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
Qinium.new(
|
|
25
|
+
bucket: "my-bucket",
|
|
26
|
+
access_key: ENV["QINIU_AK"],
|
|
27
|
+
secret_key: ENV["QINIU_SK"],
|
|
28
|
+
protocol: :https, # 或 :http
|
|
29
|
+
up_host: "xxx.kodo-accelerate.ap-southeast-1.qiniucs.com"
|
|
30
|
+
)
|
|
31
|
+
# => #up_host 返回 "https://xxx..." 或 "http://xxx..."(视 protocol)
|
|
32
|
+
```
|
|
18
33
|
|
|
19
34
|
## Development
|
|
20
35
|
|
data/lib/qinium/config.rb
CHANGED
|
@@ -11,10 +11,15 @@ class Qinium
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def up_host(bucket = self.bucket)
|
|
14
|
-
|
|
14
|
+
raw = self[:up_host]
|
|
15
|
+
unless raw.to_s.strip.empty?
|
|
16
|
+
normalize_qiniu_up_base_url(raw.to_s)
|
|
17
|
+
else
|
|
18
|
+
HostManager.new(self).up_host(bucket)
|
|
19
|
+
end
|
|
15
20
|
end
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
def fetch_host(bucket = self.bucket, opts = {})
|
|
18
23
|
self[:fetch_host] || HostManager.new(self).fetch_host(bucket, opts)
|
|
19
24
|
end
|
|
20
25
|
|
|
@@ -24,6 +29,16 @@ class Qinium
|
|
|
24
29
|
|
|
25
30
|
private
|
|
26
31
|
|
|
32
|
+
# Bare hostname is typical; optional full http(s) URL. Scheme defaults from #protocol.
|
|
33
|
+
def normalize_qiniu_up_base_url(url)
|
|
34
|
+
s = url.strip.sub(%r{/+\z}, "")
|
|
35
|
+
return s if s.match?(%r{\Ahttps?://}i)
|
|
36
|
+
|
|
37
|
+
# 仅域名时:http(s) 由 protocol 决定(支持 Symbol 或 ENV 里的 "http"/"https" 字符串)
|
|
38
|
+
proto = protocol.to_s.downcase == "http" ? "http" : "https"
|
|
39
|
+
"#{proto}://#{s.sub(%r{\A//+}, "")}"
|
|
40
|
+
end
|
|
41
|
+
|
|
27
42
|
def default_options
|
|
28
43
|
{
|
|
29
44
|
user_agent: "QiniumRuby/#{VERSION} (#{RUBY_PLATFORM}) Ruby/#{RUBY_VERSION}",
|
data/lib/qinium/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: qinium
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- xiaohui
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-04-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Qiniu Cloud Storage SDK for multi-tenant system, can call API with multiple
|
|
14
14
|
accounts
|