env_paths 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +2 -2
- data/lib/env_paths.rb +3 -3
- data/lib/env_paths/version.rb +1 -1
- data/spec/env_paths_spec.rb +28 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f272d82bd2670a4f53b36df80085aaf9ae366f50
|
4
|
+
data.tar.gz: 8d294e1b1fca7b42a1d24de2b697a7c247718ef9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7c7e9ad97c7439c0d1a82c38d6f36b9e01639900d41443c666bb0b8e4294b22a558594c9e377362ad3378d7fb397e31637014bd5bd44c9157a8e27ea9db823c
|
7
|
+
data.tar.gz: 814d433e63e1f2d990d37a72b29243ccb47202fc7c9538d2b69113d98f3447137e482697f3afd9ddd4581091b8bb8b2ef359e477acb2e5bddb1264391ebe5a8a
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
EnvPaths
|
1
|
+
EnvPaths [![Build Status](https://travis-ci.org/NickTomlin/env_paths.png?branch=master)](https://travis-ci.org/NickTomlin/env_paths.fury.io/rb/env_paths.svg)](https://badge.fury.io/rb/env_paths)
|
2
2
|
===
|
3
3
|
|
4
|
-
Provides OS specific paths for your gem/application.
|
4
|
+
Provides OS specific paths for your gem/application. A ruby port of [`env-paths`](https://github.com/sindresorhus/env-paths).
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
data/lib/env_paths.rb
CHANGED
@@ -11,10 +11,10 @@ module EnvPaths
|
|
11
11
|
OSData.new(
|
12
12
|
ENV.fetch('XDG_DATA_HOME', File.join(HOMEDIR, '.local', 'share', app_name)),
|
13
13
|
ENV.fetch('XDG_CONFIG_HOME', File.join(HOMEDIR, '.config', app_name)),
|
14
|
-
ENV.
|
14
|
+
ENV.fetch('XDG_CACHE_HOME', File.join(HOMEDIR, '.cache', app_name)),
|
15
15
|
# https://wiki.debian.org/XDGBaseDirectorySpecification#state
|
16
|
-
ENV.
|
17
|
-
File.join(Dir.tmpdir,
|
16
|
+
ENV.fetch('XDG_STATE_HOME', File.join(HOMEDIR, '.local', 'state', app_name)),
|
17
|
+
File.join(Dir.tmpdir, Etc.getlogin, app_name)
|
18
18
|
)
|
19
19
|
end
|
20
20
|
end
|
data/lib/env_paths/version.rb
CHANGED
data/spec/env_paths_spec.rb
CHANGED
@@ -12,23 +12,43 @@ describe EnvPaths do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
context 'MacOs' do
|
15
|
-
it 'returs
|
15
|
+
it 'returs 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
|
|
19
|
-
expect(env_paths.data).to match(%r{
|
20
|
-
expect(env_paths.config).to match(%r{
|
21
|
-
expect(env_paths.cache).to match(%r{
|
22
|
-
expect(env_paths.log).to match(%r{
|
23
|
-
expect(env_paths.temp).to
|
19
|
+
expect(env_paths.data).to match(%r{Library/Application Support/my_app-ruby})
|
20
|
+
expect(env_paths.config).to match(%r{Library/Preferences/my_app-ruby})
|
21
|
+
expect(env_paths.cache).to match(%r{Library/Caches/my_app-ruby})
|
22
|
+
expect(env_paths.log).to match(%r{Library/Logs/my_app-ruby})
|
23
|
+
expect(env_paths.temp).to include('my_app-ruby')
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
context 'Linux' do
|
28
|
-
it 'returs linux specific data'
|
28
|
+
it 'returs linux specific data' do
|
29
|
+
allow(EnvPaths).to receive(:_platform).and_return('hipster-linux')
|
30
|
+
env_paths = EnvPaths.get('my_app')
|
31
|
+
|
32
|
+
expect(env_paths.data).to match(%r{.local/share/my_app-ruby$})
|
33
|
+
expect(env_paths.config).to match(%r{.config/my_app-ruby$})
|
34
|
+
expect(env_paths.cache).to match(%r{.cache/my_app-ruby$})
|
35
|
+
expect(env_paths.log).to match(%r{.local/state/my_app-ruby$})
|
36
|
+
expect(env_paths.temp).to include('my_app-ruby')
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'prefers XDG_* ENV settings to defaults'
|
29
40
|
end
|
30
41
|
|
31
42
|
context 'Windows' do
|
32
|
-
it 'returs windows specific data'
|
43
|
+
it 'returs windows specific data' do
|
44
|
+
allow(EnvPaths).to receive(:_platform).and_return('win32')
|
45
|
+
env_paths = EnvPaths.get('my_app')
|
46
|
+
|
47
|
+
expect(env_paths.data).to include('Data')
|
48
|
+
expect(env_paths.config).to include('Config')
|
49
|
+
expect(env_paths.cache).to include('Cache')
|
50
|
+
expect(env_paths.log).to include('Log')
|
51
|
+
expect(env_paths.temp).not_to be_nil
|
52
|
+
end
|
33
53
|
end
|
34
54
|
end
|