From 4e95609367cf80be60848694e23dbeed1e84e371 Mon Sep 17 00:00:00 2001 From: Lucas Colombo Date: Sat, 23 Mar 2024 12:20:01 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=8D=BE=20Initial=20Commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cargo/config.toml | 5 ++++ .cocorc | 4 +++ .github/img/rustler.svg | 15 +++++++++++ .gitignore | 3 +++ .vscode/launch.json | 29 ++++++++++++++++++++ .vscode/settings.json | 25 +++++++++++++++++ .vscode/tasks.json | 19 +++++++++++++ Cargo.lock | 39 +++++++++++++++++++++++++++ Cargo.toml | 25 +++++++++++++++++ LICENSE | 21 +++++++++++++++ README.md | 9 +++++++ Taskfile.yaml | 25 +++++++++++++++++ check_size.py | 56 +++++++++++++++++++++++++++++++++++++++ rustfmt.toml | 6 +++++ src/main.rs | 7 +++++ 🤠 rustler.code-workspace | 20 ++++++++++++++ 16 files changed, 308 insertions(+) create mode 100644 .cargo/config.toml create mode 100644 .cocorc create mode 100644 .github/img/rustler.svg create mode 100644 .gitignore create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 Taskfile.yaml create mode 100644 check_size.py create mode 100644 rustfmt.toml create mode 100644 src/main.rs create mode 100644 🤠 rustler.code-workspace diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..b582f2c --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,5 @@ +[registries.lugit] +index = "sparse+http://lugit.local/api/packages/lucodear/cargo/" + +[registry] +global-credential-providers = ["cargo:token"] diff --git a/.cocorc b/.cocorc new file mode 100644 index 0000000..0f0d4e7 --- /dev/null +++ b/.cocorc @@ -0,0 +1,4 @@ +# https://github.com/lucas-labs/coco config + +askScope: false +useEmoji: true \ No newline at end of file diff --git a/.github/img/rustler.svg b/.github/img/rustler.svg new file mode 100644 index 0000000..fe6126a --- /dev/null +++ b/.github/img/rustler.svg @@ -0,0 +1,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2520a0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/target +.data/*.log +.task diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..23fb4cf --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,29 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + // debug rust on windows + { + "name": "debug: rustler", + "type": "cppvsdbg", + "request": "launch", + "program": "${workspaceFolder}/target/debug/rustler.exe", + "args": [ + "server", + "--force" + ], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [ + { + "name": "KURV_HOME", + "value": "${workspaceFolder}" + } + ], + "externalConsole": true, + "preLaunchTask": "cargo: build" + }, + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a5ad631 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,25 @@ +{ + "files.exclude": { + // ⚙️ config + "Taskfile.yaml": true, + ".cocorc": true, + ".task": true, + ".cargo": true, + // "Cargo.toml": true, + + // 📦 + "Cargo.lock": true, + "target": true, + + // 📝 readmes + "**/**/README.md": true, + "LICENSE": true, + + // 🗑️ + "check_size.py": true, + "*.code-workspace": true, + ".gitignore": true, + ".vscode": true, + ".git": true, + } +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..517eb82 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,19 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "cargo: build", + "type": "shell", + "command": "cargo build", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [ + "$rustc" + ] + }, + ] +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..d1954fa --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,39 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "eyre" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" +dependencies = [ + "indenter", + "once_cell", +] + +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + +[[package]] +name = "indoc" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "rustler" +version = "0.0.0-alpha.0" +dependencies = [ + "eyre", + "indoc", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..776f49a --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "rustler" +version = "0.0.0-alpha.0" +edition = "2021" +description = "🤠 » single-action data extractor" +authors = ["Lucas Colombo "] + +[profile.release] +strip = true +lto = true +codegen-units = 16 +opt-level = 'z' +panic = "abort" +rpath = false +overflow-checks = false +debug = 0 +debug-assertions = false + +[dependencies] +eyre = { version = "0.6.12", default-features = false, features = ["auto-install"] } +indoc = "2.0.4" + +[[bin]] +name = "rustler" +path = "src/main.rs" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..54139c6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Lucas Colombo + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..4356f3e --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +

+ +
+
+
+ +

+𝐫𝐮𝐬𝐭𝐥𝐞𝐫 is a web scraping service that scrapes several stock market providers for stock pricing data. It is built using the Rust programming language. +

diff --git a/Taskfile.yaml b/Taskfile.yaml new file mode 100644 index 0000000..023e9f2 --- /dev/null +++ b/Taskfile.yaml @@ -0,0 +1,25 @@ +# https://taskfile.dev + +version: '3' + +tasks: + run:watch: + desc: 🚀 watch rustler + cmds: + - cargo watch -c -x "run -- --version" + + build:watch: + desc: 🚀 watch rustler «build» + cmds: + - cargo watch -c -x "build" + + build: + desc: ⚡ build rustler «release» + cmds: + - cargo build --release + - python check_size.py + + fmt: + desc: 🚀 format rustler + cmds: + - cargo +nightly fmt --all \ No newline at end of file diff --git a/check_size.py b/check_size.py new file mode 100644 index 0000000..d3da0b5 --- /dev/null +++ b/check_size.py @@ -0,0 +1,56 @@ +""" +small script to run after build, to check if there was a significant +change on executable size, compared to the previous build. + +this aims to detect unwanted big differences before it's too late +""" + + +import os +import pathlib + +curr_dir = pathlib.Path(os.getcwd()) +sizefile_path = pathlib.Path(curr_dir.joinpath('.task')) + + +def bad(txt): + return '\033[91m' + txt + '\033[0m' + + +def good(txt): + return '\033[92m' + txt + '\033[0m' + + +def head(txt): + return '\033[94m' + txt + '\033[0m' + + +files = { + 'release': curr_dir.joinpath('target/release/rustler.exe'), + 'debug': curr_dir.joinpath('target/debug/rustler.exe'), +} + +print("\n🧉 » exe file sizes change\n") + +for key, exe in files.items(): + if exe.is_file(): + sizefile = sizefile_path.joinpath(key) + new_size: float = os.stat(exe).st_size / 1024 + old_size: float + + try: + with open(sizefile, 'r') as f: + old_size = float(f.read()) + except FileNotFoundError: + old_size = 0 + + # diff: str = f'{old_size:.0f}kb' + diff = new_size - old_size + diff_str = f"{'+' if diff > 0 else '=' if diff == 0 else ''}{diff:.0f}kb" + + fmt = bad if diff > 10 else good + + sizefile.parent.mkdir(parents=True, exist_ok=True) + + with open(sizefile, 'w') as f: + f.write(f'{new_size}') diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..f50e61a --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,6 @@ +max_width = 100 +array_width = 80 +chain_width = 100 +comment_width = 80 +imports_indent = "Block" +imports_granularity = "One" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..3ca4d67 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,7 @@ +use eyre::Result; + +fn main() -> Result<()> { + println!("Hello, rustler!"); + + Ok(()) +} diff --git a/🤠 rustler.code-workspace b/🤠 rustler.code-workspace new file mode 100644 index 0000000..d7fc36a --- /dev/null +++ b/🤠 rustler.code-workspace @@ -0,0 +1,20 @@ +{ + "folders": [ + { + "path": "." + } + ], + "settings": { + "terminal.integrated.env.windows": { + // allows to run the command in the terminal for development purposes + "PATH": "${workspaceFolder}/target/debug;${env:PATH}", + }, + "lucodear-icons.activeIconPack": "rust_ferris", + "lucodear-icons.folders.associations": { + ".cargo": "rust", + }, + "lucodear-icons.files.associations": { + + } + } +}