warlocks_cauldron/providers/
development.rs1use crate::Internet;
2
3use super::{Local, Datelike, dependencies::*};
4
5
6pub struct Development;
8
9impl Development {
10 pub fn dsn(dsn_type: Option<DSNType>, tld_type: Option<TLDType>, subdomains: Option<Vec<&str>>) -> String {
19 let hostname = Internet::hostname(tld_type, subdomains);
20 let (scheme, port) = validate_enum(dsn_type, None);
21 format!("{scheme}://{hostname}:{port}")
22 }
23
24 pub fn software_license() -> &'static str {
28 get_random_element(LICENSES.iter())
29 }
30
31 pub fn version(calver: bool, pre_release: bool) -> String {
39 let (major, minor, patch) = match calver {
40 true => {
41 let now = Local::now().year();
42 (randint(now - 6, now), randint(1, 10), randint(1, 10))
43 },
44 false => (randint(1, 10), randint(1, 10), randint(1, 10)),
45 };
46
47 let version = format!("{major}.{minor}.{patch}");
48
49 if pre_release {
50 let suffix = get_random_element(vec!["alpha", "beta", "rc"].into_iter());
51 let number = randint(1, 11);
52 format!("{version}-{suffix}.{number}")
53 } else {
54 version
55 }
56 }
57
58 pub fn programming_language() -> &'static str {
62 get_random_element(PROGRAMMING_LANGS.iter())
63 }
64
65 pub fn os() -> &'static str {
69 get_random_element(OS.iter())
70 }
71
72 pub fn boolean() -> bool {
76 rand_bool(0.5)
77 }
78}