filetype 1.1.0 → 1.2.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
  SHA256:
3
- metadata.gz: 6a2d1ef450a9f562428c44c8350ed9d4662c307aa85221edff8102b575f40b37
4
- data.tar.gz: 54b9014f30175593f3e6522e8c2d8a32566ada42709a711f45db84c144c900e2
3
+ metadata.gz: ea7cc215335d49eb8a449ee4f7896963256396e3dd82808977f946785623cfb5
4
+ data.tar.gz: 62ebd38de6d7f69fea1da86ab071f16dfbb660822ff48cbc6b29f47cd7c03e62
5
5
  SHA512:
6
- metadata.gz: 0cd81175532b4d105a01305a04c2a17b5a7b9674d8fe70986d151aa58f20f50341e8d81decd830319ea3762f46a8959c7b923ff05a209638c631e501d0990035
7
- data.tar.gz: c413be93671a9f96dac2b1c1079b06591508681e2a04e69f0019835367661b649f4d96397fa53c315afa5d8f66e4e70739cac0fb155e1e1b9c14eb1bdf2a3b24
6
+ metadata.gz: d83e7ac6df8cb28b3c3429190fcad96317cde1f82017828305828ffbb389d18524d1b90728685949b0a0d79afbddaa20419a0361604044f9ff375c923086c792
7
+ data.tar.gz: 2da0a3ac276ab6c35e9fef4416616fa36b7d9738eab8ed192100ecdad16d81f7ece94a3e7d8c12710f3990839b8d44873cad66dede620687cb5de7906ae80a90
data/filetype.gemspec CHANGED
@@ -10,8 +10,11 @@ Gem::Specification.new do |s|
10
10
  s.homepage = "http://github.com/injekt/filetype"
11
11
  s.summary = "Find a files type"
12
12
  s.description = "Find a file type according to a filename or extension"
13
+ s.license = "MIT"
13
14
 
14
- s.files = `git ls-files`.split("\n")
15
+ s.files = `git ls-files`.split("\n").reject do |f|
16
+ f.match(%r{^(test|spec|features|\.github)/})
17
+ end
15
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
20
  s.require_paths = ["lib"]
data/lib/filetype.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Filetype
2
2
  module_function
3
3
 
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
 
6
6
  FTYPES = {
7
7
  :actionscript => %w[ as mxml ],
@@ -33,6 +33,7 @@ module Filetype
33
33
  :html => %w[ html xhtml shtml htm ],
34
34
  :java => %w[ java jar ],
35
35
  :js => %w[ js ],
36
+ :json => %w[ json ],
36
37
  :lisp => %w[ lisp lsp ],
37
38
  :lua => %w[ lua ],
38
39
  :make => /\A[Mm]akefile\z/,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filetype
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Jarvis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-13 00:00:00.000000000 Z
11
+ date: 2022-03-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Find a file type according to a filename or extension
14
14
  email:
@@ -24,10 +24,9 @@ files:
24
24
  - Rakefile
25
25
  - filetype.gemspec
26
26
  - lib/filetype.rb
27
- - test/filetype_test.rb
28
- - test/test_helper.rb
29
27
  homepage: http://github.com/injekt/filetype
30
- licenses: []
28
+ licenses:
29
+ - MIT
31
30
  metadata: {}
32
31
  post_install_message:
33
32
  rdoc_options: []
@@ -44,10 +43,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
43
  - !ruby/object:Gem::Version
45
44
  version: '0'
46
45
  requirements: []
47
- rubygems_version: 3.0.3
46
+ rubygems_version: 3.0.3.1
48
47
  signing_key:
49
48
  specification_version: 4
50
49
  summary: Find a files type
51
- test_files:
52
- - test/filetype_test.rb
53
- - test/test_helper.rb
50
+ test_files: []
@@ -1,120 +0,0 @@
1
- require 'test_helper'
2
-
3
- class FileTypeTest < TestCase
4
-
5
- test 'testing all languages with all extensions' do
6
- assert_equal :bundler, Filetype.get('Gemfile')
7
- assert_equal :bundler, Filetype.get('gemfile') # ?
8
- assert_equal :bundler, Filetype.get('Gemfile.lock') # ?
9
- assert_equal :bundler, Filetype.get('gemfile.lock') # ?
10
- assert_equal :make, Filetype.get('Makefile')
11
- assert_equal :make, Filetype.get('makefile')
12
- assert_equal :rake, Filetype.get('Rakefile')
13
- assert_equal :rake, Filetype.get('rakefile')
14
- assert_equal :rake, Filetype.get('Rakefile.rb')
15
-
16
- assert_equal :actionscript, Filetype.get('foo.as')
17
- assert_equal :actionscript, Filetype.get('foo.AS')
18
- assert_equal :actionscript, Filetype.get('foo.mxml')
19
- assert_equal :ada, Filetype.get('foo.ada')
20
- assert_equal :ada, Filetype.get('foo.adb')
21
- assert_equal :ada, Filetype.get('foo.ads')
22
- assert_equal :asm, Filetype.get('foo.asm')
23
- assert_equal :asm, Filetype.get('foo.s')
24
- assert_equal :batch, Filetype.get('foo.bat')
25
- assert_equal :batch, Filetype.get('foo.cmd')
26
- assert_equal :c, Filetype.get('foo.c')
27
- assert_equal :c, Filetype.get('foo.h')
28
- assert_equal :clojure, Filetype.get('foo.clj')
29
- assert_equal :cpp, Filetype.get('foo.cpp')
30
- assert_equal :cpp, Filetype.get('foo.cc')
31
- assert_equal :cpp, Filetype.get('foo.cxx')
32
- assert_equal :cpp, Filetype.get('foo.m')
33
- assert_equal :cpp, Filetype.get('foo.hpp')
34
- assert_equal :cpp, Filetype.get('foo.hh')
35
- # assert_equal :cpp, Filetype.get('foo.h') # DUPLICATE
36
- assert_equal :cpp, Filetype.get('foo.hxx')
37
- assert_equal :csharp, Filetype.get('foo.cs')
38
- assert_equal :css, Filetype.get('foo.css')
39
- assert_equal :docker, Filetype.get('Dockerfile')
40
- assert_equal :docker, Filetype.get('Dockerfile.build')
41
- assert_equal :elisp, Filetype.get('foo.el')
42
- assert_equal :epub, Filetype.get('foo.epub')
43
- assert_equal :erb, Filetype.get('foo.rhtml')
44
- assert_equal :erb, Filetype.get('foo.erb')
45
- assert_equal :erlang, Filetype.get('foo.erl')
46
- assert_equal :erlang, Filetype.get('foo.hrl')
47
- assert_equal :go, Filetype.get('foo.go')
48
- assert_equal :groovy, Filetype.get('foo.groovy')
49
- assert_equal :groovy, Filetype.get('foo.gpp')
50
- assert_equal :groovy, Filetype.get('foo.grunit')
51
- assert_equal :groovy, Filetype.get('foo.gtmpl')
52
- assert_equal :haskell, Filetype.get('foo.hs')
53
- assert_equal :haskell, Filetype.get('foo.lhs')
54
- assert_equal :haml, Filetype.get('foo.haml')
55
- assert_equal :html, Filetype.get('foo.html')
56
- assert_equal :html, Filetype.get('foo.xhtml')
57
- assert_equal :html, Filetype.get('foo.shtml')
58
- assert_equal :html, Filetype.get('foo.htm')
59
- assert_equal :java, Filetype.get('foo.java')
60
- assert_equal :java, Filetype.get('foo.jar')
61
- assert_equal :js, Filetype.get('foo.js')
62
- assert_equal :lisp, Filetype.get('foo.lisp')
63
- assert_equal :lisp, Filetype.get('foo.lsp')
64
- assert_equal :lua, Filetype.get('foo.lua')
65
- # assert_equal :objc, Filetype.get('foo.m') # DUPLICATE
66
- # assert_equal :objc, Filetype.get('foo.h') # DUPLICATE
67
- assert_equal :ocaml, Filetype.get('foo.ml')
68
- assert_equal :ocaml, Filetype.get('foo.mli')
69
- assert_equal :perl, Filetype.get('foo.pl')
70
- assert_equal :perl, Filetype.get('foo.pm')
71
- assert_equal :perl, Filetype.get('foo.t')
72
- assert_equal :perl, Filetype.get('foo.pod')
73
- assert_equal :php, Filetype.get('foo.php')
74
- assert_equal :php, Filetype.get('foo.phpt')
75
- assert_equal :php, Filetype.get('foo.phtml')
76
- assert_equal :python, Filetype.get('foo.py')
77
- assert_equal :python, Filetype.get('foo.pyc')
78
- assert_equal :rackup, Filetype.get('foo.ru')
79
- assert_equal :ruby, Filetype.get('foo.rb')
80
- assert_equal :ruby, Filetype.get('foo.rake')
81
- assert_equal :ruby, Filetype.get('foo.rjs')
82
- assert_equal :sass, Filetype.get('foo.sass')
83
- assert_equal :scala, Filetype.get('foo.scala')
84
- assert_equal :scss, Filetype.get('foo.scss')
85
- assert_equal :scheme, Filetype.get('foo.scm')
86
- assert_equal :scheme, Filetype.get('foo.ss')
87
- assert_equal :shell, Filetype.get('foo.sh')
88
- assert_equal :shell, Filetype.get('foo.bash')
89
- assert_equal :shell, Filetype.get('foo.ksh')
90
- assert_equal :shell, Filetype.get('foo.zsh')
91
- assert_equal :shell, Filetype.get('foo.csh')
92
- assert_equal :smalltalk, Filetype.get('foo.st')
93
- assert_equal :sql, Filetype.get('foo.sql')
94
- assert_equal :sql, Filetype.get('foo.ctl')
95
- assert_equal :text, Filetype.get('foo.txt')
96
- assert_equal :toml, Filetype.get('foo.toml')
97
- assert_equal :yaml, Filetype.get('foo.yaml')
98
- assert_equal :yaml, Filetype.get('foo.yml')
99
- assert_equal :xml, Filetype.get('foo.xml')
100
- assert_equal :xml, Filetype.get('foo.dtd')
101
- assert_equal :xsl, Filetype.get('foo.xslt')
102
- assert_equal :xsl, Filetype.get('foo.xsl')
103
- end
104
-
105
- test 'evaluates filetype against file basename' do
106
- assert_equal :c, Filetype.get('dockerfile/foo.h')
107
- assert_equal :sql, Filetype.get('Makefile/blah.sql')
108
- end
109
-
110
- test 'fetching multiple languages of a file name' do
111
- assert_equal [:c, :cpp, :objc], Filetype.all('foo.h')
112
- assert_empty Filetype.all('foo.aahaha')
113
- end
114
-
115
- test 'adding filetypes' do
116
- Filetype.add(:bar, %w/foo bar/)
117
- assert_equal :bar, Filetype.get('hello.foo')
118
- end
119
-
120
- end
data/test/test_helper.rb DELETED
@@ -1,14 +0,0 @@
1
- class TestCase < Minitest::Test
2
- def self.test(name, &block)
3
- test_name = "test_#{name.gsub(/\s+/, '_')}".to_sym
4
- defined = instance_method(test_name) rescue false
5
- raise "#{test_name} is already defined in #{self}" if defined
6
- if block_given?
7
- define_method(test_name, &block)
8
- else
9
- define_method(test_name) do
10
- flunk "No implementation provided for #{name}"
11
- end
12
- end
13
- end
14
- end