artichoke_core/
release_metadata.rs

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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//! Information about an Artichoke build.
//!
//! Release metadata allows populating Ruby constants that describe the build,
//! like `RUBY_COPYRIGHT` for copyright information or `RUBY_PLATFORM` for
//! target architecture.

/// Information about an Artichoke build.
///
/// Implementations of this trait are used to set global Ruby constants that
/// describe the current build.
pub trait ReleaseMetadata {
    /// Copyright information.
    ///
    /// This value will populate the `RUBY_COPYRIGHT` constant.
    ///
    /// # Examples
    ///
    /// ```text
    /// artichoke - Copyright (c) 2019-2020 Ryan Lopopolo \<rjl@hyperbo.la\>
    /// ```
    fn ruby_copyright(&self) -> &str;

    /// A description of the current build.
    ///
    /// This value will populate the `RUBY_DESCRIPTION` constant.
    ///
    /// # Examples
    ///
    /// ```text
    /// artichoke 0.1.0-pre.0 (2021-01-12 revision 4009) [x86_64-apple-darwin]
    /// ```
    fn ruby_description(&self) -> &str;

    /// The engine, or VM, used in the current build.
    ///
    /// This value will populate the `RUBY_ENGINE` constant.
    ///
    /// # Examples
    ///
    /// ```text
    /// artichoke-mruby
    /// ```
    fn ruby_engine(&self) -> &str;

    /// The version of the engine, or VM, used in the current build.
    ///
    /// This value will populate the `RUBY_ENGINE_VERSION` constant.
    ///
    /// # Examples
    ///
    /// ```text
    /// 0.1.0-pre.0
    /// ```
    fn ruby_engine_version(&self) -> &str;

    /// The patch level the current build.
    ///
    /// This value will populate the `RUBY_PATCHLEVEL` constant.
    ///
    /// # Examples
    ///
    /// ```text
    /// 0
    /// ```
    fn ruby_patchlevel(&self) -> &str;

    /// The target triple of the platform this build targets.
    ///
    /// The platform will be a [Rust or LLVM target triple][triple].
    ///
    /// This value will populate the `RUBY_PLATFORM` constant.
    ///
    /// # Examples
    ///
    /// ```text
    /// x86_64-apple-darwin
    /// ```
    ///
    /// [triple]: https://forge.rust-lang.org/release/platform-support.html
    fn ruby_platform(&self) -> &str;

    /// The build date of this release.
    ///
    /// This value will populate the `RUBY_RELEASE_DATE` constant.
    ///
    /// # Examples
    ///
    /// ```text
    /// 2021-01-12
    /// ```
    fn ruby_release_date(&self) -> &str;

    /// The revision count of the Artichoke git repository used for this build.
    ///
    /// This value will populate the `RUBY_REVISION` constant.
    ///
    /// # Examples
    ///
    /// ```text
    /// 4009
    /// ```
    fn ruby_revision(&self) -> &str;

    /// The target MRI Ruby version for this build.
    ///
    /// This value will populate the `RUBY_VERSION` constant.
    ///
    /// # Examples
    ///
    /// ```text
    /// 3.1.2
    /// ```
    fn ruby_version(&self) -> &str;

    /// A description of the compiler used to build Artichoke.
    ///
    /// This value will populate the `ARTICHOKE_COMPILER_VERSION` constant.
    ///
    /// # Examples
    ///
    /// ```text
    /// rustc 1.49.0 (e1884a8e3 2020-12-29) on x86_64-apple-darwin
    /// ```
    fn artichoke_compiler_version(&self) -> Option<&str>;
}