runtime_info 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --backtrace
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "http://rubygems.org"
2
+
3
+ group :development do
4
+ gem "rspec", ">= 2.5.0"
5
+ gem "bundler", "~> 1.0.0"
6
+ gem "jeweler", "~> 1.5.2"
7
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,26 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ git (1.2.5)
6
+ jeweler (1.5.2)
7
+ bundler (~> 1.0.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rake (0.8.7)
11
+ rspec (2.5.0)
12
+ rspec-core (~> 2.5.0)
13
+ rspec-expectations (~> 2.5.0)
14
+ rspec-mocks (~> 2.5.0)
15
+ rspec-core (2.5.1)
16
+ rspec-expectations (2.5.0)
17
+ diff-lcs (~> 1.1.2)
18
+ rspec-mocks (2.5.0)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ bundler (~> 1.0.0)
25
+ jeweler (~> 1.5.2)
26
+ rspec (>= 2.5.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Tony Arcieri
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = runtime_info
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to runtime_info
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 Tony Arcieri. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "runtime_info"
16
+ gem.homepage = "http://github.com/tarcieri/runtime_info"
17
+ gem.license = "MIT"
18
+ gem.summary = "Sane interfaces to information about the Ruby runtime environment"
19
+ gem.description = <<-rofl
20
+ Getting information about the current Ruby environment can be a bit arcane.
21
+ Lots of solutions exist in the form of various globals, things like
22
+ Config::CONFIG, and various other oddities. This gem tries to bring it all
23
+ together and make it sane.
24
+ rofl
25
+
26
+ gem.email = "tony@medioh.com"
27
+ gem.authors = ["Tony Arcieri"]
28
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
29
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
30
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
31
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
32
+ end
33
+ Jeweler::RubygemsDotOrgTasks.new
34
+
35
+ require 'rspec/core'
36
+ require 'rspec/core/rake_task'
37
+ RSpec::Core::RakeTask.new(:spec) do |spec|
38
+ spec.pattern = FileList['spec/**/*_spec.rb']
39
+ end
40
+
41
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
42
+ spec.pattern = 'spec/**/*_spec.rb'
43
+ spec.rcov = true
44
+ end
45
+
46
+ task :default => :spec
47
+
48
+ require 'rake/rdoctask'
49
+ Rake::RDocTask.new do |rdoc|
50
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "runtime_info #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,55 @@
1
+ require 'rbconfig'
2
+
3
+ # DON'T REQUIRE RUBYGEMS!!! Actually I'm using a feature of Rubygems here,
4
+ # so unless you're keen on reimplementing Ruby.path yourself and sending
5
+ # me a pull request, please don't complain.
6
+ require 'rubygems'
7
+
8
+ # Interfaces to various Ruby virtual machine and platform specifics
9
+ module Runtime
10
+ module_function # a convoluted shortcut to avoid any << crap or self. shit
11
+
12
+ # A platform identifier containing CPU and OS information
13
+ def platform; RUBY_PLATFORM; end
14
+
15
+ # Host CPU architecture
16
+ def arch; Config::CONFIG['host_cpu']; end
17
+ def cpu_architecture; arch; end
18
+
19
+ # Number of physical CPU cores
20
+ def ncpus
21
+ case os
22
+ when 'darwin'
23
+ Integer(`hwprefs cpu_count`)
24
+ when 'linux'
25
+ cores = File.read("/proc/cpuinfo").scan(/core id\s+: \d+/).uniq.size
26
+ cores > 0 ? cores : 1
27
+ else raise "don't know how to determine CPU count on #{os}"
28
+ end
29
+ end
30
+ def cpu_count; ncpus; end
31
+
32
+ # Host OS
33
+ def os
34
+ Config::CONFIG['host_os'][/^[A-Za-z]+/]
35
+ end
36
+
37
+ # Ruby virtual machine in use
38
+ def engine
39
+ return RUBY_ENGINE if defined? RUBY_ENGINE
40
+ 'ruby'
41
+ end
42
+
43
+ # Version of the Ruby virtual machine in use
44
+ def version
45
+ case engine
46
+ when 'ruby' then RUBY_VERSION
47
+ when 'jruby' then JRUBY_VERSION
48
+ when 'rbx' then Rubinius::VERSION
49
+ else raise "don't know how to obtain version for #{engine}"
50
+ end
51
+ end
52
+
53
+ # Path to the Ruby interpreter currently in use
54
+ def path; Gem.ruby; end
55
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+ require 'rbconfig'
3
+
4
+ describe Runtime do
5
+ it "knows its engine" do
6
+ if defined? RUBY_ENGINE
7
+ Runtime.engine.should == RUBY_ENGINE
8
+ else
9
+ Runtime.engine.should == 'ruby'
10
+ end
11
+ end
12
+
13
+ it "knows the engine version" do
14
+ # Don't really know how to test this :(
15
+ Runtime.version.should match(/\d(.\d){2}/)
16
+ end
17
+
18
+ it "knows its platform" do
19
+ Runtime.platform.should == RUBY_PLATFORM
20
+ end
21
+
22
+ it "knows its CPU architecture" do
23
+ Runtime.arch.should == Config::CONFIG['host_cpu']
24
+ end
25
+
26
+ it "knows the number of CPUs" do
27
+ Runtime.ncpus.should be > 0
28
+ end
29
+
30
+ it "knows its OS" do
31
+ Runtime.os.should == Config::CONFIG['host_os'][/^[A-Za-z]+/]
32
+ end
33
+
34
+ it "knows the path to the Ruby interpreter" do
35
+ path = Runtime.path
36
+
37
+ File.executable?(path).should be_true
38
+
39
+ # Let's give it some Ruby to execute!
40
+ result = `#{path} -e 'p 40.send(:+, 2)'`.to_i
41
+ result.should == 42
42
+ end
43
+ end
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ $LOAD_PATH.unshift File.dirname(__FILE__)
3
+
4
+ require 'rspec'
5
+ require 'runtime_info'
6
+
7
+ # Requires supporting files with custom matchers and macros, etc,
8
+ # in ./support/ and its subdirectories.
9
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: runtime_info
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Tony Arcieri
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-04-16 00:00:00 -06:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rspec
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 2.5.0
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 1.0.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: jeweler
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.5.2
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ description: |
50
+ Getting information about the current Ruby environment can be a bit arcane.
51
+ Lots of solutions exist in the form of various globals, things like
52
+ Config::CONFIG, and various other oddities. This gem tries to bring it all
53
+ together and make it sane.
54
+
55
+ email: tony@medioh.com
56
+ executables: []
57
+
58
+ extensions: []
59
+
60
+ extra_rdoc_files:
61
+ - LICENSE.txt
62
+ - README.rdoc
63
+ files:
64
+ - .document
65
+ - .rspec
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - LICENSE.txt
69
+ - README.rdoc
70
+ - Rakefile
71
+ - VERSION
72
+ - lib/runtime_info.rb
73
+ - spec/runtime_info_spec.rb
74
+ - spec/spec_helper.rb
75
+ has_rdoc: true
76
+ homepage: http://github.com/tarcieri/runtime_info
77
+ licenses:
78
+ - MIT
79
+ post_install_message:
80
+ rdoc_options: []
81
+
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: -262431259010232139
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: "0"
99
+ requirements: []
100
+
101
+ rubyforge_project:
102
+ rubygems_version: 1.6.2
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: Sane interfaces to information about the Ruby runtime environment
106
+ test_files:
107
+ - spec/runtime_info_spec.rb
108
+ - spec/spec_helper.rb