paperclip-upyun 0.1.2 → 0.1.3

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: 3f6bb3164fc08fc30d9e7dd9e750f2ca72fbbfa8
4
- data.tar.gz: ed75355a0ea10514ff38eb28cb1a07a9ee6ebb94
3
+ metadata.gz: 41e7dccd8ab60a9e8e2b188754e189657dd5cb19
4
+ data.tar.gz: 26fb966fe916131de2d1584f25432dc068a75b90
5
5
  SHA512:
6
- metadata.gz: 4fabd9e0fb98ee0e66a9bdcf703d2c66718623096168fa241f08ae4ed11cea8773ce11b04251a8c2d7bfb8eb2603447cc4d205e7cf7563f42628ff7a04667da7
7
- data.tar.gz: a47494e8a9d2d173c5f5be5ad3ecf788664902e181eb67299cd5cd3bb5f1d083229edf2d6ccc103471398561c923510f6cae21572032cf30c1c3bae6140312d3
6
+ metadata.gz: 57d0d6a8e4f015320a9127fcb2ffd908734ac1c1d80005bb0af400b1a0cab47f3cb3fdbde08790a2d89cec353bb0174acdb6128869f3eda669a5dafc5d1f8410
7
+ data.tar.gz: f111528976b85ed109023bd323791fac4e4373c2e5b22cfab37f1f0dc8c9b33ff11441122d2f7a511c18c9448c4728b2e5d78f5a260e64408f8b152fab85d774
@@ -0,0 +1,12 @@
1
+ ## CHANGELOG
2
+
3
+ ###0.1.3(2016-4-22)
4
+ * add :need_delete option
5
+
6
+ ###0.1.2(2016-1-3)
7
+ * perfect README.md
8
+ * fix require issue
9
+ * test passing
10
+
11
+ ### 0.1.1 (2015-12-27)
12
+ * first version
data/README.md CHANGED
@@ -1,7 +1,101 @@
1
1
  # paperclip-upyun
2
- [![RubyGems](https://img.shields.io/gem/dtv/paperclip-upyun.svg?style=flat)](https://rubygems.org/gems/upyun)
2
+ [![RubyGems](https://img.shields.io/gem/dtv/paperclip-upyun.svg?style=flat)](https://rubygems.org/gems/paperclip-upyun)
3
3
  [![Build status](https://img.shields.io/badge/paperclip----upyun-passing-green.svg?style=flat)]()
4
4
 
5
+ This is a [Paperclip](https://github.com/thoughtbot/paperclip) plugin, which use [upyun](https://www.upyun.com/zh/index.html) storage.
6
+
7
+ Dependency [upyun-ruby](https://github.com/upyun/ruby-sdk) sdk.
5
8
 
6
9
  ## Install
10
+
7
11
  `gem install paperclip-upyun`
12
+
13
+ or
14
+
15
+ `gem 'paperclip-upyun'` in you Gemfile.
16
+
17
+
18
+ ## Usage
19
+
20
+ * create `config/initializers/paperclip.rb` or your program initializer. code configation as follow:
21
+
22
+ ```
23
+ Paperclip::Attachment.default_options[:storage] = :upyun
24
+ Paperclip::Attachment.default_options[:bucket] = ENV["UPYUN_BUCKET"]
25
+ Paperclip::Attachment.default_options[:operator] = ENV["UPYUN_OPERATOR"]
26
+ Paperclip::Attachment.default_options[:password] = ENV["UPYUN_PASSWORD"]
27
+ Paperclip::Attachment.default_options[:upyun_host] = ENV["UPYUN_HOST"]
28
+ Paperclip::Attachment.default_options[:use_timestamp] = false
29
+ ```
30
+
31
+ * add paperclip config in your model:
32
+
33
+ ```
34
+ class User < ActiveRecord::Base
35
+
36
+ has_attached_file :avatar,
37
+ :path => ":class/:attachment/:id/:fingerprint/:filename:version",
38
+ :default_url => ":upyun_host/:class/:attachment/default_avatar.png:version"
39
+
40
+ # validates :avatar, :attachment_presence => true
41
+ validates_attachment_content_type :avatar, :content_type => /\Aimage\/.*\Z/
42
+
43
+ end
44
+
45
+ ```
46
+
47
+ * happy code with
48
+
49
+ `User.avatar.url` or add `:version` parameter like `User.avatar.url(64)`
50
+
51
+
52
+
53
+ ## About :version Parameter
54
+
55
+ * This gem use clip image function with upyun, default separator is `!`, more information you can see [http://docs.upyun.com/guide/#_9](http://docs.upyun.com/guide/#_9)
56
+ * if you do not want this function, just don't use :version parameter in :path model configration.
57
+
58
+ ## Contributing
59
+ 1. Fork it
60
+ 2. Create your feature branch (git checkout -b my-new-feature)
61
+ 3. Commit your changes (git commit -am 'Added some feature')
62
+ 4. Push to the branch (git push origin my-new-feature)
63
+ 5. Create new Pull Request
64
+
65
+ ## CHANGELOG
66
+ ###0.1.2(2016-1-3)
67
+ * perfect REAM.md
68
+ * fix require issue
69
+ * test passing
70
+
71
+ ### 0.1.1 (2015-12-27)
72
+ * first version
73
+
74
+ ## License
75
+ ```
76
+ The MIT License (MIT)
77
+
78
+ Copyright (c) 2016 聚会玩
79
+
80
+ Permission is hereby granted, free of charge, to any person obtaining a copy
81
+ of this software and associated documentation files (the "Software"), to deal
82
+ in the Software without restriction, including without limitation the rights
83
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
84
+ copies of the Software, and to permit persons to whom the Software is
85
+ furnished to do so, subject to the following conditions:
86
+
87
+ The above copyright notice and this permission notice shall be included in all
88
+ copies or substantial portions of the Software.
89
+
90
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
91
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
92
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
93
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
94
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
95
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
96
+ SOFTWARE.
97
+ ```
98
+
99
+ ### 聚会玩,游戏就要一起玩
100
+ ![聚会玩](http://juhuiwan.cn/res/images/logo.png)
101
+
@@ -21,11 +21,9 @@ module Paperclip
21
21
  @options[:interval] = "!"
22
22
 
23
23
  @upyun = ::Upyun::Rest.new(@bucket, @operator, @password)
24
- log("@options[:path]: #{@options[:path]}")
25
- log("@options[:url]: #{@options[:url]}")
26
- @options[:path] = @options[:path].gsub(/:url/, @options[:url])
27
- log("@options[:path]: #{@options[:path]}")
28
- @options[:url] = ':upyun_public_url'
24
+ @options[:path] = @options[:path].gsub(/:url/, @options[:url])
25
+ @options[:url] = ':upyun_public_url'
26
+ @options[:need_delete] = @options[:need_delete] || true
29
27
 
30
28
  Paperclip.interpolates(:version) do |attachment, style|
31
29
  attachment.version(style)
@@ -44,7 +42,6 @@ module Paperclip
44
42
  end
45
43
 
46
44
  def exists?(style = default_style)
47
- puts "enter exists? #{style}"
48
45
  resp = @upyun.getinfo(path(style))
49
46
  begin
50
47
  Paperclip::Upyun::Response.parse(resp)
@@ -68,15 +65,15 @@ module Paperclip
68
65
  end
69
66
 
70
67
  def flush_deletes
71
- for path in @queued_for_delete do
72
- log("deleting: #{path}")
73
- delete(path)
68
+ if @options[:need_delete]
69
+ for path in @queued_for_delete do
70
+ delete(path)
71
+ end
74
72
  end
75
73
  @queued_for_delete = []
76
74
  end
77
75
 
78
76
  def public_url(style = default_style)
79
- log("url:path=>#{path(style)}")
80
77
  url = "#{@options[:upyun_host]}/#{path(style)}"
81
78
  end
82
79
 
@@ -1,5 +1,5 @@
1
1
  module Paperclip
2
2
  module Upyun
3
- VERSION = "0.1.2" unless defined? Paperclip::VERSION
3
+ VERSION = "0.1.3" unless defined? Paperclip::VERSION
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-upyun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edison-Hsu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-02 00:00:00.000000000 Z
11
+ date: 2016-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: upyun
@@ -47,6 +47,7 @@ extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
49
  - ".gitignore"
50
+ - CHANGELOG
50
51
  - README.md
51
52
  - lib/paperclip/storage/upyun.rb
52
53
  - lib/paperclip/upyun.rb