https://github.com/katzer/mruby-os
Determine system and binary capabilities at runtime
https://github.com/katzer/mruby-os
mruby-gem system-capabilities uname
Last synced: 6 months ago
JSON representation
Determine system and binary capabilities at runtime
- Host: GitHub
- URL: https://github.com/katzer/mruby-os
- Owner: katzer
- License: mit
- Created: 2017-02-13T17:10:40.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-07-05T07:49:25.000Z (over 3 years ago)
- Last Synced: 2023-03-11T06:12:48.609Z (almost 3 years ago)
- Topics: mruby-gem, system-capabilities, uname
- Language: Ruby
- Homepage:
- Size: 29.3 KB
- Stars: 5
- Watchers: 6
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mruby-os
[](https://travis-ci.com/katzer/mruby-os) [](https://ci.appveyor.com/project/katzer/mruby-os)
Determine system and binary capabilities at runtime.
## Installation
Add the line below to your `build_config.rb`:
```ruby
MRuby::Build.new do |conf|
# ... (snip) ...
conf.gem 'mruby-os'
end
```
Or add this line to your aplication's `mrbgem.rake`:
```ruby
MRuby::Gem::Specification.new('your-mrbgem') do |spec|
# ... (snip) ...
spec.add_dependency 'mruby-logger'
end
```
## Usage
To get the machine architecture:
```ruby
OS.machine # i686 or x86_64
```
To get the max "word size" of the machine:
```ruby
OS.bits # 32 or 64
# or
OS.bits :machine
```
To get the used "word size" by the binary:
```ruby
OS.bits :binary
```
To get the kernel name:
```ruby
OS.sysname # Darwin, Linux or Windows_NT
```
To execute code per platform:
```ruby
if OS.posix?
# The normal way
else
# Windows
end
```
See also `linux?`, `mac?`, `macos?`, `osx?`, `x?`.
## Development
Clone the repo:
$ git clone https://github.com/katzer/mruby-os.git && cd mruby-os/
Compile the source:
$ rake compile
Run the tests:
$ rake test
## Authors
- Sebastián Katzer, Fa. appPlant GmbH
## License
The gem is available as open source under the terms of the [MIT License][license].
Made with :yum: in Leipzig
© 2017 [appPlant GmbH][appplant]
[license]: http://opensource.org/licenses/MIT
[appplant]: www.appplant.de