fileinfo 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/lib/file_info.rb +1 -1
- data/lib/file_info/version.rb +1 -1
- data/spec/file_info_spec.rb +19 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fcd1fd05aadb34fa3d1aef1668aba25b3aa00065
|
4
|
+
data.tar.gz: ed0deda9b544ad738036ab76e623075fdbee4dcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cf59a46aac29733336c2d45905e99297158c61b098b8fc0b46ee6df9f7a777ff7648207d3610bed6d3aa26802a048e51ff7cabf0c222eaf52d1be2b27c332d3
|
7
|
+
data.tar.gz: 020c7a148b70c453077d1a564477882cb3ca3bb9ce8a1eb49ef76079d8429ea9905c716645df32f12a544c2cadc87c44e907c000d9c341e5f1997908411053c0
|
data/.travis.yml
CHANGED
data/lib/file_info.rb
CHANGED
data/lib/file_info/version.rb
CHANGED
data/spec/file_info_spec.rb
CHANGED
@@ -65,6 +65,21 @@ describe FileInfo do
|
|
65
65
|
expect(FileInfo.parse(isowindows_file.read).encoding).to eq Encoding::ISO_8859_1
|
66
66
|
expect(FileInfo.parse(utf8_file.read).encoding).to eq Encoding::UTF_8
|
67
67
|
end
|
68
|
+
|
69
|
+
context 'when internal encoding is UTF-8 (like Rails forces)' do
|
70
|
+
around do |example|
|
71
|
+
previous_encoding = Encoding.default_internal
|
72
|
+
Encoding.default_internal = Encoding::UTF_8
|
73
|
+
example.run
|
74
|
+
Encoding.default_internal = previous_encoding
|
75
|
+
end
|
76
|
+
|
77
|
+
[Encoding::ASCII_8BIT, Encoding::US_ASCII].each do |encoding|
|
78
|
+
it "accepts #{encoding} characters with no UTF-8 equivalent" do
|
79
|
+
expect { FileInfo.parse("\xFF".force_encoding(encoding)) }.not_to raise_error
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
68
83
|
end
|
69
84
|
|
70
85
|
let(:txt) { FileInfo.parse(FileInfo.parse('Hello, world!')) }
|
@@ -78,7 +93,7 @@ describe FileInfo do
|
|
78
93
|
expect(txt.content_type).to eq 'text/plain; charset=us-ascii'
|
79
94
|
expect(csv.content_type).to eq 'text/plain; charset=utf-8'
|
80
95
|
expect(psd.content_type).to eq 'image/vnd.adobe.photoshop; charset=binary'
|
81
|
-
expect(empty.content_type).to
|
96
|
+
expect(empty.content_type).to match %r{(application|inode)/x-empty; charset=binary}
|
82
97
|
expect(bytes.content_type).to eq 'application/octet-stream; charset=binary'
|
83
98
|
end
|
84
99
|
end
|
@@ -88,7 +103,7 @@ describe FileInfo do
|
|
88
103
|
expect(txt.type).to eq 'text/plain'
|
89
104
|
expect(csv.type).to eq 'text/plain'
|
90
105
|
expect(psd.type).to eq 'image/vnd.adobe.photoshop'
|
91
|
-
expect(empty.type).to
|
106
|
+
expect(empty.type).to match %r{(application|inode)/x-empty}
|
92
107
|
expect(bytes.type).to eq 'application/octet-stream'
|
93
108
|
end
|
94
109
|
end
|
@@ -98,7 +113,7 @@ describe FileInfo do
|
|
98
113
|
expect(txt.media_type).to eq 'text'
|
99
114
|
expect(csv.media_type).to eq 'text'
|
100
115
|
expect(psd.media_type).to eq 'image'
|
101
|
-
expect(empty.media_type).to
|
116
|
+
expect(empty.media_type).to match %r{(application|inode)}
|
102
117
|
expect(bytes.media_type).to eq 'application'
|
103
118
|
end
|
104
119
|
end
|
@@ -124,7 +139,7 @@ describe FileInfo do
|
|
124
139
|
expect(empty.mime_type).to eq nil
|
125
140
|
end
|
126
141
|
|
127
|
-
context 'when "mime-types" gem
|
142
|
+
context 'when "mime-types" gem is not available' do
|
128
143
|
before do
|
129
144
|
MIME.send(:remove_const, :Types)
|
130
145
|
allow_any_instance_of(FileInfo).to receive(:require).with('mime/types').and_raise(LoadError)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fileinfo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafaël Blais Masson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|