pantoglot 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/bin/pantoglot +12 -0
- data/lib/pantoglot.rb +55 -0
- data/lib/pantoglot/version.rb +3 -0
- metadata +94 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e6c33e6511a2afa41a36985a32ee2c34ee01cc9f
|
4
|
+
data.tar.gz: 1b8fb12c8b88549511592ab816250e167f1b5d86
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b0c1aadc204b1f8cfefd1f46af74fb03d0bac748b1aa6ed13fdf61c601009b49438ff1d94f20e3fbd7960e6a8bad8ce64d74c832ccc4288598c48786c3a0da11
|
7
|
+
data.tar.gz: f7a72519a0afb0b9d431bddbadfad0c2815bc41ea1104b446a22161993bc047b36113cf5ada06ab6a67f93eda6b1b9772f4cf050081932694ac6d0f3b0c43d8f
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright © 2018 Jon Adams
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/bin/pantoglot
ADDED
data/lib/pantoglot.rb
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require "pantoglot/version"
|
2
|
+
require 'linguist'
|
3
|
+
|
4
|
+
module Pantoglot
|
5
|
+
extend self
|
6
|
+
def process(path)
|
7
|
+
if File.file?(path)
|
8
|
+
return Pantoglot.analyze(path)
|
9
|
+
end
|
10
|
+
loc = 0
|
11
|
+
sloc = 0
|
12
|
+
children = []
|
13
|
+
Dir.foreach(path) do |name|
|
14
|
+
# Skip . and ..
|
15
|
+
next if name == '.' || name == '..' || name == '.git'
|
16
|
+
fullpath = path + '/' + name
|
17
|
+
if File.directory?(fullpath)
|
18
|
+
child = Pantoglot.process(fullpath)
|
19
|
+
elsif File.file?(fullpath)
|
20
|
+
child = Pantoglot.analyze(fullpath)
|
21
|
+
next if child == nil
|
22
|
+
end
|
23
|
+
loc = loc + child[:loc]
|
24
|
+
sloc = sloc + child[:sloc]
|
25
|
+
children << child
|
26
|
+
end
|
27
|
+
tree = {
|
28
|
+
name: File.basename(path),
|
29
|
+
path: path,
|
30
|
+
type: 'directory',
|
31
|
+
loc: loc,
|
32
|
+
sloc: sloc,
|
33
|
+
children: children
|
34
|
+
}
|
35
|
+
end
|
36
|
+
def analyze(path)
|
37
|
+
blob = Linguist::FileBlob.new(path, Dir.pwd)
|
38
|
+
return nil if blob.symlink?
|
39
|
+
# Skip non-Text
|
40
|
+
return nil if !blob.text?
|
41
|
+
# Skip when language not detectable
|
42
|
+
return nil if !blob.language
|
43
|
+
analysis = {
|
44
|
+
name: blob.name,
|
45
|
+
path: blob.path,
|
46
|
+
language: blob.language,
|
47
|
+
loc: blob.loc ? blob.loc : 0,
|
48
|
+
sloc: blob.sloc ? blob.sloc : 0,
|
49
|
+
size: blob.size ? blob.size : 0,
|
50
|
+
vendored: blob.vendored?,
|
51
|
+
generated: blob.generated?,
|
52
|
+
documentation: blob.documentation?
|
53
|
+
}
|
54
|
+
end
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pantoglot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jon Adams
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: github-linguist
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 6.0.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.16'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Given a path to a file or directory, excluding `.git` and its contents,
|
56
|
+
symlinks, and any non-text files, attempt to identify the language and calculate
|
57
|
+
the LOC/SLOC using Linguist and output results in JSON.
|
58
|
+
email:
|
59
|
+
- jon@kuokoa.studio
|
60
|
+
executables:
|
61
|
+
- pantoglot
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- LICENSE
|
66
|
+
- bin/pantoglot
|
67
|
+
- lib/pantoglot.rb
|
68
|
+
- lib/pantoglot/version.rb
|
69
|
+
homepage: https://github.com/daetal-us/pantoglot
|
70
|
+
licenses:
|
71
|
+
- MIT
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements: []
|
88
|
+
rubyforge_project:
|
89
|
+
rubygems_version: 2.5.2
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: Analyze source code language, LOC and SLOC breakdown for a given filetree
|
93
|
+
or file.
|
94
|
+
test_files: []
|