~janbaudisch/heron

78167b81a0e993f6467bb6e5b0a6de886aea852e — Jan Baudisch 4 years ago 55f1e23
restructure: re-split web
9 files changed, 56 insertions(+), 42 deletions(-)

M .travis.yml
M Cargo.toml
M README.md
A heron/Cargo.toml
R src/lib.rs => heron/src/lib.rs
A heron_web/Cargo.toml
R examples/web/main.rs => heron_web/src/main.rs
R examples/web/static/index.html => heron_web/static/index.html
R examples/web/static/style.css => heron_web/static/style.css
M .travis.yml => .travis.yml +6 -16
@@ 5,18 5,8 @@ rust:
  - beta
  - nightly

install:
  - rustup target add wasm32-unknown-unknown
  - .travis/install-cargo-web.sh

cache: cargo

script:
  - cargo build --verbose --all
  - cargo test --verbose --lib
  - cargo test --verbose --example cli
  - cargo web build --verbose --example web

jobs:
  include:
    - stage: lint


@@ 30,7 20,7 @@ jobs:
    - stage: format
      rust: nightly
      install:
        - rustup component add rustfmt || cargo install --git https://github.com/rust-lang/rustfmt --force --bin rustfmt
        - rustup component add rustfmt || cargo install --git https://github.com/rust-lang/rustfmt.git --force --bin rustfmt
      script:
        - cargo fmt --all -- --check



@@ 44,13 34,13 @@ jobs:
        - rustup target add wasm32-unknown-unknown
        - .travis/install-cargo-web.sh
      script:
        - cargo doc --no-deps --release
        - cargo web build --example web --release
        - cargo doc -p heron --no-deps --release
        - cargo web build -p heron_web --release
        - mv target/doc dist
        - mkdir dist/demo
        - mv target/wasm32-unknown-unknown/release/examples/web.{js,wasm} dist/demo
        - cp examples/web/static/index.html dist/demo
        - cp examples/web/static/style.css dist/demo
        - mv target/wasm32-unknown-unknown/release/heron_web.{js,wasm} dist/demo
        - cp heron_web/static/index.html dist/demo
        - cp heron_web/static/style.css dist/demo
      deploy:
        provider: pages
        local-dir: dist

M Cargo.toml => Cargo.toml +8 -12
@@ 1,13 1,9 @@
[package]
name = "heron"
version = "0.1.0"
description = "A library implementing Heron's method to find a square root."
authors = ["Jan Baudisch <dev@baudisch.xyz>"]
license = "GPL-3.0-or-later"
readme = "README.md"
edition = "2018"
[workspace]
members = [
    "heron",
    "heron_web"
]

[dependencies]

[dev-dependencies]
yew = "0.6"
[profile.release]
lto = true
codegen-units = 1

M README.md => README.md +2 -2
@@ 45,10 45,10 @@ See [here][demo-url] for a live version.

The same principle applies to the second example, which works in the browser.

[`cargo-web`][cargo-web] might be used to build and run it:
[`cargo-web`][cargo-web] might be used to build it:

```
cargo web deploy --example web
cargo web start -p heron_web
```

[build-img]: https://travis-ci.com/flyingP0tat0/heron.svg?branch=master

A heron/Cargo.toml => heron/Cargo.toml +13 -0
@@ 0,0 1,13 @@
[package]
name = "heron"
version = "0.1.0"
description = "A library implementing Heron's method to find a square root."
authors = ["Jan Baudisch <dev@baudisch.xyz>"]
license = "GPL-3.0-or-later"
readme = "README.md"
edition = "2018"

[dependencies]

[dev-dependencies]
yew = "0.6"

R src/lib.rs => heron/src/lib.rs +13 -11
@@ 1,14 1,16 @@
///! # heron - [Heron's method][https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method] implmentation
///!
///! # Example
///! ```
///! use heron::heron;
///! let square = 25.0;
///! let precision = 0.00001;
///!
///! assert_eq!(heron(square, precision), 5.0);
///! ```
///!
//! # [Heron's method](https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method) implmentation
//!
//! Heron's method is a way of approximating the square root of a number.
//! ## Example
//!
//! ```
//! use heron::heron;
//! let square = 25.0;
//! let precision = 0.00001;
//!
//! assert_eq!(heron(square, precision), 5.0);
//! ```
//!

/// Approximates the square root of the given number until it reaches the given precision.
pub fn heron(square: f32, precision: f32) -> f32 {

A heron_web/Cargo.toml => heron_web/Cargo.toml +13 -0
@@ 0,0 1,13 @@
[package]
name = "heron_web"
version = "0.1.0"
description = "A library implementing Heron's method to find a square root."
authors = ["Jan Baudisch <dev@baudisch.xyz>"]
license = "GPL-3.0-or-later"
readme = "../README.md"
edition = "2018"
workspace = ".."

[dependencies]
heron = { path = "../heron" }
yew = "0.6"

R examples/web/main.rs => heron_web/src/main.rs +0 -0
R examples/web/static/index.html => heron_web/static/index.html +1 -1
@@ 5,6 5,6 @@
        <title>Heron</title>
    </head>
    <body>
        <script src="web.js"></script>
        <script src="heron_web.js"></script>
    </body>
</html>

R examples/web/static/style.css => heron_web/static/style.css +0 -0