el_finder_s3 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +12 -0
- data/.gitignore +36 -0
- data/.travis.yml +4 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +37 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/el_finder_s3.gemspec +36 -0
- data/lib/el_finder_s3.rb +14 -0
- data/lib/el_finder_s3/action.rb +32 -0
- data/lib/el_finder_s3/adapter.rb +222 -0
- data/lib/el_finder_s3/base64.rb +24 -0
- data/lib/el_finder_s3/cache_connector.rb +27 -0
- data/lib/el_finder_s3/connector.rb +676 -0
- data/lib/el_finder_s3/image.rb +30 -0
- data/lib/el_finder_s3/mime_type.rb +83 -0
- data/lib/el_finder_s3/pathname.rb +250 -0
- data/lib/el_finder_s3/railties.rb +7 -0
- data/lib/el_finder_s3/s3_connector.rb +89 -0
- data/lib/el_finder_s3/s3_pathname.rb +179 -0
- data/lib/el_finder_s3/version.rb +3 -0
- metadata +126 -0
@@ -0,0 +1,179 @@
|
|
1
|
+
module ElFinderS3
|
2
|
+
class S3Pathname < Pathname
|
3
|
+
attr_reader :adapter
|
4
|
+
|
5
|
+
def initialize(adapter, list_entry_or_name, attrs = {})
|
6
|
+
@adapter = adapter
|
7
|
+
|
8
|
+
if list_entry_or_name.is_a? ElFinderS3::S3Pathname
|
9
|
+
super(list_entry_or_name.to_s)
|
10
|
+
self.attrs = list_entry_or_name.attrs
|
11
|
+
elsif list_entry_or_name.is_a? Aws::S3::Types::Object
|
12
|
+
super(list_entry_or_name[:key])
|
13
|
+
@size = list_entry_or_name[:size]
|
14
|
+
@type = :file
|
15
|
+
elsif list_entry_or_name.is_a? Aws::S3::Types::CommonPrefix
|
16
|
+
name = list_entry_or_name[:prefix]
|
17
|
+
super(name)
|
18
|
+
@size = 0
|
19
|
+
@type = :directory
|
20
|
+
else
|
21
|
+
super(list_entry_or_name)
|
22
|
+
self.attrs = attrs
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def +(other)
|
27
|
+
other = S3Pathname.new(adapter, other) unless S3Pathname === other
|
28
|
+
S3Pathname.new(adapter, plus(@path, other.to_s), other.attrs)
|
29
|
+
end
|
30
|
+
|
31
|
+
def attrs
|
32
|
+
{
|
33
|
+
type: @type,
|
34
|
+
time: @time,
|
35
|
+
size: @size
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def attrs=(val)
|
40
|
+
@time = val[:time]
|
41
|
+
@type = val[:type]
|
42
|
+
@size = val[:size]
|
43
|
+
end
|
44
|
+
|
45
|
+
def atime
|
46
|
+
mtime
|
47
|
+
end
|
48
|
+
|
49
|
+
def ctime
|
50
|
+
mtime
|
51
|
+
end
|
52
|
+
|
53
|
+
def mtime
|
54
|
+
@time ||= adapter.mtime(self)
|
55
|
+
end
|
56
|
+
|
57
|
+
def cleanpath
|
58
|
+
self
|
59
|
+
end
|
60
|
+
|
61
|
+
def exist?
|
62
|
+
adapter.exist?(self)
|
63
|
+
end
|
64
|
+
|
65
|
+
def directory?
|
66
|
+
type == :directory
|
67
|
+
end
|
68
|
+
|
69
|
+
def readable?
|
70
|
+
true
|
71
|
+
end
|
72
|
+
|
73
|
+
def writable?
|
74
|
+
true
|
75
|
+
end
|
76
|
+
|
77
|
+
def symlink?
|
78
|
+
false
|
79
|
+
end
|
80
|
+
|
81
|
+
def file?
|
82
|
+
type == :file
|
83
|
+
end
|
84
|
+
|
85
|
+
def realpath
|
86
|
+
self
|
87
|
+
end
|
88
|
+
|
89
|
+
def ftype
|
90
|
+
type.to_s
|
91
|
+
end
|
92
|
+
|
93
|
+
def type
|
94
|
+
@type ||= adapter.path_type(self)
|
95
|
+
end
|
96
|
+
|
97
|
+
def size
|
98
|
+
unless @type == :directory
|
99
|
+
@size ||= adapter.size(self)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def touch
|
104
|
+
adapter.touch(self)
|
105
|
+
end
|
106
|
+
|
107
|
+
def rename(to)
|
108
|
+
adapter.rename(self, to)
|
109
|
+
end
|
110
|
+
|
111
|
+
def mkdir
|
112
|
+
adapter.mkdir(self)
|
113
|
+
@type = :directory
|
114
|
+
@size = 0
|
115
|
+
end
|
116
|
+
|
117
|
+
def rmdir
|
118
|
+
adapter.rmdir(self)
|
119
|
+
end
|
120
|
+
|
121
|
+
def unlink
|
122
|
+
adapter.delete(self)
|
123
|
+
end
|
124
|
+
|
125
|
+
def read
|
126
|
+
adapter.retrieve(self)
|
127
|
+
end
|
128
|
+
|
129
|
+
def write(content)
|
130
|
+
adapter.store(self, content)
|
131
|
+
@size = nil
|
132
|
+
end
|
133
|
+
|
134
|
+
def executable?
|
135
|
+
false
|
136
|
+
end
|
137
|
+
|
138
|
+
def to_prefix_s
|
139
|
+
prefix_s = cleanpath.to_s
|
140
|
+
if prefix_s == '/'
|
141
|
+
return ''
|
142
|
+
elsif prefix_s[0] == '/'
|
143
|
+
prefix_s[0] = ''
|
144
|
+
end
|
145
|
+
|
146
|
+
if prefix_s[prefix_s.size-1] != '/'
|
147
|
+
prefix_s = prefix_s + '/'
|
148
|
+
end
|
149
|
+
prefix_s
|
150
|
+
end
|
151
|
+
|
152
|
+
def to_file_prefix_s
|
153
|
+
result = to_prefix_s
|
154
|
+
result[-1] = '' unless result[-1] != '/'
|
155
|
+
result
|
156
|
+
end
|
157
|
+
|
158
|
+
def pipe?
|
159
|
+
false
|
160
|
+
end
|
161
|
+
|
162
|
+
# These methods are part of the base class, but need to be handled specially
|
163
|
+
# since they return new instances of this class
|
164
|
+
# The code below unwraps the pathname, invokces the original method on it,
|
165
|
+
# and then wraps the result into a new, properly constructed instance of this class
|
166
|
+
{
|
167
|
+
'dirname' => {:args => '(*args)'},
|
168
|
+
'basename' => {:args => '(*args)'},
|
169
|
+
'cleanpath' => {:args => '(*args)'},
|
170
|
+
}.each_pair do |meth, opts|
|
171
|
+
class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
172
|
+
def #{meth}#{opts[:args]}
|
173
|
+
v = ::Pathname.new(self.to_s).#{meth}#{opts[:args]}
|
174
|
+
self.class.new(@adapter, v.to_s)
|
175
|
+
end
|
176
|
+
METHOD
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: el_finder_s3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Raúl Anatol
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aws-sdk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: net-ftp-list
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: Ruby gem to provide server side connector to elFinder using AWS S3 like
|
70
|
+
a container
|
71
|
+
email:
|
72
|
+
- raul@natol.es
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".editorconfig"
|
78
|
+
- ".gitignore"
|
79
|
+
- ".travis.yml"
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- el_finder_s3.gemspec
|
87
|
+
- lib/el_finder_s3.rb
|
88
|
+
- lib/el_finder_s3/action.rb
|
89
|
+
- lib/el_finder_s3/adapter.rb
|
90
|
+
- lib/el_finder_s3/base64.rb
|
91
|
+
- lib/el_finder_s3/cache_connector.rb
|
92
|
+
- lib/el_finder_s3/connector.rb
|
93
|
+
- lib/el_finder_s3/image.rb
|
94
|
+
- lib/el_finder_s3/mime_type.rb
|
95
|
+
- lib/el_finder_s3/pathname.rb
|
96
|
+
- lib/el_finder_s3/railties.rb
|
97
|
+
- lib/el_finder_s3/s3_connector.rb
|
98
|
+
- lib/el_finder_s3/s3_pathname.rb
|
99
|
+
- lib/el_finder_s3/version.rb
|
100
|
+
homepage: https://github.com/raulanatol/el_finder_s3
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata:
|
104
|
+
allowed_push_host: https://rubygems.org
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.4.8
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: elFinder server side connector for Ruby, with an S3 aws service.
|
125
|
+
test_files: []
|
126
|
+
has_rdoc:
|