eac_ruby_base0 0.7.4 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc268f7a09e9262d85be31199e73103242f49b31081cd02c85ec847b1afcfb6d
4
- data.tar.gz: 8906de337ba47f1613e059f55a3a1c9ecccd891c08e7f998ad3c16fd81288dad
3
+ metadata.gz: 10ee625f182f3829966f72f31ca5a5f8fd0e3014754ae85bcb77a4e0ddff1c34
4
+ data.tar.gz: 27cc3c2e2b5b60d294eb225a67aac634774b73611ff4246d3f0929815664a407
5
5
  SHA512:
6
- metadata.gz: 4f13d20765e6d851774c62b0e2f3156b4187f9e78bd301a9d803e0b79bea973c2373c2395c5de9f8f407cf39f2ce96b198dbec29e51e8fe80dca388dfd605e45
7
- data.tar.gz: 57a16e117774ad249ede385de1274bb2a55fa3cb34e0a7157d87050737177a439578291cae36029b53745c95c013690b86d1c97ac77a074d914f455cf2f93c54
6
+ metadata.gz: 7764d32f1bac074a0d096f6642264b59aea8363f89b9d50c0c4402e5eccd0d0230f374a4fb57ac73a8668319b9e10dd7d026ef10cdfe0d400e08a19f15d014ec
7
+ data.tar.gz: b420f162aa98c9772b63f171f5732b8d59865d45d4858071b8ceefcd6c91492aebedf3b8a7aa36a63e73bf0d639ccb6c2f9bc7218d061f05dff66c47b36abc7a
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_base0/application_xdg'
3
4
  require 'eac_ruby_gems_utils/gem'
4
5
  require 'eac_ruby_utils/core_ext'
5
6
  require 'eac_ruby_utils/filesystem_cache'
@@ -21,16 +22,8 @@ module EacRubyBase0
21
22
  vendor_gems + [self_gem]
22
23
  end
23
24
 
24
- { cache: '.cache', config: '.config', data: '.local/share' }.each do |item, subpath|
25
- xdg_env_method_name = "#{item}_xdg_env"
26
-
27
- define_method xdg_env_method_name do
28
- ENV["XDG_#{item.upcase}_HOME"].if_present(&:to_pathname)
29
- end
30
-
31
- define_method "#{item}_dir" do
32
- (send(xdg_env_method_name) || home_dir.join(subpath)).join(name)
33
- end
25
+ ::EacRubyBase0::ApplicationXdg::DIRECTORIES.each_key do |item|
26
+ delegate "#{item}_xdg_env", "#{item}_dir", to: :app_xdg
34
27
  end
35
28
 
36
29
  def fs_cache
@@ -40,7 +33,7 @@ module EacRubyBase0
40
33
  end
41
34
 
42
35
  def home_dir
43
- @home_dir ||= (options[OPTION_HOME_DIR] || ENV.fetch('HOME')).to_pathname
36
+ app_xdg.user_home_dir
44
37
  end
45
38
 
46
39
  def name
@@ -53,6 +46,10 @@ module EacRubyBase0
53
46
 
54
47
  private
55
48
 
49
+ def app_xdg_uncached
50
+ ::EacRubyBase0::ApplicationXdg.new(name, options[OPTION_HOME_DIR])
51
+ end
52
+
56
53
  def self_gem_uncached
57
54
  ::EacRubyGemsUtils::Gem.new(gemspec_dir)
58
55
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyBase0
4
+ # https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
5
+ class ApplicationXdg
6
+ class << self
7
+ # @return [Pathname]
8
+ def user_home_dir_from_env
9
+ ENV.fetch('HOME').to_pathname
10
+ end
11
+ end
12
+
13
+ DIRECTORIES = { cache: '.cache', config: '.config', data: '.local/share',
14
+ state: '.local/state' }.freeze
15
+
16
+ common_constructor :app_name, :user_home_dir, default: [nil] do
17
+ self.user_home_dir ||= self.class.user_home_dir_from_env
18
+ end
19
+
20
+ DIRECTORIES.each do |item, subpath|
21
+ xdg_env_method_name = "#{item}_xdg_env"
22
+
23
+ define_method xdg_env_method_name do
24
+ ENV["XDG_#{item.upcase}_HOME"].if_present(&:to_pathname)
25
+ end
26
+
27
+ define_method "#{item}_dir" do
28
+ (send(xdg_env_method_name) || user_home_dir.join(subpath)).join(app_name)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -12,6 +12,7 @@ module EacRubyBase0
12
12
  common_concern do
13
13
  include ::EacCli::Runner
14
14
  enable_settings_provider
15
+ enable_simple_cache
15
16
  runner_definition do
16
17
  bool_opt '--no', 'Deny confirmation without question.'
17
18
  bool_opt '--yes', 'Accept confirmation without question.'
@@ -31,6 +32,12 @@ module EacRubyBase0
31
32
  def run_confirm(message = nil)
32
33
  yield if confirm?(message)
33
34
  end
35
+
36
+ private
37
+
38
+ def cached_confirm_uncached?(message = nil)
39
+ confirm?(message)
40
+ end
34
41
  end
35
42
  end
36
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyBase0
4
- VERSION = '0.7.4'
4
+ VERSION = '0.8.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_base0
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-08 00:00:00.000000000 Z
11
+ date: 2021-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_cli
@@ -74,6 +74,7 @@ extra_rdoc_files: []
74
74
  files:
75
75
  - lib/eac_ruby_base0.rb
76
76
  - lib/eac_ruby_base0/application.rb
77
+ - lib/eac_ruby_base0/application_xdg.rb
77
78
  - lib/eac_ruby_base0/core_ext.rb
78
79
  - lib/eac_ruby_base0/jobs_runner.rb
79
80
  - lib/eac_ruby_base0/patches.rb