Skip to content

Commit fd8e0bb

Browse files
authored
hotfix: 0.2.1
2 parents 1b0ec45 + 5f47860 commit fd8e0bb

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
<h1 style="font-weight:normal">
33
<a href="https://sourcerer.io"><img src=https://user-images.githubusercontent.com/20287615/34189346-d426d4c2-e4ef-11e7-9da4-cc76a1ed111d.png alt="Sourcerer Logo", width=50></a>
4-
sourcerer.io
4+
&nbsp; sourcerer.io
55
</h1>
6-
An intelligent profile for software engineers
6+
An intelligent profile for software engineers. Start with your public GitHub at <a href="https://sourcerer.io/start">https://sourcerer.io/start</a>.
77
<br>
88

99
What is it?
@@ -22,8 +22,11 @@ news that is relevant to your code, engineers to follow and learn from,
2222
technology and libraries you should know about, projects
2323
that could use your help.
2424

25-
Both open source and closed source repos are fine. Sourcerer app does not upload
26-
source code anywhere, and it never will. The app looks at repos locally on your
25+
Both open source and closed source repos are fine. The easiest way to get started with open source repos is to go to
26+
<https://sourcerer.io/start>, and select GitHub. For closed source repos, you can
27+
use this Sourcerer app. You will still need an account, which you can get at <https://sourcerer.io/>
28+
29+
Sourcerer app does not upload source code anywhere, and it never will. The app looks at repos locally on your
2730
machine, and then sends stats to sourcerer.io. The best way to verify is to
2831
look at the code. [src/main/proto/sourcerer.proto](https://github.com/sourcerer-io/sourcerer-app/blob/develop/src/main/proto/sourcerer.proto)
2932
is a good start as it describes the client-server protocol.

src/main/kotlin/app/extractors/Extractor.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Extractor : ExtractorInterface {
1414
val TYPE_KEYWORD = 3
1515
val TYPE_SYNTAX = 4
1616
val SEPARATOR = ">"
17+
val RESTRICTED_EXTS = listOf(".min.js")
1718
}
1819

1920
fun create(extension: String): ExtractorInterface {
@@ -36,6 +37,7 @@ class Extractor : ExtractorInterface {
3637

3738
override fun extract(files: List<DiffFile>): List<CommitStats> {
3839
return files.groupBy { file -> file.extension }
40+
.filter { (extension, _) -> !RESTRICTED_EXTS.contains(extension) }
3941
.map { (extension, files) -> create(extension).extract(files) }
4042
.fold(mutableListOf()) { accStats, stats ->
4143
accStats.addAll(stats)

src/main/kotlin/app/extractors/JavascriptExtractor.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,19 @@ class JavascriptExtractor : ExtractorInterface {
2323
}
2424

2525
override fun extractImports(fileContent: List<String>): List<String> {
26-
val imports = mutableSetOf<String>()
27-
2826
val splitRegex =
2927
Regex("""\s+|,|;|:|\*|\n|\(|\)|\\[|]|\{|}|\+|=|\.|>|<|#|@|\$""")
30-
val twoOrMoreWordsRegex = Regex("""(".+?\s.+?[^"]*"|'.+?\s.+?[^']*')""")
31-
val fileTokens = twoOrMoreWordsRegex.replace(fileContent.joinToString(separator = " ").toLowerCase(), "")
32-
.split(splitRegex)
28+
val twoOrMoreWordsRegex = Regex("""(".+?\s.+?"|'.+?\s.+?')""")
3329

34-
imports.addAll(fileTokens.filter { token -> token in LIBRARIES })
30+
val line = fileContent.joinToString(separator = " ").toLowerCase()
31+
val fileTokens = twoOrMoreWordsRegex.replace(line, "").split(splitRegex)
3532

36-
return imports.toList()
33+
return fileTokens.filter { token -> token in LIBRARIES }.distinct()
3734
}
3835

3936
override fun getLineLibraries(line: String,
4037
fileLibraries: List<String>): List<String> {
41-
42-
return super.getLineLibraries(line, fileLibraries, evaluator, LANGUAGE_NAME)
38+
return super.getLineLibraries(line, fileLibraries, evaluator,
39+
LANGUAGE_NAME)
4340
}
4441
}

src/main/kotlin/app/utils/FileHelper.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ object FileHelper {
1717
private val jarPath = getJarPath()
1818
private val settingsPath = jarPath.resolve(dirName)
1919

20+
private val specificExts = listOf(".min.js")
21+
2022
fun getPath(name: String, vararg parts: String): Path {
2123
val path = settingsPath.resolve(Paths.get("", *parts))
2224
if (Files.notExists(path)) {
@@ -34,7 +36,12 @@ object FileHelper {
3436
}
3537

3638
fun getFileExtension(path: String): String {
37-
val fileName = Paths.get(path).fileName.toString()
39+
val fileName = Paths.get(path).fileName.toString().toLowerCase()
40+
for (ext in specificExts) {
41+
if (fileName.endsWith(ext)) {
42+
return ext
43+
}
44+
}
3845
return fileName.substringAfterLast(delimiter = '.',
3946
missingDelimiterValue = "")
4047
}

0 commit comments

Comments
 (0)