Skip to content

Commit 10b53f4

Browse files
Facade (#1)
* Codecov and other changes * Test workflow * Facade
1 parent 23215c2 commit 10b53f4

32 files changed

+1030
-698
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ It would be nice to have screenshot or result image uploaded
1515
Some minimal reproduce code is highly recommended
1616

1717
**Version Information**
18-
Please give us what version you are using. If you are pulling `Plotters` directly from git repo, please mention this as well
18+
Please give us what version you are using. If you are pulling `Ruex` directly from git repo, please mention this as well

.github/ISSUE_TEMPLATE/feature_request.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: Feature request
3-
about: Suggest an idea to Plotter maintainers
3+
about: Suggest an idea to Ruex maintainers
44
title: "[Feature Request]"
55
labels: feature request
66
assignees: ''

.github/codecov.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
comment:
2+
layout: "diff, flags, files"
3+
require_changes: true
4+
5+
coverage:
6+
status:
7+
project:
8+
default:
9+
informational: true

.github/workflows/audit.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Security audit
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
schedule:
8+
- cron: '0 0 * * 0'
9+
10+
jobs:
11+
security_audit:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions-rs/audit-check@v1
16+
with:
17+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/coverage.yaml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Coverage
2+
3+
#on:
4+
# push:
5+
# branches:
6+
# - main
7+
# pull_request:
8+
9+
on: [push, pull_request]
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
RUST_BACKTRACE: full
14+
15+
jobs:
16+
coverage:
17+
name: Coverage
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v2
22+
23+
- name: Install Rust
24+
uses: actions-rs/toolchain@v1
25+
with:
26+
toolchain: nightly
27+
profile: minimal
28+
default: true
29+
30+
- name: Restore cache
31+
uses: Swatinem/rust-cache@v1
32+
33+
- name: Run cargo-tarpaulin
34+
uses: actions-rs/[email protected]
35+
with:
36+
args: '--all-features --run-types Doctests,Tests'
37+
timeout: 120
38+
39+
- name: Upload to codecov.io
40+
uses: codecov/codecov-action@239febf655bba88b16ff5dea1d3135ea8663a1f9
41+
with:
42+
token: ${{ secrets.CODECOV_TOKEN }}
43+
44+
- name: Archive code coverage results
45+
uses: actions/upload-artifact@v2
46+
with:
47+
name: code-coverage-report
48+
path: cobertura.xml
49+
retention-days: 30

.github/workflows/tests.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v1
12+
- name: Build
13+
run: cargo build --verbose
14+
- name: Run tests
15+
run: cargo test --verbose
16+
17+
clippy_check:
18+
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- uses: actions/checkout@v1
23+
- run: rustup component add clippy
24+
- uses: actions-rs/clippy-check@v1
25+
with:
26+
token: ${{ secrets.GITHUB_TOKEN }}
27+
args: --all-features

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ license = "MPL-2.0"
1616
maintenance = { status = "actively-developed" }
1717

1818
[dependencies]
19-
yew = "0.17"
2019
log = "0.4"
2120
serde = { version = "1.0", features = ["derive"] }
22-
wasm-logger = "0.2"
21+
# yew = "0.17"
22+
# wasm-logger = "0.2"

README.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<div align="center">
22

3-
![Star a repo](https://dudochkin-victor.github.io/assets/ruex/logo-wide.svg)
3+
[![](https://dudochkin-victor.github.io/assets/ruex/logo-wide.svg)](#top)
44
# Ruex
55

66
[![API Docs][docrs-badge]][docrs-url]
77
[![Crates.io][crates-badge]][crates-url]
8+
[![Code coverage][codecov-badge]][codecov-url]
9+
[![Tests][tests-badge]][tests-url]
810
[![MPL-2.0 licensed][license-badge]][license-url]
911
[![Gitter chat][gitter-badge]][gitter-url]
10-
[![Rustc Version 1.45+][rust-badge]][rust-url]
1112
[![loc][loc-badge]][loc-url]
1213
</div>
1314

@@ -17,16 +18,20 @@
1718
[crates-url]: https://crates.io/crates/ruex
1819
[license-badge]: https://img.shields.io/badge/license-MPL--2.0-blue.svg?style=flat-square
1920
[license-url]: https://github.com/angular-rust/ruex/blob/master/LICENSE
20-
[gitter-badge]: https://img.shields.io/gitter/room/angular_rust/angular_rust.svg?style=flat-square
21+
[gitter-badge]: https://img.shields.io/gitter/room/angular_rust/community.svg?style=flat-square
2122
[gitter-url]: https://gitter.im/angular_rust/community
22-
[rust-badge]: https://img.shields.io/badge/rustc-1.45-lightgrey.svg?style=flat-square
23-
[rust-url]: https://blog.rust-lang.org/2020/07/16/Rust-1.45.0.html
24-
[loc-badge]: https://tokei.rs/b1/github/angular-rust/ruex?category=code
23+
[tests-badge]: https://img.shields.io/github/workflow/status/angular-rust/ruex/Tests?label=tests&logo=github&style=flat-square
24+
[tests-url]: https://github.com/angular-rust/ruex/actions/workflows/tests.yml
25+
[codecov-badge]: https://img.shields.io/codecov/c/github/angular-rust/ruex?logo=codecov&style=flat-square&token=L7KV27OLY0
26+
[codecov-url]: https://codecov.io/gh/angular-rust/ruex
27+
[loc-badge]: https://img.shields.io/tokei/lines/github/angular-rust/ruex?style=flat-square
2528
[loc-url]: https://github.com/angular-rust/ruex
2629

2730
Ruex is a Centralized State Management And Design Patterns for Rust.
2831

29-
**Angular Rust** is a high productivity, `platform-agnostic` frontend framework for the [Rust language](https://www.rust-lang.org/). It now supports desktop and web development. Angular Rust currently uses GTK for desktop development and WebAssembly for web development. We are planning to add support for mobile development.
32+
**Angular Rust** is a high productivity, `platform-agnostic` frontend framework for the [Rust language](https://www.rust-lang.org/). It now supports desktop and web development. Angular Rust currently uses Clutter for desktop development and WebAssembly for web development. We are planning to add support for mobile development.
33+
34+
![Angular Rust structure](https://dudochkin-victor.github.io/assets/angular-rust/structure.svg)
3035

3136
## Features
3237

macro/Cargo.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "ruex-macro"
3+
version = "0.1.0"
4+
authors = ["Victor Dudochkin <[email protected]>"]
5+
edition = "2018"
6+
7+
[lib]
8+
proc-macro = true
9+
10+
[dependencies]
11+
proc-macro2 = "1.0"
12+
syn = "1.0"
13+
quote = "1.0"

macro/src/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#[cfg(test)]
2+
mod tests {
3+
#[test]
4+
fn it_works() {
5+
assert_eq!(2 + 2, 4);
6+
}
7+
}

src/core/controller.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::new_ret_no_self)]
2+
13
//! A Singleton IController implementation.
24
//!
35
//! In RuEx, the Controller class follows the
@@ -111,7 +113,7 @@ impl<B, C, V> IController<B> for Controller<B, C, V> {
111113
///
112114
/// * `notification_name` - the name of the INotification
113115
/// * `command_factory` - the Class of the ICommand
114-
fn register_command(&self, notification_name: String, command_factory: Box<dyn FnOnce()>) {
116+
fn register_command(&self, notification_name: String, command_factory: Box<dyn FnOnce()>) {
115117
// if ( commandMap[ notificationName ] == null ) {
116118
// view.registerObserver( notificationName, new Observer( executeCommand, this ) );
117119
// }
@@ -120,7 +122,7 @@ impl<B, C, V> IController<B> for Controller<B, C, V> {
120122

121123
/// Check if a Command is registered for a given Notification
122124
///
123-
/// * `notification_name` -
125+
/// * `notification_name` -
124126
/// Returns whether a Command is currently registered for the given notificationName.
125127
fn has_command(&self, notification_name: String) -> bool {
126128
// return commandMap[ notificationName ] != null;

src/core/model.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::new_ret_no_self)]
2+
13
//! A Singleton IModel implementation.
24
//!
35
//! In RuEx, the Model class provides

src/core/view.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::new_ret_no_self)]
2+
13
//! A Singleton IView implementation.
24
//!
35
//! In RuEx, the View class assumes these responsibilities:
@@ -29,7 +31,7 @@ pub struct View<B, C, V> {
2931

3032
/// Mapping of Notification names to Observer lists
3133
observer_map: Vec<C>, // FIXME: adjust
32-
tmp: V // FIXME: remove
34+
tmp: V, // FIXME: remove
3335
}
3436

3537
impl<B, C, V> View<B, C, V> {
@@ -70,7 +72,7 @@ impl<B, C, V> View<B, C, V> {
7072
}
7173

7274
impl<B, C, V> IView<B, C, V> for View<B, C, V> {
73-
/// Register an IObserver to be notified
75+
/// Register an IObserver to be notified
7476
/// of INotifications with a given name.
7577
///
7678
/// * `notification_name` - the name of the INotifications to notify this IObserver of
@@ -221,7 +223,7 @@ impl<B, C, V> IView<B, C, V> for View<B, C, V> {
221223

222224
/// Check if a Mediator is registered or not
223225
///
224-
/// * `mediator_name` -
226+
/// * `mediator_name` -
225227
/// Returns whether a Mediator is registered with the given mediatorName.
226228
fn has_mediator(&self, mediator_name: String) -> bool {
227229
// return mediatorMap[ mediatorName ] != null;

src/event_bus.rs

+47-47
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
use serde::{Deserialize, Serialize};
2-
use std::collections::HashSet;
3-
use yew::worker::*;
4-
5-
#[derive(Serialize, Deserialize, Debug)]
6-
pub enum Request {
7-
EventBusMsg(String),
8-
}
9-
10-
pub struct EventBus {
11-
link: AgentLink<EventBus>,
12-
subscribers: HashSet<HandlerId>,
13-
}
14-
15-
impl Agent for EventBus {
16-
type Reach = Context<Self>;
17-
type Message = ();
18-
type Input = Request;
19-
type Output = String;
20-
21-
fn create(link: AgentLink<Self>) -> Self {
22-
Self {
23-
link,
24-
subscribers: HashSet::new(),
25-
}
26-
}
27-
28-
fn update(&mut self, _msg: Self::Message) {}
29-
30-
fn handle_input(&mut self, msg: Self::Input, _id: HandlerId) {
31-
match msg {
32-
Request::EventBusMsg(s) => {
33-
for sub in self.subscribers.iter() {
34-
self.link.respond(*sub, s.clone());
35-
}
36-
}
37-
}
38-
}
39-
40-
fn connected(&mut self, id: HandlerId) {
41-
self.subscribers.insert(id);
42-
}
43-
44-
fn disconnected(&mut self, id: HandlerId) {
45-
self.subscribers.remove(&id);
46-
}
47-
}
1+
// use serde::{Deserialize, Serialize};
2+
// use std::collections::HashSet;
3+
// use yew::worker::*;
4+
5+
// #[derive(Serialize, Deserialize, Debug)]
6+
// pub enum Request {
7+
// EventBusMsg(String),
8+
// }
9+
10+
// pub struct EventBus {
11+
// link: AgentLink<EventBus>,
12+
// subscribers: HashSet<HandlerId>,
13+
// }
14+
15+
// impl Agent for EventBus {
16+
// type Reach = Context<Self>;
17+
// type Message = ();
18+
// type Input = Request;
19+
// type Output = String;
20+
21+
// fn create(link: AgentLink<Self>) -> Self {
22+
// Self {
23+
// link,
24+
// subscribers: HashSet::new(),
25+
// }
26+
// }
27+
28+
// fn update(&mut self, _msg: Self::Message) {}
29+
30+
// fn handle_input(&mut self, msg: Self::Input, _id: HandlerId) {
31+
// match msg {
32+
// Request::EventBusMsg(s) => {
33+
// for sub in self.subscribers.iter() {
34+
// self.link.respond(*sub, s.clone());
35+
// }
36+
// }
37+
// }
38+
// }
39+
40+
// fn connected(&mut self, id: HandlerId) {
41+
// self.subscribers.insert(id);
42+
// }
43+
44+
// fn disconnected(&mut self, id: HandlerId) {
45+
// self.subscribers.remove(&id);
46+
// }
47+
// }

src/interfaces/facade.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
1111
use super::mediator::IMediator;
1212
use super::notification::INotification;
13-
use super::proxy::IProxy;
1413
use super::notifier::INotifier;
15-
14+
use super::proxy::IProxy;
1615

1716
pub trait IFacade<B, D, V>: INotifier<B> {
1817
/// Register an IProxy with the Model by name.

src/interfaces/observer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub trait IObserver<B, C> {
3434
/// The notification method should take one parameter of type INotification
3535
///
3636
/// * `notify_method` - the notification (callback) method of the interested object
37-
fn set_notify_method(&self, notify_method: Box<dyn FnOnce()>); // FIXME:
37+
fn set_notify_method(&self, notify_method: Box<dyn FnOnce()>); // FIXME:
3838

3939
/// Set the notification context.
4040
///

0 commit comments

Comments
 (0)