Code style
This commit is contained in:
parent
bf74ebb7db
commit
2230a702a4
7 changed files with 45 additions and 31 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
// rustfmt
|
// rustfmt
|
||||||
|
|
||||||
#![deny(fat_ptr_transmutes,
|
#![deny(trivial_numeric_casts, unsafe_code,
|
||||||
trivial_numeric_casts, unsafe_code,
|
|
||||||
unstable_features, unused_extern_crates,
|
unstable_features, unused_extern_crates,
|
||||||
unused_import_braces, unused_qualifications,
|
unused_import_braces, unused_qualifications,
|
||||||
variant_size_differences
|
variant_size_differences
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ impl<R: SymbolRunner> SymbolRunner for NonRepeatingSymbolRunner<R> {
|
||||||
for resource in resources {
|
for resource in resources {
|
||||||
if !done.contains(&resource) {
|
if !done.contains(&resource) {
|
||||||
has_to_run = true;
|
has_to_run = true;
|
||||||
done.insert(resource.clone());
|
assert!(done.insert(resource.clone()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !has_to_run {
|
if !has_to_run {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use std::borrow::{Borrow, Cow};
|
use std::borrow::Cow;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ use symbols::{Action, OwnedSymbolAction, SymbolAction, SymbolRunner, Symbol};
|
||||||
use symbols::acme::AcmeAccountKey;
|
use symbols::acme::AcmeAccountKey;
|
||||||
use symbols::dir::Dir;
|
use symbols::dir::Dir;
|
||||||
use symbols::file::File;
|
use symbols::file::File;
|
||||||
use symbols::hook::Hook;
|
|
||||||
use symbols::list::List;
|
use symbols::list::List;
|
||||||
use symbols::owner::Owner;
|
use symbols::owner::Owner;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::io::Error as IoError;
|
|
||||||
|
|
||||||
use command_runner::CommandRunner;
|
use command_runner::CommandRunner;
|
||||||
use resources::Resource;
|
use resources::Resource;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ use regex::Regex;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fs::File as FsFile;
|
use std::fs::File as FsFile;
|
||||||
use std::io::Read;
|
use std::io;
|
||||||
|
use std::io::{BufRead, BufReader};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
|
@ -36,17 +37,29 @@ impl<'a, C, R> Symbol for WordpressPlugin<'a, C, R> where C: Deref<Target=str> +
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
let path = self.get_path().join(self.name.to_string() + ".php");
|
let path = self.get_path().join(self.name.to_string() + ".php");
|
||||||
let mut file = try!(FsFile::open(path));
|
|
||||||
let mut file_content = String::new();
|
|
||||||
try!(file.read_to_string(&mut file_content));
|
|
||||||
let mut version = String::new();
|
let mut version = String::new();
|
||||||
let mut plugin_uri = String::new();
|
let mut plugin_uri = String::new();
|
||||||
let regex = try!(Regex::new("(?m)^(Plugin URI|Version): (.+)$"));
|
match FsFile::open(path) {
|
||||||
for matches in regex.captures_iter(&file_content) {
|
Err(e) => {
|
||||||
if &matches[1] == "Plugin URI" {
|
// Check if file exists
|
||||||
plugin_uri = matches[2].to_string();
|
return if e.kind() == io::ErrorKind::NotFound {
|
||||||
} else {
|
Ok(false)
|
||||||
version = matches[2].to_string();
|
} else {
|
||||||
|
Err(Box::new(e))
|
||||||
|
};
|
||||||
|
},
|
||||||
|
Ok(file) => {
|
||||||
|
let mut reader = BufReader::new(file);
|
||||||
|
let regex = Regex::new("(?m)^(Plugin URI|Version): (.+)$")?;
|
||||||
|
for content in reader.lines() {
|
||||||
|
for matches in regex.captures_iter(&(content?)) {
|
||||||
|
if &matches[1] == "Plugin URI" {
|
||||||
|
plugin_uri = matches[2].to_string();
|
||||||
|
} else {
|
||||||
|
version = matches[2].to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let upstream = try!(self.command_runner.get_output("curl", &["--form", &format!(r###"plugins={{"plugins":{{"{0}/{0}.php":{{"Version":"{1}", "PluginURI":"{2}"}}}}}}"###, self.name, version, plugin_uri), "https://api.wordpress.org/plugins/update-check/1.1/"]));
|
let upstream = try!(self.command_runner.get_output("curl", &["--form", &format!(r###"plugins={{"plugins":{{"{0}/{0}.php":{{"Version":"{1}", "PluginURI":"{2}"}}}}}}"###, self.name, version, plugin_uri), "https://api.wordpress.org/plugins/update-check/1.1/"]));
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use std::error::Error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fs::File as FsFile;
|
use std::fs::File as FsFile;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::Read;
|
use std::io::{BufRead, BufReader};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use command_runner::CommandRunner;
|
use command_runner::CommandRunner;
|
||||||
|
|
@ -52,20 +52,24 @@ impl<'a, C, D, R> Symbol for WordpressTranslation<'a, C, D, R> where C: AsRef<st
|
||||||
let mut newest = String::new();
|
let mut newest = String::new();
|
||||||
let match_date = Regex::new("(?m)^\"PO-Revision-Date: (.+)\\+0000\\\\n\"$").unwrap();
|
let match_date = Regex::new("(?m)^\"PO-Revision-Date: (.+)\\+0000\\\\n\"$").unwrap();
|
||||||
for (_, target) in self.get_pairs() {
|
for (_, target) in self.get_pairs() {
|
||||||
let file = FsFile::open(target.clone());
|
match FsFile::open(target.clone()) {
|
||||||
// Check if file exists
|
Err(e) => {
|
||||||
if let Err(e) = file {
|
// Check if file exists
|
||||||
return if e.kind() == io::ErrorKind::NotFound {
|
return if e.kind() == io::ErrorKind::NotFound {
|
||||||
Ok(false)
|
Ok(false)
|
||||||
} else {
|
} else {
|
||||||
Err(Box::new(e))
|
Err(Box::new(e))
|
||||||
};
|
};
|
||||||
}
|
},
|
||||||
if target.ends_with(".po") {
|
Ok(mut file) => if target.ends_with(".po") {
|
||||||
let mut content = String::new();
|
let mut reader = BufReader::new(file);
|
||||||
try!(file.unwrap().read_to_string(&mut content));
|
for content in reader.lines() {
|
||||||
let file_date = &match_date.captures(&content).unwrap()[1];
|
if let Some(match_result) = match_date.captures(&try!(content)) {
|
||||||
newest = max(newest, file_date.to_string());
|
newest = max(newest, match_result[1].to_string());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let upstream = try!(self.command_runner.get_output("curl", &[&format!("https://api.wordpress.org/core/version-check/1.7/?version={}&locale={}", self.version, self.locale)]));
|
let upstream = try!(self.command_runner.get_output("curl", &[&format!("https://api.wordpress.org/core/version-check/1.7/?version={}&locale={}", self.version, self.locale)]));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue