Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
159 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,7 @@ coverage | |
rdoc | ||
pkg | ||
|
||
## Netbeans | ||
nbproject | ||
|
||
## PROJECT::SPECIFIC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# System - System is a pure ruby interface to gather current systems information. # | ||
|
||
## About ## | ||
|
||
System is a pure ruby interface to gather systems information from the current host. System offers a simple to use interface to gather an array of information including; OS, CPU, Filesystem etc. | ||
|
||
* Version 0.1.0 - Very basic information only | ||
|
||
## GEM Installation ## | ||
|
||
After this it should be just a gem to install. For those of you with old rubygems versions first: | ||
|
||
gem install gemcutter # These two steps are only necessary if you haven't | ||
gem tumble # yet installed the gemcutter tools | ||
|
||
Otherwise and after it's simply: | ||
|
||
gem install system | ||
|
||
Then your ready to rock and roll. :) | ||
|
||
## Usage ## | ||
|
||
Heres a few little examples of using system within your programs. | ||
|
||
require 'rubygems' | ||
require 'system' | ||
|
||
HostSystem::os => Current OS as a symbol i.e. :windows, :linux, :osx, :bsd | ||
|
||
## Note on Patches/Pull Requests ## | ||
|
||
* Fork the project. | ||
* Make your feature addition or bug fix. | ||
* Add tests for it. This is important so I don't break it in a | ||
future version unintentionally. | ||
* Commit, do not mess with rakefile, version, or history. | ||
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull) | ||
* Send me a pull request. Bonus points for topic branches. | ||
|
||
## Copyright ## | ||
|
||
Copyright (c) 2010 Roja Buck. See LICENSE for details. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# system includes | ||
require 'singleton' | ||
|
||
# java includes | ||
if /java/.match(RUBY_PLATFORM) | ||
require 'java' | ||
import 'java.lang.System' | ||
end | ||
|
||
module HostSystem | ||
|
||
def self.os | ||
SystemInfo.instance.os | ||
end | ||
|
||
def self.jruby? | ||
!(/java/.match(RUBY_PLATFORM).nil?) | ||
end | ||
|
||
class SystemInfo | ||
include Singleton | ||
|
||
def initialize | ||
end | ||
|
||
def os | ||
return @os if defined? @os # if we already know then pass it | ||
if HostSystem::jruby? | ||
@os = case System.getProperty('os.name').downcase | ||
when /linux/ then :linux | ||
when /win/ then :windows | ||
when /solaris/ then :solaris | ||
when /bsd/ then :basd | ||
when /darwin/ then :darwin | ||
when /mac.*?os.*?x/ then :osx | ||
else | ||
:unknown | ||
end | ||
else | ||
potential_os = case RUBY_PLATFORM | ||
when /linux/ then :linux | ||
when /win/ then :windows | ||
when /solaris/ then :solaris | ||
when /bsd/ then :basd | ||
when /darwin/ then :darwin | ||
else | ||
:unknown | ||
end | ||
potential_os = :osx if potential_os == :darwin && defined? Config::CONFIG && Config::CONFIG['build_vendor'] == 'apple' | ||
@os = potential_os | ||
end | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Generated by jeweler | ||
# DO NOT EDIT THIS FILE DIRECTLY | ||
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command | ||
# -*- encoding: utf-8 -*- | ||
|
||
Gem::Specification.new do |s| | ||
s.name = %q{system} | ||
s.version = "0.1.0" | ||
|
||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= | ||
s.authors = ["Roja Buck"] | ||
s.date = %q{2010-01-23} | ||
s.description = %q{System is a pure ruby interface to gather systems information from the current host. System offers a simple to use interface to gather an array of information including; OS, CPU, Filesystem etc.} | ||
s.email = %q{roja@arbia.co.uk} | ||
s.extra_rdoc_files = [ | ||
"LICENSE", | ||
"README.markdown" | ||
] | ||
s.files = [ | ||
".document", | ||
".gitignore", | ||
"LICENSE", | ||
"Rakefile", | ||
"VERSION", | ||
"lib/system.rb", | ||
"test/helper.rb", | ||
"test/test_system.rb" | ||
] | ||
s.homepage = %q{http://github.com/roja/system} | ||
s.rdoc_options = ["--charset=UTF-8"] | ||
s.require_paths = ["lib"] | ||
s.rubyforge_project = %q{system} | ||
s.rubygems_version = %q{1.3.5} | ||
s.summary = %q{System is a pure ruby interface to gather current systems information; OS, CPU, Filesystem etc.} | ||
s.test_files = [ | ||
"test/helper.rb", | ||
"test/test_system.rb" | ||
] | ||
|
||
if s.respond_to? :specification_version then | ||
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION | ||
s.specification_version = 3 | ||
|
||
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then | ||
else | ||
end | ||
else | ||
end | ||
end | ||
|