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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6eab682f53b09b1c652a9d5a985e4dad0af3512c
4
- data.tar.gz: 2dafd17df4cd6d0bb90c0f139ae6e51ca381ce1c
3
+ metadata.gz: d2403c0181519a19d0c8dc3f520f78a09ce78894
4
+ data.tar.gz: 8ba5c86a239d9224ba36d0418539ff47854e0065
5
5
  SHA512:
6
- metadata.gz: a631589c320ea4ab8000dc2c164afae72e8a4c622c2593f18d17a63f0b36b2fe2473b73dd1274a21e6d220bf26a6f3cbca96e807cc6257ee5434649560d63a91
7
- data.tar.gz: 5ae3eef6de7d49f0d7c004efd157ca5a67e24aed31fffd10da83beedbac9a71443a8bb66c8fe63bbd8cd32530f9784126d5304543c09f6b3c98878d6854e6026
6
+ metadata.gz: 472c24b39cfa5fc13445ce691650868f83df596af380bbbc9dead49189ae71549fc0f39c100f0fcf1456340045a440944e27e86cb30f501df5db5544f6e18352
7
+ data.tar.gz: c78b09847a36ea2250d35d65cb71921643b016742c2a61d777abf390ad328b9b410bb29619ef16ded08540830d26dee5aec5f682e6d68e72ef6177518529e806
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
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
@@ -1,2 +1,7 @@
1
- require "bundler/gem_tasks"
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
2
4
 
5
+ RSpec::Core::RakeTask.new('spec')
6
+
7
+ task default: :spec
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.8"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 3.3"
25
26
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Languages
2
- VERSION = "1.2.2"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -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
@@ -0,0 +1,9 @@
1
+ RSpec.configure do |config|
2
+ config.expect_with :rspec do |expectations|
3
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
4
+ end
5
+
6
+ config.mock_with :rspec do |mocks|
7
+ mocks.verify_partial_doubles = true
8
+ end
9
+ end
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.2.2
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-21 00:00:00.000000000 Z
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: