Skip to content

Commit

Permalink
Merge #5: Rename the package to bencode2json
Browse files Browse the repository at this point in the history
63b33cb chore: add mandatory package attributes (Jose Celano)
875380d chore: rename package to bencode2json (Jose Celano)

Pull request description:

  Rename the package to `bencode2json`.

ACKs for top commit:
  josecelano:
    ACK 63b33cb

Tree-SHA512: 67aa4a0c97522351fb6244e43fe1d8116e8f506788102872bc0f3a123675d0ab063b7ee9a4c927818ee1ebee1ed1d110bb360ec21625a9f2da40c84c8de769a7
  • Loading branch information
josecelano committed Nov 1, 2024
2 parents ac1f13f + 63b33cb commit af9668d
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 37 deletions.
30 changes: 15 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
[package]
authors = ["Jose Celano <[email protected]>", "Cameron Garnham <[email protected]>"]
description = "A Bencoded to JSON converter library and console app with no intermediary in-memory structure."
edition = "2021"
name = "torrust-bencode2json"
exclude = [".*", "cSpell.json", "rustfmt.toml"]
license = "LGPL-3.0"
name = "bencode2json"
repository = "https://github.com/torrust/bencode2json"
version = "0.1.0"

[workspace]
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,21 @@ echo "d3:foold3:bari42eeee" | cargo run | jq
You can install the binary with:

```console
cargo install torrust-bencode2json
cargo install bencode2json
```

Or by using [cargo-binstall](https://github.com/cargo-bins/cargo-binstall):

```console
cargo binstall torrust-bencode2json
cargo binstall bencode2json
```

## Library

You can install the library with:

```console
cargo add torrust-bencode2json
cargo add bencode2json
```

There two ways of using the library:
Expand All @@ -117,7 +117,7 @@ There two ways of using the library:
Example using the high-level parser wrappers:

```rust
use torrust_bencode2json::{try_bencode_to_json};
use bencode2json::{try_bencode_to_json};

let result = try_bencode_to_json(b"d4:spam4:eggse").unwrap();

Expand All @@ -127,7 +127,7 @@ assert_eq!(result, r#"{"spam":"eggs"}"#);
Example using the low-level parser:

```rust
use torrust_bencode2json::parsers::{BencodeParser};
use bencode2json::parsers::{BencodeParser};

let mut output = String::new();

Expand Down
2 changes: 1 addition & 1 deletion examples/parser_file_in_file_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
};

use clap::{Arg, Command};
use torrust_bencode2json::parsers::BencodeParser;
use bencode2json::parsers::BencodeParser;

fn main() {
let matches = Command::new("parser_file_in_file_out")
Expand Down
2 changes: 1 addition & 1 deletion examples/parser_stdin_stdout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//! It prints "spam".
use std::io;

use torrust_bencode2json::parsers::BencodeParser;
use bencode2json::parsers::BencodeParser;

fn main() {
let input = Box::new(io::stdin());
Expand Down
2 changes: 1 addition & 1 deletion examples/parser_string_in_string_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! ```
//!
//! It prints "spam".
use torrust_bencode2json::parsers::BencodeParser;
use bencode2json::parsers::BencodeParser;

fn main() {
let input = "4:spam".to_string();
Expand Down
2 changes: 1 addition & 1 deletion examples/parser_string_in_vec_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! ```
//!
//! It prints "spam".
use torrust_bencode2json::parsers::BencodeParser;
use bencode2json::parsers::BencodeParser;

fn main() {
let input = "4:spam".to_string();
Expand Down
2 changes: 1 addition & 1 deletion examples/parser_vec_in_string_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! ```
//!
//! It prints "spam".
use torrust_bencode2json::parsers::BencodeParser;
use bencode2json::parsers::BencodeParser;

fn main() {
let input = b"4:spam".to_vec();
Expand Down
2 changes: 1 addition & 1 deletion examples/parser_vec_in_vec_out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! ```
//!
//! It prints "spam".
use torrust_bencode2json::parsers::BencodeParser;
use bencode2json::parsers::BencodeParser;

fn main() {
let input = b"4:spam".to_vec();
Expand Down
2 changes: 1 addition & 1 deletion examples/try_bencode_to_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! ```not_rust
//! cargo run --example try_bencode_to_json
//! ```
use torrust_bencode2json::try_bencode_to_json;
use bencode2json::try_bencode_to_json;

fn main() {
let result = try_bencode_to_json(b"d4:spam4:eggse").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! function:
//!
//! ```rust
//! use torrust_bencode2json::{try_bencode_to_json};
//! use bencode2json::{try_bencode_to_json};
//!
//! let result = try_bencode_to_json(b"d4:spam4:eggse").unwrap();
//!
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
//! ```text
//! cargo run -- -i ./tests/fixtures/sample.bencode -o output.json
//! ```
use bencode2json::parsers::BencodeParser;
use clap::{Arg, Command};
use std::fs::File;
use std::io::{self, Read, Write};
use torrust_bencode2json::parsers::BencodeParser;

fn main() {
run();
}

fn run() {
let matches = Command::new("torrust-bencode2json")
let matches = Command::new("bencode2json")
.version("0.1.0")
.author("Torrust Organization")
.about("Converts Bencode to JSON")
Expand Down
12 changes: 6 additions & 6 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod it_should {

#[test]
fn read_from_stdin_and_write_to_stdout() {
let mut cmd = Command::cargo_bin("torrust-bencode2json").unwrap();
let mut cmd = Command::cargo_bin("bencode2json").unwrap();
cmd.write_stdin("4:spam")
.assert()
.success()
Expand All @@ -20,7 +20,7 @@ mod it_should {

let output_file = temp_dir.path().join("output.json");

let mut cmd = Command::cargo_bin("torrust-bencode2json").unwrap();
let mut cmd = Command::cargo_bin("bencode2json").unwrap();

cmd.arg("-i")
.arg("tests/fixtures/sample.bencode")
Expand All @@ -40,7 +40,7 @@ mod it_should {

let output_file = temp_dir.path().join("new_file.json");

let mut cmd = Command::cargo_bin("torrust-bencode2json").unwrap();
let mut cmd = Command::cargo_bin("bencode2json").unwrap();

cmd.arg("-i")
.arg("tests/fixtures/sample.bencode")
Expand All @@ -56,7 +56,7 @@ mod it_should {

#[test]
fn fail_when_the_bencoded_input_is_invalid() {
let mut cmd = Command::cargo_bin("torrust-bencode2json").unwrap();
let mut cmd = Command::cargo_bin("bencode2json").unwrap();
cmd.write_stdin("a")
.assert()
.failure()
Expand All @@ -69,7 +69,7 @@ mod it_should {

let output_file = temp_dir.path().join("output.json");

let mut cmd = Command::cargo_bin("torrust-bencode2json").unwrap();
let mut cmd = Command::cargo_bin("bencode2json").unwrap();

cmd.arg("-i")
.arg("non_existing_file.bencode")
Expand All @@ -85,7 +85,7 @@ mod it_should {

let output_file = temp_dir.path().join("non_existing_dir/new_file.json");

let mut cmd = Command::cargo_bin("torrust-bencode2json").unwrap();
let mut cmd = Command::cargo_bin("bencode2json").unwrap();

cmd.arg("-i")
.arg("tests/fixtures/sample.bencode")
Expand Down

0 comments on commit af9668d

Please sign in to comment.