browse-everything 0.5.1 → 0.5.2
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.
- checksums.yaml +8 -8
- data/HISTORY.md +3 -0
- data/app/helpers/browse_everything_helper.rb +24 -1
- data/lib/browse_everything/version.rb +1 -1
- data/spec/unit/browse_everything_helper_spec.rb +40 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2UyMTc2ZWFhNGRhNjAxYzgwNzI1YTkzMjgyNTVjOGUwMThjZTEyZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjRiNTM4NDhlZTlmMWE0ODQ4ZDM1ODJhN2I3Mzc3OGY0MmI4OTE3Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmMwMjVjNjFmM2Q5ZmVmMTdjYzVlZWI1MzQ2MWM5M2RjNTc0YmMxNjAzYmYw
|
10
|
+
NDIzNTQ3NDA2MDQwM2IzODc3ZDQ2OTg0NDczMWJmMTgyYzQ3ZmU3NzQyZDBj
|
11
|
+
YTg4NTQyNDBlMzk2YjFkNGZmMjVlMzc3YWQ1NGM0ZDZhNGI1YWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmQ1NmNkYzcyZDM3NmE0ZTlmNTY1ODkxZGFlZWIxMjhkYmYxNjE1YmM4ODVm
|
14
|
+
ZDFmYTYyZDI1NGQ0MmZmNDIyZDRjY2E0Y2QxOWRkYmUwNzAzZjAzNjJiMmFl
|
15
|
+
MDBiYzg4NWQ2OGVhYTIxMGFjYTIyODRiMzg5OTMwODQyNTJmNzE=
|
data/HISTORY.md
CHANGED
@@ -8,10 +8,33 @@ module BrowseEverythingHelper
|
|
8
8
|
fields.join("\n").html_safe
|
9
9
|
end
|
10
10
|
|
11
|
+
# Extracted from Rack::Mime 1.5.2 for use with earlier versions
|
12
|
+
# of Rack/Rails
|
13
|
+
def mime_match?(value, matcher)
|
14
|
+
v1, v2 = value.split('/', 2)
|
15
|
+
m1, m2 = matcher.split('/', 2)
|
16
|
+
|
17
|
+
if m1 == '*'
|
18
|
+
if m2.nil? || m2 == '*'
|
19
|
+
return true
|
20
|
+
elsif m2 == v2
|
21
|
+
return true
|
22
|
+
else
|
23
|
+
return false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
return false if v1 != m1
|
28
|
+
|
29
|
+
return true if m2.nil? || m2 == '*'
|
30
|
+
|
31
|
+
m2 == v2
|
32
|
+
end
|
33
|
+
|
11
34
|
def is_acceptable?(file)
|
12
35
|
acceptable = params[:accept] || '*/*'
|
13
36
|
acceptable_types = acceptable.split(/,\s*/)
|
14
37
|
acceptable_types << 'application/x-directory'
|
15
|
-
acceptable_types.any? { |type|
|
38
|
+
acceptable_types.any? { |type| mime_match?(file.type, type) }
|
16
39
|
end
|
17
40
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.expand_path('../../spec_helper',__FILE__)
|
2
|
+
|
3
|
+
describe BrowseEverythingHelper do
|
4
|
+
|
5
|
+
let(:test_class) {
|
6
|
+
Class.new do
|
7
|
+
include BrowseEverythingHelper
|
8
|
+
attr_reader :params
|
9
|
+
def initialize params
|
10
|
+
@params = params
|
11
|
+
end
|
12
|
+
end
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:test_file) { BrowseEverything::FileEntry.new 0, '/path/to/file.mp4', 'file.mp4', 12345, Time.now, false }
|
16
|
+
|
17
|
+
it "should match a full type" do
|
18
|
+
expect(test_class.new(accept: 'video/mp4').is_acceptable?(test_file)).to eq(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should match a wildcard type" do
|
22
|
+
expect(test_class.new(accept: 'video/*').is_acceptable?(test_file)).to eq(true)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should not match the wrong full type" do
|
26
|
+
expect(test_class.new(accept: 'video/mpeg').is_acceptable?(test_file)).to eq(false)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should not match the wrong wildcard type" do
|
30
|
+
expect(test_class.new(accept: 'audio/*').is_acceptable?(test_file)).to eq(false)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should match a type list" do
|
34
|
+
expect(test_class.new(accept: 'audio/*, video/mp4').is_acceptable?(test_file)).to eq(true)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should not match the wrong type list" do
|
38
|
+
expect(test_class.new(accept: 'audio/*, application/json').is_acceptable?(test_file)).to eq(false)
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: browse-everything
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carolyn Cole
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2014-07-
|
16
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: rails
|
@@ -363,6 +363,7 @@ files:
|
|
363
363
|
- spec/support/app/views/file_handler/main.html.erb
|
364
364
|
- spec/support/lib/generators/test_app_generator.rb
|
365
365
|
- spec/unit/base_spec.rb
|
366
|
+
- spec/unit/browse_everything_helper_spec.rb
|
366
367
|
- spec/unit/browser_spec.rb
|
367
368
|
- spec/unit/drop_box_spec.rb
|
368
369
|
- spec/unit/file_entry_spec.rb
|
@@ -411,6 +412,7 @@ test_files:
|
|
411
412
|
- spec/support/app/views/file_handler/main.html.erb
|
412
413
|
- spec/support/lib/generators/test_app_generator.rb
|
413
414
|
- spec/unit/base_spec.rb
|
415
|
+
- spec/unit/browse_everything_helper_spec.rb
|
414
416
|
- spec/unit/browser_spec.rb
|
415
417
|
- spec/unit/drop_box_spec.rb
|
416
418
|
- spec/unit/file_entry_spec.rb
|