fileinfo 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fcd1fd05aadb34fa3d1aef1668aba25b3aa00065
4
- data.tar.gz: ed0deda9b544ad738036ab76e623075fdbee4dcb
3
+ metadata.gz: ef15eb6d6152498892fa78fa6d4361e6c3d14932
4
+ data.tar.gz: 2313c820cbafacdb9c707966c1a0786554464627
5
5
  SHA512:
6
- metadata.gz: 4cf59a46aac29733336c2d45905e99297158c61b098b8fc0b46ee6df9f7a777ff7648207d3610bed6d3aa26802a048e51ff7cabf0c222eaf52d1be2b27c332d3
7
- data.tar.gz: 020c7a148b70c453077d1a564477882cb3ca3bb9ce8a1eb49ef76079d8429ea9905c716645df32f12a544c2cadc87c44e907c000d9c341e5f1997908411053c0
6
+ metadata.gz: e885d126ade6f5f077b181b24bed9d316e236105a6b15dc22977d297d7f1363388ef4f75cdf7329b6f32b3672b54407d9c4040edc40c543c4f588d676eb3c1ec
7
+ data.tar.gz: 3415d0dfcfd593df5177a6a660fbc0f6b605b5607cb934a4e44f100cbeacf582b1425611758097c5b9d2c33fd0fe4c2cd7dd2cb4ece170da54e75c6e9e14e410
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.1.2
4
+ - 2.1.4
5
5
  - 2.0.0
6
6
  - 1.9.3
7
7
 
@@ -39,7 +39,7 @@ class FileInfo
39
39
  end
40
40
 
41
41
  def charset
42
- @charset ||= content_type.match(CHARSET_REGEX)[1]
42
+ @charset ||= (matches = content_type.match(CHARSET_REGEX)) ? matches[1] : 'binary'
43
43
  end
44
44
 
45
45
  def encoding
@@ -1,3 +1,3 @@
1
1
  class FileInfo
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FileInfo do
4
+ let(:binary_file) { fixture('one_byte.txt') }
4
5
  let(:ascii_file) { fixture('encoding_ascii.csv') }
5
6
  let(:isolatin_file) { fixture('encoding_isolatin.csv') }
6
7
  let(:isowindows_file) { fixture('encoding_isowindows.csv') }
@@ -12,6 +13,7 @@ describe FileInfo do
12
13
 
13
14
  describe '#charset' do
14
15
  it 'returns encoding string' do
16
+ expect(FileInfo.parse('h').charset).to eq 'binary'
15
17
  expect(FileInfo.load(ascii_file.path).charset).to eq 'us-ascii'
16
18
  expect(FileInfo.load(isolatin_file.path).charset).to eq 'iso-8859-1'
17
19
  expect(FileInfo.load(isowindows_file.path).charset).to eq 'iso-8859-1'
@@ -21,6 +23,7 @@ describe FileInfo do
21
23
 
22
24
  describe '#encoding' do
23
25
  it 'returns Encoding instance' do
26
+ expect(FileInfo.load(binary_file.path).encoding).to eq Encoding::BINARY
24
27
  expect(FileInfo.load(ascii_file.path).encoding).to eq Encoding::US_ASCII
25
28
  expect(FileInfo.load(isolatin_file.path).encoding).to eq Encoding::ISO_8859_1
26
29
  expect(FileInfo.load(isowindows_file.path).encoding).to eq Encoding::ISO_8859_1
@@ -0,0 +1 @@
1
+ H
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.0
4
+ version: 0.5.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-07-21 00:00:00.000000000 Z
11
+ date: 2014-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -93,6 +93,7 @@ files:
93
93
  - spec/fixtures/encoding_macroman.csv
94
94
  - spec/fixtures/encoding_utf8.csv
95
95
  - spec/fixtures/mockup.psd
96
+ - spec/fixtures/one_byte.txt
96
97
  - spec/spec_helper.rb
97
98
  homepage: http://github.com/rafBM/fileinfo
98
99
  licenses:
@@ -128,4 +129,5 @@ test_files:
128
129
  - spec/fixtures/encoding_macroman.csv
129
130
  - spec/fixtures/encoding_utf8.csv
130
131
  - spec/fixtures/mockup.psd
132
+ - spec/fixtures/one_byte.txt
131
133
  - spec/spec_helper.rb