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::*};


/// Methods collection for getting fake data for Developers
pub struct Development;

impl Development {
    /// Generates a random DSN (Data Source Name)
    ///
    /// return example: postgres://some.host:5432
    ///
    /// # Arguments
    /// * `tld_type` - DSNType provide service scheme and port
    /// * `tld_type` - TLDType provide hostname domain
    /// * `subdomains` - vec of subdomains
    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}")
    }

    /// Generate a random software license
    ///
    /// return example: GNU General Public License (GPL)
    pub fn software_license() -> &'static str {
        get_random_element(LICENSES.iter())
    }

    /// Generate version number
    ///
    /// return example: 6.6.6
    /// 
    /// # Arguments
    /// * `calver` - ISBN format
    /// * `pre_release` - Locale code from enum
    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
        }
    }

    /// Get a random programming language
    /// 
    /// return example: Rust
    pub fn programming_language() -> &'static str {
        get_random_element(PROGRAMMING_LANGS.iter())
    }

    /// Get a random operating system or distributive name
    /// 
    /// return example: Windows 11
    pub fn os() -> &'static str {
        get_random_element(OS.iter())
    }

    /// Generate a random PIN code
    /// 
    /// return example: pin string
    pub fn boolean() -> bool {
        rand_bool(0.5)
    }
}