languages 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/README.md +8 -0
- data/Rakefile +6 -1
- data/languages.gemspec +1 -0
- data/lib/languages.rb +13 -1
- data/lib/languages/version.rb +1 -1
- data/spec/languages_spec.rb +12 -0
- data/spec/spec_helper.rb +9 -0
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2403c0181519a19d0c8dc3f520f78a09ce78894
|
4
|
+
data.tar.gz: 8ba5c86a239d9224ba36d0418539ff47854e0065
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 472c24b39cfa5fc13445ce691650868f83df596af380bbbc9dead49189ae71549fc0f39c100f0fcf1456340045a440944e27e86cb30f501df5db5544f6e18352
|
7
|
+
data.tar.gz: c78b09847a36ea2250d35d65cb71921643b016742c2a61d777abf390ad328b9b410bb29619ef16ded08540830d26dee5aec5f682e6d68e72ef6177518529e806
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -24,8 +24,16 @@ Or install it yourself as:
|
|
24
24
|
Languages::Language['ruby'] #=> <Languages::Language name=Ruby color=#701516>
|
25
25
|
|
26
26
|
Languages::Language.all #=> [#<Languages::Language name=ActionScript color=#e3491a>, ..]
|
27
|
+
|
28
|
+
Languages::Language.by_extension('.rb') #=> <Languages::Language name=Ruby color=#701516>
|
27
29
|
```
|
28
30
|
|
31
|
+
## Testing
|
32
|
+
|
33
|
+
Run the tests with:
|
34
|
+
|
35
|
+
$ bundle exec rake
|
36
|
+
|
29
37
|
## Contributing
|
30
38
|
|
31
39
|
1. Fork it ( https://github.com/librariesio/languages/fork )
|
data/Rakefile
CHANGED
data/languages.gemspec
CHANGED
data/lib/languages.rb
CHANGED
@@ -11,6 +11,7 @@ module Languages
|
|
11
11
|
@index = {}
|
12
12
|
@name_index = {}
|
13
13
|
@alias_index = {}
|
14
|
+
@extension_index = {}
|
14
15
|
|
15
16
|
# Valid Languages types
|
16
17
|
TYPES = [:data, :markup, :programming, :prose]
|
@@ -24,6 +25,15 @@ module Languages
|
|
24
25
|
all.select { |h| h.type == type }
|
25
26
|
end
|
26
27
|
|
28
|
+
# Detect languages by a specific extension
|
29
|
+
#
|
30
|
+
# extension - An extension for the file (.ruby)
|
31
|
+
#
|
32
|
+
# Returns an array
|
33
|
+
def self.by_extension(extension)
|
34
|
+
@extension_index[extension.downcase]
|
35
|
+
end
|
36
|
+
|
27
37
|
# Internal: Create a new Language object
|
28
38
|
#
|
29
39
|
# attributes - A hash of attributes
|
@@ -56,6 +66,7 @@ module Languages
|
|
56
66
|
raise ArgumentError, "Extension is missing a '.': #{extension.inspect}"
|
57
67
|
end
|
58
68
|
|
69
|
+
@extension_index[extension] ||= []
|
59
70
|
@extension_index[extension] << language
|
60
71
|
end
|
61
72
|
|
@@ -403,7 +414,8 @@ module Languages
|
|
403
414
|
:group_name => options['group'],
|
404
415
|
:searchable => options.fetch('searchable', true),
|
405
416
|
:search_term => options['search_term'],
|
406
|
-
:popular => popular.include?(name)
|
417
|
+
:popular => popular.include?(name),
|
418
|
+
:extensions => options['extensions']
|
407
419
|
)
|
408
420
|
end
|
409
421
|
end
|
data/lib/languages/version.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'languages'
|
3
|
+
|
4
|
+
describe Languages::Language do
|
5
|
+
describe ".by_extension" do
|
6
|
+
it "returns an array of candidate languages by extension" do
|
7
|
+
ruby_language = described_class.find_by_name("Ruby")
|
8
|
+
|
9
|
+
expect(described_class.by_extension('.rb')).to eq([ruby_language])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: languages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Nesbitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: escape_utils
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.3'
|
55
69
|
description: Just the language names, details and colors from github-linguist
|
56
70
|
email:
|
57
71
|
- andrewnez@gmail.com
|
@@ -60,6 +74,7 @@ extensions: []
|
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
62
76
|
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
63
78
|
- CODE_OF_CONDUCT.md
|
64
79
|
- CONTRIBUTING.md
|
65
80
|
- Gemfile
|
@@ -71,6 +86,8 @@ files:
|
|
71
86
|
- lib/languages.yml
|
72
87
|
- lib/languages/version.rb
|
73
88
|
- lib/popular.yml
|
89
|
+
- spec/languages_spec.rb
|
90
|
+
- spec/spec_helper.rb
|
74
91
|
homepage: https://github.com/librariesio/languages
|
75
92
|
licenses:
|
76
93
|
- MIT
|
@@ -95,5 +112,7 @@ rubygems_version: 2.4.8
|
|
95
112
|
signing_key:
|
96
113
|
specification_version: 4
|
97
114
|
summary: GitHub language details and colors
|
98
|
-
test_files:
|
115
|
+
test_files:
|
116
|
+
- spec/languages_spec.rb
|
117
|
+
- spec/spec_helper.rb
|
99
118
|
has_rdoc:
|