Skip to content

Commit

Permalink
Very basic information only
Browse files Browse the repository at this point in the history
  • Loading branch information
roja committed Jan 23, 2010
1 parent 227e4cf commit 74f5e06
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -18,4 +18,7 @@ coverage
rdoc
pkg

## Netbeans
nbproject

## PROJECT::SPECIFIC
43 changes: 43 additions & 0 deletions README.markdown
@@ -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.
17 changes: 0 additions & 17 deletions README.rdoc

This file was deleted.

10 changes: 7 additions & 3 deletions Rakefile
Expand Up @@ -5,15 +5,19 @@ begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "system"
gem.summary = %Q{TODO: one-line summary of your gem}
gem.description = %Q{TODO: longer description of your gem}
gem.summary = %Q{System is a pure ruby interface to gather current systems information; OS, CPU, Filesystem etc.}
gem.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.}
gem.email = "roja@arbia.co.uk"
gem.homepage = "http://github.com/roja/system"
gem.authors = ["Roja Buck"]
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
gem.rubyforge_project = 'system'
# gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
Jeweler::GemcutterTasks.new
Jeweler::RubyforgeTasks.new do |rubyforge|
rubyforge.doc_task = "rdoc"
end
rescue LoadError
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
end
Expand Down
56 changes: 56 additions & 0 deletions lib/system.rb
@@ -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
50 changes: 50 additions & 0 deletions system.gemspec
@@ -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

0 comments on commit 74f5e06

Please sign in to comment.