paperclip_mogilefs_storage_ennder 0.9.5
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.
- data/.bnsignore +18 -0
- data/.directory +3 -0
- data/History.txt +4 -0
- data/README.md +75 -0
- data/Rakefile +17 -0
- data/bin/.directory +3 -0
- data/bin/paperclip_mogilefs_storage_ennder +7 -0
- data/lib/.directory +3 -0
- data/lib/paperclip_mogilefs_storage_ennder.rb +65 -0
- data/lib/paperclip_mogilefs_storage_ennder/.directory +3 -0
- data/lib/paperclip_mogilefs_storage_ennder/mogilefsconnect.rb +27 -0
- data/lib/paperclip_mogilefs_storage_ennder/paperclip_attachment.rb +21 -0
- data/spec/paperclip_mogilefs_storage_ennder_spec.rb +6 -0
- data/spec/spec_helper.rb +15 -0
- data/test/.directory +3 -0
- data/test/test_paperclip_mogilefs_storage_ennder.rb +0 -0
- data/version.txt +1 -0
- metadata +107 -0
data/.bnsignore
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# The list of files that should be ignored by Mr Bones.
|
2
|
+
# Lines that start with '#' are comments.
|
3
|
+
#
|
4
|
+
# A .gitignore file can be used instead by setting it as the ignore
|
5
|
+
# file in your Rakefile:
|
6
|
+
#
|
7
|
+
# Bones {
|
8
|
+
# ignore_file '.gitignore'
|
9
|
+
# }
|
10
|
+
#
|
11
|
+
# For a project with a C extension, the following would be a good set of
|
12
|
+
# exclude patterns (uncomment them if you want to use them):
|
13
|
+
# *.[oa]
|
14
|
+
# *~
|
15
|
+
announcement.txt
|
16
|
+
coverage
|
17
|
+
doc
|
18
|
+
pkg
|
data/.directory
ADDED
data/History.txt
ADDED
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
paperclip_mogilefs_storage_ennder
|
2
|
+
===========
|
3
|
+
|
4
|
+
Modifies the support of a Mogilefs server to store the images with the Paperclip Plugin :
|
5
|
+
To get the url of the images on the Mogilefs server
|
6
|
+
|
7
|
+
Features
|
8
|
+
--------
|
9
|
+
|
10
|
+
Adds the hablity to get the url of the images on the Mogilefs server
|
11
|
+
Paperclip
|
12
|
+
Mogilefs
|
13
|
+
Paperclip_mogilefs_storage Plugin (https://github.com/dekart/paperclip_mogilefs_storage)
|
14
|
+
|
15
|
+
Examples
|
16
|
+
--------
|
17
|
+
|
18
|
+
Given Model a model and image the name choiced for its attachment,
|
19
|
+
the url on the mogilefs server of the image is :
|
20
|
+
Model.image.mogilefs_url(style)
|
21
|
+
|
22
|
+
Requirements
|
23
|
+
------------
|
24
|
+
|
25
|
+
Paperclip Gem
|
26
|
+
Mogilefs-client Gem
|
27
|
+
|
28
|
+
A functionnal Mogilefs Server
|
29
|
+
|
30
|
+
Paperclip_mogilefs_storage Plugin (https://github.com/dekart/paperclip_mogilefs_storage)
|
31
|
+
|
32
|
+
Install
|
33
|
+
-------
|
34
|
+
|
35
|
+
[sudo] gem install paperclip_mogilefs_storage_ennder
|
36
|
+
|
37
|
+
Author
|
38
|
+
------
|
39
|
+
|
40
|
+
Original author: Ennder
|
41
|
+
|
42
|
+
Contributors:
|
43
|
+
Joris Trooster (trooster@interstroom.nl)
|
44
|
+
This Gem was made from his Plugin on Github (https://github.com/trooster/paperclip_mogilefs_storage),
|
45
|
+
Thas seems to do not work as of 2011/01/14)
|
46
|
+
|
47
|
+
Which is a fork of Alexey Dmitriev's (rene.dekart@gmail.com) Plugin :
|
48
|
+
https://github.com/dekart/paperclip_mogilefs_storage
|
49
|
+
|
50
|
+
|
51
|
+
License
|
52
|
+
-------
|
53
|
+
|
54
|
+
(The MIT License)
|
55
|
+
|
56
|
+
Copyright (c) 2011 Ennder
|
57
|
+
|
58
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
59
|
+
a copy of this software and associated documentation files (the
|
60
|
+
'Software'), to deal in the Software without restriction, including
|
61
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
62
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
63
|
+
permit persons to whom the Software is furnished to do so, subject to
|
64
|
+
the following conditions:
|
65
|
+
|
66
|
+
The above copyright notice and this permission notice shall be
|
67
|
+
included in all copies or substantial portions of the Software.
|
68
|
+
|
69
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
70
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
71
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
72
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
73
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
74
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
75
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
begin
|
3
|
+
require 'bones'
|
4
|
+
rescue LoadError
|
5
|
+
abort '### Please install the "bones" gem ###'
|
6
|
+
end
|
7
|
+
|
8
|
+
task :default => 'test:run'
|
9
|
+
task 'gem:release' => 'test:run'
|
10
|
+
|
11
|
+
Bones {
|
12
|
+
name 'paperclip_mogilefs_storage_ennder'
|
13
|
+
authors 'Ennder'
|
14
|
+
email 'mel@ennder.fr'
|
15
|
+
url 'http://www.ennder.fr'
|
16
|
+
}
|
17
|
+
|
data/bin/.directory
ADDED
data/lib/.directory
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
|
2
|
+
module PaperclipMogilefsStorageEnnder
|
3
|
+
|
4
|
+
# :stopdoc:
|
5
|
+
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
6
|
+
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
7
|
+
# :startdoc:
|
8
|
+
|
9
|
+
# Returns the version string for the library.
|
10
|
+
#
|
11
|
+
def self.version
|
12
|
+
@version ||= File.read(path('version.txt')).strip
|
13
|
+
end
|
14
|
+
|
15
|
+
# Returns the library path for the module. If any arguments are given,
|
16
|
+
# they will be joined to the end of the libray path using
|
17
|
+
# <tt>File.join</tt>.
|
18
|
+
#
|
19
|
+
def self.libpath( *args, &block )
|
20
|
+
rv = args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
|
21
|
+
if block
|
22
|
+
begin
|
23
|
+
$LOAD_PATH.unshift LIBPATH
|
24
|
+
rv = block.call
|
25
|
+
ensure
|
26
|
+
$LOAD_PATH.shift
|
27
|
+
end
|
28
|
+
end
|
29
|
+
return rv
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns the lpath for the module. If any arguments are given,
|
33
|
+
# they will be joined to the end of the path using
|
34
|
+
# <tt>File.join</tt>.
|
35
|
+
#
|
36
|
+
def self.path( *args, &block )
|
37
|
+
rv = args.empty? ? PATH : ::File.join(PATH, args.flatten)
|
38
|
+
if block
|
39
|
+
begin
|
40
|
+
$LOAD_PATH.unshift PATH
|
41
|
+
rv = block.call
|
42
|
+
ensure
|
43
|
+
$LOAD_PATH.shift
|
44
|
+
end
|
45
|
+
end
|
46
|
+
return rv
|
47
|
+
end
|
48
|
+
|
49
|
+
# Utility method used to require all files ending in .rb that lie in the
|
50
|
+
# directory below this file that has the same name as the filename passed
|
51
|
+
# in. Optionally, a specific _directory_ name can be passed in such that
|
52
|
+
# the _filename_ does not have to be equivalent to the directory.
|
53
|
+
#
|
54
|
+
def self.require_all_libs_relative_to( fname, dir = nil )
|
55
|
+
dir ||= ::File.basename(fname, '.*')
|
56
|
+
search_me = ::File.expand_path(
|
57
|
+
::File.join(::File.dirname(fname), dir, '**', '*.rb'))
|
58
|
+
|
59
|
+
Dir.glob(search_me).sort.each {|rb| require rb}
|
60
|
+
end
|
61
|
+
|
62
|
+
end # module PaperclipMogilefsStorageEnnder
|
63
|
+
|
64
|
+
PaperclipMogilefsStorageEnnder.require_all_libs_relative_to(__FILE__)
|
65
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module MogileFSConnect
|
2
|
+
extend self
|
3
|
+
|
4
|
+
# singleton
|
5
|
+
|
6
|
+
def connect_tracker
|
7
|
+
@mogilefs ||= MogileFS::MogileFS.new(connection_params)
|
8
|
+
@mogilefs
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_class
|
12
|
+
@getclass ||= mogilefs_options[:class ]
|
13
|
+
@getclass
|
14
|
+
end
|
15
|
+
|
16
|
+
def connection_params
|
17
|
+
connection_options = mogilefs_options[:connection]
|
18
|
+
connection_params = {:domain => connection_options[:domain.to_s], :hosts => connection_options[:hosts.to_s]}
|
19
|
+
connection_params
|
20
|
+
end
|
21
|
+
|
22
|
+
def mogilefs_options
|
23
|
+
@mogilefs_options ||= YAML.load_file(File.join(Rails.root, "config", "mogilefs.yml"))[RAILS_ENV].symbolize_keys
|
24
|
+
@mogilefs_options
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Paperclip
|
2
|
+
class Attachment
|
3
|
+
|
4
|
+
def mogilefs_url style = default_style
|
5
|
+
mogilefs = MogileFSConnect.connect_tracker
|
6
|
+
url = original_filename.nil? ? interpolate(@default_url, style) : interpolate(@url, style)
|
7
|
+
mogilefs.get_paths(url)[0]
|
8
|
+
rescue MogileFS::Backend::UnknownKeyError
|
9
|
+
Paperclip.logger.error("[paperclip] Error: #{url} not found in MogileFS")
|
10
|
+
end
|
11
|
+
|
12
|
+
def mogilefs_get_paths style = default_style
|
13
|
+
mogilefs = MogileFSConnect.connect_tracker
|
14
|
+
url = original_filename.nil? ? interpolate(@default_url, style) : interpolate(@url, style)
|
15
|
+
mogilefs.get_paths(url)
|
16
|
+
rescue MogileFS::Backend::UnknownKeyError
|
17
|
+
Paperclip.logger.error("[paperclip] Error: #{url} not found in MogileFS")
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
require File.expand_path(
|
3
|
+
File.join(File.dirname(__FILE__), %w[.. lib paperclip_mogilefs_storage_ennder]))
|
4
|
+
|
5
|
+
Spec::Runner.configure do |config|
|
6
|
+
# == Mock Framework
|
7
|
+
#
|
8
|
+
# RSpec uses it's own mocking framework by default. If you prefer to
|
9
|
+
# use mocha, flexmock or RR, uncomment the appropriate line:
|
10
|
+
#
|
11
|
+
# config.mock_with :mocha
|
12
|
+
# config.mock_with :flexmock
|
13
|
+
# config.mock_with :rr
|
14
|
+
end
|
15
|
+
|
data/test/.directory
ADDED
File without changes
|
data/version.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.9.5
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paperclip_mogilefs_storage_ennder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 49
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 9
|
9
|
+
- 5
|
10
|
+
version: 0.9.5
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Ennder
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-14 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: bones
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 27
|
30
|
+
segments:
|
31
|
+
- 3
|
32
|
+
- 5
|
33
|
+
- 4
|
34
|
+
version: 3.5.4
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
description: |-
|
38
|
+
Modifies the support of a Mogilefs server to store the images with the Paperclip Plugin :
|
39
|
+
To get the url of the images on the Mogilefs server
|
40
|
+
email: mel@ennder.fr
|
41
|
+
executables:
|
42
|
+
- .directory
|
43
|
+
- paperclip_mogilefs_storage_ennder
|
44
|
+
extensions: []
|
45
|
+
|
46
|
+
extra_rdoc_files:
|
47
|
+
- History.txt
|
48
|
+
- bin/.directory
|
49
|
+
- bin/paperclip_mogilefs_storage_ennder
|
50
|
+
- lib/.directory
|
51
|
+
- lib/paperclip_mogilefs_storage_ennder/.directory
|
52
|
+
- version.txt
|
53
|
+
files:
|
54
|
+
- .bnsignore
|
55
|
+
- .directory
|
56
|
+
- History.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- bin/.directory
|
60
|
+
- bin/paperclip_mogilefs_storage_ennder
|
61
|
+
- lib/.directory
|
62
|
+
- lib/paperclip_mogilefs_storage_ennder.rb
|
63
|
+
- lib/paperclip_mogilefs_storage_ennder/.directory
|
64
|
+
- lib/paperclip_mogilefs_storage_ennder/mogilefsconnect.rb
|
65
|
+
- lib/paperclip_mogilefs_storage_ennder/paperclip_attachment.rb
|
66
|
+
- spec/paperclip_mogilefs_storage_ennder_spec.rb
|
67
|
+
- spec/spec_helper.rb
|
68
|
+
- test/.directory
|
69
|
+
- test/test_paperclip_mogilefs_storage_ennder.rb
|
70
|
+
- version.txt
|
71
|
+
has_rdoc: true
|
72
|
+
homepage: http://www.ennder.fr
|
73
|
+
licenses: []
|
74
|
+
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options:
|
77
|
+
- --main
|
78
|
+
- README.md
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
version: "0"
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
hash: 3
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
version: "0"
|
99
|
+
requirements: []
|
100
|
+
|
101
|
+
rubyforge_project: paperclip_mogilefs_storage_ennder
|
102
|
+
rubygems_version: 1.3.7
|
103
|
+
signing_key:
|
104
|
+
specification_version: 3
|
105
|
+
summary: "Modifies the support of a Mogilefs server to store the images with the Paperclip Plugin : To get the url of the images on the Mogilefs server"
|
106
|
+
test_files:
|
107
|
+
- test/test_paperclip_mogilefs_storage_ennder.rb
|