add gem and crate error codes
Seto Elkahfi committed
Aug 5, 2024 at 08:11 UTC
40f072281622c567be37d3a04bad33762c90121e
32 files changed
+1034
-41
.vscode/settings.json
+3
-1
@@ -1,6 +1,8 @@
1
{
2
"rust-analyzer.linkedProjects": [
3
- "frontend/splitfire-desktop/src-tauri/Cargo.toml",
3
"backend/rust-axum/Cargo.toml",
4
+ "frontend/splitfire-desktop/src-tauri/Cargo.toml",
5
+ "lib/crate_error_codes/Cargo.toml",
6
+ "lib/gem_error_codes/ext/gem_error_codes/Cargo.toml",
7
],
8
}
\ No newline at end of file
backend/musik88-web/Gemfile
+4
@@ -68,6 +68,10 @@ gem 'sprockets', '3.7.2'
68
gem 'tolk', '4.1.0'
69
gem 'webpacker'
70
gem 'will_paginate', '~> 3.3.0'
71
+
72
+# Local gems
73
+gem 'gem_error_codes', path: '../../lib/gem_error_codes'
74
+
75
group :test, :development do
76
gem 'dotenv-rails'
77
gem 'htmlbeautifier'
backend/musik88-web/Gemfile.lock
+6
@@ -1,3 +1,8 @@
1
+PATH
2
+ remote: ../../lib/gem_error_codes
3
+ specs:
4
+ gem_error_codes (0.1.0)
5
+
6
GEM
7
remote: https://rubygems.org/
8
specs:
@@ -546,6 +551,7 @@ DEPENDENCIES
551
dotenv-rails
552
fog-aws
553
font-awesome-rails
554
+ gem_error_codes!
555
google-api-client
556
htmlbeautifier
557
httpclient
backend/musik88-web/app/controllers/api/v1/user_controller.rb
+10
-4
@@ -1,3 +1,7 @@
1
+# frozen_string_literal: true
2
+
3
+require 'gem_error_codes'
4
+
5
module Api
6
module V1
7
class UserController < Devise::SessionsController
@@ -6,6 +10,8 @@ module Api
10
11
def login
12
find_user
13
+ return render_error(GemErrorCodes.user_not_found, GemErrorCodes.user_not_found_message, :not_found) unless @user
14
+
15
if @user&.valid_password?(params[:password])
16
logger.debug 'User logged in.'
17
sign_in(:user, @user)
@@ -99,14 +105,14 @@ module Api
105
code: 200,
106
message: 'OK.',
107
user: @user.as_json_packed
102
- }
108
+ }, status: :ok
109
end
110
105
- def render_error(message)
111
+ def render_error(error_code, message, status = :unauthorized)
112
render json: {
107
- code: 500,
113
+ error_code: error_code,
114
message: message
109
- }
115
+ }, status: status
116
end
117
118
def render_user_following
backend/musik88-web/app/models/user.rb
+1
-1
@@ -110,7 +110,7 @@ class User < ApplicationRecord # rubocop:disable Metrics/ClassLength
110
# Omniauth helpers
111
def self.new_with_session(params, session)
112
super.tap do |user|
113
- if data = session['devise.facebook_data'] && session['devise.facebook_data']['extra']['raw_info'] && user.email.blank?
113
+ if data == session['devise.facebook_data'] && session['devise.facebook_data']['extra']['raw_info'] && user.email.blank?
114
user.email = data['email']
115
end
116
end
frontend/splitfire-desktop/BUILD
+2
@@ -4,6 +4,8 @@ tauri(
4
name = "dev",
5
data = glob(["**"]) + [
6
"@npm//next",
7
+ ] + [
8
+ "//lib:crate_error_codes",
9
],
10
templated_args = [
11
"dev",
frontend/splitfire-desktop/src-tauri/Cargo.lock
+40
@@ -100,6 +100,7 @@ version = "0.2.0"
100
dependencies = [
101
"anyhow",
102
"chrono",
103
+ "crate_error_codes",
104
"futures",
105
"home",
106
"hound",
@@ -641,6 +642,14 @@ dependencies = [
642
"libc",
643
]
644
645
+[[package]]
646
+name = "crate_error_codes"
647
+version = "0.1.0"
648
+dependencies = [
649
+ "serde",
650
+ "ts-rs",
651
+]
652
+
653
[[package]]
654
name = "crc32fast"
655
version = "1.4.0"
@@ -3837,6 +3846,15 @@ dependencies = [
3846
"utf-8",
3847
]
3848
3849
+[[package]]
3850
+name = "termcolor"
3851
+version = "1.4.1"
3852
+source = "registry+https://github.com/rust-lang/crates.io-index"
3853
+checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
3854
+dependencies = [
3855
+ "winapi-util",
3856
+]
3857
+
3858
[[package]]
3859
name = "thin-slice"
3860
version = "0.1.1"
@@ -4122,6 +4140,28 @@ version = "0.2.5"
4140
source = "registry+https://github.com/rust-lang/crates.io-index"
4141
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
4142
4143
+[[package]]
4144
+name = "ts-rs"
4145
+version = "9.0.1"
4146
+source = "registry+https://github.com/rust-lang/crates.io-index"
4147
+checksum = "b44017f9f875786e543595076374b9ef7d13465a518dd93d6ccdbf5b432dde8c"
4148
+dependencies = [
4149
+ "thiserror",
4150
+ "ts-rs-macros",
4151
+]
4152
+
4153
+[[package]]
4154
+name = "ts-rs-macros"
4155
+version = "9.0.1"
4156
+source = "registry+https://github.com/rust-lang/crates.io-index"
4157
+checksum = "c88cc88fd23b5a04528f3a8436024f20010a16ec18eb23c164b1242f65860130"
4158
+dependencies = [
4159
+ "proc-macro2",
4160
+ "quote",
4161
+ "syn 2.0.53",
4162
+ "termcolor",
4163
+]
4164
+
4165
[[package]]
4166
name = "typenum"
4167
version = "1.17.0"
frontend/splitfire-desktop/src-tauri/Cargo.toml
+3
@@ -32,6 +32,9 @@ tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace",
32
url-builder = "0.1.1"
33
uri-template-system = "=0.1.0"
34
35
+# Local crates
36
+crate_error_codes = { path = "./../../../lib/crate_error_codes" }
37
+
38
[features]
39
# by default Tauri runs in production mode
40
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
frontend/splitfire-desktop/src-tauri/src/models/account.rs
+8
@@ -1,3 +1,4 @@
1
+use crate_error_codes::UserError;
2
use serde::{Deserialize, Serialize};
3
use super::player::TauriResponse;
4
@@ -10,6 +11,13 @@ pub struct AccountLoginResponse {
11
pub user: Option<User>,
12
}
13
14
+#[derive(Serialize, Deserialize)]
15
+#[derive(Debug)]
16
+pub struct ErrorResponse {
17
+ pub error_code: UserError,
18
+ pub message: String,
19
+}
20
+
21
#[derive(Serialize, Deserialize)]
22
#[derive(Debug)]
23
pub struct LoginResponse {
frontend/splitfire-desktop/src-tauri/src/rest/account.rs
+34
-34
@@ -5,19 +5,19 @@ use crate::{
5
},
6
models::{
7
account::{
8
- AccountLoginResponse, AccountProfileResponse, AccountRegisterResponse, LoginResponse,
9
- ProfileResponse, RegisterResponse,
8
+ AccountLoginResponse, AccountProfileResponse, AccountRegisterResponse, ErrorResponse, LoginResponse, ProfileResponse, RegisterResponse
9
},
10
player::TauriResponse,
12
- },
11
+ }, rest::try_parsing_error_codes,
12
};
13
+use crate_error_codes::UserError;
14
use log::{debug, error};
15
use reqwest::Client;
16
use serde_json::json;
17
use tauri;
18
19
#[tauri::command]
20
-pub async fn account_login(username: String, password: String) -> AccountLoginResponse {
20
+pub async fn account_login(username: String, password: String) -> Result<AccountLoginResponse, ErrorResponse> {
21
debug!(
22
"Logging in with username {}, password {}",
23
username, password
@@ -33,65 +33,65 @@ pub async fn account_login(username: String, password: String) -> AccountLoginRe
33
.send()
34
.await;
35
36
- let res = match response {
37
- Ok(response) => response,
36
+ let ok_response = match response {
37
+ Ok(response) => {
38
+ match response.error_for_status() {
39
+ Ok(ok_response) => ok_response,
40
+ Err(e) => {
41
+ debug!("Response failed: {:?}", e);
42
+ return try_parsing_error_codes::<AccountLoginResponse>(response).await;
43
+ }
44
+ }
45
+ },
46
Err(e) => {
47
debug!("Failed to get response: {:?}", e);
40
- return AccountLoginResponse {
41
- status: TauriResponse::Error,
42
- message: e.to_string(),
43
- access_token: None,
44
- user: None,
45
- };
48
+ return Err(ErrorResponse {
49
+ error_code: UserError::NetworkError,
50
+ message: UserError::NetworkError.error_message().to_string(),
51
+ });
52
}
53
};
48
- let token = match res.headers().get("Authorization") {
54
+ let token = match ok_response.headers().get("Authorization") {
55
Some(token) => {
56
// Trim Bearer prefix
57
let token = match token.to_str() {
58
Ok(token) => token.trim_start_matches("Bearer "),
59
Err(e) => {
60
error!("Cannot convert token to str: {:?}", e);
55
- return AccountLoginResponse {
56
- status: TauriResponse::Error,
57
- message: e.to_string(),
58
- access_token: None,
59
- user: None,
60
- };
61
+ return Err(ErrorResponse {
62
+ error_code: UserError::ParseError,
63
+ message: UserError::ParseError.error_message().to_string(),
64
+ });
65
}
66
};
67
Some(token.to_string())
68
}
69
None => {
70
error!("No Authorization header found.");
67
- return AccountLoginResponse {
68
- status: TauriResponse::Error,
69
- message: "No Authorization header found".to_string(),
70
- access_token: None,
71
- user: None,
72
- };
71
+ return Err(ErrorResponse {
72
+ error_code: UserError::ParseError,
73
+ message: UserError::ParseError.error_message().to_string(),
74
+ });
75
}
76
};
77
debug!("Token: {:?}", token);
76
- let res: LoginResponse = match res.json().await {
78
+ let res: LoginResponse = match ok_response.json().await {
79
Ok(json) => json,
80
Err(e) => {
81
error!("Failed to parse response: {:?}", e);
80
- return AccountLoginResponse {
81
- status: TauriResponse::Error,
82
- message: e.to_string(),
83
- access_token: None,
84
- user: None,
85
- };
82
+ return Err(ErrorResponse {
83
+ error_code: UserError::ParseError,
84
+ message: UserError::ParseError.error_message().to_string(),
85
+ });
86
}
87
};
88
debug!("Login response: {:?}", res);
89
- AccountLoginResponse {
89
+ Ok(AccountLoginResponse {
90
status: TauriResponse::Success,
91
message: res.message,
92
access_token: token,
93
user: res.user,
94
- }
94
+ })
95
}
96
97
#[tauri::command]
frontend/splitfire-desktop/src-tauri/src/rest/mod.rs
+20
-1
@@ -1,2 +1,21 @@
1
+use crate::models::account::ErrorResponse;
2
+use crate_error_codes::UserError;
3
+use log::error;
4
+use reqwest::Response;
5
+
6
pub mod account;
2
-pub mod content;
\ No newline at end of file
7
+pub mod content;
8
+
9
+async fn try_parsing_error_codes<T>(response: Response) -> Result<T, ErrorResponse> {
10
+ let e: ErrorResponse = match response.json().await {
11
+ Ok(json) => json,
12
+ Err(e) => {
13
+ error!("Failed to parse response: {:?}", e);
14
+ return Err(ErrorResponse {
15
+ error_code: UserError::ParseError,
16
+ message: e.to_string(),
17
+ });
18
+ }
19
+ };
20
+ return Err(e);
21
+}
lib/BUILD
new
+6
@@ -0,0 +1,6 @@
1
+
2
+filegroup(
3
+ name = "crate_error_codes",
4
+ srcs = glob(["crate_error_codes/**"]),
5
+ visibility = ["//visibility:public"],
6
+)
\ No newline at end of file
lib/crate_error_codes/Cargo.lock
new
+199
@@ -0,0 +1,199 @@
1
+# This file is automatically @generated by Cargo.
2
+# It is not intended for manual editing.
3
+version = 3
4
+
5
+[[package]]
6
+name = "crate_error_codes"
7
+version = "0.1.0"
8
+dependencies = [
9
+ "serde",
10
+ "ts-rs",
11
+]
12
+
13
+[[package]]
14
+name = "proc-macro2"
15
+version = "1.0.86"
16
+source = "registry+https://github.com/rust-lang/crates.io-index"
17
+checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
18
+dependencies = [
19
+ "unicode-ident",
20
+]
21
+
22
+[[package]]
23
+name = "quote"
24
+version = "1.0.36"
25
+source = "registry+https://github.com/rust-lang/crates.io-index"
26
+checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
27
+dependencies = [
28
+ "proc-macro2",
29
+]
30
+
31
+[[package]]
32
+name = "serde"
33
+version = "1.0.204"
34
+source = "registry+https://github.com/rust-lang/crates.io-index"
35
+checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12"
36
+dependencies = [
37
+ "serde_derive",
38
+]
39
+
40
+[[package]]
41
+name = "serde_derive"
42
+version = "1.0.204"
43
+source = "registry+https://github.com/rust-lang/crates.io-index"
44
+checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222"
45
+dependencies = [
46
+ "proc-macro2",
47
+ "quote",
48
+ "syn",
49
+]
50
+
51
+[[package]]
52
+name = "syn"
53
+version = "2.0.72"
54
+source = "registry+https://github.com/rust-lang/crates.io-index"
55
+checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af"
56
+dependencies = [
57
+ "proc-macro2",
58
+ "quote",
59
+ "unicode-ident",
60
+]
61
+
62
+[[package]]
63
+name = "termcolor"
64
+version = "1.4.1"
65
+source = "registry+https://github.com/rust-lang/crates.io-index"
66
+checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
67
+dependencies = [
68
+ "winapi-util",
69
+]
70
+
71
+[[package]]
72
+name = "thiserror"
73
+version = "1.0.63"
74
+source = "registry+https://github.com/rust-lang/crates.io-index"
75
+checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
76
+dependencies = [
77
+ "thiserror-impl",
78
+]
79
+
80
+[[package]]
81
+name = "thiserror-impl"
82
+version = "1.0.63"
83
+source = "registry+https://github.com/rust-lang/crates.io-index"
84
+checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
85
+dependencies = [
86
+ "proc-macro2",
87
+ "quote",
88
+ "syn",
89
+]
90
+
91
+[[package]]
92
+name = "ts-rs"
93
+version = "9.0.1"
94
+source = "registry+https://github.com/rust-lang/crates.io-index"
95
+checksum = "b44017f9f875786e543595076374b9ef7d13465a518dd93d6ccdbf5b432dde8c"
96
+dependencies = [
97
+ "thiserror",
98
+ "ts-rs-macros",
99
+]
100
+
101
+[[package]]
102
+name = "ts-rs-macros"
103
+version = "9.0.1"
104
+source = "registry+https://github.com/rust-lang/crates.io-index"
105
+checksum = "c88cc88fd23b5a04528f3a8436024f20010a16ec18eb23c164b1242f65860130"
106
+dependencies = [
107
+ "proc-macro2",
108
+ "quote",
109
+ "syn",
110
+ "termcolor",
111
+]
112
+
113
+[[package]]
114
+name = "unicode-ident"
115
+version = "1.0.12"
116
+source = "registry+https://github.com/rust-lang/crates.io-index"
117
+checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
118
+
119
+[[package]]
120
+name = "winapi-util"
121
+version = "0.1.9"
122
+source = "registry+https://github.com/rust-lang/crates.io-index"
123
+checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
124
+dependencies = [
125
+ "windows-sys",
126
+]
127
+
128
+[[package]]
129
+name = "windows-sys"
130
+version = "0.59.0"
131
+source = "registry+https://github.com/rust-lang/crates.io-index"
132
+checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
133
+dependencies = [
134
+ "windows-targets",
135
+]
136
+
137
+[[package]]
138
+name = "windows-targets"
139
+version = "0.52.6"
140
+source = "registry+https://github.com/rust-lang/crates.io-index"
141
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
142
+dependencies = [
143
+ "windows_aarch64_gnullvm",
144
+ "windows_aarch64_msvc",
145
+ "windows_i686_gnu",
146
+ "windows_i686_gnullvm",
147
+ "windows_i686_msvc",
148
+ "windows_x86_64_gnu",
149
+ "windows_x86_64_gnullvm",
150
+ "windows_x86_64_msvc",
151
+]
152
+
153
+[[package]]
154
+name = "windows_aarch64_gnullvm"
155
+version = "0.52.6"
156
+source = "registry+https://github.com/rust-lang/crates.io-index"
157
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
158
+
159
+[[package]]
160
+name = "windows_aarch64_msvc"
161
+version = "0.52.6"
162
+source = "registry+https://github.com/rust-lang/crates.io-index"
163
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
164
+
165
+[[package]]
166
+name = "windows_i686_gnu"
167
+version = "0.52.6"
168
+source = "registry+https://github.com/rust-lang/crates.io-index"
169
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
170
+
171
+[[package]]
172
+name = "windows_i686_gnullvm"
173
+version = "0.52.6"
174
+source = "registry+https://github.com/rust-lang/crates.io-index"
175
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
176
+
177
+[[package]]
178
+name = "windows_i686_msvc"
179
+version = "0.52.6"
180
+source = "registry+https://github.com/rust-lang/crates.io-index"
181
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
182
+
183
+[[package]]
184
+name = "windows_x86_64_gnu"
185
+version = "0.52.6"
186
+source = "registry+https://github.com/rust-lang/crates.io-index"
187
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
188
+
189
+[[package]]
190
+name = "windows_x86_64_gnullvm"
191
+version = "0.52.6"
192
+source = "registry+https://github.com/rust-lang/crates.io-index"
193
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
194
+
195
+[[package]]
196
+name = "windows_x86_64_msvc"
197
+version = "0.52.6"
198
+source = "registry+https://github.com/rust-lang/crates.io-index"
199
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
lib/crate_error_codes/Cargo.toml
new
+10
@@ -0,0 +1,10 @@
1
+[package]
2
+name = "crate_error_codes"
3
+version = "0.1.0"
4
+edition = "2021"
5
+
6
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
+
8
+[dependencies]
9
+serde = { version = "1.0", features = ["derive"] }
10
+ts-rs = "9.0"
\ No newline at end of file
lib/crate_error_codes/bindings/UserError.ts
new
+3
@@ -0,0 +1,3 @@
1
+// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+
3
+export type UserError = "UserNotFound" | "InvalidRequest" | "ParseError" | "NetworkError";
lib/crate_error_codes/src/lib.rs
new
+29
@@ -0,0 +1,29 @@
1
+use serde::{Deserialize, Serialize};
2
+use ts_rs::TS;
3
+
4
+#[derive(TS)]
5
+#[ts(export)]
6
+#[repr(i32)]
7
+#[derive(Serialize, Deserialize)]
8
+#[derive(Debug)]
9
+pub enum UserError {
10
+ // User defined error codes starts from 1000
11
+ UserNotFound = 1000,
12
+
13
+ // Generic error codes starts from 1
14
+ InvalidRequest = 1,
15
+ ParseError = 2,
16
+ NetworkError = 3,
17
+}
18
+
19
+impl UserError {
20
+ pub fn error_message(&self) -> &str {
21
+ match self {
22
+ UserError::UserNotFound => "User not found.",
23
+ UserError::InvalidRequest => "Invalid request.",
24
+ UserError::ParseError => "Failed to parse response.",
25
+ UserError::NetworkError => "Failed to get response.",
26
+ }
27
+ }
28
+
29
+}
\ No newline at end of file
lib/gem_error_codes/.gitignore
new
+14
@@ -0,0 +1,14 @@
1
+/.bundle/
2
+/.yardoc
3
+/_yardoc/
4
+/coverage/
5
+/doc/
6
+/pkg/
7
+/spec/reports/
8
+/tmp/
9
+*.bundle
10
+*.so
11
+*.o
12
+*.a
13
+mkmf.log
14
+target/
lib/gem_error_codes/Cargo.lock
new
+445
@@ -0,0 +1,445 @@
1
+# This file is automatically @generated by Cargo.
2
+# It is not intended for manual editing.
3
+version = 3
4
+
5
+[[package]]
6
+name = "aho-corasick"
7
+version = "1.1.3"
8
+source = "registry+https://github.com/rust-lang/crates.io-index"
9
+checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
10
+dependencies = [
11
+ "memchr",
12
+]
13
+
14
+[[package]]
15
+name = "bindgen"
16
+version = "0.69.4"
17
+source = "registry+https://github.com/rust-lang/crates.io-index"
18
+checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0"
19
+dependencies = [
20
+ "bitflags",
21
+ "cexpr",
22
+ "clang-sys",
23
+ "itertools",
24
+ "lazy_static",
25
+ "lazycell",
26
+ "proc-macro2",
27
+ "quote",
28
+ "regex",
29
+ "rustc-hash",
30
+ "shlex",
31
+ "syn",
32
+]
33
+
34
+[[package]]
35
+name = "bitflags"
36
+version = "2.6.0"
37
+source = "registry+https://github.com/rust-lang/crates.io-index"
38
+checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
39
+
40
+[[package]]
41
+name = "cexpr"
42
+version = "0.6.0"
43
+source = "registry+https://github.com/rust-lang/crates.io-index"
44
+checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
45
+dependencies = [
46
+ "nom",
47
+]
48
+
49
+[[package]]
50
+name = "cfg-if"
51
+version = "1.0.0"
52
+source = "registry+https://github.com/rust-lang/crates.io-index"
53
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
54
+
55
+[[package]]
56
+name = "clang-sys"
57
+version = "1.8.1"
58
+source = "registry+https://github.com/rust-lang/crates.io-index"
59
+checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
60
+dependencies = [
61
+ "glob",
62
+ "libc",
63
+ "libloading",
64
+]
65
+
66
+[[package]]
67
+name = "crate_error_codes"
68
+version = "0.1.0"
69
+dependencies = [
70
+ "serde",
71
+ "ts-rs",
72
+]
73
+
74
+[[package]]
75
+name = "either"
76
+version = "1.13.0"
77
+source = "registry+https://github.com/rust-lang/crates.io-index"
78
+checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
79
+
80
+[[package]]
81
+name = "gem_error_codes"
82
+version = "0.1.0"
83
+dependencies = [
84
+ "crate_error_codes",
85
+ "magnus",
86
+]
87
+
88
+[[package]]
89
+name = "glob"
90
+version = "0.3.1"
91
+source = "registry+https://github.com/rust-lang/crates.io-index"
92
+checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
93
+
94
+[[package]]
95
+name = "itertools"
96
+version = "0.12.1"
97
+source = "registry+https://github.com/rust-lang/crates.io-index"
98
+checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
99
+dependencies = [
100
+ "either",
101
+]
102
+
103
+[[package]]
104
+name = "lazy_static"
105
+version = "1.5.0"
106
+source = "registry+https://github.com/rust-lang/crates.io-index"
107
+checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
108
+
109
+[[package]]
110
+name = "lazycell"
111
+version = "1.3.0"
112
+source = "registry+https://github.com/rust-lang/crates.io-index"
113
+checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
114
+
115
+[[package]]
116
+name = "libc"
117
+version = "0.2.155"
118
+source = "registry+https://github.com/rust-lang/crates.io-index"
119
+checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
120
+
121
+[[package]]
122
+name = "libloading"
123
+version = "0.8.5"
124
+source = "registry+https://github.com/rust-lang/crates.io-index"
125
+checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
126
+dependencies = [
127
+ "cfg-if",
128
+ "windows-targets",
129
+]
130
+
131
+[[package]]
132
+name = "magnus"
133
+version = "0.6.4"
134
+source = "registry+https://github.com/rust-lang/crates.io-index"
135
+checksum = "b1597ef40aa8c36be098249e82c9a20cf7199278ac1c1a1a995eeead6a184479"
136
+dependencies = [
137
+ "magnus-macros",
138
+ "rb-sys",
139
+ "rb-sys-env",
140
+ "seq-macro",
141
+]
142
+
143
+[[package]]
144
+name = "magnus-macros"
145
+version = "0.6.0"
146
+source = "registry+https://github.com/rust-lang/crates.io-index"
147
+checksum = "5968c820e2960565f647819f5928a42d6e874551cab9d88d75e3e0660d7f71e3"
148
+dependencies = [
149
+ "proc-macro2",
150
+ "quote",
151
+ "syn",
152
+]
153
+
154
+[[package]]
155
+name = "memchr"
156
+version = "2.7.4"
157
+source = "registry+https://github.com/rust-lang/crates.io-index"
158
+checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
159
+
160
+[[package]]
161
+name = "minimal-lexical"
162
+version = "0.2.1"
163
+source = "registry+https://github.com/rust-lang/crates.io-index"
164
+checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
165
+
166
+[[package]]
167
+name = "nom"
168
+version = "7.1.3"
169
+source = "registry+https://github.com/rust-lang/crates.io-index"
170
+checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
171
+dependencies = [
172
+ "memchr",
173
+ "minimal-lexical",
174
+]
175
+
176
+[[package]]
177
+name = "proc-macro2"
178
+version = "1.0.86"
179
+source = "registry+https://github.com/rust-lang/crates.io-index"
180
+checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
181
+dependencies = [
182
+ "unicode-ident",
183
+]
184
+
185
+[[package]]
186
+name = "quote"
187
+version = "1.0.36"
188
+source = "registry+https://github.com/rust-lang/crates.io-index"
189
+checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
190
+dependencies = [
191
+ "proc-macro2",
192
+]
193
+
194
+[[package]]
195
+name = "rb-sys"
196
+version = "0.9.100"
197
+source = "registry+https://github.com/rust-lang/crates.io-index"
198
+checksum = "87f2ba20be84b32fad6b0ce397764bcdd0f2dca4431cf7035f6a6721e5747565"
199
+dependencies = [
200
+ "rb-sys-build",
201
+]
202
+
203
+[[package]]
204
+name = "rb-sys-build"
205
+version = "0.9.100"
206
+source = "registry+https://github.com/rust-lang/crates.io-index"
207
+checksum = "7ecae2bdcb118ee721d9a3929f89e8578237fade298dfcf8c928609aa88abc48"
208
+dependencies = [
209
+ "bindgen",
210
+ "lazy_static",
211
+ "proc-macro2",
212
+ "quote",
213
+ "regex",
214
+ "shell-words",
215
+ "syn",
216
+]
217
+
218
+[[package]]
219
+name = "rb-sys-env"
220
+version = "0.1.2"
221
+source = "registry+https://github.com/rust-lang/crates.io-index"
222
+checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb"
223
+
224
+[[package]]
225
+name = "regex"
226
+version = "1.10.6"
227
+source = "registry+https://github.com/rust-lang/crates.io-index"
228
+checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
229
+dependencies = [
230
+ "aho-corasick",
231
+ "memchr",
232
+ "regex-automata",
233
+ "regex-syntax",
234
+]
235
+
236
+[[package]]
237
+name = "regex-automata"
238
+version = "0.4.7"
239
+source = "registry+https://github.com/rust-lang/crates.io-index"
240
+checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
241
+dependencies = [
242
+ "aho-corasick",
243
+ "memchr",
244
+ "regex-syntax",
245
+]
246
+
247
+[[package]]
248
+name = "regex-syntax"
249
+version = "0.8.4"
250
+source = "registry+https://github.com/rust-lang/crates.io-index"
251
+checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
252
+
253
+[[package]]
254
+name = "rustc-hash"
255
+version = "1.1.0"
256
+source = "registry+https://github.com/rust-lang/crates.io-index"
257
+checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
258
+
259
+[[package]]
260
+name = "seq-macro"
261
+version = "0.3.5"
262
+source = "registry+https://github.com/rust-lang/crates.io-index"
263
+checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4"
264
+
265
+[[package]]
266
+name = "serde"
267
+version = "1.0.204"
268
+source = "registry+https://github.com/rust-lang/crates.io-index"
269
+checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12"
270
+dependencies = [
271
+ "serde_derive",
272
+]
273
+
274
+[[package]]
275
+name = "serde_derive"
276
+version = "1.0.204"
277
+source = "registry+https://github.com/rust-lang/crates.io-index"
278
+checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222"
279
+dependencies = [
280
+ "proc-macro2",
281
+ "quote",
282
+ "syn",
283
+]
284
+
285
+[[package]]
286
+name = "shell-words"
287
+version = "1.1.0"
288
+source = "registry+https://github.com/rust-lang/crates.io-index"
289
+checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
290
+
291
+[[package]]
292
+name = "shlex"
293
+version = "1.3.0"
294
+source = "registry+https://github.com/rust-lang/crates.io-index"
295
+checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
296
+
297
+[[package]]
298
+name = "syn"
299
+version = "2.0.72"
300
+source = "registry+https://github.com/rust-lang/crates.io-index"
301
+checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af"
302
+dependencies = [
303
+ "proc-macro2",
304
+ "quote",
305
+ "unicode-ident",
306
+]
307
+
308
+[[package]]
309
+name = "termcolor"
310
+version = "1.4.1"
311
+source = "registry+https://github.com/rust-lang/crates.io-index"
312
+checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755"
313
+dependencies = [
314
+ "winapi-util",
315
+]
316
+
317
+[[package]]
318
+name = "thiserror"
319
+version = "1.0.63"
320
+source = "registry+https://github.com/rust-lang/crates.io-index"
321
+checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
322
+dependencies = [
323
+ "thiserror-impl",
324
+]
325
+
326
+[[package]]
327
+name = "thiserror-impl"
328
+version = "1.0.63"
329
+source = "registry+https://github.com/rust-lang/crates.io-index"
330
+checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
331
+dependencies = [
332
+ "proc-macro2",
333
+ "quote",
334
+ "syn",
335
+]
336
+
337
+[[package]]
338
+name = "ts-rs"
339
+version = "9.0.1"
340
+source = "registry+https://github.com/rust-lang/crates.io-index"
341
+checksum = "b44017f9f875786e543595076374b9ef7d13465a518dd93d6ccdbf5b432dde8c"
342
+dependencies = [
343
+ "thiserror",
344
+ "ts-rs-macros",
345
+]
346
+
347
+[[package]]
348
+name = "ts-rs-macros"
349
+version = "9.0.1"
350
+source = "registry+https://github.com/rust-lang/crates.io-index"
351
+checksum = "c88cc88fd23b5a04528f3a8436024f20010a16ec18eb23c164b1242f65860130"
352
+dependencies = [
353
+ "proc-macro2",
354
+ "quote",
355
+ "syn",
356
+ "termcolor",
357
+]
358
+
359
+[[package]]
360
+name = "unicode-ident"
361
+version = "1.0.12"
362
+source = "registry+https://github.com/rust-lang/crates.io-index"
363
+checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
364
+
365
+[[package]]
366
+name = "winapi-util"
367
+version = "0.1.9"
368
+source = "registry+https://github.com/rust-lang/crates.io-index"
369
+checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
370
+dependencies = [
371
+ "windows-sys",
372
+]
373
+
374
+[[package]]
375
+name = "windows-sys"
376
+version = "0.59.0"
377
+source = "registry+https://github.com/rust-lang/crates.io-index"
378
+checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
379
+dependencies = [
380
+ "windows-targets",
381
+]
382
+
383
+[[package]]
384
+name = "windows-targets"
385
+version = "0.52.6"
386
+source = "registry+https://github.com/rust-lang/crates.io-index"
387
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
388
+dependencies = [
389
+ "windows_aarch64_gnullvm",
390
+ "windows_aarch64_msvc",
391
+ "windows_i686_gnu",
392
+ "windows_i686_gnullvm",
393
+ "windows_i686_msvc",
394
+ "windows_x86_64_gnu",
395
+ "windows_x86_64_gnullvm",
396
+ "windows_x86_64_msvc",
397
+]
398
+
399
+[[package]]
400
+name = "windows_aarch64_gnullvm"
401
+version = "0.52.6"
402
+source = "registry+https://github.com/rust-lang/crates.io-index"
403
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
404
+
405
+[[package]]
406
+name = "windows_aarch64_msvc"
407
+version = "0.52.6"
408
+source = "registry+https://github.com/rust-lang/crates.io-index"
409
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
410
+
411
+[[package]]
412
+name = "windows_i686_gnu"
413
+version = "0.52.6"
414
+source = "registry+https://github.com/rust-lang/crates.io-index"
415
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
416
+
417
+[[package]]
418
+name = "windows_i686_gnullvm"
419
+version = "0.52.6"
420
+source = "registry+https://github.com/rust-lang/crates.io-index"
421
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
422
+
423
+[[package]]
424
+name = "windows_i686_msvc"
425
+version = "0.52.6"
426
+source = "registry+https://github.com/rust-lang/crates.io-index"
427
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
428
+
429
+[[package]]
430
+name = "windows_x86_64_gnu"
431
+version = "0.52.6"
432
+source = "registry+https://github.com/rust-lang/crates.io-index"
433
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
434
+
435
+[[package]]
436
+name = "windows_x86_64_gnullvm"
437
+version = "0.52.6"
438
+source = "registry+https://github.com/rust-lang/crates.io-index"
439
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
440
+
441
+[[package]]
442
+name = "windows_x86_64_msvc"
443
+version = "0.52.6"
444
+source = "registry+https://github.com/rust-lang/crates.io-index"
445
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
lib/gem_error_codes/Cargo.toml
new
+7
@@ -0,0 +1,7 @@
1
+# This Cargo.toml is here to let externals tools (IDEs, etc.) know that this is
2
+# a Rust project. Your extensions dependencies should be added to the Cargo.toml
3
+# in the ext/ directory.
4
+
5
+[workspace]
6
+members = ["./ext/gem_error_codes"]
7
+resolver = "2"
lib/gem_error_codes/Gemfile
new
+11
@@ -0,0 +1,11 @@
1
+# frozen_string_literal: true
2
+
3
+source 'https://rubygems.org'
4
+
5
+# Specify your gem's dependencies in gem_error_codes.gemspec
6
+gemspec
7
+
8
+gem 'rake', '~> 13.0'
9
+
10
+gem 'rake-compiler'
11
+gem 'rb_sys', '~> 0.9.63'
lib/gem_error_codes/Gemfile.lock
new
+25
@@ -0,0 +1,25 @@
1
+PATH
2
+ remote: .
3
+ specs:
4
+ gem_error_codes (0.1.0)
5
+
6
+GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (13.2.1)
10
+ rake-compiler (1.2.7)
11
+ rake
12
+ rb_sys (0.9.100)
13
+
14
+PLATFORMS
15
+ arm64-darwin-22
16
+ ruby
17
+
18
+DEPENDENCIES
19
+ gem_error_codes!
20
+ rake (~> 13.0)
21
+ rake-compiler
22
+ rb_sys (~> 0.9.63)
23
+
24
+BUNDLED WITH
25
+ 2.5.15
lib/gem_error_codes/README.md
new
+31
@@ -0,0 +1,31 @@
1
+# GemErrorCodes
2
+
3
+TODO: Delete this and the text below, and describe your gem
4
+
5
+Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gem_error_codes`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+## Installation
8
+
9
+TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+Install the gem and add to the application's Gemfile by executing:
12
+
13
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
+
15
+If bundler is not being used to manage dependencies, install the gem by executing:
16
+
17
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
+
19
+## Usage
20
+
21
+TODO: Write usage instructions here
22
+
23
+## Development
24
+
25
+After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+## Contributing
30
+
31
+Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gem_error_codes.
lib/gem_error_codes/Rakefile
new
+14
@@ -0,0 +1,14 @@
1
+# frozen_string_literal: true
2
+
3
+require "bundler/gem_tasks"
4
+require "rb_sys/extensiontask"
5
+
6
+task build: :compile
7
+
8
+GEMSPEC = Gem::Specification.load("gem_error_codes.gemspec")
9
+
10
+RbSys::ExtensionTask.new("gem_error_codes", GEMSPEC) do |ext|
11
+ ext.lib_dir = "lib/gem_error_codes"
12
+end
13
+
14
+task default: :compile
lib/gem_error_codes/bin/console
new
+11
@@ -0,0 +1,11 @@
1
+#!/usr/bin/env ruby
2
+# frozen_string_literal: true
3
+
4
+require "bundler/setup"
5
+require "gem_error_codes"
6
+
7
+# You can add fixtures and/or initialization code here to make experimenting
8
+# with your gem easier. You can also use a different console, if you like.
9
+
10
+require "irb"
11
+IRB.start(__FILE__)
lib/gem_error_codes/bin/setup
new
+8
@@ -0,0 +1,8 @@
1
+#!/usr/bin/env bash
2
+set -euo pipefail
3
+IFS=$'\n\t'
4
+set -vx
5
+
6
+bundle install
7
+
8
+# Do any other automated setup that you need to do here
lib/gem_error_codes/ext/gem_error_codes/Cargo.toml
new
+13
@@ -0,0 +1,13 @@
1
+[package]
2
+name = "gem_error_codes"
3
+version = "0.1.0"
4
+edition = "2021"
5
+authors = ["Seto Elkahfi <setoelkahfi@gmail.com>"]
6
+publish = false
7
+
8
+[lib]
9
+crate-type = ["cdylib"]
10
+
11
+[dependencies]
12
+magnus = { version = "0.6.2" }
13
+crate_error_codes = { path = "../../../crate_error_codes" }
lib/gem_error_codes/ext/gem_error_codes/extconf.rb
new
+6
@@ -0,0 +1,6 @@
1
+# frozen_string_literal: true
2
+
3
+require "mkmf"
4
+require "rb_sys/mkmf"
5
+
6
+create_rust_makefile("gem_error_codes/gem_error_codes")
lib/gem_error_codes/ext/gem_error_codes/src/lib.rs
new
+17
@@ -0,0 +1,17 @@
1
+use crate_error_codes::UserError::UserNotFound;
2
+use magnus::{function, prelude::*, Error, Ruby};
3
+
4
+fn user_not_found() -> i32 {
5
+ UserNotFound as i32
6
+}
7
+fn user_not_found_message() -> String {
8
+ UserNotFound.error_message().to_string()
9
+}
10
+
11
+#[magnus::init]
12
+fn init(ruby: &Ruby) -> Result<(), Error> {
13
+ let module = ruby.define_module("GemErrorCodes")?;
14
+ module.define_singleton_method("user_not_found", function!(user_not_found, 0))?;
15
+ module.define_singleton_method("user_not_found_message", function!(user_not_found_message, 0))?;
16
+ Ok(())
17
+}
lib/gem_error_codes/gem_error_codes.gemspec
new
+36
@@ -0,0 +1,36 @@
1
+# frozen_string_literal: true
2
+
3
+require_relative 'lib/gem_error_codes/version'
4
+
5
+Gem::Specification.new do |spec|
6
+ spec.name = 'gem_error_codes'
7
+ spec.version = GemErrorCodes::VERSION
8
+ spec.authors = ['Seto Elkahfi']
9
+ spec.email = ['setoelkahfi@gmail.com']
10
+
11
+ spec.summary = 'Ruby binding error_codes from crate_error_codes.'
12
+ spec.description = 'Write a longer description or delete this line.'
13
+ spec.homepage = 'https://splitfire.ai/gem_error_codes'
14
+ spec.required_ruby_version = '>= 3.0.0'
15
+ spec.required_rubygems_version = '>= 3.3.11'
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ gemspec = File.basename(__FILE__)
20
+ spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
21
+ ls.readlines("\x0", chomp: true).reject do |f|
22
+ (f == gemspec) ||
23
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
24
+ end
25
+ end
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+ spec.extensions = ['ext/gem_error_codes/Cargo.toml']
30
+
31
+ # Uncomment to register a new dependency of your gem
32
+ # spec.add_dependency "example-gem", "~> 1.0"
33
+
34
+ # For more information and examples about making a new gem, check out our
35
+ # guide at: https://bundler.io/guides/creating_gem.html
36
+end
lib/gem_error_codes/lib/gem_error_codes.rb
new
+9
@@ -0,0 +1,9 @@
1
+# frozen_string_literal: true
2
+
3
+require_relative 'gem_error_codes/version'
4
+require_relative 'gem_error_codes/gem_error_codes'
5
+
6
+module GemErrorCodes
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+end
lib/gem_error_codes/lib/gem_error_codes/version.rb
new
+5
@@ -0,0 +1,5 @@
1
+# frozen_string_literal: true
2
+
3
+module GemErrorCodes
4
+ VERSION = "0.1.0"
5
+end
lib/gem_error_codes/sig/gem_error_codes.rbs
new
+4
@@ -0,0 +1,4 @@
1
+module GemErrorCodes
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+end