paperclip-qiniu 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 21288b60900a5b121be0bc783dfbbdecbdbf2df4
4
+ data.tar.gz: ce73d61101dceba176a921a243f610fdaa970b84
5
+ SHA512:
6
+ metadata.gz: 5c118af4f1ce0de1ceb3d0921cf3011e8a0d7a96d5ff51eaa128df577bb8a7c3dd1d7ca68d0a752b68bad998dd50bfee58dd86457517f37fc07955ad5cc5aa9d
7
+ data.tar.gz: 7e36ce9a617ca4fde6398b1eb59b86286bad5f637eec79c792961827ba5126617e96f3b721ca8a95a60a6bb43b95d2f18d5593947eefb756d93a1a6905b29b53
@@ -1,55 +1,63 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paperclip-qiniu (0.1.0)
4
+ paperclip-qiniu (0.2.0)
5
5
  paperclip
6
- qiniu-rs (~> 3.0)
6
+ qiniu (~> 6.4.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (3.2.8)
12
- activesupport (= 3.2.8)
13
- builder (~> 3.0.0)
14
- activerecord (3.2.8)
15
- activemodel (= 3.2.8)
16
- activesupport (= 3.2.8)
17
- arel (~> 3.0.2)
18
- tzinfo (~> 0.3.29)
19
- activesupport (3.2.8)
20
- i18n (~> 0.6)
21
- multi_json (~> 1.0)
22
- arel (3.0.2)
23
- builder (3.0.0)
24
- cocaine (0.3.0)
25
- diff-lcs (1.1.3)
26
- i18n (0.6.1)
27
- json (1.7.5)
28
- mime-types (1.19)
29
- multi_json (1.3.6)
30
- paperclip (3.1.4)
11
+ activemodel (4.2.0)
12
+ activesupport (= 4.2.0)
13
+ builder (~> 3.1)
14
+ activesupport (4.2.0)
15
+ i18n (~> 0.7)
16
+ json (~> 1.7, >= 1.7.7)
17
+ minitest (~> 5.1)
18
+ thread_safe (~> 0.3, >= 0.3.4)
19
+ tzinfo (~> 1.1)
20
+ builder (3.2.2)
21
+ climate_control (0.0.3)
22
+ activesupport (>= 3.0)
23
+ cocaine (0.5.5)
24
+ climate_control (>= 0.0.3, < 1.0)
25
+ diff-lcs (1.2.5)
26
+ i18n (0.7.0)
27
+ json (1.8.2)
28
+ mime-types (2.4.3)
29
+ minitest (5.5.1)
30
+ netrc (0.10.2)
31
+ paperclip (4.2.1)
31
32
  activemodel (>= 3.0.0)
32
- activerecord (>= 3.0.0)
33
33
  activesupport (>= 3.0.0)
34
- cocaine (>= 0.0.2)
34
+ cocaine (~> 0.5.3)
35
35
  mime-types
36
- qiniu-rs (3.0.5)
37
- json (~> 1.7.5)
38
- mime-types (~> 1.19)
39
- rest-client (~> 1.6.7)
40
- ruby-hmac (~> 0.4.0)
41
- rest-client (1.6.7)
42
- mime-types (>= 1.16)
43
- rspec (2.11.0)
44
- rspec-core (~> 2.11.0)
45
- rspec-expectations (~> 2.11.0)
46
- rspec-mocks (~> 2.11.0)
47
- rspec-core (2.11.1)
48
- rspec-expectations (2.11.3)
49
- diff-lcs (~> 1.1.3)
50
- rspec-mocks (2.11.2)
36
+ qiniu (6.4.1)
37
+ json (~> 1.7)
38
+ mime-types (~> 2.4.3)
39
+ rest-client (~> 1.6)
40
+ ruby-hmac (~> 0.4)
41
+ rest-client (1.7.2)
42
+ mime-types (>= 1.16, < 3.0)
43
+ netrc (~> 0.7)
44
+ rspec (3.2.0)
45
+ rspec-core (~> 3.2.0)
46
+ rspec-expectations (~> 3.2.0)
47
+ rspec-mocks (~> 3.2.0)
48
+ rspec-core (3.2.0)
49
+ rspec-support (~> 3.2.0)
50
+ rspec-expectations (3.2.0)
51
+ diff-lcs (>= 1.2.0, < 2.0)
52
+ rspec-support (~> 3.2.0)
53
+ rspec-mocks (3.2.0)
54
+ diff-lcs (>= 1.2.0, < 2.0)
55
+ rspec-support (~> 3.2.0)
56
+ rspec-support (3.2.1)
51
57
  ruby-hmac (0.4.0)
52
- tzinfo (0.3.33)
58
+ thread_safe (0.3.4)
59
+ tzinfo (1.2.2)
60
+ thread_safe (~> 0.1)
53
61
 
54
62
  PLATFORMS
55
63
  ruby
data/README.md CHANGED
@@ -4,7 +4,9 @@ storage [paperclip](https://github.com/thoughtbot/paperclip/) attachments to htt
4
4
 
5
5
  example project: https://github.com/lidaobing/paperclip-qiniu-example
6
6
 
7
- example site: http://stark-cloud-4321.herokuapp.com/
7
+ example site: http://paperclip-qiniu-example.herokuapp.com/
8
+
9
+ if you are using Rails 3, please use version 0.1.0: https://rubygems.org/gems/paperclip-qiniu/versions/0.1.0
8
10
 
9
11
  ## Usage
10
12
 
@@ -15,25 +17,22 @@ example site: http://stark-cloud-4321.herokuapp.com/
15
17
  ```ruby
16
18
  gem 'paperclip'
17
19
  gem 'paperclip-qiniu'
20
+ # or get the latest version
21
+ # gem 'paperclip-qiniu', :git => "git://github.com/lidaobing/paperclip-qiniu"
18
22
  ```
19
23
 
20
- * edit your `config/application.rb`
24
+ * create `config/initializers/paperclip.rb`
21
25
 
22
26
  ```ruby
23
- module PaperclipQiniuExample
24
- class Application < Rails::Application
25
- # ....
26
- config.paperclip_defaults = {:storage => :qiniu,
27
- :qiniu_credentials => {
28
- :access_key => ENV['QINIU_ACCESS_KEY'] || raise("set env QINIU_ACCESS_KEY"),
29
- :secret_key => ENV['QINIU_SECRET_KEY'] || raise("set env QINIU_SECRET_KEY")
30
- },
31
- :bucket => "paperclip-qiniu-example",
32
- :use_timestamp => false, # required, and must be set to false
33
- :qiniu_host => "cdn.example.com" # optional
34
- }
35
- end
36
- end
27
+ Paperclip::Attachment.default_options[:storage] = :qiniu
28
+ Paperclip::Attachment.default_options[:qiniu_credentials] = {
29
+ :access_key => ENV['QINIU_ACCESS_KEY'] || raise("set env QINIU_ACCESS_KEY"),
30
+ :secret_key => ENV['QINIU_SECRET_KEY'] || raise("set env QINIU_SECRET_KEY")
31
+ }
32
+ Paperclip::Attachment.default_options[:bucket] = 'paperclip-qiniu-example'
33
+ Paperclip::Attachment.default_options[:use_timestamp] = false
34
+ Paperclip::Attachment.default_options[:qiniu_host] =
35
+ 'http://cdn.example.com'
37
36
  ```
38
37
 
39
38
  for more information on `qiniu_host`, read http://docs.qiniutek.com/v2/sdk/ruby/#publish
@@ -45,6 +44,7 @@ class Image < ActiveRecord::Base
45
44
  attr_accessible :file
46
45
  has_attached_file :file, :path => ":class/:attachment/:id/:basename.:extension"
47
46
  validates :file, :attachment_presence => true
47
+ validates_attachment_content_type :file, :content_type => /\Aimage\/.*\Z/
48
48
  end
49
49
  ```
50
50
 
@@ -68,6 +68,10 @@ support options: `thumbnail`, `gravity`, `crop`, `quality`, `rotate`, `format`,
68
68
 
69
69
  ## CHANGELOG
70
70
 
71
+ ### 0.1.1 (2015-01-06)
72
+
73
+ * upgrade Ruby SDK from `qiniu-rs` to `6.4.1`
74
+
71
75
  ### 0.1.0 (2012-09-06)
72
76
 
73
77
  * add view helper: qiniu_image_tag, qiniu_image_path
@@ -1,5 +1,5 @@
1
1
  module Paperclip
2
2
  module Qiniu
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -5,9 +5,9 @@ module Paperclip
5
5
  module Qiniu
6
6
  def self.extended base
7
7
  begin
8
- require 'qiniu-rs'
8
+ require 'qiniu'
9
9
  rescue LoadError => e
10
- e.message << " (You may need to install the qiniu-rs gem)"
10
+ e.message << " (You may need to install the qiniu gem)"
11
11
  raise e
12
12
  end unless defined?(::Qiniu)
13
13
 
@@ -25,7 +25,7 @@ module Paperclip
25
25
 
26
26
  def exists?(style = default_style)
27
27
  init
28
- !!::Qiniu::RS.stat(bucket, path(style))
28
+ !!::Qiniu.stat(bucket, path(style))
29
29
  end
30
30
 
31
31
  def flush_writes
@@ -48,7 +48,7 @@ module Paperclip
48
48
  def flush_deletes
49
49
  init
50
50
  for path in @queued_for_delete do
51
- ::Qiniu::RS.delete(bucket, path)
51
+ ::Qiniu.delete(bucket, path)
52
52
  end
53
53
  @queued_for_delete = []
54
54
  end
@@ -58,7 +58,7 @@ module Paperclip
58
58
  if @options[:qiniu_host]
59
59
  "#{dynamic_fog_host_for_style(style)}/#{path(style)}"
60
60
  else
61
- res = ::Qiniu::RS.get(bucket, path(style))
61
+ res = ::Qiniu.get(bucket, path(style))
62
62
  if res
63
63
  res["url"]
64
64
  else
@@ -71,19 +71,19 @@ module Paperclip
71
71
 
72
72
  def init
73
73
  return if @inited
74
- ::Qiniu::RS.establish_connection! @options[:qiniu_credentials]
74
+ ::Qiniu.establish_connection! @options[:qiniu_credentials]
75
75
  inited = true
76
76
  end
77
77
 
78
78
  def upload(file, path)
79
- upload_token = ::Qiniu::RS.generate_upload_token :scope => bucket
79
+ upload_token = ::Qiniu.generate_upload_token :scope => bucket
80
80
  opts = {:uptoken => upload_token,
81
81
  :file => file.path,
82
82
  :key => path,
83
83
  :bucket => bucket,
84
84
  :mime_type => file.content_type,
85
85
  :enable_crc32_check => true}
86
- unless ::Qiniu::RS.upload_file(opts)
86
+ unless ::Qiniu.upload_file(opts)
87
87
  raise Paperclip::Qiniu::UploadFailed
88
88
  end
89
89
  end
@@ -15,6 +15,6 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Paperclip::Qiniu::VERSION
17
17
  gem.add_dependency 'paperclip'
18
- gem.add_dependency 'qiniu-rs', '~> 3.0'
18
+ gem.add_dependency 'qiniu', '~> 6.4.1'
19
19
  gem.add_development_dependency 'rspec'
20
20
  end
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-qiniu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - LI Daobing
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-09-06 00:00:00.000000000 Z
11
+ date: 2015-02-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: paperclip
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
- name: qiniu-rs
28
+ name: qiniu
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: '3.0'
33
+ version: 6.4.1
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: '3.0'
40
+ version: 6.4.1
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description: paperclip plugin for qiniu
@@ -66,8 +59,8 @@ executables: []
66
59
  extensions: []
67
60
  extra_rdoc_files: []
68
61
  files:
69
- - .gitignore
70
- - .rspec
62
+ - ".gitignore"
63
+ - ".rspec"
71
64
  - Gemfile
72
65
  - Gemfile.lock
73
66
  - LICENSE
@@ -85,29 +78,27 @@ files:
85
78
  - spec/spec_helper.rb
86
79
  homepage: https://github.com/lidaobing/paperclip-qiniu
87
80
  licenses: []
81
+ metadata: {}
88
82
  post_install_message:
89
83
  rdoc_options: []
90
84
  require_paths:
91
85
  - lib
92
86
  required_ruby_version: !ruby/object:Gem::Requirement
93
- none: false
94
87
  requirements:
95
- - - ! '>='
88
+ - - ">="
96
89
  - !ruby/object:Gem::Version
97
90
  version: '0'
98
91
  required_rubygems_version: !ruby/object:Gem::Requirement
99
- none: false
100
92
  requirements:
101
- - - ! '>='
93
+ - - ">="
102
94
  - !ruby/object:Gem::Version
103
95
  version: '0'
104
96
  requirements: []
105
97
  rubyforge_project:
106
- rubygems_version: 1.8.23
98
+ rubygems_version: 2.4.2
107
99
  signing_key:
108
- specification_version: 3
100
+ specification_version: 4
109
101
  summary: paperclip plugin for qiniu
110
102
  test_files:
111
103
  - spec/lib/paperclip/storage/qiniu_spec.rb
112
104
  - spec/spec_helper.rb
113
- has_rdoc: