Update packages to latest versions

- Users v0.5.1, which renames OSUsers to UsersCache
- Locale v0.2, which returns to libc v0.1
- Datetime v0.4.2, which mimics the locale update, and puts timezone definitions in:
- Zoneinfo-data, which is needed to obtain the current timezone
This commit is contained in:
Ben S 2016-02-10 15:22:43 +00:00
parent e1d2c3f46e
commit 75b2748ab1
5 changed files with 97 additions and 122 deletions

138
Cargo.lock generated
View File

@ -4,19 +4,20 @@ version = "0.4.0"
dependencies = [
"ansi_term 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"datetime 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"datetime 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
"git2 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"locale 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"locale 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"natord 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"number_prefix 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"scoped_threadpool 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"term_grid 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"users 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
"users 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"zoneinfo_data 0.1.0 (git+https://github.com/rust-datetime/zoneinfo-data.git)",
]
[[package]]
@ -28,14 +29,6 @@ dependencies = [
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "aho-corasick"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"memchr 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ansi_term"
version = "0.7.1"
@ -46,35 +39,29 @@ name = "bitflags"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "byteorder"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cmake"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "datetime"
version = "0.4.1"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"locale 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"iso8601 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"locale 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)",
"pad 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.1.47 (registry+https://github.com/rust-lang/crates.io-index)",
"tz 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "gcc"
version = "0.3.21"
version = "0.3.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -100,11 +87,19 @@ version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libgit2-sys 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"libgit2-sys 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
"url 0.2.38 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "iso8601"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"nom 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "kernel32-sys"
version = "0.2.1"
@ -126,19 +121,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.2.5"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libgit2-sys"
version = "0.3.9"
version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cmake 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libssh2-sys 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"libssh2-sys 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
"libz-sys 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -152,13 +147,13 @@ dependencies = [
[[package]]
name = "libssh2-sys"
version = "0.1.34"
version = "0.1.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cmake 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"libz-sys 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"openssl-sys 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -169,14 +164,14 @@ name = "libz-sys"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gcc 0.3.21 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "locale"
version = "0.1.8"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
@ -188,26 +183,23 @@ name = "matches"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "memchr"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "natord"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "nom"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "num"
version = "0.1.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -216,7 +208,7 @@ version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -230,11 +222,11 @@ dependencies = [
[[package]]
name = "openssl-sys"
version = "0.7.4"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"gdi32-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pkg-config 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"user32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -267,33 +259,18 @@ version = "0.3.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex"
version = "0.1.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aho-corasick 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex-syntax"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc-serialize"
version = "0.3.16"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustc_version"
version = "0.1.4"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
@ -304,7 +281,7 @@ name = "scoped_threadpool"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rustc_version 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -328,14 +305,6 @@ dependencies = [
"unicode-width 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "tz"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "unicode-width"
version = "0.1.3"
@ -347,7 +316,7 @@ version = "0.2.38"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -362,10 +331,10 @@ dependencies = [
[[package]]
name = "users"
version = "0.4.4"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -374,7 +343,7 @@ version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand 0.3.13 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@ -396,3 +365,12 @@ dependencies = [
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "zoneinfo_data"
version = "0.1.0"
source = "git+https://github.com/rust-datetime/zoneinfo-data.git#2ad3b0ea2a64676b529c79e9a381ce7fbf43aa94"
dependencies = [
"datetime 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"locale 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

View File

@ -9,18 +9,18 @@ name = "exa"
[dependencies]
ansi_term = "0.7.1"
bitflags = "0.1"
datetime = "0.4.1"
datetime = "0.4.2"
getopts = "0.2.14"
lazy_static = "0.1.*"
libc = "0.2.0"
locale = "0.1.2"
locale = "0.2.0"
natord = "1.0.7"
num_cpus = "0.2.7"
number_prefix = "0.2.3"
scoped_threadpool = "0.1.*"
term_grid = "0.1.2"
unicode-width = "0.1.3"
users = "0.4.3"
users = "0.5.1"
[features]
default = [ "git" ]
@ -34,3 +34,6 @@ lto = true
[dependencies.git2]
version = "0.3.2"
optional = true
[dependencies.zoneinfo_data]
git = "https://github.com/rust-datetime/zoneinfo-data.git"

View File

@ -14,6 +14,7 @@ extern crate scoped_threadpool;
extern crate term_grid;
extern crate unicode_width;
extern crate users;
extern crate zoneinfo_data;
#[cfg(feature="git")] extern crate git2;
#[macro_use] extern crate lazy_static;

View File

@ -71,7 +71,6 @@
//! are used in place of the filename.
use std::error::Error;
use std::io;
use std::ops::Add;
use std::path::PathBuf;
@ -80,13 +79,14 @@ use std::sync::{Arc, Mutex};
use ansi_term::Style;
use datetime::format::DateFormat;
use datetime::local::{LocalDateTime, DatePiece};
use datetime::zoned::TimeZone;
use datetime::fmt::DateFormat;
use datetime::{LocalDateTime, DatePiece};
use datetime::TimeZone;
use zoneinfo_data::ZoneinfoData;
use locale;
use users::{OSUsers, Users, Groups};
use users::{Users, Groups, UsersCache};
use dir::Dir;
use feature::xattr::{Attribute, FileAttributes};
@ -162,14 +162,14 @@ pub struct Environment<U: Users+Groups> {
users: Mutex<U>,
}
impl Default for Environment<OSUsers> {
impl Default for Environment<UsersCache> {
fn default() -> Self {
Environment {
current_year: LocalDateTime::now().year(),
numeric: locale::Numeric::load_user_locale().unwrap_or_else(|_| locale::Numeric::english()),
time: locale::Time::load_user_locale().unwrap_or_else(|_| locale::Time::english()),
tz: TimeZone::localtime().unwrap(),
users: Mutex::new(OSUsers::empty_cache()),
tz: TimeZone::system().expect("Unable to determine time zone"),
users: Mutex::new(UsersCache::new()),
}
}
}
@ -188,7 +188,7 @@ impl Details {
};
// Then, retrieve various environment variables.
let env = Arc::new(Environment::<OSUsers>::default());
let env = Arc::new(Environment::<UsersCache>::default());
// Build the table to put rows in.
let mut table = Table {
@ -577,7 +577,7 @@ impl<'a, U: Users+Groups+'a> Table<'a, U> {
#[allow(trivial_numeric_casts)]
fn render_time(&self, timestamp: f::Time) -> TextCell {
let date = self.env.tz.at(LocalDateTime::at(timestamp.0 as i64));
let date = self.env.tz.to_zoned(LocalDateTime::at(timestamp.0 as i64));
let datestamp = if date.year() == self.env.current_year {
DATE_AND_TIME.format(&date, &self.env.time)
@ -613,7 +613,7 @@ impl<'a, U: Users+Groups+'a> Table<'a, U> {
let user_name = match users.get_user_by_uid(user.0) {
Some(user) => (*user.name).clone(),
Some(user) => user.name().to_owned(),
None => user.0.to_string(),
};
@ -623,6 +623,8 @@ impl<'a, U: Users+Groups+'a> Table<'a, U> {
}
fn render_group(&self, group: f::Group) -> TextCell {
use users::os::unix::GroupExt;
let mut style = self.opts.colours.users.group_not_yours;
let users = self.env.users.lock().unwrap();
@ -633,13 +635,13 @@ impl<'a, U: Users+Groups+'a> Table<'a, U> {
let current_uid = users.get_current_uid();
if let Some(current_user) = users.get_user_by_uid(current_uid) {
if current_user.primary_group == group.gid
|| group.members.contains(&current_user.name) {
if current_user.primary_group_id() == group.gid()
|| group.members().contains(&current_user.name().to_owned()) {
style = self.opts.colours.users.group_yours;
}
}
TextCell::paint(style, (*group.name).clone())
TextCell::paint(style, group.name().to_owned())
}
/// Render the table as a vector of Cells, to be displayed on standard output.
@ -720,6 +722,7 @@ pub mod test {
pub use users::{User, Group, uid_t, gid_t};
pub use users::mock::MockUsers;
pub use users::os::unix::{UserExt, GroupExt};
pub use ansi_term::Style;
pub use ansi_term::Colour::*;
@ -727,7 +730,8 @@ pub mod test {
impl Default for Environment<MockUsers> {
fn default() -> Self {
use locale;
use datetime::zoned::TimeZone;
use datetime::TimeZone;
use zoneinfo_data::ZoneinfoData;
use users::mock::MockUsers;
use std::sync::Mutex;
@ -735,7 +739,7 @@ pub mod test {
current_year: 1234,
numeric: locale::Numeric::english(),
time: locale::Time::english(),
tz: TimeZone::localtime().unwrap(),
tz: TimeZone::system().unwrap(),
users: Mutex::new(MockUsers::with_current_uid(0)),
}
}
@ -752,19 +756,6 @@ pub mod test {
}
}
pub fn newser(uid: uid_t, name: &str, group: gid_t) -> User {
use std::sync::Arc;
User {
uid: uid,
name: Arc::new(name.to_string()),
primary_group: group,
home_dir: String::new(),
shell: String::new(),
}
}
mod users {
#![allow(unused_results)]
use super::*;
@ -779,7 +770,7 @@ pub mod test {
let mut table = new_table(&columns, &details);
let mut users = MockUsers::with_current_uid(1000);
users.add_user(newser(1000, "enoch", 100));
users.add_user(User::new(1000, "enoch", 100));
Arc::get_mut(&mut table.env).unwrap().users = Mutex::new(users);
let user = f::User(1000);
@ -811,7 +802,7 @@ pub mod test {
let table = new_table(&columns, &details);
table.env.users.lock().unwrap().add_user(newser(1000, "enoch", 100));
table.env.users.lock().unwrap().add_user(User::new(1000, "enoch", 100));
let user = f::User(1000);
let expected = TextCell::paint_str(Green.bold(), "enoch");
@ -859,7 +850,7 @@ pub mod test {
let mut table = new_table(&columns, &details);
let mut users = MockUsers::with_current_uid(1000);
users.add_group(Group { gid: 100, name: Arc::new("folk".to_string()), members: vec![] });
users.add_group(Group::new(100, "folk"));
Arc::get_mut(&mut table.env).unwrap().users = Mutex::new(users);
let group = f::Group(100);
@ -892,8 +883,8 @@ pub mod test {
let mut table = new_table(&columns, &details);
let mut users = MockUsers::with_current_uid(2);
users.add_user(newser(2, "eve", 100));
users.add_group(Group { gid: 100, name: Arc::new("folk".to_string()), members: vec![] });
users.add_user(User::new(2, "eve", 100));
users.add_group(Group::new(100, "folk"));
Arc::get_mut(&mut table.env).unwrap().users = Mutex::new(users);
let group = f::Group(100);
@ -910,8 +901,10 @@ pub mod test {
let mut table = new_table(&columns, &details);
let mut users = MockUsers::with_current_uid(2);
users.add_user(newser(2, "eve", 666));
users.add_group(Group { gid: 100, name: Arc::new("folk".to_string()), members: vec![ "eve".to_string() ] });
users.add_user(User::new(2, "eve", 666));
let test_group = Group::new(100, "folk").add_member("eve");
users.add_group(test_group);
Arc::get_mut(&mut table.env).unwrap().users = Mutex::new(users);
let group = f::Group(100);

View File

@ -1,7 +1,7 @@
use std::sync::Arc;
use ansi_term::ANSIStrings;
use users::OSUsers;
use users::UsersCache;
use term_grid as grid;
use dir::Dir;
@ -70,7 +70,7 @@ impl GridDetails {
}
}
fn make_table<'a>(&'a self, env: Arc<Environment<OSUsers>>, columns_for_dir: &'a [Column]) -> Table<OSUsers> {
fn make_table<'a>(&'a self, env: Arc<Environment<UsersCache>>, columns_for_dir: &'a [Column]) -> Table<UsersCache> {
let mut table = Table {
columns: columns_for_dir,
opts: &self.details,
@ -83,7 +83,7 @@ impl GridDetails {
table
}
fn make_grid<'a>(&'a self, env: Arc<Environment<OSUsers>>, column_count: usize, columns_for_dir: &'a [Column], file_names: &[TextCell], cells: Vec<Vec<TextCell>>) -> grid::Grid {
fn make_grid<'a>(&'a self, env: Arc<Environment<UsersCache>>, column_count: usize, columns_for_dir: &'a [Column], file_names: &[TextCell], cells: Vec<Vec<TextCell>>) -> grid::Grid {
let mut tables = Vec::new();
for _ in 0 .. column_count {
tables.push(self.make_table(env.clone(), columns_for_dir));