tty-platform 0.1.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 +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +24 -0
- data/Gemfile +15 -0
- data/LICENSE.txt +22 -0
- data/README.md +83 -0
- data/Rakefile +9 -0
- data/lib/tty-platform.rb +4 -0
- data/lib/tty/platform.rb +137 -0
- data/lib/tty/platform/version.rb +7 -0
- data/spec/spec_helper.rb +45 -0
- data/spec/unit/new_spec.rb +59 -0
- data/spec/unit/platform_spec.rb +65 -0
- data/spec/unit/to_s_spec.rb +9 -0
- data/tasks/console.rake +10 -0
- data/tasks/coverage.rake +11 -0
- data/tasks/spec.rake +29 -0
- data/tty-platform.gemspec +22 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7e68ecc0742c5f300e164e6664cfc3c228cc31f4
|
4
|
+
data.tar.gz: a9abe4cc3950411fe3e2155fc5796347459a7fd7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 72112f32a469e449c1b897b9a268976b50c8485b8895cb558e09f6f92634ab32189bf1767235e93cd6f198aa68884638188e394ca2e1eb0c5b1d36e9c961ca00
|
7
|
+
data.tar.gz: fe28d96ede597fa9b693937588330739aad7a49ce1bec753509d0748ea60f1fcf854022bb1787d2a2ebc3885d135d35a31524632c5ba93969f208e8ad5b03daa
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0
|
data/.travis.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
language: ruby
|
2
|
+
bundler_args: --without yard benchmarks
|
3
|
+
script: "bundle exec rake ci"
|
4
|
+
rvm:
|
5
|
+
- 1.9.3
|
6
|
+
- 2.0
|
7
|
+
- 2.1
|
8
|
+
- 2.2
|
9
|
+
- ruby-head
|
10
|
+
matrix:
|
11
|
+
include:
|
12
|
+
- rvm: jruby-19mode
|
13
|
+
- rvm: jruby-20mode
|
14
|
+
- rvm: jruby-21mode
|
15
|
+
- rvm: jruby-head
|
16
|
+
- rvm: rbx-2
|
17
|
+
allow_failures:
|
18
|
+
- rvm: ruby-head
|
19
|
+
- rvm: jruby-head
|
20
|
+
- rvm: jruby-20mode
|
21
|
+
- rvm: jruby-21mode
|
22
|
+
fast_finish: true
|
23
|
+
branches:
|
24
|
+
only: master
|
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
group :development do
|
6
|
+
gem 'rake', '~> 10.4.2'
|
7
|
+
gem 'rspec', '~> 3.2.0'
|
8
|
+
gem 'yard', '~> 0.8.7'
|
9
|
+
end
|
10
|
+
|
11
|
+
group :metrics do
|
12
|
+
gem 'coveralls', '~> 0.8.1'
|
13
|
+
gem 'simplecov', '~> 0.10.0'
|
14
|
+
gem 'yardstick', '~> 0.9.9'
|
15
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Piotr Murach
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# TTY::Platform
|
2
|
+
[][gem]
|
3
|
+
[][travis]
|
4
|
+
[][codeclimate]
|
5
|
+
[][coverage]
|
6
|
+
|
7
|
+
[gem]: http://badge.fury.io/rb/tty-platform
|
8
|
+
[travis]: http://travis-ci.org/peter-murach/tty-platform
|
9
|
+
[codeclimate]: https://codeclimate.com/github/peter-murach/tty-platform
|
10
|
+
[coverage]: https://coveralls.io/r/peter-murach/tty-platform
|
11
|
+
|
12
|
+
> Terminal platform query methods for detecting different operating systems.
|
13
|
+
|
14
|
+
**TTY::Platform** provides independent operating system detection component for [TTY](https://github.com/peter-murach/tty) toolkit.
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'tty-platform'
|
22
|
+
```
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
$ bundle
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
$ gem install tty-platform
|
31
|
+
|
32
|
+
## 1. Usage
|
33
|
+
|
34
|
+
With **TTY::Platform** you can find out the properties of your operating system by creating an instance:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
platform = TTY::Platform.new
|
38
|
+
```
|
39
|
+
|
40
|
+
To query for processor name use `cpu` method:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
platform.cpu # => 'x86_64'
|
44
|
+
```
|
45
|
+
|
46
|
+
A `nil` is returned if the value cannot be determined.
|
47
|
+
|
48
|
+
To get the system/OS name use `os` method:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
platform.os # => 'darwin'
|
52
|
+
```
|
53
|
+
|
54
|
+
A `nil` is returned if the value cannot be determined.
|
55
|
+
|
56
|
+
To get system's release version use `version` method:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
platform.version # => '10.6.1'
|
60
|
+
```
|
61
|
+
|
62
|
+
A `nil` is returned. Note that many platforms do not provide this information.
|
63
|
+
|
64
|
+
In addition, you can use more generic methods to check the type of operating system out of `windows`, `linux`, `mac` and `unix`:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
platform.windows? # => false
|
68
|
+
platform.unix? # => true
|
69
|
+
platform.linux? # => false
|
70
|
+
platform.mac? # => true
|
71
|
+
```
|
72
|
+
|
73
|
+
## Contributing
|
74
|
+
|
75
|
+
1. Fork it ( https://github.com/peter-murach/tty-platform/fork )
|
76
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
77
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
78
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
79
|
+
5. Create a new Pull Request
|
80
|
+
|
81
|
+
## Copyright
|
82
|
+
|
83
|
+
Copyright (c) 2015 Piotr Murach. See LICENSE for further details.
|
data/Rakefile
ADDED
data/lib/tty-platform.rb
ADDED
data/lib/tty/platform.rb
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'tty/platform/version'
|
4
|
+
|
5
|
+
module TTY
|
6
|
+
# Detects system platform properties
|
7
|
+
#
|
8
|
+
# @api public
|
9
|
+
class Platform
|
10
|
+
WINDOWS_PATTERN = /(cygwin|mswin|mingw|bccwin|wince|emx)/i
|
11
|
+
|
12
|
+
UNIX_PATTERN = /(aix|arch|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
|
13
|
+
|
14
|
+
LINUX_PATTERN = /linux|arch/i
|
15
|
+
|
16
|
+
MAC_PATTERN = /darwin/i
|
17
|
+
|
18
|
+
# Returns processor name, e.g. 'amdk6'
|
19
|
+
#
|
20
|
+
# @api public
|
21
|
+
attr_reader :cpu
|
22
|
+
|
23
|
+
# Returns the system/OS name, e.g. 'darwin'
|
24
|
+
#
|
25
|
+
# @api public
|
26
|
+
attr_reader :os
|
27
|
+
|
28
|
+
# Returns system's release version, e.g. '10.8.1'
|
29
|
+
#
|
30
|
+
# @api public
|
31
|
+
attr_reader :version
|
32
|
+
|
33
|
+
# Create platform properties
|
34
|
+
#
|
35
|
+
# @api public
|
36
|
+
def initialize(arch = nil)
|
37
|
+
@cpu, @os, @version = *detect_system_properties(arch)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Add operating system query methods
|
41
|
+
constants.grep(/PATTERN/).each do |pattern|
|
42
|
+
name = pattern.to_s.split('_').first.downcase
|
43
|
+
system_query = :"#{name}?"
|
44
|
+
define_method(system_query) do
|
45
|
+
match_os?(self.class.const_get(pattern))
|
46
|
+
end
|
47
|
+
self.class.class_eval do
|
48
|
+
define_method(system_query) do
|
49
|
+
new.public_send(system_query)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Detect if using windows path delimiter
|
55
|
+
#
|
56
|
+
# @return [Boolean]
|
57
|
+
#
|
58
|
+
# @api public
|
59
|
+
def windows_file_path?
|
60
|
+
::File::ALT_SEPARATOR == '\\'
|
61
|
+
end
|
62
|
+
|
63
|
+
# Check if platform matches given systems
|
64
|
+
#
|
65
|
+
# @return [Boolean]
|
66
|
+
#
|
67
|
+
# @api public
|
68
|
+
def match_os?(matcher)
|
69
|
+
!!(@os =~ matcher)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Queries for system architecture information
|
73
|
+
#
|
74
|
+
# @return [String]
|
75
|
+
#
|
76
|
+
# @api public
|
77
|
+
def architecture
|
78
|
+
RbConfig::CONFIG['arch']
|
79
|
+
end
|
80
|
+
|
81
|
+
# @return [Array[String]]
|
82
|
+
#
|
83
|
+
# @api public
|
84
|
+
def to_a
|
85
|
+
[@cpu, @os, @version]
|
86
|
+
end
|
87
|
+
|
88
|
+
# String representation
|
89
|
+
#
|
90
|
+
# @api public
|
91
|
+
def to_s
|
92
|
+
to_a.compact.join('-')
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
# Infer system properties from architecture information
|
98
|
+
#
|
99
|
+
# @return [Array[String, String String]]
|
100
|
+
#
|
101
|
+
# @api private
|
102
|
+
def detect_system_properties(arch)
|
103
|
+
parts = (arch || architecture).split('-', 2)
|
104
|
+
|
105
|
+
if parts.length == 1
|
106
|
+
@cpu, system = nil, parts.shift
|
107
|
+
else
|
108
|
+
@cpu, system = *parts
|
109
|
+
end
|
110
|
+
@os, @version = *find_os_and_version(system)
|
111
|
+
[@cpu, @os, @version]
|
112
|
+
end
|
113
|
+
|
114
|
+
# @param [String] system
|
115
|
+
#
|
116
|
+
# @api private
|
117
|
+
def find_os_and_version(system)
|
118
|
+
case system
|
119
|
+
when /aix(\d+(\.\d+)*)?/ then ['aix', $1]
|
120
|
+
when /bccwin(\d+(\.\d+)*)?/ then ['bccwin', $1]
|
121
|
+
when /bitrig(\d+(\.\d+)*)?/ then ['bitrig', $1]
|
122
|
+
when /cygwin/ then ['cygwin', nil]
|
123
|
+
when /darwin(\d+(\.\d+)*)?/ then ['darwin', $1]
|
124
|
+
when /emx/ then ['emx', nil]
|
125
|
+
when /freebsd(\d+(\.\d+)*)?/ then ['freebsd', $1]
|
126
|
+
when /linux(\d+(\.\d+)*)?/ then ['linux', $1]
|
127
|
+
when /mingw32/ then ['mingw32', nil]
|
128
|
+
when /(mswin\d+)((\_|-)(\d+))?/ then [$1, $4]
|
129
|
+
when /netbsdelf/ then ['netbsdelf', nil]
|
130
|
+
when /openbsd(\d+(\.\d+)*)?/ then ['openbsd', $1]
|
131
|
+
when /solaris(\d+(\.\d+)*)?/ then ['solaris', $1]
|
132
|
+
when /wince(\d+(\.\d+)*)?/ then ['wince', $1]
|
133
|
+
else ['unknown', nil]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end # Platform
|
137
|
+
end # TTY
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
if RUBY_VERSION > '1.9' and (ENV['COVERAGE'] || ENV['TRAVIS'])
|
4
|
+
require 'simplecov'
|
5
|
+
require 'coveralls'
|
6
|
+
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
8
|
+
SimpleCov::Formatter::HTMLFormatter,
|
9
|
+
Coveralls::SimpleCov::Formatter
|
10
|
+
]
|
11
|
+
|
12
|
+
SimpleCov.start do
|
13
|
+
command_name 'spec'
|
14
|
+
add_filter 'spec'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'tty-platform'
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
config.expect_with :rspec do |expectations|
|
22
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
23
|
+
end
|
24
|
+
|
25
|
+
config.mock_with :rspec do |mocks|
|
26
|
+
mocks.verify_partial_doubles = true
|
27
|
+
end
|
28
|
+
|
29
|
+
config.filter_run :focus
|
30
|
+
config.run_all_when_everything_filtered = true
|
31
|
+
|
32
|
+
config.disable_monkey_patching!
|
33
|
+
|
34
|
+
config.warnings = true
|
35
|
+
|
36
|
+
if config.files_to_run.one?
|
37
|
+
config.default_formatter = 'doc'
|
38
|
+
end
|
39
|
+
|
40
|
+
config.profile_examples = 2
|
41
|
+
|
42
|
+
config.order = :random
|
43
|
+
|
44
|
+
Kernel.srand config.seed
|
45
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
RSpec.describe TTY::Platform, '#new' do
|
4
|
+
it "detects system properties" do
|
5
|
+
allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('i686-darwin8.10.1')
|
6
|
+
platform = TTY::Platform.new
|
7
|
+
expect(platform.cpu).to eq('i686')
|
8
|
+
expect(platform.os).to eq('darwin')
|
9
|
+
expect(platform.version).to eq('8.10.1')
|
10
|
+
end
|
11
|
+
|
12
|
+
{
|
13
|
+
# aix
|
14
|
+
'powerpc-aix7.1' => ['powerpc', 'aix', '7.1'],
|
15
|
+
# bitrig
|
16
|
+
'amd64-bitrig1.0' => ['amd64', 'bitrig', '1.0'],
|
17
|
+
'armv7-bitrig1.0' => ['armv7', 'bitrig', '1.0'],
|
18
|
+
'bitrig1.0' => [nil, 'bitrig', '1.0'],
|
19
|
+
# cygwin
|
20
|
+
'i386-cygwin' => ['i386', 'cygwin', nil],
|
21
|
+
# darwin
|
22
|
+
'powerpc-darwin7' => ['powerpc', 'darwin', '7'],
|
23
|
+
'universal-darwin9' => ['universal', 'darwin', '9'],
|
24
|
+
'x86_64-darwin14.0.0' => ['x86_64', 'darwin', '14.0.0'],
|
25
|
+
'x86_64-darwin' => ['x86_64', 'darwin', nil],
|
26
|
+
# freebsd
|
27
|
+
'amd64-freebsd10.1' => ['amd64', 'freebsd', '10.1'],
|
28
|
+
'i386-freebsd10.1' => ['i386', 'freebsd', '10.1'],
|
29
|
+
'i386-freebsd10' => ['i386', 'freebsd', '10'],
|
30
|
+
'i386-freebsd' => ['i386', 'freebsd', nil],
|
31
|
+
'universal-freebsd' => ['universal', 'freebsd', nil],
|
32
|
+
# linux
|
33
|
+
'powerpc-linux' => ['powerpc', 'linux', nil],
|
34
|
+
'i686-linux' => ['i686', 'linux', nil],
|
35
|
+
'x86_64-linux' => ['x86_64', 'linux', nil],
|
36
|
+
'i386-linux-gnu' => ['i386', 'linux', nil],
|
37
|
+
# mswin
|
38
|
+
'i386-mingw32' => ['i386', 'mingw32', nil],
|
39
|
+
'mswin32' => [nil, 'mswin32', nil],
|
40
|
+
'i386-mswin32' => ['i386', 'mswin32', nil],
|
41
|
+
'i386-mswin32_80' => ['i386', 'mswin32', '80'],
|
42
|
+
'i386-mswin32-80' => ['i386', 'mswin32', '80'],
|
43
|
+
# netbsd
|
44
|
+
'i386-netbsdelf' => ['i386', 'netbsdelf', nil],
|
45
|
+
# openbsd
|
46
|
+
'i386-openbsd4.0' => ['i386', 'openbsd', '4.0'],
|
47
|
+
'x86_64-openbsd4.0' => ['x86_64', 'openbsd', '4.0'],
|
48
|
+
# solaris
|
49
|
+
'sparc-solaris2.10' => ['sparc', 'solaris', '2.10'],
|
50
|
+
'i386-solaris2.10' => ['i386', 'solaris', '2.10'],
|
51
|
+
# wince
|
52
|
+
'i386-wince7.0' => ['i386', 'wince', '7.0'],
|
53
|
+
}.each do |arch, expected|
|
54
|
+
it "detectes #{sprintf("%-22s", "'#{arch}'")} as #{expected}" do
|
55
|
+
platform = TTY::Platform.new(arch)
|
56
|
+
expect(platform.to_a).to eq(expected)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
RSpec.describe TTY::Platform, 'platform' do
|
4
|
+
it "correctly detects windows platform" do
|
5
|
+
allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('x86-mswin32_60')
|
6
|
+
platform = TTY::Platform.new
|
7
|
+
expect(platform.windows?).to eq(true)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "fails to detect windows" do
|
11
|
+
allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('unknown')
|
12
|
+
platform = TTY::Platform.new
|
13
|
+
expect(platform.windows?).to eq(false)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "correctly detects windows platform at class level" do
|
17
|
+
allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('x86-mswin32_60')
|
18
|
+
expect(TTY::Platform.windows?).to eq(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "correctly detects linux platform" do
|
22
|
+
allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('x86_64-linux')
|
23
|
+
platform = TTY::Platform.new
|
24
|
+
expect(platform.linux?).to eq(true)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "fails to detect linux platform" do
|
28
|
+
allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('unknown')
|
29
|
+
platform = TTY::Platform.new
|
30
|
+
expect(platform.linux?).to eq(false)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "correctly detects linux platform at class level" do
|
34
|
+
allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('x86_64-linux')
|
35
|
+
expect(TTY::Platform.linux?).to eq(true)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "correctly detects mac platform" do
|
39
|
+
allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('x86_64-darwin')
|
40
|
+
platform = TTY::Platform.new
|
41
|
+
expect(platform.mac?).to eq(true)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "fails to detect mac platform" do
|
45
|
+
allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('unknown')
|
46
|
+
platform = TTY::Platform.new
|
47
|
+
expect(platform.mac?).to eq(false)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "correctly detects mac platform at class level" do
|
51
|
+
allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('x86_64-darwin')
|
52
|
+
expect(TTY::Platform.mac?).to eq(true)
|
53
|
+
end
|
54
|
+
|
55
|
+
it "correctly detects unix platform" do
|
56
|
+
allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('x86_64-darwin')
|
57
|
+
platform = TTY::Platform.new
|
58
|
+
expect(platform.unix?).to eq(true)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "correctly detects unix platform at class level" do
|
62
|
+
allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('x86_64-darwin')
|
63
|
+
expect(TTY::Platform.unix?).to eq(true)
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
RSpec.describe TTY::Platform, '.to_s' do
|
4
|
+
it "display platform information" do
|
5
|
+
allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_return('i686-darwin8.10.1')
|
6
|
+
platform = TTY::Platform.new
|
7
|
+
expect(platform.to_s).to eq('i686-darwin-8.10.1')
|
8
|
+
end
|
9
|
+
end
|
data/tasks/console.rake
ADDED
data/tasks/coverage.rake
ADDED
data/tasks/spec.rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
desc 'Run all specs'
|
7
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
8
|
+
task.pattern = 'spec/{unit,integration}{,/*/**}/*_spec.rb'
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace :spec do
|
12
|
+
desc 'Run unit specs'
|
13
|
+
RSpec::Core::RakeTask.new(:unit) do |task|
|
14
|
+
task.pattern = 'spec/unit{,/*/**}/*_spec.rb'
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Run integration specs'
|
18
|
+
RSpec::Core::RakeTask.new(:integration) do |task|
|
19
|
+
task.pattern = 'spec/integration{,/*/**}/*_spec.rb'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
rescue LoadError
|
24
|
+
%w[spec spec:unit spec:integration].each do |name|
|
25
|
+
task name do
|
26
|
+
$stderr.puts "In order to run #{name}, do `gem install rspec`"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'tty/platform/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "tty-platform"
|
8
|
+
spec.version = TTY::Platform::VERSION
|
9
|
+
spec.authors = ["Piotr Murach"]
|
10
|
+
spec.email = [""]
|
11
|
+
spec.summary = %q{Query methods for detecting different operating systems.}
|
12
|
+
spec.description = %q{Query methods for detecting different operating systems.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tty-platform
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Piotr Murach
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
description: Query methods for detecting different operating systems.
|
28
|
+
email:
|
29
|
+
- ''
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- .rspec
|
36
|
+
- .ruby-version
|
37
|
+
- .travis.yml
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- lib/tty-platform.rb
|
43
|
+
- lib/tty/platform.rb
|
44
|
+
- lib/tty/platform/version.rb
|
45
|
+
- spec/spec_helper.rb
|
46
|
+
- spec/unit/new_spec.rb
|
47
|
+
- spec/unit/platform_spec.rb
|
48
|
+
- spec/unit/to_s_spec.rb
|
49
|
+
- tasks/console.rake
|
50
|
+
- tasks/coverage.rake
|
51
|
+
- tasks/spec.rake
|
52
|
+
- tty-platform.gemspec
|
53
|
+
homepage: ''
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
metadata: {}
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 2.0.3
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: Query methods for detecting different operating systems.
|
77
|
+
test_files:
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
- spec/unit/new_spec.rb
|
80
|
+
- spec/unit/platform_spec.rb
|
81
|
+
- spec/unit/to_s_spec.rb
|
82
|
+
has_rdoc:
|