monkslc / hyperpolyglot Goto Github PK
View Code? Open in Web Editor NEWA fast programming language detector
License: Apache License 2.0
A fast programming language detector
License: Apache License 2.0
tested against:
use std::collections::HashMap;
use std::fmt::{self, Debug, Formatter};
use std::path::{Path, PathBuf};
use crate::core::{Dependency, Package, PackageId, Source, SourceId, Summary};
use crate::sources::PathSource;
use crate::util::errors::CargoResult;
use crate::util::Config;
use anyhow::Context as _;
use cargo_util::{paths, Sha256};
use serde::Deserialize;
pub struct DirectorySource<'cfg> {
source_id: SourceId,
root: PathBuf,
packages: HashMap<PackageId, (Package, Checksum)>,
config: &'cfg Config,
}
#[derive(Deserialize)]
struct Checksum {
package: Option<String>,
files: HashMap<String, String>,
}
impl<'cfg> DirectorySource<'cfg> {
pub fn new(path: &Path, id: SourceId, config: &'cfg Config) -> DirectorySource<'cfg> {
DirectorySource {
source_id: id,
root: path.to_path_buf(),
config,
packages: HashMap::new(),
}
}
}
filename: code
Expected result: Rust
Actual result:
.pm and .pl are not Raku, they're Perl5 exclusive. See the commit message in #8 for more information.
Before patch on Debian's /usr/share/perl5
$ cargo run -- /usr/share/perl5 -sb | grep Raku
Compiling hyperpolyglot v0.1.7 (/tmp/hyperpolyglot)
Finished dev [unoptimized + debuginfo] target(s) in 4.84s
Running `target/debug/hyply /usr/share/perl5 -sb`
0.57% Raku
Raku (10)
/usr/share/perl5/App/cpanminus.pm (Raku)
/usr/share/perl5/Data/Dump/FilterContext.pm (Raku)
/usr/share/perl5/Method/Generate/Accessor.pm (Raku)
/usr/share/perl5/Moo.pm (Raku)
/usr/share/perl5/Date/Language/Amharic.pm (Raku)
/usr/share/perl5/Date/Language/TigrinyaEritrean.pm (Raku)
/usr/share/perl5/Date/Language/TigrinyaEthiopian.pm (Raku)
/usr/share/perl5/LWP/DebugFile.pm (Raku)
/usr/share/perl5/MailTools.pm (Raku)
/usr/share/perl5/stat.pl (Raku)
After patch.
$ cargo run -- /usr/share/perl5
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
Running `target/debug/hyply /usr/share/perl5`
100.00% Perl
For example grab a C file, change its extension to .go
. All github-linguist
, enry
and hyperpolyglot
detect it as a Go source.
If I remove the extension, hyperpolyglot
returns empty.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.