env_paths 0.0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +19 -0
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/env_paths.gemspec +3 -4
- data/lib/env_paths.rb +4 -4
- data/lib/env_paths/version.rb +1 -1
- data/spec/env_paths_spec.rb +32 -9
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa23c3678a7bf1bf6ddf27ca88c133301b5e8bca
|
4
|
+
data.tar.gz: 4a132162ea3b4593a33f5dfb464b4291b697d33c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09fea10406a8a9d59ffc8b1ed7504f1f157c0370d27179c621c991aeef4582c9ef7d0fb5d6a39b636763de54b85a1a66d6403a41cfafc0c1a61e762ad1b4b1a0'
|
7
|
+
data.tar.gz: c61384809f13718f8400451a47a99e13198aa35481c44af41479207011dd56544e41efd86a4559e4fd7a61dfeabac6f346617c39dd0e9919b4077f2877b65ac6
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,4 +1,23 @@
|
|
1
1
|
Documentation:
|
2
2
|
Enabled: false
|
3
|
+
|
3
4
|
Metrics/LineLength:
|
4
5
|
Enabled: false
|
6
|
+
|
7
|
+
Metrics/AbcSize:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Metrics/BlockLength:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Metrics/ClassLength:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Metrics/CyclomaticComplexity:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Metrics/ModuleLength:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Metrics/PerceivedComplexity:
|
23
|
+
Enabled: false
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
EnvPaths
|
1
|
+
EnvPaths ![Build Status](https://travis-ci.org/NickTomlin/env_paths.png?branch=master) [![Gem Version](https://badge.fury.io/rb/env_paths.svg)](https://badge.fury.io/rb/env_paths)
|
2
2
|
===
|
3
3
|
|
4
4
|
Provides OS specific paths for your gem/application. A ruby port of [`env-paths`](https://github.com/sindresorhus/env-paths).
|
data/Rakefile
CHANGED
data/env_paths.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'env_paths/version'
|
@@ -8,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
8
7
|
spec.version = EnvPaths::VERSION
|
9
8
|
spec.authors = ['Nick Tomlin']
|
10
9
|
spec.email = ['nick.tomlin@gmail.com']
|
11
|
-
spec.summary = 'Environment specific paths. A port of
|
10
|
+
spec.summary = 'Environment specific paths. A port of node\'s env-paths'
|
12
11
|
spec.license = 'MIT'
|
13
12
|
|
14
13
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -17,7 +16,7 @@ Gem::Specification.new do |spec|
|
|
17
16
|
spec.require_paths = ['lib']
|
18
17
|
|
19
18
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
20
|
-
spec.add_development_dependency 'rspec', '~> 3.5'
|
21
19
|
spec.add_development_dependency 'rake', '~> 10.0'
|
22
|
-
spec.add_development_dependency '
|
20
|
+
spec.add_development_dependency 'rspec', '~> 3.5'
|
21
|
+
spec.add_development_dependency 'rubocop', '~> 0.51.0'
|
23
22
|
end
|
data/lib/env_paths.rb
CHANGED
@@ -9,11 +9,11 @@ module EnvPaths
|
|
9
9
|
module Linux
|
10
10
|
def self.config(app_name)
|
11
11
|
OSData.new(
|
12
|
-
ENV.fetch('XDG_DATA_HOME', File.join(HOMEDIR, '.local', 'share', app_name)
|
13
|
-
ENV.fetch('XDG_CONFIG_HOME', File.join(HOMEDIR, '.config', app_name)
|
14
|
-
ENV.fetch('XDG_CACHE_HOME', File.join(HOMEDIR, '.cache', app_name)
|
12
|
+
File.join(ENV.fetch('XDG_DATA_HOME', File.join(HOMEDIR, '.local', 'share')), app_name),
|
13
|
+
File.join(ENV.fetch('XDG_CONFIG_HOME', File.join(HOMEDIR, '.config')), app_name),
|
14
|
+
File.join(ENV.fetch('XDG_CACHE_HOME', File.join(HOMEDIR, '.cache')), app_name),
|
15
15
|
# https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
16
|
-
ENV.fetch('XDG_STATE_HOME', File.join(HOMEDIR, '.local', 'state', app_name)
|
16
|
+
File.join(ENV.fetch('XDG_STATE_HOME', File.join(HOMEDIR, '.local', 'state')), app_name),
|
17
17
|
File.join(Dir.tmpdir, Etc.getlogin, app_name)
|
18
18
|
)
|
19
19
|
end
|
data/lib/env_paths/version.rb
CHANGED
data/spec/env_paths_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe EnvPaths do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'MacOs' do
|
15
|
-
it '
|
15
|
+
it 'returns OSX-specific data' do
|
16
16
|
allow(EnvPaths).to receive(:_platform).and_return('x86_64-darwin13.0')
|
17
17
|
env_paths = EnvPaths.get('my_app')
|
18
18
|
|
@@ -25,22 +25,45 @@ describe EnvPaths do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
context 'Linux' do
|
28
|
-
|
29
|
-
|
28
|
+
xdg_vars = %w[XDG_DATA_HOME XDG_CONFIG_HOME XDG_CACHE_HOME XDG_STATE_HOME]
|
29
|
+
platform = 'x86_64-linux'
|
30
|
+
|
31
|
+
it 'returns Linux-specific data' do
|
32
|
+
xdg_vars.each do |var|
|
33
|
+
allow(ENV).to receive(:fetch).with(var, anything) do |_, default|
|
34
|
+
default
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
allow(EnvPaths).to receive(:_platform).and_return(platform)
|
30
39
|
env_paths = EnvPaths.get('my_app')
|
31
40
|
|
32
|
-
expect(env_paths.data).to match(%r{
|
33
|
-
expect(env_paths.config).to match(%r{
|
34
|
-
expect(env_paths.cache).to match(%r{
|
35
|
-
expect(env_paths.log).to match(%r{
|
41
|
+
expect(env_paths.data).to match(%r{\.local/share/my_app-ruby$})
|
42
|
+
expect(env_paths.config).to match(%r{\.config/my_app-ruby$})
|
43
|
+
expect(env_paths.cache).to match(%r{\.cache/my_app-ruby$})
|
44
|
+
expect(env_paths.log).to match(%r{\.local/state/my_app-ruby$})
|
36
45
|
expect(env_paths.temp).to include('my_app-ruby')
|
37
46
|
end
|
38
47
|
|
39
|
-
it 'prefers XDG_* ENV settings to defaults'
|
48
|
+
it 'prefers XDG_* ENV settings to defaults' do
|
49
|
+
xdg_vars.each do |var|
|
50
|
+
dir = var[/^XDG_(\w+)_HOME$/, 1].downcase
|
51
|
+
allow(ENV).to receive(:fetch).with(var, anything).and_return("/home/test/#{dir}")
|
52
|
+
end
|
53
|
+
|
54
|
+
allow(EnvPaths).to receive(:_platform).and_return(platform)
|
55
|
+
env_paths = EnvPaths.get('my_app')
|
56
|
+
|
57
|
+
expect(env_paths.data).to eq('/home/test/data/my_app-ruby')
|
58
|
+
expect(env_paths.config).to eq('/home/test/config/my_app-ruby')
|
59
|
+
expect(env_paths.cache).to eq('/home/test/cache/my_app-ruby')
|
60
|
+
expect(env_paths.log).to eq('/home/test/state/my_app-ruby')
|
61
|
+
expect(env_paths.temp).to include('my_app-ruby')
|
62
|
+
end
|
40
63
|
end
|
41
64
|
|
42
65
|
context 'Windows' do
|
43
|
-
it '
|
66
|
+
it 'returns Windows-specific data' do
|
44
67
|
allow(EnvPaths).to receive(:_platform).and_return('win32')
|
45
68
|
env_paths = EnvPaths.get('my_app')
|
46
69
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: env_paths
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Tomlin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -25,47 +25,47 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3.5'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3.5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rubocop
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.51.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.51.0
|
69
69
|
description:
|
70
70
|
email:
|
71
71
|
- nick.tomlin@gmail.com
|
@@ -106,10 +106,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.6.8
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
|
-
summary: Environment specific paths. A port of
|
112
|
+
summary: Environment specific paths. A port of node's env-paths
|
113
113
|
test_files:
|
114
114
|
- spec/env_paths_spec.rb
|
115
115
|
- spec/spec_helper.rb
|