filetype 0.3.2 → 1.0.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 +4 -4
- data/lib/filetype.rb +3 -1
- data/test/filetype_test.rb +5 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a56c7ff8c99578de57f5c70bc4e29e14f163839860edbfb9064e89d6c32d88a
|
4
|
+
data.tar.gz: 877cc1dc0f8584fb0e824914af1d2e2ac08f15efc66ed085d23b8ff989b39a74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7f2b4bfb8ebb254c827303f7faa7cae1e590e7262f426f9ed0fc0ba46404c5d8fb25b32edd5adafb2dd3464f70750b3dcb59280064541f7230295410a56e3ef
|
7
|
+
data.tar.gz: cb5f20e546c4ce6cb3337b4ba9f5915630c9d1a1f769ce41a6f9024795df22c053792b5ec05dfb91e230c40a17f56603c0c123c1958660d919cc84bc656ad4c6
|
data/lib/filetype.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Filetype
|
2
2
|
module_function
|
3
3
|
|
4
|
-
VERSION = '0.
|
4
|
+
VERSION = '1.0.0'
|
5
5
|
|
6
6
|
FTYPES = {
|
7
7
|
:actionscript => %w[ as mxml ],
|
@@ -70,6 +70,7 @@ module Filetype
|
|
70
70
|
# Filetype.get('Rakefile') #=> :rake
|
71
71
|
# @return [Symbol] The language found or nil
|
72
72
|
def get(fname)
|
73
|
+
fname = File.basename(fname)
|
73
74
|
FTYPES.each do |ftype, rule|
|
74
75
|
case rule
|
75
76
|
when Array
|
@@ -90,6 +91,7 @@ module Filetype
|
|
90
91
|
# Filetype.all('foo.h') #=> [:c, :cpp, :objc]
|
91
92
|
# @return [Array] The list of languages found
|
92
93
|
def all(fname)
|
94
|
+
fname = File.basename(fname)
|
93
95
|
FTYPES.select do |ftype, rule|
|
94
96
|
ftype if rule.is_a?(Array) && rule.include?(ext(fname))
|
95
97
|
end.keys
|
data/test/filetype_test.rb
CHANGED
@@ -101,6 +101,11 @@ class FileTypeTest < TestCase
|
|
101
101
|
assert_equal :xsl, Filetype.get('foo.xsl')
|
102
102
|
end
|
103
103
|
|
104
|
+
test 'evaluates filetype against file basename' do
|
105
|
+
assert_equal :c, Filetype.get('dockerfile/foo.h')
|
106
|
+
assert_equal :sql, Filetype.get('Makefile/blah.sql')
|
107
|
+
end
|
108
|
+
|
104
109
|
test 'fetching multiple languages of a file name' do
|
105
110
|
assert_equal [:c, :cpp, :objc], Filetype.all('foo.h')
|
106
111
|
assert_empty Filetype.all('foo.aahaha')
|