From 7f2b34b2c3078519de60ba90b354ce95514a17a2 Mon Sep 17 00:00:00 2001 From: Sri Harsha Kappala Date: Fri, 10 Jul 2015 14:47:52 +0530 Subject: [PATCH 1/6] Removed crate dependency & loading issue --- src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index be7d3d0..0d846a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,8 @@ -#![crate_name = "rust-github"] +#![crate_name = "rust_github"] #![crate_type = "rlib"] #![feature(core)] extern crate curl; -extern crate "rustc-serialize" as rustc_serialize; +extern crate rustc_serialize; use client::Client; use users::UserService; @@ -16,7 +16,7 @@ pub struct Github { impl Github { pub fn new() -> Github { let client = Client; - Github { + Github { users: UserService::new(client), repositories: RepositoryService::new(client), } From 5303b581e84ffe27a25b394f3ac037497cd31831 Mon Sep 17 00:00:00 2001 From: Sri Harsha Kappala Date: Mon, 13 Jul 2015 12:03:58 +0530 Subject: [PATCH 2/6] as_slice changed to as_ref --- src/repositories.rs | 4 ++-- src/users.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/repositories.rs b/src/repositories.rs index 373366b..826ec46 100644 --- a/src/repositories.rs +++ b/src/repositories.rs @@ -18,9 +18,9 @@ impl RepositoryService { url.push_str(username); url.push_str("/repos"); - let req = self.client.request(url.as_slice()); + let req = self.client.request(url.as_ref()); - let repos: Vec = json::decode(req.as_slice()).unwrap(); + let repos: Vec = json::decode(req.as_ref()).unwrap(); return repos; } diff --git a/src/users.rs b/src/users.rs index 8a9cc41..b05c807 100644 --- a/src/users.rs +++ b/src/users.rs @@ -17,9 +17,9 @@ impl UserService { let mut url = "https://api.github.com/users/".to_string(); url.push_str(name); - let req = self.client.request(url.as_slice()); + let req = self.client.request(url.as_ref()); - let user: User = json::decode(req.as_slice()).unwrap(); + let user: User = json::decode(req.as_ref()).unwrap(); return user; } From f434c0448aa407552b7658d97e0b3dc0accec48b Mon Sep 17 00:00:00 2001 From: Sri Harsha Kappala Date: Mon, 13 Jul 2015 12:06:21 +0530 Subject: [PATCH 3/6] Implementing Clone and Copy too --- src/client.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client.rs b/src/client.rs index fc0bf03..40c94da 100644 --- a/src/client.rs +++ b/src/client.rs @@ -3,7 +3,7 @@ extern crate curl; use std::str; use curl::http; -#[derive(Copy)] +#[derive(Copy,Clone)] pub struct Client; impl Client { From 33c75d5817bc338650f2da2a44c6f603c0ff0ddc Mon Sep 17 00:00:00 2001 From: Sri Harsha Kappala Date: Mon, 13 Jul 2015 12:07:25 +0530 Subject: [PATCH 4/6] unstable core feature removed from lib --- src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 0d846a9..56d0b2e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ #![crate_name = "rust_github"] #![crate_type = "rlib"] -#![feature(core)] extern crate curl; extern crate rustc_serialize; From 0676872931f678a6b3c2139edf87c389a9e0fe23 Mon Sep 17 00:00:00 2001 From: Sri Harsha Kappala Date: Mon, 13 Jul 2015 12:42:23 +0530 Subject: [PATCH 5/6] Updated README and usage of the crate --- README.md | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 2c25e6b..4072eb9 100644 --- a/README.md +++ b/README.md @@ -4,33 +4,24 @@ Rust based library for interacting with the Github API. This is just a practice ## Examples -### Get a user +### Get User Information & Repositories This request will return a single `github::users::User` struct. ```rust -extern crate "rust-github" as github; - -use github::Github; +extern crate rust_github; +use rust_github::Github; fn main() { let github = Github::new(); - let user = github.users.get("octocat"); + let user = github.users.get("sriharshakappala"); + let repositories = github.repositories.by_user("sriharshakappala"); println!("Name: {:?}", user.name); println!("Email: {:?}", user.email); println!("Location: {:?}", user.location); -} -``` - -### Get all repositories by user - -Get a list of repositories by user, exposes a `Vec`. - -```rust -let github = Github::new(); -let repositories = github.repositories.by_user("octocat"); -for repo in repositories.iter() { - println!("{:?}", repo.name); + for repo in repositories.iter() { + println!("{:?}", repo.name); + } } ``` From 8c18a31c0a39dd08a2b9cb3b86bb8daba86ee746 Mon Sep 17 00:00:00 2001 From: Sri Harsha Kappala Date: Tue, 14 Jul 2015 16:34:19 +0530 Subject: [PATCH 6/6] Generalized readme file --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4072eb9..23d1e63 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ use rust_github::Github; fn main() { let github = Github::new(); let user = github.users.get("sriharshakappala"); - let repositories = github.repositories.by_user("sriharshakappala"); + let repositories = github.repositories.by_user("octocat"); println!("Name: {:?}", user.name); println!("Email: {:?}", user.email); println!("Location: {:?}", user.location);