Skip to content

Commit 760a4e7

Browse files
authored
Merge pull request #10 from messense/feature/feature-gate-hyper
Feature gate hyper
2 parents 7e3a47b + 66661fd commit 760a4e7

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ repository = "https://github.com/messense/robotparser-rs"
1111
version = "0.6.0"
1212

1313
[dependencies]
14-
hyper = "0.9"
15-
url = "1.1"
14+
url = "1.2"
15+
16+
[dependencies.hyper]
17+
version = "0.9"
18+
optional = true
1619

1720
[dependencies.clippy]
1821
optional = true
1922
version = "^0.*"
2023

2124
[features]
25+
default = ["http"]
26+
http = ["hyper"]
2227
unstable = []

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ environment:
88
# - TARGET: x86_64-pc-windows-msvc
99
# BITS: 64
1010
install:
11-
- ps: Start-FileDownload "http://slproweb.com/download/Win${env:BITS}OpenSSL-1_0_2h.exe"
12-
- Win%BITS%OpenSSL-1_0_2h.exe /SILENT /VERYSILENT /SP- /DIR="C:\OpenSSL"
11+
- ps: Start-FileDownload "http://slproweb.com/download/Win${env:BITS}OpenSSL-1_0_2j.exe"
12+
- Win%BITS%OpenSSL-1_0_2j.exe /SILENT /VERYSILENT /SP- /DIR="C:\OpenSSL"
1313
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe"
1414
- rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
1515
- SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin

src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//!
1717
//! # Examples
1818
//!
19-
//! ```
19+
//! ```ignore
2020
//! extern crate robotparser;
2121
//!
2222
//! use robotparser::RobotFileParser;
@@ -33,19 +33,27 @@
3333
#![cfg_attr(feature="clippy", warn(cyclomatic_complexity))]
3434

3535
extern crate url;
36+
#[cfg(feature = "http")]
3637
extern crate hyper;
3738

39+
#[cfg(feature = "http")]
3840
use std::io::Read;
3941
use std::cell::{Cell, RefCell};
4042
use std::borrow::Cow;
4143
use std::time::{Duration, SystemTime, UNIX_EPOCH};
4244

4345
use url::Url;
46+
47+
#[cfg(feature = "http")]
4448
use hyper::Client;
49+
#[cfg(feature = "http")]
4550
use hyper::header::UserAgent;
51+
#[cfg(feature = "http")]
4652
use hyper::status::StatusCode;
53+
#[cfg(feature = "http")]
4754
use hyper::client::Response;
4855

56+
#[cfg(feature = "http")]
4957
const USER_AGENT: &'static str = "robotparser-rs (https://crates.io/crates/robotparser)";
5058

5159
/// A rule line is a single "Allow:" (allowance==True) or "Disallow:"
@@ -243,6 +251,7 @@ impl<'a> RobotFileParser<'a> {
243251
self.last_checked.set(0i64);
244252
}
245253

254+
#[cfg(feature = "http")]
246255
/// Reads the robots.txt URL and feeds it to the parser.
247256
pub fn read(&self) {
248257
let client = Client::new();
@@ -266,6 +275,7 @@ impl<'a> RobotFileParser<'a> {
266275
}
267276
}
268277

278+
#[cfg(feature = "http")]
269279
/// Reads the HTTP response and feeds it to the parser.
270280
pub fn from_response(&self, response: &mut Response) {
271281
let mut buf = String::new();

tests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ fn test_robots_txt_13() {
213213
robot_test_simple(doc, good, bad);
214214
}
215215

216+
#[cfg(feature = "http")]
216217
#[test]
217218
fn test_robots_txt_read() {
218219
let parser = RobotFileParser::new("http://www.python.org/robots.txt");

0 commit comments

Comments
 (0)