ruby-filemagic 0.6.0 → 0.6.1

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: 1403f497e908d066aeaeb6d235b1b947de376a3f
4
- data.tar.gz: 546e5fa1ac73f1a69ebee0f9347ffc2171ebe65d
3
+ metadata.gz: 8defa2096e9b64ff01af2cb0cdfebfbf25fd8177
4
+ data.tar.gz: 6f3018740cf798e2fa4d54d343e8b4942e71f695
5
5
  SHA512:
6
- metadata.gz: 1ea4401b1fcc93e015d4e7049928bc95381013f4e915f0e3a02ca30476d5f3a0454408b8da9ac875bf62427e6237630ac4cd8db2025347a86dae7ae04a65f004
7
- data.tar.gz: 616165278b30cd859741a4a76dc752b6a798f5ac93951e294e0f4a5aaf228648f977d98899f165ccf28dfcc275cf087e6a7353f90f0511db32cfe4a60a04cde5
6
+ metadata.gz: 8b9ed685e46ac3c6516e95a96cc0ce9eeb1cc07053fa8a697853a6f963cee69e561492cd6e34d1d78b2b310f8eb0d02ea89c523e4da464f80544a21f461169ce
7
+ data.tar.gz: 30f8367ed63c08a609119d6fa0d69fcb904de20210cf1eb3fa598ec8d95dcd8c1916fbca6655e663b530ea4ce45e225bb202ee152c7810e78c1e2cb0e0e9704d
data/ChangeLog CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  = Revision history for ruby-filemagic
4
4
 
5
+ == 0.6.1 [2014-08-19]
6
+
7
+ * Account for options passed to FileMagic.fm (issue #7 reported by Adam
8
+ Wróbel).
9
+
5
10
  == 0.6.0 [2014-05-16]
6
11
 
7
12
  * Required Ruby version >= 1.9.3.
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to filemagic version 0.6.0
5
+ This documentation refers to filemagic version 0.6.1
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -53,11 +53,13 @@ class FileMagic
53
53
 
54
54
  # Provide a "magic singleton".
55
55
  def fm(*flags)
56
- if fm = @fm[flags = flags(flags)]
56
+ options = flags.last.is_a?(Hash) ? flags.pop : {}
57
+
58
+ if fm = @fm[key = [flags = flags(flags), options]]
57
59
  return fm unless fm.closed?
58
60
  end
59
61
 
60
- @fm[flags] = new(flags)
62
+ @fm[key] = new(flags, options)
61
63
  end
62
64
 
63
65
  # Clear our instance cache.
@@ -20,15 +20,13 @@ module FileMagic::Ext
20
20
  end
21
21
 
22
22
  def mime_type(file, *flags)
23
- flags.unshift :mime
24
- file_type(file, *flags)
23
+ file_type(file, *flags.unshift(:mime))
25
24
  end
26
25
 
27
26
  alias_method :mime, :mime_type
28
27
 
29
28
  def content_type(file, *flags)
30
- flags << { :simplified => true }
31
- mime_type(file, *flags)
29
+ mime_type(file, *flags << { simplified: true })
32
30
  end
33
31
 
34
32
  end
@@ -4,7 +4,7 @@ class FileMagic
4
4
 
5
5
  MAJOR = 0
6
6
  MINOR = 6
7
- TINY = 0
7
+ TINY = 1
8
8
 
9
9
  class << self
10
10
 
@@ -160,7 +160,7 @@ magic file from #{FileMagic.path}
160
160
  def test_abbrev_mime_type
161
161
  fm = FileMagic.mime
162
162
 
163
- assert !fm.simplified?
163
+ refute fm.simplified?
164
164
  assert_equal('text/plain; charset=us-ascii', fm.file(path_to('perl')))
165
165
 
166
166
  fm.simplified = true
@@ -173,6 +173,29 @@ magic file from #{FileMagic.path}
173
173
  ), fm.file(path_to('excel-example.xls')))
174
174
  end
175
175
 
176
+ def test_singleton
177
+ fm1 = FileMagic.fm
178
+ assert_equal(fm1, FileMagic.fm)
179
+
180
+ refute fm1.simplified?
181
+ assert_equal('ASCII text', fm1.file(path_to('perl')))
182
+
183
+ fm2 = FileMagic.fm(:mime)
184
+ assert_equal(fm2, FileMagic.fm(:mime))
185
+ refute_equal(fm2, fm1)
186
+
187
+ refute fm2.simplified?
188
+ assert_equal('text/plain; charset=us-ascii', fm2.file(path_to('perl')))
189
+
190
+ fm3 = FileMagic.fm(:mime, simplified: true)
191
+ assert_equal(fm3, FileMagic.fm(:mime, simplified: true))
192
+ refute_equal(fm3, fm2)
193
+ refute_equal(fm3, fm1)
194
+
195
+ assert fm3.simplified?
196
+ assert_equal('text/plain', fm3.file(path_to('perl')))
197
+ end
198
+
176
199
  # utility methods:
177
200
 
178
201
  def path_to(file, dir = File.dirname(__FILE__))
metadata CHANGED
@@ -1,15 +1,36 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-filemagic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Whitton
8
8
  - Jens Wille
9
9
  autorequire:
10
10
  bindir: bin
11
- cert_chain: []
12
- date: 2014-05-16 00:00:00.000000000 Z
11
+ cert_chain:
12
+ - |
13
+ -----BEGIN CERTIFICATE-----
14
+ MIIDMDCCAhigAwIBAgIBADANBgkqhkiG9w0BAQUFADA+MQswCQYDVQQDDAJ3dzEb
15
+ MBkGCgmSJomT8ixkARkWC2JsYWNrd2ludGVyMRIwEAYKCZImiZPyLGQBGRYCZGUw
16
+ HhcNMTMwMTMxMDkyMjIyWhcNMTQwMTMxMDkyMjIyWjA+MQswCQYDVQQDDAJ3dzEb
17
+ MBkGCgmSJomT8ixkARkWC2JsYWNrd2ludGVyMRIwEAYKCZImiZPyLGQBGRYCZGUw
18
+ ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDVXmfa6rbTwKOvtuGoROc1
19
+ I4qZjgLX0BA4WecYB97PjwLJmJ1hRvf9JulVCJYYmt5ZEPPXbgi9xLbcp6ofGmnC
20
+ i68/kbhcz20/fRUtIJ2phU3ypQTEd2pFddpL7SR2FxLkzvvg5E6nslGn7o2erDpO
21
+ 8sm610A3xsgT/eNIr9QA7k4pHh18X1KvZKmmQR4/AjVyKmKawzauKUoHHepjvjVs
22
+ s0pVoM7UmOmrS4SafQ3OwUo37f19CVdN2/FW7z3e5+iYhKxdIFdhniX9iDWtA3Jn
23
+ 7oUOtiolhCRK4P/c30UjTCDkRkOldsWciFUasROJ5VAV2SVv7FtGHoQLDZ/++tRr
24
+ AgMBAAGjOTA3MAkGA1UdEwQCMAAwHQYDVR0OBBYEFIAPWU4BEoYUe82hY/0EkoGd
25
+ Oo/WMAsGA1UdDwQEAwIEsDANBgkqhkiG9w0BAQUFAAOCAQEAf2YnB0mj42of22dA
26
+ MimgJCAEgB3H5aHbZ6B5WVnFvrC2UUnhP+/kLj/6UgOfqcasy4Xh62NVGuNrf7rF
27
+ 7NMN87XwexGuU2GCpIMUd6VCTA7zMP2OWuXEcba7jT5OtiI55buO0J4CRtyeX1XF
28
+ qwlGgx4ItcGhMTlDFXj3IkpeVtjD8O7yWE21bHf9lLURmqK/r9KjoxrrVi7+cESJ
29
+ H19TDW3R9p594jCl1ykPs3dz/0Bk+r1HTd35Yw+yBbyprSJb4S7OcRRHCryuo09l
30
+ NBGyZvOBuqUp0xostWSk0dfxyn/YQ7eqvQRGBhK1VGa7Tg/KYqnemDE57+VOXrua
31
+ 59wzaA==
32
+ -----END CERTIFICATE-----
33
+ date: 2014-08-19 00:00:00.000000000 Z
13
34
  dependencies:
14
35
  - !ruby/object:Gem::Dependency
15
36
  name: hen
@@ -104,21 +125,14 @@ licenses:
104
125
  metadata: {}
105
126
  post_install_message: |2+
106
127
 
107
- ruby-filemagic-0.6.0 [2014-05-16]:
128
+ ruby-filemagic-0.6.1 [2014-08-19]:
108
129
 
109
- * Required Ruby version >= 1.9.3.
110
- * New method FileMagic#list (+magic_list+).
111
- * New method FileMagic#load (+magic_load+).
112
- * New method FileMagic.path (+magic_getpath+).
113
- * New method FileMagic.magic_version.
114
- * New method FileMagic.flags.
115
- * New flag +no_check_builtin+.
116
- * Tests print libmagic version and path.
117
- * Internal refactoring.
130
+ * Account for options passed to FileMagic.fm (issue #7 reported by Adam
131
+ Wróbel).
118
132
 
119
133
  rdoc_options:
120
134
  - "--title"
121
- - ruby-filemagic Application documentation (v0.6.0)
135
+ - ruby-filemagic Application documentation (v0.6.1)
122
136
  - "--charset"
123
137
  - UTF-8
124
138
  - "--line-numbers"
@@ -139,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
153
  version: '0'
140
154
  requirements: []
141
155
  rubyforge_project:
142
- rubygems_version: 2.2.2.x
156
+ rubygems_version: 2.4.1
143
157
  signing_key:
144
158
  specification_version: 4
145
159
  summary: Ruby bindings to the magic(4) library