which_osx 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,12 +1,10 @@
1
1
  # which_osx
2
2
 
3
- ![The contemplative Mac](http://i.imgur.com/RNIc8.png)
4
-
5
3
  - http://github.com/imkmf/which_osx
6
4
 
7
5
  ## DESCRIPTION:
8
6
 
9
- A simple ruby program for outputting some information about your Mac.
7
+ A simple ruby program for outputting some information about your Mac's version, as well as some clever ways of intepreting it.
10
8
 
11
9
  ## FEATURES/PROBLEMS:
12
10
 
@@ -16,36 +14,48 @@ A simple ruby program for outputting some information about your Mac.
16
14
 
17
15
  ## USAGE:
18
16
 
19
- which_osx can be imported into a project and used to return the current version of OS X (as of writing, my computer returns "10.7.3"):
17
+ By requiring which_osx, you gain access to a couple useful methods:
18
+
19
+ ### WhichOSX.version
20
+
21
+ puts WhichOSX.version
22
+ => 10.8.2
20
23
 
21
- require 'which_osx'
24
+ ### WhichOSX.full_name
25
+
26
+ puts WhichOSX.full_name
27
+ => Mac OS X 10.8.2
22
28
 
23
- module ForTheREADME
24
- def self.test
25
- who_am_i = WhichOSX.version
26
- end
27
- end
29
+ ### WhichOSX.short_name
28
30
 
29
- which_osx version 1.0.3 adds new methods for different outputs:
31
+ puts WhichOSX.short_name
32
+ => Mountain Lion
30
33
 
31
- $ WhichOSX.full_name
32
- => Mac OS X 10.7.3
34
+ WhichOSX version 1.0.5 introduces boolean methods for checking the operating system:
33
35
 
34
- $ WhichOSX.short_name
35
- => Lion
36
+ ### WhichOSX.is_mountain_lion
37
+
38
+ WhichOSX.is_mountain_lion
39
+ => true
40
+
41
+ Includes `is_mountain_lion`, `is_lion`, `is_snow_leopard`, `is_leopard`, and `is_tiger`.
42
+
43
+ ### Binary
36
44
 
37
45
  Running from the command line returns the OS version by default:
38
46
 
39
47
  $ which_osx
40
- => 10.7.3
48
+ => This Mac is currently running 10.8.2.
41
49
 
42
50
  ## REQUIREMENTS:
43
51
 
44
- - None
52
+ - [Rspec](http://rspec.info)
53
+ - [YARD](http://yardoc.org) (and [redcarpet](http://yardoc.org) for Markdown formatting)
54
+
45
55
 
46
56
  ## INSTALL:
47
57
 
48
- sudo gem install which_osx
58
+ gem install which_osx
49
59
 
50
60
  ## DEVELOPERS:
51
61
 
data/Rakefile CHANGED
@@ -3,24 +3,24 @@ require 'rubygems/package_task'
3
3
  require 'rake/rdoctask' unless RUBY_VERSION >= '1.9.0'
4
4
  require 'rdoc/task' unless RUBY_VERSION <= '1.9.0'
5
5
  require 'rubygems/specification'
6
- require 'spec/rake/spectask'
6
+ require 'rspec/core/rake_task'
7
+ require 'yard'
7
8
 
8
9
  spec = Gem::Specification.load("#{File.dirname(__FILE__)}/which_osx.gemspec")
9
10
 
10
11
  task :default => :spec
11
12
 
12
- desc "Run specs"
13
- Spec::Rake::SpecTask.new do |t|
14
- t.spec_files = FileList['spec/**/*_spec.rb']
15
- t.spec_opts = %w(-fs --color)
16
- t.libs << ["spec", '.']
13
+ # Generate docs
14
+ YARD::Rake::YardocTask.new do |t|
15
+ t.files = ['lib/**/*.rb'] # optional
16
+ t.options = ['--any', '--extra', '--opts'] # optional
17
17
  end
18
18
 
19
- desc "Run all examples with RCov"
20
- Spec::Rake::SpecTask.new('spec:rcov') do |t|
21
- t.spec_files = FileList['spec/**/*_spec.rb']
22
- t.rcov = true
23
- t.rcov_opts = ['-T', '--sort', 'coverage', '--exclude', 'gems/*,spec/*']
19
+ # Run specs
20
+ desc "Run specs"
21
+ RSpec::Core::RakeTask.new(:core) do |spec|
22
+ spec.pattern = 'spec/*_spec.rb'
23
+ spec.rspec_opts = ['--backtrace']
24
24
  end
25
25
 
26
26
  # Gem tasks
data/bin/which_osx ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'which_osx'
4
+
5
+ puts "This Mac is currently running #{ WhichOSX.version }"
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module WhichOsx
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
data/lib/which_osx.rb CHANGED
@@ -7,7 +7,13 @@ output = `sw_vers`.scan(/\d\d\.\d\.\d/).flatten.to_s
7
7
  output.delete! "[]\""
8
8
  VERSION = output
9
9
 
10
- module WhichOSX
10
+ class WhichOSX
11
+
12
+ # Get the version of OS X currently running.
13
+ # This method returns something in the format of
14
+ # "XX.X.X" - it is used to help the rest of the commands
15
+ # execute properly.
16
+
11
17
  def self.version
12
18
  short_version = VERSION
13
19
  return short_version
@@ -17,11 +23,17 @@ module WhichOSX
17
23
 
18
24
  end
19
25
 
26
+ # Get the full name including version.
27
+ # Will always return "Mac OS X XX.X.X"
28
+
20
29
  def self.full_name
21
30
  full_name = "Mac OS X " + VERSION
22
31
  return full_name
23
32
  end
24
33
 
34
+ # Returns the common name for the operating system,
35
+ # such as "Mountain Lion" or "Tiger".
36
+
25
37
  def self.short_name
26
38
  # We just want the major versions -- 10.6, 10.7, etc.
27
39
  major_version = VERSION.chop.chop
@@ -41,4 +53,46 @@ module WhichOSX
41
53
 
42
54
  return short_name
43
55
  end
56
+
57
+ # A helper method for boolean checks. Compares the short name
58
+ # to the given version name and returns true or false accordingly.
59
+
60
+ def self.is(version)
61
+ if short_name == version
62
+ return true
63
+ else
64
+ return false
65
+ end
66
+ end
67
+
68
+ # Checks if the operating system is currently running Mountain Lion.
69
+
70
+ def self.is_mountain_lion
71
+ self.is("Mountain Lion")
72
+ end
73
+
74
+ # Checks if the operating system is currently running Lion.
75
+
76
+ def self.is_lion
77
+ self.is("Lion")
78
+ end
79
+
80
+ # Checks if the operating system is currently running Snow Leopard.
81
+
82
+ def self.is_snow_leopard
83
+ self.is("Snow Leopard")
84
+ end
85
+
86
+ # Checks if the operating system is currently running Leopard.
87
+
88
+ def self.is_leopard
89
+ self.is("Leopard")
90
+ end
91
+
92
+ # Checks if the operating system is currently running Tiger.
93
+
94
+ def self.is_tiger
95
+ self.is("Tiger")
96
+ end
97
+
44
98
  end
@@ -9,23 +9,19 @@ require 'which_osx'
9
9
  end
10
10
 
11
11
  it "should convert version to a nice string" do
12
- WhichOSX.version.should =~ /[0-9][0-9].[0-9].[0-9]/
12
+ WhichOSX.version.should =~ /1[0-9].[0-9].[0-9]/
13
13
  end
14
-
15
- # it "should tell you when you're not on Mac OS X" do
16
- # # how best to mock a non-Mac OS X environment?
17
- # end
18
14
  end
19
15
 
20
16
  describe "full name" do
21
17
  it "should return the full name of the OS" do
22
- WhichOSX.full_name.should =~ /Mac OS X [0-9][0-9].[0-9].[0-9]/
18
+ WhichOSX.full_name.should =~ /Mac OS X 1[0-9].[0-9].[0-9]/
23
19
  end
24
20
  end
25
21
 
26
22
  describe "short name" do
27
23
  it "should chomp the version into a major release number" do
28
- WhichOSX.version.chop.chop.should =~ /[0-9][0-9].[0-9]/
24
+ WhichOSX.version.chop.chop.should =~ /1[0-9].[0-9]/
29
25
  end
30
26
 
31
27
  it "should return a major release name (Lion, Leopard, etc.)" do
@@ -33,3 +29,9 @@ require 'which_osx'
33
29
  end
34
30
  end
35
31
 
32
+ describe "is... checks" do
33
+ it "should return true if the OS is Mountain Lion" do
34
+ WhichOSX.is_mountain_lion.should be_true
35
+ end
36
+ end
37
+
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: which_osx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kristian Freeman
9
- autorequire: ''
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-21 00:00:00.000000000 Z
12
+ date: 2012-11-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -27,6 +27,38 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: 1.3.2
30
+ - !ruby/object:Gem::Dependency
31
+ name: yard
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: redcarpet
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
30
62
  - !ruby/object:Gem::Dependency
31
63
  name: rake
32
64
  requirement: !ruby/object:Gem::Requirement
@@ -46,8 +78,9 @@ dependencies:
46
78
  description: A simple ruby program for returning the version number of the current
47
79
  Mac OS X system.
48
80
  email:
49
- - kristian@kayeff.me
50
- executables: []
81
+ - kristian@kristianfreeman.com
82
+ executables:
83
+ - which_osx
51
84
  extensions: []
52
85
  extra_rdoc_files: []
53
86
  files:
@@ -58,6 +91,7 @@ files:
58
91
  - lib/version.rb
59
92
  - lib/which_osx.rb
60
93
  - spec/which_osx_spec.rb
94
+ - bin/which_osx
61
95
  homepage: http://github.com/imkmf/which_osx
62
96
  licenses: []
63
97
  post_install_message:
@@ -78,9 +112,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
78
112
  version: '0'
79
113
  requirements: []
80
114
  rubyforge_project:
81
- rubygems_version: 1.8.21
115
+ rubygems_version: 1.8.23
82
116
  signing_key:
83
117
  specification_version: 3
84
118
  summary: A simple ruby program for returning the version number of the current Mac
85
119
  OS X system.
86
120
  test_files: []
121
+ has_rdoc: false