which_osx 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module WhichOsx
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
data/lib/which_osx.rb CHANGED
@@ -1,14 +1,44 @@
1
1
  # A simple tool to determine the current version of Mac OS X.
2
- # TODO : Catch if it's *not* OS X - whether that's Windows, or Linux.
2
+
3
+ # Regex for "##.#.#"
4
+ output = `sw_vers`.scan(/\d\d\.\d\.\d/).flatten.to_s
5
+
6
+ # Take out some weird bits
7
+ output.delete! "[]\""
8
+ VERSION = output
3
9
 
4
10
  module WhichOSX
5
11
  def self.version
6
- output = `sw_vers`.scan(/\d\d\.\d\.\d/).flatten.to_s
7
- output.delete! "[]\""
8
- return output
12
+ short_version = VERSION
13
+ return short_version
9
14
 
10
15
  rescue Errno::ENOENT
11
16
  puts "It looks like you aren't using Mac OS X. Sorry!"
12
17
 
13
18
  end
19
+
20
+ def self.full_version
21
+ full_version = "Mac OS X " + VERSION
22
+ return full_version
23
+ end
24
+
25
+ def self.short_name
26
+ # We just want the major versions -- 10.6, 10.7, etc.
27
+ major_version = VERSION.chop.chop
28
+
29
+ case
30
+ when major_version == "10.4"
31
+ short_name = "Tiger"
32
+ when major_version == "10.5"
33
+ short_name = "Leopard"
34
+ when major_version == "10.6"
35
+ short_name = "Snow Leopard"
36
+ when major_version == "10.7"
37
+ short_name = "Lion"
38
+ when major_version == "10.8"
39
+ short_name = "Mountain Lion"
40
+ end
41
+
42
+ return short_name
43
+ end
14
44
  end
@@ -1,4 +1,6 @@
1
1
  # which_osx_spec.rb
2
+ # todo: mock this so we don't encounter errors when we update our OS
3
+
2
4
  require 'which_osx'
3
5
 
4
6
  describe "version" do
@@ -13,5 +15,21 @@ require 'which_osx'
13
15
  # it "should tell you when you're not on Mac OS X" do
14
16
  # # how best to mock a non-Mac OS X environment?
15
17
  # end
18
+ end
16
19
 
20
+ describe "full version" do
21
+ it "should return the full name of the OS" do
22
+ WhichOSX.full_version.should === "Mac OS X 10.7.3"
23
+ end
17
24
  end
25
+
26
+ describe "short name" do
27
+ it "should chomp the version into a major release number" do
28
+ WhichOSX.version.chop.chop.should === "10.7"
29
+ end
30
+
31
+ it "should return a major release name (Lion, Leopard, etc.)" do
32
+ WhichOSX.short_name.should === "Lion"
33
+ end
34
+ end
35
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: which_osx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: