eac_ruby_base0 0.7.4 → 0.10.1

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: a709f0715b2ad1c20bd3dac837e4267b64f0e2bf553133544f2ef1dd767de9b9
4
+ data.tar.gz: c919d5103cf7eee653678b3655ec673d9b3fa3eef976d80ae0c0bbba390f7d1a
5
5
  SHA512:
6
- metadata.gz: 4f13d20765e6d851774c62b0e2f3156b4187f9e78bd301a9d803e0b79bea973c2373c2395c5de9f8f407cf39f2ce96b198dbec29e51e8fe80dca388dfd605e45
7
- data.tar.gz: 57a16e117774ad249ede385de1274bb2a55fa3cb34e0a7157d87050737177a439578291cae36029b53745c95c013690b86d1c97ac77a074d914f455cf2f93c54
6
+ metadata.gz: 701c01a6cd2902b2ef7b04687881787261dbac5e532a908a2bd2755b9b6b4a62efcd63f4b99f3680992657219a44cefdf16fbb9362d9c8e1e33ebf90ba0ae3af
7
+ data.tar.gz: 621cf6ef74fb023a029b8505a1d5a3fbb2bc03df336011e2f0b7d5faabfd42bb5439cfe5d3021f5bfb5952aa55392f5825011180cb88fd40cf20f891b5405e30
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_cli/config'
4
+ require 'eac_config/envvars_node'
5
+ require 'eac_config/yaml_file_node'
6
+ require 'eac_ruby_base0/application_xdg'
3
7
  require 'eac_ruby_gems_utils/gem'
4
8
  require 'eac_ruby_utils/core_ext'
5
9
  require 'eac_ruby_utils/filesystem_cache'
@@ -21,16 +25,22 @@ module EacRubyBase0
21
25
  vendor_gems + [self_gem]
22
26
  end
23
27
 
24
- { cache: '.cache', config: '.config', data: '.local/share' }.each do |item, subpath|
25
- xdg_env_method_name = "#{item}_xdg_env"
28
+ # @return [EacCli::Config]
29
+ def build_config(path = nil)
30
+ envvar_node = ::EacConfig::EnvvarsNode.new
31
+ file_node = ::EacConfig::YamlFileNode.new(path || config_default_path)
32
+ envvar_node.load_path.push(file_node.url)
33
+ envvar_node.write_node = file_node
34
+ ::EacCli::Config.new(envvar_node)
35
+ end
26
36
 
27
- define_method xdg_env_method_name do
28
- ENV["XDG_#{item.upcase}_HOME"].if_present(&:to_pathname)
29
- end
37
+ # @return [EacCli::Config]
38
+ def config_default_path
39
+ config_dir.join('eac_config.yaml')
40
+ end
30
41
 
31
- define_method "#{item}_dir" do
32
- (send(xdg_env_method_name) || home_dir.join(subpath)).join(name)
33
- end
42
+ ::EacRubyBase0::ApplicationXdg::DIRECTORIES.each_key do |item|
43
+ delegate "#{item}_xdg_env", "#{item}_dir", to: :app_xdg
34
44
  end
35
45
 
36
46
  def fs_cache
@@ -40,7 +50,7 @@ module EacRubyBase0
40
50
  end
41
51
 
42
52
  def home_dir
43
- @home_dir ||= (options[OPTION_HOME_DIR] || ENV.fetch('HOME')).to_pathname
53
+ app_xdg.user_home_dir
44
54
  end
45
55
 
46
56
  def name
@@ -53,6 +63,10 @@ module EacRubyBase0
53
63
 
54
64
  private
55
65
 
66
+ def app_xdg_uncached
67
+ ::EacRubyBase0::ApplicationXdg.new(name, options[OPTION_HOME_DIR])
68
+ end
69
+
56
70
  def self_gem_uncached
57
71
  ::EacRubyGemsUtils::Gem.new(gemspec_dir)
58
72
  end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRubyBase0
6
+ # https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
7
+ class ApplicationXdg
8
+ class << self
9
+ # @return [Pathname]
10
+ def user_home_dir_from_env
11
+ ENV.fetch('HOME').to_pathname
12
+ end
13
+ end
14
+
15
+ DIRECTORIES = { cache: '.cache', config: '.config', data: '.local/share',
16
+ state: '.local/state' }.freeze
17
+
18
+ common_constructor :app_name, :user_home_dir, default: [nil] do
19
+ self.user_home_dir ||= self.class.user_home_dir_from_env
20
+ end
21
+
22
+ DIRECTORIES.each do |item, subpath|
23
+ xdg_env_method_name = "#{item}_xdg_env"
24
+
25
+ define_method xdg_env_method_name do
26
+ ENV["XDG_#{item.upcase}_HOME"].if_present(&:to_pathname)
27
+ end
28
+
29
+ define_method "#{item}_dir" do
30
+ (send(xdg_env_method_name) || user_home_dir.join(subpath)).join(app_name)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'eac_cli/core_ext'
4
4
  require 'eac_cli/speaker'
5
+ require 'eac_config/node'
5
6
  require 'eac_ruby_utils/speaker'
6
7
 
7
8
  module EacRubyBase0
@@ -23,10 +24,12 @@ module EacRubyBase0
23
24
 
24
25
  def run
25
26
  ::EacRubyUtils::Speaker.context.on(build_speaker) do
26
- if parsed.version?
27
- show_version
28
- else
29
- run_with_subcommand
27
+ ::EacConfig::Node.context.on(runner_context.call(:application).build_config) do
28
+ if parsed.version?
29
+ show_version
30
+ else
31
+ run_with_subcommand
32
+ end
30
33
  end
31
34
  end
32
35
  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.10.1'
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.10.1
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-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_cli
@@ -16,56 +16,68 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.20'
19
+ version: '0.22'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.22.2
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '0.20'
29
+ version: '0.22'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.22.2
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: eac_ruby_gems_utils
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '0.8'
39
+ version: '0.9'
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: 0.9.5
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
47
  - - "~>"
39
48
  - !ruby/object:Gem::Version
40
- version: '0.8'
49
+ version: '0.9'
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: 0.9.5
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: eac_ruby_utils
43
55
  requirement: !ruby/object:Gem::Requirement
44
56
  requirements:
45
57
  - - "~>"
46
58
  - !ruby/object:Gem::Version
47
- version: '0.67'
59
+ version: '0.70'
48
60
  type: :runtime
49
61
  prerelease: false
50
62
  version_requirements: !ruby/object:Gem::Requirement
51
63
  requirements:
52
64
  - - "~>"
53
65
  - !ruby/object:Gem::Version
54
- version: '0.67'
66
+ version: '0.70'
55
67
  - !ruby/object:Gem::Dependency
56
68
  name: eac_ruby_gem_support
57
69
  requirement: !ruby/object:Gem::Requirement
58
70
  requirements:
59
71
  - - "~>"
60
72
  - !ruby/object:Gem::Version
61
- version: '0.2'
73
+ version: '0.3'
62
74
  type: :development
63
75
  prerelease: false
64
76
  version_requirements: !ruby/object:Gem::Requirement
65
77
  requirements:
66
78
  - - "~>"
67
79
  - !ruby/object:Gem::Version
68
- version: '0.2'
80
+ version: '0.3'
69
81
  description:
70
82
  email:
71
83
  executables: []
@@ -74,6 +86,7 @@ extra_rdoc_files: []
74
86
  files:
75
87
  - lib/eac_ruby_base0.rb
76
88
  - lib/eac_ruby_base0/application.rb
89
+ - lib/eac_ruby_base0/application_xdg.rb
77
90
  - lib/eac_ruby_base0/core_ext.rb
78
91
  - lib/eac_ruby_base0/jobs_runner.rb
79
92
  - lib/eac_ruby_base0/patches.rb
@@ -107,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
120
  - !ruby/object:Gem::Version
108
121
  version: '0'
109
122
  requirements: []
110
- rubygems_version: 3.0.9
123
+ rubygems_version: 3.1.6
111
124
  signing_key:
112
125
  specification_version: 4
113
126
  summary: Put here de description.