env_ext 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +3 -0
- data/.gemtest +0 -0
- data/.gitignore +3 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/ChangeLog.md +19 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +20 -0
- data/README.md +67 -0
- data/Rakefile +10 -0
- data/env_ext.gemspec +61 -0
- data/gemspec.yml +21 -0
- data/lib/env_ext.rb +2 -0
- data/lib/env_ext/core_ext.rb +3 -0
- data/lib/env_ext/methods.rb +198 -0
- data/lib/env_ext/version.rb +4 -0
- data/spec/core_ext_spec.rb +10 -0
- data/spec/methods_spec.rb +149 -0
- data/spec/spec_helper.rb +1 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cf181a7ab8b681f2a72c90c2f2dc411bfa278ada9215ccc771529f39f4d6a5b2
|
4
|
+
data.tar.gz: 510e63c45a83b17ac02bbb616e4eda7f81ea4d9263939d5e157637fd5ba4e493
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: adc29127cb0ee3af12b3baf76d43839612d7a8088a678736546aa1e78187dc2b6100dce065607523c358bdd823215660c70b9f968046035e37dcfa30a0938784
|
7
|
+
data.tar.gz: fa51e166f74a0cad5a6d5c23aef3415e17e6196b2744cc5257fa3bbf2da3115dfc17a4ec785f025051b7c17a510321fcd3df3eeca0111549d73c6217833bab0b
|
data/.document
ADDED
data/.gemtest
ADDED
File without changes
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour --format documentation
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--markup markdown --title "env Documentation" --protected
|
data/ChangeLog.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
### 0.1.0 / 2020-12-27
|
2
|
+
|
3
|
+
* Initial release:
|
4
|
+
* {EnvExt::Methods#paths ENV.paths} -`PATH`
|
5
|
+
* {EnvExt::Methods#ld_library_paths ENV.ld_library_paths} - `LD_LIBRARY_PATH`
|
6
|
+
* {EnvExt::Methods#host_name ENV.host_name} -`HOMENAME`
|
7
|
+
* {EnvExt::Methods#user ENV.user} -`USER` or `LOGNAME`
|
8
|
+
* {EnvExt::Methods#home ENV.home}` - `HOME`, `USERPROFILE`, or `HOMEPATH` and `HOMEDRIVE` on Windows.
|
9
|
+
* {EnvExt::Methods#lang ENV.lang} - `LANG`
|
10
|
+
* {EnvExt::Methods#timezone ENV.timezone} - `TZ`
|
11
|
+
* {EnvExt::Methods#shell ENV.shell} - `SHELL`
|
12
|
+
* {EnvExt::Methods#shell ENV.shell_name} - `SHELL`
|
13
|
+
* {EnvExt::Methods#columns ENV.columns} - `COLOMNS`
|
14
|
+
* {EnvExt::Methods#lines ENV.lines} - `LINES`
|
15
|
+
* {EnvExt::Methods#terminal ENV.terminal} - `TERM` or `COLORTERM`
|
16
|
+
* {EnvExt::Methods#editor ENV.editor} - `EDITOR`
|
17
|
+
* {EnvExt::Methods#browser ENV.browser} - `BROWSER`
|
18
|
+
* {EnvExt::Methods#debug? ENV.debug?} - `DEBUG`
|
19
|
+
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011-2020 Hal Brodigan
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# env_ext
|
2
|
+
|
3
|
+
* [Homepage](https://github.com/postmodern/env_ext)
|
4
|
+
* [Issues](https://github.com/postmodern/env_ext/issues)
|
5
|
+
* [Documentation](http://rubydoc.info/gems/env_ext/frames)
|
6
|
+
* [Email](mailto:postmodern.mod3 at gmail.com)
|
7
|
+
|
8
|
+
## Description
|
9
|
+
|
10
|
+
env_ext adds additional methods to `ENV` for common environment variables,
|
11
|
+
used on Linux, BSD, OSX and Windows.
|
12
|
+
|
13
|
+
## Methods
|
14
|
+
|
15
|
+
* {EnvExt::Methods#paths ENV.paths} -`PATH`
|
16
|
+
* {EnvExt::Methods#ld_library_paths ENV.ld_library_paths} - `LD_LIBRARY_PATH`
|
17
|
+
* {EnvExt::Methods#host_name ENV.host_name} -`HOMENAME`
|
18
|
+
* {EnvExt::Methods#user ENV.user} -`USER` or `LOGNAME`
|
19
|
+
* {EnvExt::Methods#home ENV.home}` - `HOME`, `USERPROFILE`, or `HOMEPATH` and `HOMEDRIVE` on Windows.
|
20
|
+
* {EnvExt::Methods#lang ENV.lang} - `LANG`
|
21
|
+
* {EnvExt::Methods#timezone ENV.timezone} - `TZ`
|
22
|
+
* {EnvExt::Methods#shell ENV.shell} - `SHELL`
|
23
|
+
* {EnvExt::Methods#shell ENV.shell_name} - `SHELL`
|
24
|
+
* {EnvExt::Methods#columns ENV.columns} - `COLOMNS`
|
25
|
+
* {EnvExt::Methods#lines ENV.lines} - `LINES`
|
26
|
+
* {EnvExt::Methods#terminal ENV.terminal} - `TERM` or `COLORTERM`
|
27
|
+
* {EnvExt::Methods#editor ENV.editor} - `EDITOR`
|
28
|
+
* {EnvExt::Methods#browser ENV.browser} - `BROWSER`
|
29
|
+
* {EnvExt::Methods#debug? ENV.debug?} - `DEBUG`
|
30
|
+
|
31
|
+
## Examples
|
32
|
+
|
33
|
+
require 'env_ext'
|
34
|
+
|
35
|
+
Parse complex variables:
|
36
|
+
|
37
|
+
ENV.home
|
38
|
+
# => #<Pathname:/home/alice>
|
39
|
+
|
40
|
+
ENV.paths
|
41
|
+
# => [#<Pathname:/usr/local/bin>, #<Pathname:/usr/bin>, #<Pathname:/bin>, #<Pathname:/usr/local/sbin>, #<Pathname:/usr/sbin>, #<Pathname:/sbin>]
|
42
|
+
|
43
|
+
ENV.lang
|
44
|
+
# => ["en_US", "utf8"]
|
45
|
+
|
46
|
+
ENV.terminal
|
47
|
+
# => "gnome-terminal"
|
48
|
+
|
49
|
+
ENV.shell
|
50
|
+
# => "/bin/bash"
|
51
|
+
|
52
|
+
ENV.editor
|
53
|
+
# => "vim"
|
54
|
+
|
55
|
+
Extend your own `ENV` hash:
|
56
|
+
|
57
|
+
MyENV.extend EnvExt::Methods
|
58
|
+
|
59
|
+
## Install
|
60
|
+
|
61
|
+
$ gem install env_ext
|
62
|
+
|
63
|
+
## Copyright
|
64
|
+
|
65
|
+
Copyright (c) 2011-2020 Hal Brodigan
|
66
|
+
|
67
|
+
See {file:LICENSE.txt} for details.
|
data/Rakefile
ADDED
data/env_ext.gemspec
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gemspec = YAML.load_file('gemspec.yml')
|
7
|
+
|
8
|
+
gem.name = gemspec.fetch('name')
|
9
|
+
gem.version = gemspec.fetch('version') do
|
10
|
+
lib_dir = File.join(File.dirname(__FILE__),'lib')
|
11
|
+
$LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
|
12
|
+
|
13
|
+
require 'env_ext/version'
|
14
|
+
EnvExt::VERSION
|
15
|
+
end
|
16
|
+
|
17
|
+
gem.summary = gemspec['summary']
|
18
|
+
gem.description = gemspec['description']
|
19
|
+
gem.licenses = Array(gemspec['license'])
|
20
|
+
gem.authors = Array(gemspec['authors'])
|
21
|
+
gem.email = gemspec['email']
|
22
|
+
gem.homepage = gemspec['homepage']
|
23
|
+
gem.metadata = gemspec['metadata'] if gemspec['metadata']
|
24
|
+
|
25
|
+
glob = lambda { |patterns| gem.files & Dir[*patterns] }
|
26
|
+
|
27
|
+
gem.files = `git ls-files`.split($/)
|
28
|
+
gem.files = glob[gemspec['files']] if gemspec['files']
|
29
|
+
|
30
|
+
gem.executables = gemspec.fetch('executables') do
|
31
|
+
glob['bin/*'].map { |path| File.basename(path) }
|
32
|
+
end
|
33
|
+
gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
|
34
|
+
|
35
|
+
gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
|
36
|
+
gem.test_files = glob[gemspec['test_files'] || '{test/{**/}*_test.rb']
|
37
|
+
gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
|
38
|
+
|
39
|
+
gem.require_paths = Array(gemspec.fetch('require_paths') {
|
40
|
+
%w[ext lib].select { |dir| File.directory?(dir) }
|
41
|
+
})
|
42
|
+
|
43
|
+
gem.requirements = gemspec['requirements']
|
44
|
+
gem.required_ruby_version = gemspec['required_ruby_version']
|
45
|
+
gem.required_rubygems_version = gemspec['required_rubygems_version']
|
46
|
+
gem.post_install_message = gemspec['post_install_message']
|
47
|
+
|
48
|
+
split = lambda { |string| string.split(/,\s*/) }
|
49
|
+
|
50
|
+
if gemspec['dependencies']
|
51
|
+
gemspec['dependencies'].each do |name,versions|
|
52
|
+
gem.add_dependency(name,split[versions])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
if gemspec['development_dependencies']
|
57
|
+
gemspec['development_dependencies'].each do |name,versions|
|
58
|
+
gem.add_development_dependency(name,split[versions])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/gemspec.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
name: env_ext
|
2
|
+
summary: Adds additional methods to ENV
|
3
|
+
description:
|
4
|
+
env_ext adds additional methods to ENV for common environment variables,
|
5
|
+
used on Linux, BSD, OSX and Windows.
|
6
|
+
|
7
|
+
license: MIT
|
8
|
+
authors: Postmodern
|
9
|
+
email: postmodern.mod3@gmail.com
|
10
|
+
homepage: https://github.com/postmodern/env_ext#readme
|
11
|
+
|
12
|
+
metadata:
|
13
|
+
documentation_uri: https://rubydoc.info/gems/env_ext
|
14
|
+
source_code_uri: https://github.com/postmodern/env_ext
|
15
|
+
bug_tracker_uri: https://github.com/postmodern/env_ext/issues
|
16
|
+
changelog_uri: https://github.com/postmodern/env_ext/blob/master/ChangeLog.md
|
17
|
+
|
18
|
+
has_yard: true
|
19
|
+
|
20
|
+
development_dependencies:
|
21
|
+
bundler: ~> 2.0
|
data/lib/env_ext.rb
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module EnvExt
|
4
|
+
module Methods
|
5
|
+
#
|
6
|
+
# The directories to search within for executables.
|
7
|
+
#
|
8
|
+
# @return [Array<Pathname>]
|
9
|
+
# The paths of the directories.
|
10
|
+
#
|
11
|
+
def paths
|
12
|
+
parse_paths(self['PATH'])
|
13
|
+
end
|
14
|
+
|
15
|
+
#
|
16
|
+
# The directories to search within for libraries.
|
17
|
+
#
|
18
|
+
# @return [Array<Pathname>]
|
19
|
+
# The paths of the directories.
|
20
|
+
#
|
21
|
+
def ld_library_paths
|
22
|
+
parse_paths(self['LD_LIBRARY_PATH'])
|
23
|
+
end
|
24
|
+
|
25
|
+
#
|
26
|
+
# The host-name of the system.
|
27
|
+
#
|
28
|
+
# @return [String]
|
29
|
+
# The host-name.
|
30
|
+
#
|
31
|
+
def host_name
|
32
|
+
self['HOSTNAME']
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# The name of the current user.
|
37
|
+
#
|
38
|
+
# @return [String]
|
39
|
+
# The name of the user.
|
40
|
+
#
|
41
|
+
def user
|
42
|
+
# USER is used on GNU/Linux and Windows
|
43
|
+
# LOGNAME is the POSIX user-name ENV variable
|
44
|
+
self['USER'] || self['LOGNAME']
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# The home directory.
|
49
|
+
#
|
50
|
+
# @return [Pathname]
|
51
|
+
# The path of the home directory.
|
52
|
+
#
|
53
|
+
def home
|
54
|
+
# logic adapted from Gem.find_home.
|
55
|
+
path = if (self['HOME'] || self['USERPROFILE'])
|
56
|
+
self['HOME'] || self['USERPROFILE']
|
57
|
+
elsif (self['HOMEDRIVE'] && self['HOMEPATH'])
|
58
|
+
"#{self['HOMEDRIVE']}#{self['HOMEPATH']}"
|
59
|
+
else
|
60
|
+
begin
|
61
|
+
File.expand_path('~')
|
62
|
+
rescue
|
63
|
+
if File::ALT_SEPARATOR
|
64
|
+
'C:/'
|
65
|
+
else
|
66
|
+
'/'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
return Pathname.new(path)
|
72
|
+
end
|
73
|
+
|
74
|
+
#
|
75
|
+
# The default language.
|
76
|
+
#
|
77
|
+
# @return [Array<String, String>]
|
78
|
+
# The language name and encoding.
|
79
|
+
#
|
80
|
+
def lang
|
81
|
+
if (lang = self['LANG'])
|
82
|
+
lang.split('.',2)
|
83
|
+
else
|
84
|
+
[]
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
#
|
89
|
+
# The default timezone.
|
90
|
+
#
|
91
|
+
# @return [String, nil]
|
92
|
+
# The timezone name.
|
93
|
+
#
|
94
|
+
def timezone
|
95
|
+
self['TZ']
|
96
|
+
end
|
97
|
+
|
98
|
+
#
|
99
|
+
# The number of columns in the terminal.
|
100
|
+
#
|
101
|
+
# @return [Integer]
|
102
|
+
# The number of columns.
|
103
|
+
#
|
104
|
+
def columns
|
105
|
+
self['COLUMNS'].to_i if self['COLUMNS']
|
106
|
+
end
|
107
|
+
|
108
|
+
#
|
109
|
+
# The number of lines in the terminal.
|
110
|
+
#
|
111
|
+
# @return [Integer]
|
112
|
+
# The number of lines.
|
113
|
+
#
|
114
|
+
def lines
|
115
|
+
self['LINES'].to_i if self['LINES']
|
116
|
+
end
|
117
|
+
|
118
|
+
#
|
119
|
+
# The path of the default shell.
|
120
|
+
#
|
121
|
+
# @return [String, nil]
|
122
|
+
# The path to the default shell.
|
123
|
+
#
|
124
|
+
def shell
|
125
|
+
self['SHELL']
|
126
|
+
end
|
127
|
+
|
128
|
+
#
|
129
|
+
# The name of the default shell.
|
130
|
+
#
|
131
|
+
# @return [String, nil]
|
132
|
+
# The program name of the shell.
|
133
|
+
#
|
134
|
+
def shell_name
|
135
|
+
File.basename(shell) if shell
|
136
|
+
end
|
137
|
+
|
138
|
+
#
|
139
|
+
# The default terminal to use.
|
140
|
+
#
|
141
|
+
# @return [String, nil]
|
142
|
+
# The name of the terminal program.
|
143
|
+
#
|
144
|
+
def term
|
145
|
+
self['COLORTERM'] || self['TERM']
|
146
|
+
end
|
147
|
+
|
148
|
+
alias terminal term
|
149
|
+
|
150
|
+
#
|
151
|
+
# The default editor to use.
|
152
|
+
#
|
153
|
+
# @return [String, nil]
|
154
|
+
# The name of the editor program.
|
155
|
+
#
|
156
|
+
def editor
|
157
|
+
self['EDITOR']
|
158
|
+
end
|
159
|
+
|
160
|
+
#
|
161
|
+
# The default browser to use.
|
162
|
+
#
|
163
|
+
# @return [String, nil]
|
164
|
+
# The name of the browser program.
|
165
|
+
#
|
166
|
+
def browser
|
167
|
+
self['BROWSER']
|
168
|
+
end
|
169
|
+
|
170
|
+
#
|
171
|
+
# Determines whether optional Debugging was enabled.
|
172
|
+
#
|
173
|
+
# @return [Boolean]
|
174
|
+
# Specifies whether the `DEBUG` variable was specified.
|
175
|
+
#
|
176
|
+
def debug?
|
177
|
+
true if self['DEBUG']
|
178
|
+
end
|
179
|
+
|
180
|
+
protected
|
181
|
+
|
182
|
+
#
|
183
|
+
# Parses a String containing multiple paths.
|
184
|
+
#
|
185
|
+
# @return [Array<Pathname>]
|
186
|
+
# The multiple paths.
|
187
|
+
#
|
188
|
+
def parse_paths(paths)
|
189
|
+
if paths
|
190
|
+
paths.split(File::PATH_SEPARATOR).map do |path|
|
191
|
+
Pathname.new(path)
|
192
|
+
end
|
193
|
+
else
|
194
|
+
[]
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'env_ext/methods'
|
3
|
+
|
4
|
+
describe EnvExt::Methods do
|
5
|
+
subject { Object.new.extend(Methods) }
|
6
|
+
|
7
|
+
let(:home) { '/home/alice' }
|
8
|
+
let(:term) { 'xterm' }
|
9
|
+
let(:shell) { '/bin/bash' }
|
10
|
+
|
11
|
+
let(:env) do
|
12
|
+
{
|
13
|
+
'PATH' => '/usr/local/bin:/usr/bin:/bin',
|
14
|
+
'HOME' => home,
|
15
|
+
'TERM' => term,
|
16
|
+
'LANG' => 'en_US.UTF8',
|
17
|
+
'COLUMNS' => '80',
|
18
|
+
'LINES' => '10',
|
19
|
+
'SHELL' => '/bin/bash',
|
20
|
+
'DEBUG' => '1'
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
subject do
|
25
|
+
env.tap { |hash| hash.extend described_class }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#path" do
|
29
|
+
it "should parse the contents of the PATH variable" do
|
30
|
+
expect(subject.paths).to eq([
|
31
|
+
Pathname.new('/usr/local/bin'),
|
32
|
+
Pathname.new('/usr/bin'),
|
33
|
+
Pathname.new('/bin')
|
34
|
+
])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#home" do
|
39
|
+
it "should provide access to the HOME variable" do
|
40
|
+
expect(subject.home).to eq(Pathname.new(home))
|
41
|
+
end
|
42
|
+
|
43
|
+
context "whne USERPROFILE is set, but HOME is not set" do
|
44
|
+
let(:env) do
|
45
|
+
{
|
46
|
+
'USERPROFILE' => home
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should use the USERPROFILE variable if HOME is not set" do
|
51
|
+
expect(subject.home).to be == Pathname.new(home)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "when HOMEDRIVE and HOMEPATH are set, but HOME is not" do
|
56
|
+
let(:drive) { 'C:' }
|
57
|
+
let(:env) do
|
58
|
+
{
|
59
|
+
'HOMEDRIVE' => drive,
|
60
|
+
'HOMEPATH' => home
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should use HOMEDRIVE and HOMEPATH if HOME is not set" do
|
65
|
+
expect(subject.home).to be == Pathname.new(drive + home)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "when HOME isn't set" do
|
70
|
+
let(:env) { {} }
|
71
|
+
|
72
|
+
it "should attempt to expand '~' if none of the HOME variables are set" do
|
73
|
+
expect(subject.home).to be_directory
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "#lang" do
|
79
|
+
it "should parse the LANG variable" do
|
80
|
+
name, encoding = subject.lang
|
81
|
+
|
82
|
+
expect(name).to eq('en_US')
|
83
|
+
expect(encoding).to eq('UTF8')
|
84
|
+
end
|
85
|
+
|
86
|
+
context "when LANG is not set" do
|
87
|
+
let(:env) { {} }
|
88
|
+
|
89
|
+
it "should return an empty Array if LANG is not set" do
|
90
|
+
expect(subject.lang).to be_empty
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "#columns" do
|
96
|
+
it "should parse the COLUMNS variable" do
|
97
|
+
expect(subject.columns).to eq(80)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "#lines" do
|
102
|
+
it "should parse the LINES variable" do
|
103
|
+
expect(subject.lines).to eq(10)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "#shell" do
|
108
|
+
it "should provide access to the SHELL variable" do
|
109
|
+
expect(subject.shell).to eq(shell)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "#shell_name" do
|
114
|
+
it "should determine the program name of the current Shell" do
|
115
|
+
expect(subject.shell_name).to eq('bash')
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#term" do
|
120
|
+
it "should determine the current TERM" do
|
121
|
+
expect(subject.term).to eq(term)
|
122
|
+
end
|
123
|
+
|
124
|
+
context "when COLORTERM and TERM are set" do
|
125
|
+
let(:env) do
|
126
|
+
{
|
127
|
+
'COLORTERM' => 'gnome-terminal',
|
128
|
+
'TERM' => term
|
129
|
+
}
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should check COLORTERM before the TERM variable" do
|
133
|
+
expect(subject.term).to eq('gnome-terminal')
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "#terminal" do
|
139
|
+
it "should be an alias to #term" do
|
140
|
+
expect(subject.terminal).to be == subject.term
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe "#debug" do
|
145
|
+
it "should check if DEBUG was set" do
|
146
|
+
expect(subject).to be_debug
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rspec'
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: env_ext
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Postmodern
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-12-27 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: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
description: env_ext adds additional methods to ENV for common environment variables,
|
28
|
+
used on Linux, BSD, OSX and Windows.
|
29
|
+
email: postmodern.mod3@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files:
|
33
|
+
- ChangeLog.md
|
34
|
+
- LICENSE.txt
|
35
|
+
- README.md
|
36
|
+
files:
|
37
|
+
- ".document"
|
38
|
+
- ".gemtest"
|
39
|
+
- ".gitignore"
|
40
|
+
- ".rspec"
|
41
|
+
- ".yardopts"
|
42
|
+
- ChangeLog.md
|
43
|
+
- Gemfile
|
44
|
+
- LICENSE.txt
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
47
|
+
- env_ext.gemspec
|
48
|
+
- gemspec.yml
|
49
|
+
- lib/env_ext.rb
|
50
|
+
- lib/env_ext/core_ext.rb
|
51
|
+
- lib/env_ext/methods.rb
|
52
|
+
- lib/env_ext/version.rb
|
53
|
+
- spec/core_ext_spec.rb
|
54
|
+
- spec/methods_spec.rb
|
55
|
+
- spec/spec_helper.rb
|
56
|
+
homepage: https://github.com/postmodern/env_ext#readme
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata:
|
60
|
+
documentation_uri: https://rubydoc.info/gems/env_ext
|
61
|
+
source_code_uri: https://github.com/postmodern/env_ext
|
62
|
+
bug_tracker_uri: https://github.com/postmodern/env_ext/issues
|
63
|
+
changelog_uri: https://github.com/postmodern/env_ext/blob/master/ChangeLog.md
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubygems_version: 3.2.3
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Adds additional methods to ENV
|
83
|
+
test_files: []
|