system 0.1.1 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- system (0.1.1)
4
+ system (0.1.3)
5
+ version (~> 1.0.0)
5
6
 
6
7
  GEM
7
8
  remote: http://rubygems.org/
@@ -66,4 +67,3 @@ DEPENDENCIES
66
67
  rake (~> 0.9)
67
68
  rb-fsevent (~> 0.9.1)
68
69
  system!
69
- version (~> 1.0.0)
data/Rakefile CHANGED
@@ -1,8 +1,15 @@
1
- require 'rake/version_task'
2
- require 'rspec/core/rake_task'
3
- require 'rubygems/package_task'
4
1
  require 'pathname'
5
2
 
3
+ def require_task(path)
4
+ begin
5
+ require path
6
+
7
+ yield
8
+ rescue LoadError
9
+ puts '', "Could not load '#{path}'.", 'Try to `rake gem:spec` and `bundle install` and try again.', ''
10
+ end
11
+ end
12
+
6
13
  spec = Gem::Specification.new do |s|
7
14
  s.name = 'system'
8
15
  s.version = Pathname.new(__FILE__).dirname.join('VERSION').read.strip
@@ -15,7 +22,7 @@ spec = Gem::Specification.new do |s|
15
22
  s.files = `git ls-files`.lines.to_a.collect { |s| s.strip }
16
23
  s.executables = `git ls-files -- bin/*`.lines.to_a.collect { |s| File.basename(s.strip) }
17
24
 
18
- s.add_development_dependency 'version', '~> 1.0.0'
25
+ s.add_dependency 'version', '~> 1.0.0'
19
26
  s.add_development_dependency 'rake', '~> 0.9'
20
27
  s.add_development_dependency 'guard-rspec', '~> 2.1.1'
21
28
  s.add_development_dependency 'guard-yard', '~> 2.0.1'
@@ -24,16 +31,27 @@ spec = Gem::Specification.new do |s|
24
31
  s.add_development_dependency 'kramdown', '~> 0.14.0'
25
32
  end
26
33
 
27
- Rake::VersionTask.new do |t|
28
- t.with_git_tag = true
29
- t.with_gemspec = spec
34
+
35
+ require_task 'rake/version_task' do
36
+ Rake::VersionTask.new do |t|
37
+ t.with_git_tag = true
38
+ t.with_gemspec = spec
39
+ end
30
40
  end
31
41
 
32
- RSpec::Core::RakeTask.new
42
+ namespace :gem do
43
+ desc 'Generate the gemspec defined in this Rakefile'
44
+ task :spec do
45
+ Pathname.new("#{spec.name}.gemspec").open('w') { |f| f.write(spec.to_ruby) }
46
+ end
47
+ end
33
48
 
49
+ require 'rubygems/package_task'
34
50
  Gem::PackageTask.new(spec) do |t|
35
51
  t.need_zip = false
36
52
  t.need_tar = false
37
53
  end
38
54
 
39
- task :default => :spec
55
+ task :default do
56
+ puts `rake -T`
57
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.3
@@ -1,27 +1,30 @@
1
1
  # System includes
2
2
  require 'rbconfig'
3
3
  require 'pathname'
4
+ require 'bundler/setup'
5
+ require 'version'
4
6
 
5
7
  # Java includes - Have to load this way to avoid overloading of our classes
6
8
  if /java/.match(RUBY_PLATFORM) # TODO: For now, this is a good place for this but it will need abstracting..
7
9
  require 'java'
8
- import 'java.lang.System'
10
+ java_import java.lang.System
9
11
  end
10
12
 
11
13
  # Prepare LOAD_PATH
12
14
  __LIB__ ||= Pathname.new(__FILE__).dirname
13
15
  $:.unshift(__LIB__.to_s) unless $:.include?(__LIB__.to_s)
14
16
 
15
- # Local includes
16
- require 'system/version'
17
- require 'system/ruby'
18
- require 'system/os'
19
- require 'system/cpu'
20
- require 'system/backwards_compatibility'
21
-
22
17
  # System is a cross-platform and cross-implementation interface to gather system information from the current host.
23
18
  #
24
19
  # System offers a simple to use interface to gather an array of information including; OS, CPU, Filesystem, etc..
25
20
  #
26
21
  # @since 0.1.0
27
- class System; end
22
+ class System
23
+ is_versioned
24
+ end
25
+
26
+ # Local includes
27
+ require 'system/ruby'
28
+ require 'system/os'
29
+ require 'system/cpu'
30
+ require 'system/backwards_compatibility'
@@ -1,4 +1,4 @@
1
- require 'system/version'
1
+ require 'system'
2
2
 
3
3
  class System
4
4
  class << self
@@ -9,6 +9,7 @@ class System
9
9
  #
10
10
  # @return [Symbol] The name of the operating system.
11
11
  # @since 0.1.0
12
+ # @deprecated 0.2.0
12
13
  def os
13
14
  System::OS.name
14
15
  end
@@ -20,6 +21,7 @@ class System
20
21
  #
21
22
  # @return [TrueClass, FalseClass] Is the current Ruby implementation using Java?
22
23
  # @since 0.1.0
24
+ # @deprecated 0.2.0
23
25
  def java?
24
26
  System::Ruby.java?
25
27
  end
@@ -30,6 +32,7 @@ class System
30
32
  #
31
33
  # @return [TrueClass, FalseClass] Is the current Ruby implementation JRuby?
32
34
  # @since 0.1.0
35
+ # @deprecated 0.2.0
33
36
  def jruby?
34
37
  System::Ruby.jruby?
35
38
  end
@@ -1,4 +1,4 @@
1
- require 'system/version'
1
+ require 'system'
2
2
 
3
3
  class System
4
4
 
@@ -1,4 +1,4 @@
1
- require 'system/version'
1
+ require 'system'
2
2
 
3
3
  class System
4
4
 
@@ -37,6 +37,64 @@ class System
37
37
 
38
38
  class << self
39
39
 
40
+ # @method linux?
41
+ # Get if the name of the operating system running on the current host is `System::OS::Linux`.
42
+ #
43
+ # @since 0.1.3
44
+ # @return [TrueClass, FalseClass]
45
+ # @example
46
+ # System::OS.name # => :linux
47
+ # System::OS.linux? # => true
48
+
49
+ # @method windows?
50
+ # Get if the name of the operating system running on the current host is `System::OS::Windows`.
51
+ #
52
+ # @since 0.1.3
53
+ # @return [TrueClass, FalseClass]
54
+ # @example
55
+ # System::OS.name # => :windows
56
+ # System::OS.windows? # => true
57
+
58
+ # @method solaris?
59
+ # Get if the name of the operating system running on the current host is `System::OS::Solaris`.
60
+ #
61
+ # @since 0.1.3
62
+ # @return [TrueClass, FalseClass]
63
+ # @example
64
+ # System::OS.name # => :solaris
65
+ # System::OS.solaris? # => true
66
+
67
+ # @method bsd?
68
+ # Get if the name of the operating system running on the current host is `System::OS::BSD`.
69
+ #
70
+ # @since 0.1.3
71
+ # @return [TrueClass, FalseClass]
72
+ # @example
73
+ # System::OS.name # => :bsd
74
+ # System::OS.bsd? # => true
75
+
76
+ # @method osx?
77
+ # Get if the name of the operating system running on the current host is `System::OS::OSX`.
78
+ #
79
+ # @since 0.1.3
80
+ # @return [TrueClass, FalseClass]
81
+ # @example
82
+ # System::OS.name # => :osx
83
+ # System::OS.osx? # => true
84
+
85
+ # @method darwin?
86
+ # Get if the name of the operating system running on the current host is `System::OS::Darwin`.
87
+ #
88
+ # @since 0.1.3
89
+ # @return [TrueClass, FalseClass]
90
+ # @example
91
+ # System::OS.name # => :darwin
92
+ # System::OS.darwin? # => true
93
+
94
+ [Linux, Windows, Solaris, BSD, OSX, Darwin].each do |name|
95
+ define_method("#{name}?") { self.name == name }
96
+ end
97
+
40
98
  # Get the name of the operating system running on the current host.
41
99
  #
42
100
  # @return [Symbol] The name of the operating system.
@@ -1,100 +1,251 @@
1
- require 'system/version'
1
+ require 'system'
2
+ require 'system/os'
3
+ require 'rubygems/platform'
2
4
 
3
5
  class System
4
6
 
5
- # Information about the current Ruby implementation.
7
+ # Information about the current Ruby interpreter.
6
8
  #
7
9
  # @since 0.1.1
8
10
  module Ruby
9
11
  class << self
10
12
 
13
+ # The C language.
14
+ # @since 0.1.3
15
+ C = :c
16
+
17
+ # The C++ language.
18
+ # @since 0.1.3
19
+ CPlusPlus = :c_plus_plus
20
+
21
+ # The Java language.
22
+ # @since 0.1.3
23
+ Java = :java
24
+
25
+ # The Ruby interpreter: MRI.
26
+ # @since 0.1.3
27
+ MRI = :mri
28
+
29
+ # The Ruby interpreter: JRuby.
30
+ # @since 0.1.3
31
+ JRuby = :jruby
32
+
33
+ # The Ruby interpreter: Rubinius.
34
+ # @since 0.1.3
35
+ Rubinius = :rbx
36
+
37
+ # The Ruby interpreter: MagLev.
38
+ # @since 0.1.3
39
+ MagLev = :maglev
40
+
11
41
  # @method copyright
12
- # Return the current Ruby implementation's copyright.
42
+ # Return the current Ruby interpreter's copyright.
13
43
  #
14
44
  # @since 0.1.1
15
- # @return [String] The current Ruby implementation's copyright.
45
+ # @return [String] The current Ruby interpreter's copyright.
16
46
  # @example
17
47
  # System::Ruby.copyright # => "ruby - Copyright (C) 1993-2012 Yukihiro Matsumoto"
18
48
 
49
+ # @method copyright?
50
+ # Return if we have information about the copyright.
51
+ #
52
+ # @since 0.1.3
53
+ # @return [TrueClass, FalseClass]
54
+ # @example
55
+ # System::Ruby.copyright # => "ruby - Copyright (C) 1993-2012 Yukihiro Matsumoto"
56
+ # System::Ruby.copyright? # => true
57
+
19
58
  # @method description
20
- # Return the current Ruby implementation's description which includes the engine, version,
59
+ # Return the current Ruby interpreter's description which includes the engine, version,
21
60
  # release date, revision, and platform.
22
61
  #
23
62
  # @since 0.1.1
24
- # @return [String] The current Ruby implementation's engine.
63
+ # @return [String] The current Ruby interpreter's engine.
25
64
  # @example
26
- # System::Ruby.copyright # => "ruby"
65
+ # System::Ruby.description # => "ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0]"
66
+
67
+ # @method description?
68
+ # Return if we have information about the description.
69
+ #
70
+ # @since 0.1.3
71
+ # @return [TrueClass, FalseClass]
72
+ # @example
73
+ # System::Ruby.description # => "ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-darwin12.2.0]"
74
+ # System::Ruby.description? # => true
27
75
 
28
76
  # @method engine
29
- # Return the current Ruby implementation's engine.
77
+ # Return the current Ruby interpreter's engine.
30
78
  #
31
79
  # @since 0.1.1
32
- # @return [String] The current Ruby implementation's engine.
80
+ # @return [String] The current Ruby interpreter's engine.
81
+ # @example
82
+ # System::Ruby.engine # => "ruby"
83
+
84
+ # @method engine?
85
+ # Return if we have information about the engine.
86
+ #
87
+ # @since 0.1.3
88
+ # @return [TrueClass, FalseClass]
33
89
  # @example
34
- # System::Ruby.copyright # => "ruby"
90
+ # System::Ruby.engine # => "ruby"
91
+ # System::Ruby.engine? # => true
35
92
 
36
93
  # @method patchlevel
37
- # Return the current Ruby implementation's patch-level.
94
+ # Return the current Ruby interpreter's patch-level.
38
95
  #
39
96
  # @since 0.1.1
40
- # @return [Integer] The current Ruby implementation's patch-level.
97
+ # @return [Integer] The current Ruby interpreter's patch-level.
41
98
  # @example
42
99
  # System::Ruby.patchlevel # => 286
43
100
 
101
+ # @method patchlevel?
102
+ # Return if we have information about the patchlevel.
103
+ #
104
+ # @since 0.1.3
105
+ # @return [TrueClass, FalseClass]
106
+ # @example
107
+ # System::Ruby.patchlevel # => 286
108
+ # System::Ruby.patchlevel? # => true
109
+
44
110
  # @method platform
45
- # Return the system platform the current Ruby implementation is running on.
111
+ # Return the system platform the current Ruby interpreter is running on.
46
112
  #
47
113
  # @since 0.1.1
48
- # @return [String] The system platform the current Ruby implementation is running on.
114
+ # @return [String] The system platform the current Ruby interpreter is running on.
49
115
  # @example
50
116
  # System::Ruby.platform # => "x86_64-darwin12.2.0"
51
117
 
118
+ # @method platform?
119
+ # Return if we have information about the platform.
120
+ #
121
+ # @since 0.1.3
122
+ # @return [TrueClass, FalseClass]
123
+ # @example
124
+ # System::Ruby.platform # => "x86_64-darwin12.2.0"
125
+ # System::Ruby.platform? # => true
126
+
52
127
  # @method revision
53
- # Return the current Ruby implementation's revision.
128
+ # Return the current Ruby interpreter's revision.
54
129
  #
55
130
  # @since 0.1.1
56
- # @return [Integer] The current Ruby implementation's revision.
131
+ # @return [Integer] The current Ruby interpreter's revision.
132
+ # @example
133
+ # System::Ruby.revision # => 37165
134
+
135
+ # @method revision?
136
+ # Return if we have information about the revision.
137
+ #
138
+ # @since 0.1.3
139
+ # @return [TrueClass, FalseClass]
57
140
  # @example
58
141
  # System::Ruby.revision # => 37165
142
+ # System::Ruby.revision? # => true
59
143
 
60
144
  # @method release_date
61
- # Return the current Ruby implementation's release date.
145
+ # Return the current Ruby interpreter's release date.
62
146
  #
63
147
  # @since 0.1.1
64
- # @return [String] The current Ruby implementation's release date.
148
+ # @return [String] The current Ruby interpreter's release date.
65
149
  # @example
66
150
  # System::Ruby.release_date # => "2012-10-12"
67
151
 
152
+ # @method release_date?
153
+ # Return if we have information about the release_date.
154
+ #
155
+ # @since 0.1.3
156
+ # @return [TrueClass, FalseClass]
157
+ # @example
158
+ # System::Ruby.release_date # => "2012-10-12"
159
+ # System::Ruby.release_date? # => true
160
+
68
161
  # @method version
69
- # Return the current Ruby implementation's version.
162
+ # Return the current Ruby interpreter's version.
70
163
  #
71
164
  # @since 0.1.1
72
- # @return [String] The current Ruby implementation's version.
165
+ # @return [String] The current Ruby interpreter's version.
73
166
  # @example
74
167
  # System::Ruby.version # => "1.9.3"
75
168
 
169
+ # @method version?
170
+ # Return if we have information about the version.
171
+ #
172
+ # @since 0.1.3
173
+ # @return [TrueClass, FalseClass]
174
+ # @example
175
+ # System::Ruby.version # => "2012-10-12"
176
+ # System::Ruby.version? # => true
177
+
76
178
  Object.constants.grep(/^RUBY_/).each do |const_name|
77
179
  method_name = const_name.to_s.gsub(/^RUBY_/, '').downcase.to_sym
78
180
 
79
- define_method(method_name) { Object.const_get(const_name) }
181
+ define_method(method_name) do
182
+ Object.const_defined?(const_name) ? Object.const_get(const_name) : nil
183
+ end
184
+
185
+ define_method("#{method_name}?") { !send(method_name).nil? }
186
+ end
187
+
188
+ # Return the current Ruby interpreter's name.
189
+ #
190
+ # @return [Symbol] The name of the operating system.
191
+ # @example Return OS name
192
+ # System::OS.name # => :osx
193
+ # @example Assert current OS
194
+ # System::OS.name == System::OS::OSX # => true
195
+ # @since 0.1.3
196
+ def name
197
+ @name ||= if !OS.windows? && ruby?
198
+ MRI
199
+ elsif ruby? && engine? && engine == 'rbx'
200
+ Rubinius
201
+ elsif ruby? && engine? && engine == 'maglev'
202
+ MagLev
203
+ elsif engine? && engine == 'jruby'
204
+ JRuby
205
+ end
80
206
  end
81
207
 
82
- # Check if Ruby is using Java.
83
- # Delegates to System::Ruby.java? for backwards compatibility.
208
+ # Return the current Ruby interpreter's base language.
84
209
  #
85
- # @return [TrueClass, FalseClass] Is the current Ruby implementation using Java?
210
+ # @return [Symbol] The name of the base language.
211
+ # @example On MRI 1.9
212
+ # System::Ruby.language # => :ruby
213
+ # @example On JRuby
214
+ # System::Ruby.language # => :java
215
+ # @since 0.1.3
216
+ def language
217
+ @language ||= if %W[rbx maglev].any? { |name| engine == name }
218
+ CPlusPlus
219
+ elsif platform =~ /java/
220
+ Java
221
+ else
222
+ C
223
+ end
224
+ end
225
+
226
+ # Check if Ruby is using Java as it's base language.
227
+ #
228
+ # @return [TrueClass, FalseClass]
86
229
  # @since 0.1.1
87
230
  def java?
88
- !(/java/.match(platform).nil?)
231
+ language == Java
232
+ end
233
+
234
+ # Check if Ruby is using C or CPlusPlus as it's base language.
235
+ #
236
+ # @return [TrueClass, FalseClass]
237
+ # @since 0.1.3
238
+ def ruby?
239
+ [C, CPlusPlus].any? { |language| self.language == language }
89
240
  end
90
241
 
91
- # Check if Ruby is JRuby.
242
+ # Check if Ruby interpreter is JRuby.
92
243
  # Delegates to System::Ruby.jruby? for backwards compatibility.
93
244
  #
94
- # @return [TrueClass, FalseClass] Is the current Ruby implementation JRuby?
245
+ # @return [TrueClass, FalseClass] Is the current Ruby interpreter JRuby?
95
246
  # @since 0.1.1
96
247
  def jruby?
97
- java? ? !!(/jruby/.match(engine)) : false
248
+ java? ? engine =~ /jruby/ : false
98
249
  end
99
250
 
100
251
  end
@@ -2,14 +2,14 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "system"
5
- s.version = "0.1.1"
5
+ s.version = "0.1.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Roja Buck", "Ryan Scott Lewis"]
9
- s.date = "2012-11-10"
9
+ s.date = "2012-11-20"
10
10
  s.description = "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..."
11
11
  s.email = ["roja@arbia.co.uk", "ryan@rynet.us"]
12
- s.files = [".gitignore", ".rvmrc", "Gemfile", "Gemfile.lock", "Guardfile", "LICENSE", "NOTES.md", "README.md", "Rakefile", "VERSION", "lib/system.rb", "lib/system/backwards_compatibility.rb", "lib/system/cpu.rb", "lib/system/os.rb", "lib/system/ruby.rb", "lib/system/version.rb", "spec/spec_helper.rb", "spec/system/backwards_compatibility_spec.rb", "spec/system/version_spec.rb", "system.gemspec"]
12
+ s.files = [".gitignore", ".rvmrc", "Gemfile", "Gemfile.lock", "Guardfile", "LICENSE", "NOTES.md", "README.md", "Rakefile", "VERSION", "lib/system.rb", "lib/system/backwards_compatibility.rb", "lib/system/cpu.rb", "lib/system/os.rb", "lib/system/ruby.rb", "spec/spec_helper.rb", "spec/system/backwards_compatibility_spec.rb", "spec/system/version_spec.rb", "system.gemspec"]
13
13
  s.homepage = "http://github.com/roja/system"
14
14
  s.require_paths = ["lib"]
15
15
  s.rubygems_version = "1.8.24"
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.specification_version = 3
20
20
 
21
21
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
22
- s.add_development_dependency(%q<version>, ["~> 1.0.0"])
22
+ s.add_runtime_dependency(%q<version>, ["~> 1.0.0"])
23
23
  s.add_development_dependency(%q<rake>, ["~> 0.9"])
24
24
  s.add_development_dependency(%q<guard-rspec>, ["~> 2.1.1"])
25
25
  s.add_development_dependency(%q<guard-yard>, ["~> 2.0.1"])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: system
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-10 00:00:00.000000000 Z
13
+ date: 2012-11-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: version
@@ -20,7 +20,7 @@ dependencies:
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
22
  version: 1.0.0
23
- type: :development
23
+ type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  none: false
@@ -149,7 +149,6 @@ files:
149
149
  - lib/system/cpu.rb
150
150
  - lib/system/os.rb
151
151
  - lib/system/ruby.rb
152
- - lib/system/version.rb
153
152
  - spec/spec_helper.rb
154
153
  - spec/system/backwards_compatibility_spec.rb
155
154
  - spec/system/version_spec.rb
@@ -168,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
167
  version: '0'
169
168
  segments:
170
169
  - 0
171
- hash: -1923509668655408142
170
+ hash: 2597936987996136108
172
171
  required_rubygems_version: !ruby/object:Gem::Requirement
173
172
  none: false
174
173
  requirements:
@@ -1,5 +0,0 @@
1
- require 'version'
2
-
3
- class System
4
- is_versioned
5
- end