artichoke_core/release_metadata.rs
1//! Information about an Artichoke build.
2//!
3//! Release metadata allows populating Ruby constants that describe the build,
4//! like `RUBY_COPYRIGHT` for copyright information or `RUBY_PLATFORM` for
5//! target architecture.
6
7/// Information about an Artichoke build.
8///
9/// Implementations of this trait are used to set global Ruby constants that
10/// describe the current build.
11pub trait ReleaseMetadata {
12 /// Copyright information.
13 ///
14 /// This value will populate the `RUBY_COPYRIGHT` constant.
15 ///
16 /// # Examples
17 ///
18 /// ```text
19 /// artichoke - Copyright (c) 2019-2020 Ryan Lopopolo \<rjl@hyperbo.la\>
20 /// ```
21 fn ruby_copyright(&self) -> &str;
22
23 /// A description of the current build.
24 ///
25 /// This value will populate the `RUBY_DESCRIPTION` constant.
26 ///
27 /// # Examples
28 ///
29 /// ```text
30 /// artichoke 0.1.0-pre.0 (2021-01-12 revision 4009) [x86_64-apple-darwin]
31 /// ```
32 fn ruby_description(&self) -> &str;
33
34 /// The engine, or VM, used in the current build.
35 ///
36 /// This value will populate the `RUBY_ENGINE` constant.
37 ///
38 /// # Examples
39 ///
40 /// ```text
41 /// artichoke-mruby
42 /// ```
43 fn ruby_engine(&self) -> &str;
44
45 /// The version of the engine, or VM, used in the current build.
46 ///
47 /// This value will populate the `RUBY_ENGINE_VERSION` constant.
48 ///
49 /// # Examples
50 ///
51 /// ```text
52 /// 0.1.0-pre.0
53 /// ```
54 fn ruby_engine_version(&self) -> &str;
55
56 /// The patch level the current build.
57 ///
58 /// This value will populate the `RUBY_PATCHLEVEL` constant.
59 ///
60 /// # Examples
61 ///
62 /// ```text
63 /// 0
64 /// ```
65 fn ruby_patchlevel(&self) -> &str;
66
67 /// The target triple of the platform this build targets.
68 ///
69 /// The platform will be a [Rust or LLVM target triple][triple].
70 ///
71 /// This value will populate the `RUBY_PLATFORM` constant.
72 ///
73 /// # Examples
74 ///
75 /// ```text
76 /// x86_64-apple-darwin
77 /// ```
78 ///
79 /// [triple]: https://forge.rust-lang.org/release/platform-support.html
80 fn ruby_platform(&self) -> &str;
81
82 /// The build date of this release.
83 ///
84 /// This value will populate the `RUBY_RELEASE_DATE` constant.
85 ///
86 /// # Examples
87 ///
88 /// ```text
89 /// 2021-01-12
90 /// ```
91 fn ruby_release_date(&self) -> &str;
92
93 /// The revision count of the Artichoke git repository used for this build.
94 ///
95 /// This value will populate the `RUBY_REVISION` constant.
96 ///
97 /// # Examples
98 ///
99 /// ```text
100 /// 4009
101 /// ```
102 fn ruby_revision(&self) -> &str;
103
104 /// The target MRI Ruby version for this build.
105 ///
106 /// This value will populate the `RUBY_VERSION` constant.
107 ///
108 /// # Examples
109 ///
110 /// ```text
111 /// 3.1.2
112 /// ```
113 fn ruby_version(&self) -> &str;
114
115 /// A description of the compiler used to build Artichoke.
116 ///
117 /// This value will populate the `ARTICHOKE_COMPILER_VERSION` constant.
118 ///
119 /// # Examples
120 ///
121 /// ```text
122 /// rustc 1.49.0 (e1884a8e3 2020-12-29) on x86_64-apple-darwin
123 /// ```
124 fn artichoke_compiler_version(&self) -> Option<&str>;
125}