upgrade from ordermap to indexmap

This commit is contained in:
Sam Rijs 2018-02-17 09:31:38 +11:00
parent b93fde6ebc
commit 26d18be9af
7 changed files with 32 additions and 32 deletions

20
Cargo.lock generated
View file

@ -217,6 +217,14 @@ dependencies = [
"tokio-tls 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "indexmap"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "iovec"
version = "0.1.2"
@ -470,14 +478,6 @@ dependencies = [
"unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ordermap"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "percent-encoding"
version = "1.0.1"
@ -679,10 +679,10 @@ dependencies = [
"futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.11.18 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"indexmap 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"maud 0.17.2 (registry+https://github.com/rust-lang/crates.io-index)",
"ordermap 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"relative-path 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"route-recognizer 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"sass-rs 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -957,6 +957,7 @@ dependencies = [
"checksum httparse 1.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2f407128745b78abc95c0ffbe4e5d37427fdc0d45470710cfef8c44522a2e37"
"checksum hyper 0.11.18 (registry+https://github.com/rust-lang/crates.io-index)" = "c4f9b276c87e3fc1902a8bdfcce264c3f7c8a1c35e5e0c946062739f55026664"
"checksum hyper-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c81fa95203e2a6087242c38691a0210f23e9f3f8f944350bd676522132e2985"
"checksum indexmap 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7164c96d6e18ccc3ce43f3dedac996c21a220670a106c275b96ad92110401362"
"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08"
"checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
@ -988,7 +989,6 @@ dependencies = [
"checksum openssl 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "a3605c298474a3aa69de92d21139fb5e2a81688d308262359d85cdd0d12a7985"
"checksum openssl-sys 0.9.25 (registry+https://github.com/rust-lang/crates.io-index)" = "93b3cbfaccf11969aea8c2041bfafc43c81666c1ce673476e19395c92cc77bf4"
"checksum ordered-float 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "58d25b6c0e47b20d05226d288ff434940296e7e2f8b877975da32f862152241f"
"checksum ordermap 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "88fc9d511a8e8d3adc7ba9f4b8f9683a2eface9c14b652ad77f975c4f95c787b"
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"

View file

@ -8,10 +8,10 @@ failure = "0.1.1"
futures = "0.1.18"
hyper = "0.11.15"
hyper-tls = "0.1.2"
indexmap = { version = "0.4.1", features = ["serde-1"] }
lazy_static = "1.0.0"
lru-cache = "0.1.1"
maud = "0.17.2"
ordermap = { version = "0.4.0", features = ["serde-1"] }
relative-path = { version = "0.3.7", features = ["serde"] }
route-recognizer = "0.1.12"
semver = { version = "0.9.0", features = ["serde"] }

View file

@ -2,13 +2,13 @@ use std::collections::HashMap;
use failure::Error;
use relative_path::RelativePathBuf;
use ordermap::map::OrderMap;
use indexmap::IndexMap;
use ::parsers::manifest::parse_manifest_toml;
use ::models::crates::{CrateDep, CrateDeps, CrateName, CrateManifest};
pub struct ManifestCrawlerOutput {
pub crates: OrderMap<CrateName, CrateDeps>
pub crates: IndexMap<CrateName, CrateDeps>
}
pub struct ManifestCrawlerStepOutput {
@ -17,14 +17,14 @@ pub struct ManifestCrawlerStepOutput {
pub struct ManifestCrawler {
manifests: HashMap<RelativePathBuf, CrateManifest>,
leaf_crates: OrderMap<CrateName, CrateDeps>
leaf_crates: IndexMap<CrateName, CrateDeps>
}
impl ManifestCrawler {
pub fn new() -> ManifestCrawler {
ManifestCrawler {
manifests: HashMap::new(),
leaf_crates: OrderMap::new()
leaf_crates: IndexMap::new()
}
}

View file

@ -8,10 +8,10 @@ extern crate badge;
#[macro_use] extern crate futures;
extern crate hyper;
extern crate hyper_tls;
extern crate indexmap;
#[macro_use] extern crate lazy_static;
extern crate lru_cache;
extern crate maud;
extern crate ordermap;
extern crate relative_path;
extern crate route_recognizer;
extern crate semver;

View file

@ -2,7 +2,7 @@ use std::borrow::Borrow;
use std::str::FromStr;
use failure::Error;
use ordermap::OrderMap;
use indexmap::IndexMap;
use relative_path::RelativePathBuf;
use semver::{Version, VersionReq};
@ -84,9 +84,9 @@ impl CrateDep {
#[derive(Clone, Debug, Default)]
pub struct CrateDeps {
pub main: OrderMap<CrateName, CrateDep>,
pub dev: OrderMap<CrateName, CrateDep>,
pub build: OrderMap<CrateName, CrateDep>
pub main: IndexMap<CrateName, CrateDep>,
pub dev: IndexMap<CrateName, CrateDep>,
pub build: IndexMap<CrateName, CrateDep>
}
#[derive(Debug)]
@ -112,9 +112,9 @@ impl AnalyzedDependency {
#[derive(Debug)]
pub struct AnalyzedDependencies {
pub main: OrderMap<CrateName, AnalyzedDependency>,
pub dev: OrderMap<CrateName, AnalyzedDependency>,
pub build: OrderMap<CrateName, AnalyzedDependency>
pub main: IndexMap<CrateName, AnalyzedDependency>,
pub dev: IndexMap<CrateName, AnalyzedDependency>,
pub build: IndexMap<CrateName, AnalyzedDependency>
}
impl AnalyzedDependencies {

View file

@ -1,5 +1,5 @@
use failure::Error;
use ordermap::OrderMap;
use indexmap::IndexMap;
use relative_path::RelativePathBuf;
use semver::VersionReq;
use toml;
@ -38,13 +38,13 @@ struct CargoToml {
#[serde(default)]
workspace: Option<CargoTomlWorkspace>,
#[serde(default)]
dependencies: OrderMap<String, CargoTomlDependency>,
dependencies: IndexMap<String, CargoTomlDependency>,
#[serde(rename = "dev-dependencies")]
#[serde(default)]
dev_dependencies: OrderMap<String, CargoTomlDependency>,
dev_dependencies: IndexMap<String, CargoTomlDependency>,
#[serde(rename = "build-dependencies")]
#[serde(default)]
build_dependencies: OrderMap<String, CargoTomlDependency>
build_dependencies: IndexMap<String, CargoTomlDependency>
}
fn convert_dependency(cargo_dep: (String, CargoTomlDependency)) -> Option<Result<(CrateName, CrateDep), Error>> {
@ -86,11 +86,11 @@ pub fn parse_manifest_toml(input: &str) -> Result<CrateManifest, Error> {
let crate_name = package.name.parse::<CrateName>()?;
let dependencies = cargo_toml.dependencies
.into_iter().filter_map(convert_dependency).collect::<Result<OrderMap<_, _>, _>>()?;
.into_iter().filter_map(convert_dependency).collect::<Result<IndexMap<_, _>, _>>()?;
let dev_dependencies = cargo_toml.dev_dependencies
.into_iter().filter_map(convert_dependency).collect::<Result<OrderMap<_, _>, _>>()?;
.into_iter().filter_map(convert_dependency).collect::<Result<IndexMap<_, _>, _>>()?;
let build_dependencies = cargo_toml.build_dependencies
.into_iter().filter_map(convert_dependency).collect::<Result<OrderMap<_, _>, _>>()?;
.into_iter().filter_map(convert_dependency).collect::<Result<IndexMap<_, _>, _>>()?;
let deps = CrateDeps {
main: dependencies,

View file

@ -1,6 +1,6 @@
use hyper::Response;
use maud::{Markup, html};
use ordermap::OrderMap;
use indexmap::IndexMap;
use ::engine::AnalyzeDependenciesOutcome;
use ::models::crates::{CrateName, AnalyzedDependency, AnalyzedDependencies};
@ -34,7 +34,7 @@ fn dependency_tables(crate_name: CrateName, deps: AnalyzedDependencies) -> Marku
}
}
fn dependency_table(title: &str, deps: OrderMap<CrateName, AnalyzedDependency>) -> Markup {
fn dependency_table(title: &str, deps: IndexMap<CrateName, AnalyzedDependency>) -> Markup {
let count_total = deps.len();
let count_outdated = deps.iter().filter(|&(_, dep)| dep.is_outdated()).count();