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