technologist 0.1.0 → 0.2.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 +1 -0
- data/lib/technologist.rb +1 -0
- data/lib/technologist/framework_detector.rb +1 -7
- data/lib/technologist/frameworks.yml +23 -10
- data/lib/technologist/git_repository.rb +33 -12
- data/lib/technologist/rules/directory_presence_rule.rb +9 -0
- data/lib/technologist/rules/file_content_rule.rb +9 -0
- data/lib/technologist/rules/file_presence_rule.rb +9 -0
- data/lib/technologist/rules/gem_rule.rb +13 -0
- data/lib/technologist/rules/rule.rb +9 -0
- data/lib/technologist/version.rb +1 -1
- data/technologist.gemspec +3 -2
- metadata +13 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0702a8fcc2a5cb321b18b1eeecd77fa506acaade
|
4
|
+
data.tar.gz: ee9bae10218646991f9c6368c863a1465b0a79ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bdf9f824a3a4437f7402ad55e1d99713d5bec201eaa8f8a67cace1b6b8457d450856f4ec046ec619ada9f5b5beed05fce252ba32d0323c02f29c6c00096d690
|
7
|
+
data.tar.gz: 971c2070f033c4483813779f786f5c114c60aa437570bc10ed402008df353700db69049934bc88a903979a8e04a14eeacbfcf132a5ba83e3e99a61b564cea012
|
data/.travis.yml
CHANGED
data/lib/technologist.rb
CHANGED
@@ -34,13 +34,7 @@ module Technologist
|
|
34
34
|
begin
|
35
35
|
rules.map do |technology, definition|
|
36
36
|
definition['rules'].map do |rule|
|
37
|
-
|
38
|
-
file_name = rule.first
|
39
|
-
pattern = rule.last
|
40
|
-
# may use single or double quotes
|
41
|
-
pattern = pattern.gsub(/["']/, %q{["']})
|
42
|
-
|
43
|
-
if repository.file_content(file_name) =~ /#{pattern}/
|
37
|
+
if rule.matches?(technology, repository)
|
44
38
|
technology
|
45
39
|
end
|
46
40
|
end
|
@@ -1,26 +1,39 @@
|
|
1
|
-
|
1
|
+
Rails:
|
2
2
|
rules:
|
3
|
-
-
|
4
|
-
primary: Rails
|
3
|
+
- !ruby/object:GemRule {}
|
5
4
|
|
6
|
-
|
5
|
+
Locomotive:
|
7
6
|
rules:
|
8
|
-
-
|
7
|
+
- !ruby/object:GemRule { gem_name: 'locomotivecms_wagon' }
|
8
|
+
primary: Rails
|
9
9
|
|
10
10
|
Magnolia:
|
11
11
|
rules:
|
12
|
-
- pom.xml: <magnoliaVersion>
|
12
|
+
- !ruby/object:FileContentRule { file_name: 'pom.xml', file_content_pattern: '<magnoliaVersion>' }
|
13
13
|
|
14
14
|
Sinatra:
|
15
15
|
rules:
|
16
|
-
- config.ru: run Sinatra::Application
|
17
|
-
-
|
16
|
+
- !ruby/object:FileContentRule { file_name: 'config.ru', file_content_pattern: 'run Sinatra::Application' }
|
17
|
+
- !ruby/object:GemRule {}
|
18
18
|
|
19
19
|
Dashing:
|
20
20
|
rules:
|
21
|
-
-
|
21
|
+
- !ruby/object:GemRule {}
|
22
22
|
primary: Sinatra
|
23
23
|
|
24
24
|
Middleman:
|
25
25
|
rules:
|
26
|
-
-
|
26
|
+
- !ruby/object:GemRule {}
|
27
|
+
|
28
|
+
Meteor:
|
29
|
+
rules:
|
30
|
+
- !ruby/object:DirectoryPresenceRule { directory_name: '.meteor' }
|
31
|
+
|
32
|
+
Spree:
|
33
|
+
rules:
|
34
|
+
- !ruby/object:GemRule { gem_name: 'spree' }
|
35
|
+
primary: Rails
|
36
|
+
|
37
|
+
Wordpress:
|
38
|
+
rules:
|
39
|
+
- !ruby/object:FilePresenceRule { file_name: 'wp-settings.php' }
|
@@ -18,30 +18,51 @@ module Technologist
|
|
18
18
|
#
|
19
19
|
# @return [String] The content of the file or nil if the file cannot be found.
|
20
20
|
def file_content(file_name)
|
21
|
-
file =
|
21
|
+
file = find_blob(file_name)
|
22
22
|
|
23
23
|
file.content if file
|
24
24
|
end
|
25
25
|
|
26
|
-
# Recursively searches for the
|
27
|
-
# in all subdirectories in the repository.
|
26
|
+
# Recursively searches for the blob identified by `blob_name`
|
27
|
+
# in all subdirectories in the repository. A blob is usually either
|
28
|
+
# a file or a directory.
|
28
29
|
#
|
29
|
-
# @param
|
30
|
-
# @param current_tree [Rugged::Tree] the git directory tree in which to look for the
|
30
|
+
# @param blob_name [String] the blob name
|
31
|
+
# @param current_tree [Rugged::Tree] the git directory tree in which to look for the blob.
|
31
32
|
# Defaults to the root tree (see `#root_tree`).
|
32
33
|
#
|
33
|
-
# @return [Rugged::Blob] The
|
34
|
-
def
|
35
|
-
|
34
|
+
# @return [Rugged::Blob] The blob blob or nil if it cannot be found.
|
35
|
+
def find_blob(blob_name, current_tree = root_tree)
|
36
|
+
blob = current_tree[blob_name]
|
36
37
|
|
37
|
-
if
|
38
|
-
repository.lookup(
|
38
|
+
if blob
|
39
|
+
repository.lookup(blob[:oid])
|
39
40
|
else
|
40
41
|
current_tree.each_tree do |sub_tree|
|
41
|
-
|
42
|
-
break
|
42
|
+
blob = find_blob(blob_name, repository.lookup(sub_tree[:oid]))
|
43
|
+
break blob if blob
|
43
44
|
end
|
44
45
|
end
|
45
46
|
end
|
47
|
+
|
48
|
+
# Looks for a directory and returns true when the directory
|
49
|
+
# can be found.
|
50
|
+
#
|
51
|
+
# @param directory_name [String] the directory name
|
52
|
+
#
|
53
|
+
# @return [Boolean] true if the directory can be found.
|
54
|
+
def directory_exists?(directory_name)
|
55
|
+
!!find_blob(directory_name)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Looks for a file and returns true when the file
|
59
|
+
# can be found.
|
60
|
+
#
|
61
|
+
# @param file_name [String] the file name
|
62
|
+
#
|
63
|
+
# @return [Boolean] true if the file can be found.
|
64
|
+
def file_exists?(file_name)
|
65
|
+
!!find_blob(file_name)
|
66
|
+
end
|
46
67
|
end
|
47
68
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'technologist/rules/file_content_rule'
|
2
|
+
|
3
|
+
class GemRule < FileContentRule
|
4
|
+
attr_accessor :gem_name
|
5
|
+
|
6
|
+
def matches?(framework_name, repository)
|
7
|
+
self.file_name = 'Gemfile'
|
8
|
+
self.gem_name ||= framework_name.downcase
|
9
|
+
self.file_content_pattern = /^\s*gem ["']#{gem_name}["']/
|
10
|
+
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
data/lib/technologist/version.rb
CHANGED
data/technologist.gemspec
CHANGED
@@ -10,8 +10,9 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["mail@koffeinfrei.org"]
|
11
11
|
|
12
12
|
spec.summary = %q{Detects the technologies used in a repository.}
|
13
|
-
spec.description = %q{}
|
13
|
+
spec.description = %q{Detects technologies in a repository by applying a set of rules and returning primary and secondary frameworks.}
|
14
14
|
spec.homepage = "https://github.com/github/koffeinfrei/linguist"
|
15
|
+
spec.license = "AGPL-3.0"
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
18
|
spec.bindir = "exe"
|
@@ -22,5 +23,5 @@ Gem::Specification.new do |spec|
|
|
22
23
|
|
23
24
|
spec.add_development_dependency "bundler", "~> 1.7"
|
24
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
-
spec.add_development_dependency "rspec", "~> 3.3
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.3"
|
26
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: technologist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Reigel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rugged
|
@@ -58,15 +58,16 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.3
|
61
|
+
version: '3.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 3.3
|
69
|
-
description:
|
68
|
+
version: '3.3'
|
69
|
+
description: Detects technologies in a repository by applying a set of rules and returning
|
70
|
+
primary and secondary frameworks.
|
70
71
|
email:
|
71
72
|
- mail@koffeinfrei.org
|
72
73
|
executables: []
|
@@ -88,10 +89,16 @@ files:
|
|
88
89
|
- lib/technologist/frameworks.yml
|
89
90
|
- lib/technologist/git_repository.rb
|
90
91
|
- lib/technologist/repository.rb
|
92
|
+
- lib/technologist/rules/directory_presence_rule.rb
|
93
|
+
- lib/technologist/rules/file_content_rule.rb
|
94
|
+
- lib/technologist/rules/file_presence_rule.rb
|
95
|
+
- lib/technologist/rules/gem_rule.rb
|
96
|
+
- lib/technologist/rules/rule.rb
|
91
97
|
- lib/technologist/version.rb
|
92
98
|
- technologist.gemspec
|
93
99
|
homepage: https://github.com/github/koffeinfrei/linguist
|
94
|
-
licenses:
|
100
|
+
licenses:
|
101
|
+
- AGPL-3.0
|
95
102
|
metadata: {}
|
96
103
|
post_install_message:
|
97
104
|
rdoc_options: []
|