mingle-storage 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/lib/storage/s3_store.rb +95 -2
  3. data/lib/storage.rb +13 -102
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTliODIxMzIzMDNmMTYzOTNmNmZiOWEyYTY5YmEwMTUwNDVkZjAyMg==
4
+ Y2MyNTM1YmZiMTJhZDFlMzI0MmE1MzJiOGEzZTQwYTZlZmZmMjFiMA==
5
5
  data.tar.gz: !binary |-
6
- M2UzMGQ5MjNkNTE0MDk0YmIwZmY3Njc3OWU4ZTVlM2U0NDdmNzhlMA==
6
+ YmU0ZmVjMGNlZjQyNzg5YzhkYzNkZjNmNjJiYTE4YjIxOGE5YWE2Yg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NTdjNGFkYjEzODllMzFlNGUyZWM4YzA4ZmJjMDljNmI3MGY5MTYzY2M3NDA1
10
- MTNkYTFmZTMyMjY4ZjkzMWNiNGEwYTY2NzY3Y2UyM2QyNzdhYmU3MmZkNjNk
11
- NzUzZTczZmNmYmZhZWNjNTQ0Nzk5NTI0NjhkMzMzMThiYmI0MzQ=
9
+ Njk5NWRjNGE2Mjg0MGJjM2Y2MDVhNTc3YzUzMjliMDAyY2MxM2IxNDBiYjI2
10
+ MTBmYmRiMTYzNzQ0MDEwYTg4YmQ5ZmQxMjBiYWIwZDg3MDdmNWQ1NDVlZWZh
11
+ NWU5NzI4MzgxOTdiM2UwOGY2MjBlMmJmMWFjNTJmODQ1MjNlN2I=
12
12
  data.tar.gz: !binary |-
13
- OTZkYTEwMzYyZjMwOTZmOGEwYTg1MjgwNzJkMTJiYWY3ZjNhMmI1NTgxMDU2
14
- YTQxZjBlMTNkOTk5NWMwMzI3OWJhM2JhMGY2ZmY0Y2NkMmIzMjZjMmE4OTYx
15
- Njg5YzJlYTQyMWNjYTg0NWFkMDA4ZTYwMDVkYmJmMDI0MmM2ODk=
13
+ NTk5MTM5OWY0MzRlN2EwZDJmM2M1YThjYzIzYzBlM2ZmNThiODhjMWI2YzYw
14
+ MGIxZmM5MDgzYWQzMjQ5YmE1N2VmM2M2YmUyZTA0YzhkMjU1MmRlNjk4MzAy
15
+ M2I2MTlmNTg1MzQ5Y2VhNmQ1OTMwMGM1OWJmNDdmNWFjNjkwOGI=
@@ -3,6 +3,99 @@ module Storage
3
3
 
4
4
  HALF_AN_HOUR = 30 * 60
5
5
 
6
+ CONTENT_TYPES = {
7
+ "html" => "text/html",
8
+ "htm" => "text/html",
9
+ "shtml" => "text/html",
10
+ "css" => "text/css",
11
+ "xml" => "text/xml",
12
+ "gif" => "image/gif",
13
+ "jpeg" => "image/jpeg",
14
+ "jpg" => "image/jpeg",
15
+ "js" => "application/x-javascript",
16
+ "atom" => "application/atom+xml",
17
+ "rss" => "application/rss+xml",
18
+ "json" => "application/json",
19
+ "mml" => "text/mathml",
20
+ "txt" => "text/plain",
21
+ "jad" => "text/vnd.sun.j2me.app-descriptor",
22
+ "wml" => "text/vnd.wap.wml",
23
+ "htc" => "text/x-component",
24
+ "png" => "image/png",
25
+ "tif" => "image/tiff",
26
+ "tiff" => "image/tiff",
27
+ "wbmp" => "image/vnd.wap.wbmp",
28
+ "ico" => "image/x-icon",
29
+ "jng" => "image/x-jng",
30
+ "bmp" => "image/x-ms-bmp",
31
+ "svg" => "image/svg+xml",
32
+ "jar" => "application/java-archive",
33
+ "war" => "application/java-archive",
34
+ "ear" => "application/java-archive",
35
+ "hqx" => "application/mac-binhex40",
36
+ "doc" => "application/msword",
37
+ "pdf" => "application/pdf",
38
+ "ps" => "application/postscript",
39
+ "eps" => "application/postscript",
40
+ "ai" => "application/postscript",
41
+ "rtf" => "application/rtf",
42
+ "xls" => "application/vnd.ms-excel",
43
+ "ppt" => "application/vnd.ms-powerpoint",
44
+ "wmlc" => "application/vnd.wap.wmlc",
45
+ "xhtml" => "application/vnd.wap.xhtml+xml",
46
+ "kml" => "application/vnd.google-earth.kml+xml",
47
+ "kmz" => "application/vnd.google-earth.kmz",
48
+ "7z" => "application/x-7z-compressed",
49
+ "cco" => "application/x-cocoa",
50
+ "jardiff" => "application/x-java-archive-diff",
51
+ "jnlp" => "application/x-java-jnlp-file",
52
+ "run" => "application/x-makeself",
53
+ "pl" => "application/x-perl",
54
+ "pm" => "application/x-perl",
55
+ "prc" => "application/x-pilot",
56
+ "pdb" => "application/x-pilot",
57
+ "rar" => "application/x-rar-compressed",
58
+ "rpm" => "application/x-redhat-package-manager",
59
+ "sea" => "application/x-sea",
60
+ "swf" => "application/x-shockwave-flash",
61
+ "sit" => "application/x-stuffit",
62
+ "tcl" => "application/x-tcl",
63
+ "tk" => "application/x-tcl",
64
+ "der" => "application/x-x509-ca-cert",
65
+ "pem" => "application/x-x509-ca-cert",
66
+ "crt" => "application/x-x509-ca-cert",
67
+ "xpi" => "application/x-xpinstall",
68
+ "zip" => "application/zip",
69
+ "bin" => "application/octet-stream",
70
+ "exe" => "application/octet-stream",
71
+ "dll" => "application/octet-stream",
72
+ "deb" => "application/octet-stream",
73
+ "dmg" => "application/octet-stream",
74
+ "eot" => "application/octet-stream",
75
+ "iso" => "application/octet-stream",
76
+ "img" => "application/octet-stream",
77
+ "msi" => "application/octet-stream",
78
+ "msp" => "application/octet-stream",
79
+ "msm" => "application/octet-stream",
80
+ "mid" => "audio/midi",
81
+ "midi" => "audio/midi",
82
+ "kar" => "audio/midi",
83
+ "mp3" => "audio/mpeg",
84
+ "ra" => "audio/x-realaudio",
85
+ "3gpp" => "video/3gpp",
86
+ "3gp" => "video/3gpp",
87
+ "mpeg" => "video/mpeg",
88
+ "mpg" => "video/mpeg",
89
+ "mov" => "video/quicktime",
90
+ "flv" => "video/x-flv",
91
+ "mng" => "video/x-mng",
92
+ "asx" => "video/x-ms-asf",
93
+ "asf" => "video/x-ms-asf",
94
+ "wmv" => "video/x-ms-wmv",
95
+ "avi" => "video/x-msvideo"
96
+ }
97
+
98
+
6
99
  def initialize(path_prefix, options)
7
100
  @path_prefix = path_prefix
8
101
  @url_expires = options[:url_expires] || HALF_AN_HOUR
@@ -65,7 +158,7 @@ module Storage
65
158
  end
66
159
 
67
160
  def clear
68
- if s3_path.blank?
161
+ if s3_path.nil? || s3_path.empty?
69
162
  bucket.clear
70
163
  else
71
164
  bucket.objects.with_prefix(s3_path).delete_all
@@ -79,7 +172,7 @@ module Storage
79
172
  private
80
173
  def derive_content_type(file_name)
81
174
  file_extension = file_name.split(".").last
82
- Storage::CONTENT_TYPES[file_extension]
175
+ CONTENT_TYPES[file_extension]
83
176
  end
84
177
 
85
178
  def s3
data/lib/storage.rb CHANGED
@@ -4,98 +4,7 @@ require 'storage/filesystem_store.rb'
4
4
  require 'storage/s3_store.rb'
5
5
 
6
6
  module Storage
7
-
8
- CONTENT_TYPES = {
9
- "html" => "text/html",
10
- "htm" => "text/html",
11
- "shtml" => "text/html",
12
- "css" => "text/css",
13
- "xml" => "text/xml",
14
- "gif" => "image/gif",
15
- "jpeg" => "image/jpeg",
16
- "jpg" => "image/jpeg",
17
- "js" => "application/x-javascript",
18
- "atom" => "application/atom+xml",
19
- "rss" => "application/rss+xml",
20
- "json" => "application/json",
21
- "mml" => "text/mathml",
22
- "txt" => "text/plain",
23
- "jad" => "text/vnd.sun.j2me.app-descriptor",
24
- "wml" => "text/vnd.wap.wml",
25
- "htc" => "text/x-component",
26
- "png" => "image/png",
27
- "tif" => "image/tiff",
28
- "tiff" => "image/tiff",
29
- "wbmp" => "image/vnd.wap.wbmp",
30
- "ico" => "image/x-icon",
31
- "jng" => "image/x-jng",
32
- "bmp" => "image/x-ms-bmp",
33
- "svg" => "image/svg+xml",
34
- "jar" => "application/java-archive",
35
- "war" => "application/java-archive",
36
- "ear" => "application/java-archive",
37
- "hqx" => "application/mac-binhex40",
38
- "doc" => "application/msword",
39
- "pdf" => "application/pdf",
40
- "ps" => "application/postscript",
41
- "eps" => "application/postscript",
42
- "ai" => "application/postscript",
43
- "rtf" => "application/rtf",
44
- "xls" => "application/vnd.ms-excel",
45
- "ppt" => "application/vnd.ms-powerpoint",
46
- "wmlc" => "application/vnd.wap.wmlc",
47
- "xhtml" => "application/vnd.wap.xhtml+xml",
48
- "kml" => "application/vnd.google-earth.kml+xml",
49
- "kmz" => "application/vnd.google-earth.kmz",
50
- "7z" => "application/x-7z-compressed",
51
- "cco" => "application/x-cocoa",
52
- "jardiff" => "application/x-java-archive-diff",
53
- "jnlp" => "application/x-java-jnlp-file",
54
- "run" => "application/x-makeself",
55
- "pl" => "application/x-perl",
56
- "pm" => "application/x-perl",
57
- "prc" => "application/x-pilot",
58
- "pdb" => "application/x-pilot",
59
- "rar" => "application/x-rar-compressed",
60
- "rpm" => "application/x-redhat-package-manager",
61
- "sea" => "application/x-sea",
62
- "swf" => "application/x-shockwave-flash",
63
- "sit" => "application/x-stuffit",
64
- "tcl" => "application/x-tcl",
65
- "tk" => "application/x-tcl",
66
- "der" => "application/x-x509-ca-cert",
67
- "pem" => "application/x-x509-ca-cert",
68
- "crt" => "application/x-x509-ca-cert",
69
- "xpi" => "application/x-xpinstall",
70
- "zip" => "application/zip",
71
- "bin" => "application/octet-stream",
72
- "exe" => "application/octet-stream",
73
- "dll" => "application/octet-stream",
74
- "deb" => "application/octet-stream",
75
- "dmg" => "application/octet-stream",
76
- "eot" => "application/octet-stream",
77
- "iso" => "application/octet-stream",
78
- "img" => "application/octet-stream",
79
- "msi" => "application/octet-stream",
80
- "msp" => "application/octet-stream",
81
- "msm" => "application/octet-stream",
82
- "mid" => "audio/midi",
83
- "midi" => "audio/midi",
84
- "kar" => "audio/midi",
85
- "mp3" => "audio/mpeg",
86
- "ra" => "audio/x-realaudio",
87
- "3gpp" => "video/3gpp",
88
- "3gp" => "video/3gpp",
89
- "mpeg" => "video/mpeg",
90
- "mpg" => "video/mpeg",
91
- "mov" => "video/quicktime",
92
- "flv" => "video/x-flv",
93
- "mng" => "video/x-mng",
94
- "asx" => "video/x-ms-asf",
95
- "asf" => "video/x-ms-asf",
96
- "wmv" => "video/x-ms-wmv",
97
- "avi" => "video/x-msvideo"
98
- }
7
+ @@store_classes = {}
99
8
 
100
9
  class Builder
101
10
  def initialize(type)
@@ -103,16 +12,7 @@ module Storage
103
12
  end
104
13
 
105
14
  def build(path_prefix, options={})
106
- store_class.new(path_prefix, options)
107
- end
108
-
109
- private
110
-
111
- def store_class
112
- {
113
- :filesystem => Storage::FilesystemStore,
114
- :s3 => Storage::S3Store
115
- }[@type.to_sym]
15
+ Storage.store_class_for(@type).new(path_prefix, options)
116
16
  end
117
17
  end
118
18
 
@@ -121,4 +21,15 @@ module Storage
121
21
  builder.build(path_prefix, options)
122
22
  end
123
23
 
24
+ def self.add_store_class(label, clazz)
25
+ @@store_classes[label.to_sym] = clazz
26
+ end
27
+
28
+ def self.store_class_for(label)
29
+ @@store_classes[label.to_sym]
30
+ end
31
+
32
+
33
+ add_store_class(:filesystem, Storage::FilesystemStore)
34
+ add_store_class(:s3, Storage::S3Store)
124
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mingle-storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ThoughtWorks Studios