Rename Project to SourceProject

This commit is contained in:
Lucien Greathouse 2018-06-04 23:28:52 -07:00
parent 204084dcae
commit 6b9367c370
3 changed files with 14 additions and 14 deletions

View file

@ -1,10 +1,10 @@
use std::path::PathBuf; use std::path::PathBuf;
use std::process; use std::process;
use project::Project; use project::SourceProject;
pub fn init(project_path: &PathBuf) { pub fn init(project_path: &PathBuf) {
match Project::init(project_path) { match SourceProject::init(project_path) {
Ok(_) => { Ok(_) => {
println!("Created new empty project at {}", project_path.display()); println!("Created new empty project at {}", project_path.display());
}, },

View file

@ -5,7 +5,7 @@ use std::fs;
use rand; use rand;
use project::Project; use project::SourceProject;
use web; use web;
use session::{Session, SessionConfig}; use session::{Session, SessionConfig};
use partition::Partition; use partition::Partition;
@ -13,7 +13,7 @@ use partition::Partition;
pub fn serve(project_path: &PathBuf, port: Option<u64>) { pub fn serve(project_path: &PathBuf, port: Option<u64>) {
let server_id = rand::random::<u64>(); let server_id = rand::random::<u64>();
let project = match Project::load(project_path) { let project = match SourceProject::load(project_path) {
Ok(v) => { Ok(v) => {
println!("Using project from {}", fs::canonicalize(project_path).unwrap().display()); println!("Using project from {}", fs::canonicalize(project_path).unwrap().display());
v v

View file

@ -63,7 +63,7 @@ impl fmt::Display for ProjectInitError {
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ProjectPartition { pub struct SourceProjectPartition {
/// A slash-separated path to a file or folder, relative to the project's /// A slash-separated path to a file or folder, relative to the project's
/// directory. /// directory.
pub path: String, pub path: String,
@ -79,15 +79,15 @@ pub struct ProjectPartition {
/// configurables /// configurables
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(default, rename_all = "camelCase")] #[serde(default, rename_all = "camelCase")]
pub struct Project { pub struct SourceProject {
pub name: String, pub name: String,
pub serve_port: u64, pub serve_port: u64,
pub partitions: HashMap<String, ProjectPartition>, pub partitions: HashMap<String, SourceProjectPartition>,
} }
impl Project { impl SourceProject {
/// Initializes a new project inside the given folder path. /// Initializes a new project inside the given folder path.
pub fn init<T: AsRef<Path>>(location: T) -> Result<Project, ProjectInitError> { pub fn init<T: AsRef<Path>>(location: T) -> Result<SourceProject, ProjectInitError> {
let location = location.as_ref(); let location = location.as_ref();
let package_path = location.join(PROJECT_FILENAME); let package_path = location.join(PROJECT_FILENAME);
@ -109,7 +109,7 @@ impl Project {
let serve_port = rand::thread_rng().gen_range(2000, 49151); let serve_port = rand::thread_rng().gen_range(2000, 49151);
// Configure the project with all of the values we know so far. // Configure the project with all of the values we know so far.
let project = Project { let project = SourceProject {
name, name,
serve_port, serve_port,
partitions: HashMap::new(), partitions: HashMap::new(),
@ -124,7 +124,7 @@ impl Project {
/// Attempts to load a project from the file named PROJECT_FILENAME from the /// Attempts to load a project from the file named PROJECT_FILENAME from the
/// given folder. /// given folder.
pub fn load<T: AsRef<Path>>(location: T) -> Result<Project, ProjectLoadError> { pub fn load<T: AsRef<Path>>(location: T) -> Result<SourceProject, ProjectLoadError> {
let package_path = location.as_ref().join(Path::new(PROJECT_FILENAME)); let package_path = location.as_ref().join(Path::new(PROJECT_FILENAME));
fs::metadata(&package_path) fs::metadata(&package_path)
@ -157,9 +157,9 @@ impl Project {
} }
} }
impl Default for Project { impl Default for SourceProject {
fn default() -> Project { fn default() -> SourceProject {
Project { SourceProject {
name: "new-project".to_string(), name: "new-project".to_string(),
serve_port: 8000, serve_port: 8000,
partitions: HashMap::new(), partitions: HashMap::new(),