os_name 0.1.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1174b42e25770fbab500ef7eca4a47252463810
4
- data.tar.gz: 79dd573d20d90bbf9ae285209342147dbb5af0ab
3
+ metadata.gz: 4aba0133bb193a5996b37cade8dd989abdc0ec6b
4
+ data.tar.gz: 1769dcffe9400eb9a6f06dff380408592a2d0cf8
5
5
  SHA512:
6
- metadata.gz: fd2a18fbedc00c3c293efabc0b76065114bd75154e414c11addf32724ab6874c6171bb87bf9d11770f212879f68bff7b0b499527118de8a086a19ac061c2c7f8
7
- data.tar.gz: 779bae259f55e7cee178a62c237e73e319f253d698e5163ba047a6a51dfc5bf31f3e5270a2ac367e8bf2624dddde9ddf4e1655e88b9dae91d539a50aa764757c
6
+ metadata.gz: d02102b829d3f6f631cc7e5cc4cb405a980f047137d91467b8aae579359c3b64ffe069f89c6f9c71b8cd6518f5f125c8722240a7cb20b2d698427e221fe7a19b
7
+ data.tar.gz: c7728a6c6dc2f477e638dba898aa77b679078f9f334801ee9c0e403761c6bdc847bd109e02eefc32c9d837cc66cc6f48211bff12ce3decb1b6e07e63e37373a5
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
@@ -0,0 +1,25 @@
1
+ before_install:
2
+ - gem update bundler
3
+ bundler_args: --without development
4
+ language: ruby
5
+ env:
6
+ global:
7
+ - CODECLIMATE_REPO_TOKEN=1fa179913fd57a6d2aab7013a56a224c3837561da507f5cff8f10e13c425d289
8
+ rvm:
9
+ - 1.9.3
10
+ - 2.0.0
11
+ - 2.1
12
+ - rbx-2
13
+ - ruby-head
14
+ matrix:
15
+ include:
16
+ - rvm: jruby-19mode
17
+ env: JRUBY_OPTS="$JRUBY_OPTS --debug"
18
+ - rvm: jruby-head
19
+ env: JRUBY_OPTS="$JRUBY_OPTS --debug"
20
+ allow_failures:
21
+ - rvm: rbx-2
22
+ - rvm: jruby-head
23
+ - rvm: ruby-head
24
+ fast_finish: true
25
+ script: bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
6
+
7
+ group :test do
8
+ gem 'minitest'
9
+ gem 'codeclimate-test-reporter', require: false
10
+ end
data/README.md CHANGED
@@ -1,11 +1,12 @@
1
1
  # `OSName`
2
2
 
3
- [![Gem Version](http://img.shields.io/gem/v/os_name.svg)][gem]
3
+ [![Gem Version](https://badge.fury.io/rb/os_name.svg)][gem]
4
4
  [![Build Status](https://travis-ci.org/JuanitoFatas/comer_de_tapas.svg)][travis]
5
5
  [![Dependency Status](https://gemnasium.com/JuanitoFatas/os_name.svg)][gemnasium]
6
6
  [![Inline docs ](http://inch-ci.org/github/JuanitoFatas/os_name.svg)][docs]
7
7
  [![Code Climate](https://codeclimate.com/github/JuanitoFatas/os_name.png)][codeclimate]
8
8
  [![Coverage](https://codeclimate.com/github/JuanitoFatas/os_name/coverage.png)][coverage]
9
+ [![PullReview stats](https://www.pullreview.com/github/JuanitoFatas/os_name/badges/master.svg?)][pull-review]
9
10
 
10
11
  [gem]: https://rubygems.org/gems/os_name
11
12
  [travis]: https://travis-ci.org/JuanitoFatas/os_name
@@ -13,6 +14,7 @@
13
14
  [docs]: http://inch-ci.org/github/juanitofatas/os_name
14
15
  [codeclimate]: https://codeclimate.com/github/JuanitoFatas/os_name
15
16
  [coverage]: https://codeclimate.com/github/JuanitoFatas/os_name
17
+ [pull-review]: https://www.pullreview.com/github/JuanitoFatas/os_name/reviews/master
16
18
 
17
19
  Get the name of the current operating system.
18
20
 
@@ -2,17 +2,17 @@
2
2
 
3
3
  Signal.trap('INT') { abort }
4
4
 
5
- $:.unshift File.join(File.dirname(__FILE__), *%w{ .. lib })
6
-
7
5
  require 'optparse'
8
- require "os_name"
6
+ require_relative '../lib/os_name'
9
7
 
10
8
  OptionParser.new do |opts|
11
- opts.banner = <<-BANNER
12
- Example:
13
- $ os_name
14
- OS X Mavericks
15
- BANNER
9
+ opts.banner = 'Usage: os_name [options]'
10
+
11
+ opts.on('-v', '--version', 'os_name version') do |_|
12
+ puts OSName::VERSION
13
+ exit
14
+ end
15
+
16
16
  end.parse!
17
17
 
18
18
  puts Class.new.extend(OSName).os_name
@@ -0,0 +1,75 @@
1
+ require 'os_name/version'
2
+
3
+ # Operating System Name
4
+ module OSName
5
+ # Win32 platform version mapping
6
+ WIN32 = {
7
+ '6.4' => '10',
8
+ '6.3' => '8.1',
9
+ '6.2' => '8',
10
+ '6.1' => '7',
11
+ '6.0' => 'Vista',
12
+ '5.1' => 'XP',
13
+ '5.0' => '2000',
14
+ '4.9' => 'ME',
15
+ '4.1' => '98',
16
+ '4.0' => '95'
17
+ }
18
+
19
+ # OS X platform version mapping
20
+ OSX = {
21
+ '14' => 'Yosemite',
22
+ '13' => 'Mavericks',
23
+ '12' => 'Mountain Lion',
24
+ '11' => 'Lion',
25
+ '10' => 'Snow Leopard',
26
+ '9' => 'Leopard',
27
+ '8' => 'Tiger',
28
+ '7' => 'Panther',
29
+ '6' => 'Jaguar',
30
+ '5' => 'Puma'
31
+ }
32
+
33
+ # Return Operating System name with given os and version.
34
+ #
35
+ # @param os [String] Operating System: darwin, linux, win32.
36
+ # @param version [String] version (release): 14.0.0, 3.13.0-24-generic, 5.1.2600.
37
+ # @return [String] the name of operating system.
38
+ #
39
+ # Usage:
40
+ # > os_name 'darwin', '14.0.0'
41
+ # => 'OS X Yosemite'
42
+ # > os_name 'linux', '3.13.0-24-generic'
43
+ # => 'Linux 3.13'
44
+ # os_name 'win32', '5.1.2600'
45
+ # => 'Windows XP'
46
+ # os_name 'win32'
47
+ # => 'Windows'
48
+ def os_name os=nil, version=nil
49
+ if !os && version
50
+ raise ArgumentError, "You can't specify a `version` without specfying `os`"
51
+ end
52
+
53
+ os ||= platform.os
54
+ version ||= platform.version
55
+
56
+ case os
57
+ when 'darwin'
58
+ id = OSX.fetch version.split('.')[0]
59
+ 'OS X' + (id ? " #{id}" : '')
60
+ when 'linux'
61
+ id = version.sub(/^(\d+\.\d+).*/, '\1')
62
+ 'Linux' + (id ? " #{id}" : '')
63
+ when 'win32'
64
+ id = WIN32[version.slice(0, 3)]
65
+ 'Windows' + (id ? " #{id}" : '')
66
+ end
67
+ end
68
+
69
+ private
70
+
71
+ # @return [Gem::Platform] Current machine's platform information.
72
+ def platform
73
+ @platform ||= Gem::Platform.local
74
+ end
75
+ end
@@ -0,0 +1,3 @@
1
+ module OSName
2
+ VERSION = '0.9.0'
3
+ end
@@ -4,19 +4,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'os_name/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "os_name"
7
+ spec.name = 'os_name'
8
8
  spec.version = OSName::VERSION
9
- spec.authors = ["Juanito Fatas"]
10
- spec.email = ["katehuang0320@gmail.com"]
11
- spec.summary = %q{Get the name of the current operating system. Example: OS X Yosemite}
9
+ spec.authors = ['Juanito Fatas']
10
+ spec.email = ['katehuang0320@gmail.com']
11
+ spec.summary = 'Get the name of the current operating system. Example: OS X Yosemite'
12
12
  spec.description = spec.summary
13
- spec.homepage = "https://github.com/juanitofatas/os_name"
14
- spec.license = "MIT"
13
+ spec.homepage = 'https://github.com/juanitofatas/os_name'
14
+ spec.license = 'MIT'
15
15
 
16
- spec.files = %w[LICENSE README.md Rakefile os_name.gemspec]
17
- spec.executables = %w[os_name]
18
- spec.test_files = Dir.glob('spec/**/*')
19
- spec.require_paths = ["lib"]
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
17
 
21
- spec.add_development_dependency "bundler", ">= 1.3.0"
18
+ spec.executables = %w(os_name)
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '>= 1.3.0'
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: os_name
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juanito Fatas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-04 00:00:00.000000000 Z
11
+ date: 2014-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -32,10 +32,15 @@ executables:
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
+ - ".gitignore"
36
+ - ".travis.yml"
37
+ - Gemfile
35
38
  - LICENSE
36
39
  - README.md
37
40
  - Rakefile
38
41
  - bin/os_name
42
+ - lib/os_name.rb
43
+ - lib/os_name/version.rb
39
44
  - os_name.gemspec
40
45
  homepage: https://github.com/juanitofatas/os_name
41
46
  licenses:
@@ -57,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
62
  version: '0'
58
63
  requirements: []
59
64
  rubyforge_project:
60
- rubygems_version: 2.3.0
65
+ rubygems_version: 2.4.2
61
66
  signing_key:
62
67
  specification_version: 4
63
68
  summary: 'Get the name of the current operating system. Example: OS X Yosemite'