carrierwave-aliyun 0.2.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
  SHA1:
3
- metadata.gz: 26578c252fe9854ba9c649f43f34085a9e08d8a9
4
- data.tar.gz: 4aa49c1451a5552aa9918bc5482bbfbc143e329f
3
+ metadata.gz: 6c88a9af587b855318be9ced43af6fd29e964f40
4
+ data.tar.gz: ecab21ea3488317eeb406fdf71024181e1610328
5
5
  SHA512:
6
- metadata.gz: b0ed5151b787618e4496807b065ec493c3a60e141ac7286d9eab5acdbd8c1fa74197b328867243daa62979defd237642a518fd97b9fa2f06eb2aa9aab3dcdb4a
7
- data.tar.gz: 6a4a619a5e131a94bc2a4b3e1c8e12eeb26143a074227b3d9ff59f8425a71f00a3e6e602cfa5e14a0159b1dbb7c53e223a06d1b1ca21d75e02faf7450403d97c
6
+ metadata.gz: 37a7b3e42a51bae11d7cd9f829c827f4eea442e79aa34895e835a3a95203a37702f1d1a6a9fde48eed1afa9346e0d70486a378ddac37f89c4caf21f958e36315
7
+ data.tar.gz: e9418dafc9f763fc80006d13e99a5c968349a06fbb3b7675944eb99d7927de4fde32e680e2a3270cb7b12f1bd8f69837813fb838415c5cb73b6d268f59e5c3fa
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ bundler_args: --without development
3
+
4
+ rvm:
5
+ - 2.0.0
6
+ - 1.9.3
7
+ - 1.9.2
8
+
9
+ script: RAILS_ENV=test bundle exec rake spec
data/Changelogs.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.3.0
2
+
3
+ * 新增 `aliyun_area` 参数,用于配置 OSS 所在地区数据中心;
4
+
1
5
  ## 0.2.1
2
6
 
3
7
  * 避免计算上传文件的时候读取所有内容到内存,之前的做法对于大文件会耗费过多的内存;
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This gem adds support for [Aliyun OSS](http://oss.aliyun.com) to [CarrierWave](https://github.com/jnicklas/carrierwave/)
4
4
 
5
+ - [![Gem Version](https://badge.fury.io/rb/carrierwave-aliyun.png)](https://rubygems.org/gems/carrierwave-aliyun)
6
+
5
7
  ## Installation
6
8
 
7
9
  ```bash
@@ -28,6 +30,8 @@ CarrierWave.configure do |config|
28
30
  config.aliyun_bucket = "simple"
29
31
  # 是否使用内部连接,true - 使用 Aliyun 局域网的方式访问 false - 外部网络访问
30
32
  config.aliyun_internal = true
33
+ # 配置存储的地区数据中心,默认: cn-hangzhou
34
+ # config.aliyun_area = "cn-hangzhou"
31
35
  # 使用自定义域名,设定此项,carrierwave 返回的 URL 将会用自定义域名
32
36
  # 自定于域名请 CNAME 到 you_bucket_name.oss.aliyuncs.com (you_bucket_name 是你的 bucket 的名称)
33
37
  config.aliyun_host = "foo.bar.com"
@@ -36,4 +40,4 @@ end
36
40
 
37
41
  ## 跳过 CarrierWave 直接调用 Aliyun API
38
42
 
39
- 如果你有需求想跳过 CarrierWave,直接调用 Aliyun 的接口,可以参看 `spec/aliyun_spec.rb` 里面有例子。
43
+ 如果你有需求想跳过 CarrierWave,直接调用 Aliyun 的接口,可以参看 `spec/aliyun_spec.rb` 里面有例子。
@@ -6,6 +6,7 @@ module CarrierWave
6
6
  add_config :aliyun_access_id
7
7
  add_config :aliyun_access_key
8
8
  add_config :aliyun_bucket
9
+ add_config :aliyun_area
9
10
  add_config :aliyun_internal
10
11
  add_config :aliyun_host
11
12
  end
@@ -1,7 +1,7 @@
1
1
  module CarrierWave
2
2
  module Aliyun
3
3
  class Version
4
- MAJOR, MINOR, PATCH = 0, 2, 1
4
+ MAJOR, MINOR, PATCH = 0, 3, 0
5
5
 
6
6
  ##
7
7
  # Returns the major version ( big release based off of multiple minor releases )
@@ -14,13 +14,14 @@ module CarrierWave
14
14
  @aliyun_access_id = options[:aliyun_access_id]
15
15
  @aliyun_access_key = options[:aliyun_access_key]
16
16
  @aliyun_bucket = options[:aliyun_bucket]
17
+ @aliyun_area = options[:aliyun_area] || 'cn-hangzhou'
17
18
  # Host for upload
18
- @aliyun_upload_host = "#{@aliyun_bucket}.oss.aliyuncs.com"
19
+ @aliyun_upload_host = "#{@aliyun_bucket}.oss-#{@aliyun_area}.aliyuncs.com"
19
20
  if options[:aliyun_internal] == true
20
- @aliyun_upload_host = "#{@aliyun_bucket}.oss-internal.aliyuncs.com"
21
+ @aliyun_upload_host = "#{@aliyun_bucket}.oss-#{@aliyun_area}-internal.aliyuncs.com"
21
22
  end
22
23
  # Host for get request
23
- @aliyun_host = options[:aliyun_host] || "#{@aliyun_bucket}.oss.aliyuncs.com"
24
+ @aliyun_host = options[:aliyun_host] || "#{@aliyun_bucket}.oss-#{@aliyun_area}.aliyuncs.com"
24
25
  end
25
26
 
26
27
  =begin rdoc
@@ -185,6 +186,7 @@ module CarrierWave
185
186
  config = {
186
187
  :aliyun_access_id => @uploader.aliyun_access_id,
187
188
  :aliyun_access_key => @uploader.aliyun_access_key,
189
+ :aliyun_area => @uploader.aliyun_area,
188
190
  :aliyun_bucket => @uploader.aliyun_bucket,
189
191
  :aliyun_internal => @uploader.aliyun_internal,
190
192
  :aliyun_host => @uploader.aliyun_host
data/spec/aliyun_spec.rb CHANGED
@@ -11,7 +11,7 @@ describe "Aliyun" do
11
11
  }
12
12
  @connection = CarrierWave::Storage::Aliyun::Connection.new(@opts)
13
13
  end
14
-
14
+
15
15
  it "should put" do
16
16
  url = @connection.put("a/a.jpg",load_file("foo.jpg"))
17
17
  Net::HTTP.get_response(URI.parse(url)).code.should == "200"
@@ -29,7 +29,7 @@ describe "Aliyun" do
29
29
 
30
30
  it "should use default domain" do
31
31
  url = @connection.put("a/a.jpg",load_file("foo.jpg"))
32
- url.should == "http://#{ALIYUN_BUCKET}.oss.aliyuncs.com/a/a.jpg"
32
+ url.should == "http://#{ALIYUN_BUCKET}.oss-cn-hangzhou.aliyuncs.com/a/a.jpg"
33
33
  end
34
34
 
35
35
  it "should support custom domain" do
data/spec/spec_helper.rb CHANGED
@@ -33,6 +33,7 @@ CarrierWave.configure do |config|
33
33
  config.aliyun_access_id = ALIYUN_ACCESS_ID
34
34
  config.aliyun_access_key = ALIYUN_ACCESS_KEY
35
35
  config.aliyun_bucket = ALIYUN_BUCKET
36
+ config.aliyun_area = "cn-hangzhou"
36
37
  # config.aliyun_internal = false
37
38
  end
38
39
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-aliyun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-13 00:00:00.000000000 Z
11
+ date: 2013-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: carrierwave
@@ -47,6 +47,7 @@ extra_rdoc_files: []
47
47
  files:
48
48
  - .gitignore
49
49
  - .rspec
50
+ - .travis.yml
50
51
  - Changelogs.md
51
52
  - Gemfile
52
53
  - README.md
@@ -81,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
82
  version: '0'
82
83
  requirements: []
83
84
  rubyforge_project:
84
- rubygems_version: 2.0.3
85
+ rubygems_version: 2.1.11
85
86
  signing_key:
86
87
  specification_version: 4
87
88
  summary: Aliyun OSS support for Carrierwave
@@ -92,4 +93,3 @@ test_files:
92
93
  - spec/foo.zip
93
94
  - spec/spec_helper.rb
94
95
  - spec/upload_spec.rb
95
- has_rdoc: