fileinfo 0.3.0 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1fd22a80c28289631c040bde751eee82a7b51369
4
- data.tar.gz: 38320adc6dc77ad1e6e38e6d4d1b4c49052da480
3
+ metadata.gz: fcd1fd05aadb34fa3d1aef1668aba25b3aa00065
4
+ data.tar.gz: ed0deda9b544ad738036ab76e623075fdbee4dcb
5
5
  SHA512:
6
- metadata.gz: 24f820540d61e3e613b3c511eb3d5e8cebc7663de1c8828d6b4456a7215835ec7c18e1574411315e8961c0a7b1de2c63f7eddf1654b675a45139a0cf0ac8b59c
7
- data.tar.gz: 2823c8c4c042db5d8b8aecbfffd38b3c552c7c2b20f1300bbddd4aacf5b08ff8139127339fd20d19043d795e1152dc6c3a88f32195aa86ec8f9d2eaf2f466e54
6
+ metadata.gz: 4cf59a46aac29733336c2d45905e99297158c61b098b8fc0b46ee6df9f7a777ff7648207d3610bed6d3aa26802a048e51ff7cabf0c222eaf52d1be2b27c332d3
7
+ data.tar.gz: 020c7a148b70c453077d1a564477882cb3ca3bb9ce8a1eb49ef76079d8429ea9905c716645df32f12a544c2cadc87c44e907c000d9c341e5f1997908411053c0
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
+ - 2.1.2
4
5
  - 2.0.0
5
6
  - 1.9.3
6
7
 
@@ -54,7 +54,7 @@ class FileInfo
54
54
  end
55
55
 
56
56
  def self.parse(content)
57
- file = Tempfile.new(rand.to_s)
57
+ file = Tempfile.new(rand.to_s, encoding: Encoding::ASCII_8BIT)
58
58
  file.write(content)
59
59
  file.rewind
60
60
  new `file --mime --brief #{file.path}`
@@ -1,3 +1,3 @@
1
1
  class FileInfo
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -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 eq 'application/x-empty; charset=binary'
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 eq 'application/x-empty'
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 eq 'application'
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 isn’t available' do
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.3.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-04-10 00:00:00.000000000 Z
11
+ date: 2014-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler