fog-xiaozhu 0.2.1 → 0.2.2

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
  SHA1:
3
- metadata.gz: 4ab66dc904b634dd5a0abb2fe0407f7911a0ba5e
4
- data.tar.gz: 73941e4d09c8d594ffa29ee489606c32c438edd0
3
+ metadata.gz: c1ed05f3f7da66e49b666241541244cc978362fc
4
+ data.tar.gz: 9982ae5765a7eed4a8d32177c85c46d538339578
5
5
  SHA512:
6
- metadata.gz: 075aabe14c9415dec10c5b6240b696c5c7629e5c4bc9fa62d0698729bd67b3de786739fb48e2b4440151ff5b86d8077feffe72b28d5626d29148cb85afc81448
7
- data.tar.gz: 1d90a461ed5bf521020ba7ac1e383a79af2f9d22f8d35b6dc60e1ddab814428f7aaa1c0f09886c4936e2e1ebc6fc9ff1b62461141febff7fc1ae25a51aa9e9b6
6
+ metadata.gz: 0f651be8538f6075bd546c6fe4511112aab5c4e080f243cc3fa87c46a703a2efb73701f59eb7e47e7630f5780c52af47c0f1e6220a6db0bf23a55bfe2a6f33b0
7
+ data.tar.gz: be45df163589e9742425b99240600cf9112757e629c18baed72103a25324ad59708934eff9fa85e63998d2b5e32909022d28cca4123fdd784de029e8ded478ac
data/README.md CHANGED
@@ -32,7 +32,9 @@ Since it's a bad practice to have your credentials in source code, you should lo
32
32
  default:
33
33
  :aliyun_accesskey_id: <YOUR_ACCESS_KEY_ID>,
34
34
  :aliyun_accesskey_secret: <YOUR_SECRET_ACCESS_KEY>,
35
- :aliyun_region_id: <YOUR_TARGET_REGION>
35
+ :aliyun_oss_endpoint: <YOUR_OSS_ENDPOINT>,
36
+ :aliyun_oss_location: <YOUR_OSS_LOACTION>,
37
+ :aliyun_oss_bucket: <YOUR_OSS_BUCKET>
36
38
  ```
37
39
 
38
40
  ### Connecting to OSS
@@ -46,17 +48,12 @@ opt = {
46
48
  :provider => 'aliyun',
47
49
  :aliyun_accesskey_id => <YOUR_ACCESS_KEY_ID>,
48
50
  :aliyun_accesskey_secret => <YOUR_SECRET_ACCESS_KEY>,
49
- :aliyun_oss_bucket => <YOUR_OSS_BUCKET>,
50
- :aliyun_region_id => <YOUR_TARGET_REGION>,
51
51
  :aliyun_oss_endpoint => <YOUR_OSS_ENDPOINT>,
52
+ :aliyun_oss_location => <YOUR_OSS_LOACTION>,
53
+ :aliyun_oss_bucket => <YOUR_OSS_BUCKET>,
52
54
  }
53
55
  conn = Fog::Storage.new(opt)
54
56
  ```
55
- **-> Note:** `:aliyun_region_id` is optional and default to "cn-hangzhou".
56
- **-> Note:** `:aliyun_oss_endpoint` is optional. If it is not specified, it will be generated automatically by `:aliyun_region_id`.
57
- Its basic format is "oss-<region-id>.aliyuncs.com" and with default schema "http" and default port "80".
58
- If you want to use https or 443 port, you can use a format "<schema>://oss-<region-id>.aliyuncs.com:<port>".
59
-
60
57
 
61
58
  ## Fog::Aliyun Abstractions
62
59
 
@@ -3,21 +3,11 @@ require 'xmlsimple'
3
3
  module Fog
4
4
  module Storage
5
5
  class Aliyun < Fog::Service
6
-
7
- DEFAULT_REGION = 'cn-hangzhou'
8
-
9
- DEFAULT_SCHEME = 'http'
10
- DEFAULT_SCHEME_PORT = {
11
- 'http' => 80,
12
- 'https' => 443
13
- }
14
-
15
6
  recognizes :aliyun_oss_endpoint,
16
7
  :aliyun_oss_location,
17
- :aliyun_region_id
18
- requires :aliyun_accesskey_id,
19
- :aliyun_accesskey_secret,
20
8
  :aliyun_oss_bucket
9
+ requires :aliyun_accesskey_id,
10
+ :aliyun_accesskey_secret
21
11
 
22
12
  model_path 'fog/aliyun/models/storage'
23
13
  model :directory
@@ -47,9 +37,9 @@ module Fog
47
37
  # Initialize connection to OSS
48
38
  #
49
39
  # ==== Notes
50
- # options parameter must include values for :aliyun_accesskey_id, :aliyun_secret_access_key and :aliyun_oss_bucket in order to create a connection.
51
- # :aliyun_oss_location will be replaced by :aliyun_region_id, and it has a default value cn-hangzhou
52
- # if :aliyun_oss_endpoint is not specified, it will be generated by method region_to_endpoint
40
+ # options parameter must include values for :aliyun_oss_endpoint, :aliyun_accesskey_id,
41
+ # :aliyun_secret_access_key, :aliyun_oss_location and :aliyun_oss_bucket in order to create a connection.
42
+ # if you haven't set these values in the configuration file.
53
43
  #
54
44
  # ==== Examples
55
45
  # sdb = Fog::Storage.new(:provider=>'aliyun',
@@ -65,37 +55,32 @@ module Fog
65
55
  attr_reader :aliyun_accesskey_id
66
56
  attr_reader :aliyun_accesskey_secret
67
57
  attr_reader :aliyun_oss_endpoint
68
- attr_reader :aliyun_region_id
58
+ attr_reader :aliyun_oss_location
69
59
  attr_reader :aliyun_oss_bucket
70
60
 
71
61
  def initialize(options = {})
72
62
  # initialize the parameters
73
- @aliyun_region_id = options[:aliyun_region_id] || options[:aliyun_oss_location] || DEFAULT_REGION
74
- @aliyun_oss_endpoint = options[:aliyun_oss_endpoint] || region_to_endpoint(@aliyun_region_id)
63
+ @aliyun_oss_endpoint = options[:aliyun_oss_endpoint]
64
+ @aliyun_oss_location = options[:aliyun_oss_location]
75
65
  @aliyun_accesskey_id = options[:aliyun_accesskey_id]
76
66
  @aliyun_accesskey_secret = options[:aliyun_accesskey_secret]
77
67
  @aliyun_oss_bucket = options[:aliyun_oss_bucket]
78
68
 
79
69
  # check for the parameters
80
70
  missing_credentials = []
81
- missing_credentials << :aliyun_oss_bucket unless @aliyun_oss_bucket
71
+ missing_credentials << :aliyun_oss_endpoint unless @aliyun_oss_endpoint
72
+ missing_credentials << :aliyun_oss_location unless @aliyun_oss_location
82
73
  missing_credentials << :aliyun_accesskey_id unless @aliyun_accesskey_id
83
74
  missing_credentials << :aliyun_accesskey_secret unless @aliyun_accesskey_secret
84
75
  raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
85
76
 
86
77
  @connection_options = options[:connection_options] || {}
87
78
 
88
- endpoint = @aliyun_oss_endpoint
89
-
90
- if !endpoint.start_with?(DEFAULT_SCHEME)
91
- @aliyun_oss_endpoint = "#{DEFAULT_SCHEME}://#{endpoint}"
92
- end
93
-
94
79
  uri = URI.parse(@aliyun_oss_endpoint)
95
80
  @host = uri.host
96
81
  @path = uri.path
97
- @scheme = uri.scheme || DEFAULT_SCHEME
98
- @port = uri.port || DEFAULT_SCHEME_PORT[@scheme]
82
+ @port = uri.port
83
+ @scheme = uri.scheme
99
84
 
100
85
  @persistent = options[:persistent] || false
101
86
  end
@@ -104,15 +89,6 @@ module Fog
104
89
  @connection.reset
105
90
  end
106
91
 
107
- def region_to_endpoint(region=nil)
108
- case region.to_s
109
- when ''
110
- "oss-#{DEFAULT_REGION}.aliyuncs.com"
111
- else
112
- "oss-#{region}.aliyuncs.com"
113
- end
114
- end
115
-
116
92
  def request(params)
117
93
  method = params[:method]
118
94
  time = Time.new.utc
@@ -205,14 +181,14 @@ module Fog
205
181
  class Mock
206
182
  def initialize(options = {})
207
183
  @aliyun_oss_endpoint = options[:aliyun_oss_endpoint]
208
- @aliyun_region_id = options[:aliyun_region_id]
184
+ @aliyun_oss_location = options[:aliyun_oss_location]
209
185
  @aliyun_accesskey_id = options[:aliyun_accesskey_id]
210
186
  @aliyun_accesskey_secret = options[:aliyun_accesskey_secret]
211
187
  @aliyun_oss_bucket = options[:aliyun_oss_bucket]
212
188
 
213
189
  # missing_credentials = Array.new
214
190
  # missing_credentials << :aliyun_oss_endpoint unless @aliyun_oss_endpoint
215
- # missing_credentials << :aliyun_region_id unless @aliyun_region_id
191
+ # missing_credentials << :aliyun_oss_location unless @aliyun_oss_location
216
192
  # missing_credentials << :aliyun_accesskey_id unless @aliyun_accesskey_id
217
193
  # missing_credentials << :aliyun_accesskey_secret unless @aliyun_accesskey_secret
218
194
  # raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Aliyun
3
- VERSION = '0.2.1'.freeze
3
+ VERSION = '0.2.2'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-xiaozhu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Qinsi Deng, Jianxun Li, Jane Han