eac_ruby_base0 0.7.2 → 0.10.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: e9f7c0d02f93751b57d727ec34df37d8cdaf2124fc084f122f86dd2b71493a81
4
- data.tar.gz: 3a55fa3722e1a1867783defb171815f65b36555c5761111f010cc3830c4d0b0a
3
+ metadata.gz: 34b99d130c097b0cc5861ef5bbf142142ce55196d3a7871ac301bad86591c2b6
4
+ data.tar.gz: 8fbd22d9230277a1658d234706639241b6838f36d02693d7763babfd8e2300b9
5
5
  SHA512:
6
- metadata.gz: ce58f60898f6acccee9e2973813ef04f64c20c74a4a85847fda9cd238f88ff5cfafa4d866718593ffb97a3721fccafb154d180eda68e1df6622957e8ff57d32b
7
- data.tar.gz: 01ef701c6677f14615847a9a951d55c6cc7664de07350ca097c537d860d619abcd56497ed4e165707f2ee03ed9847918cd81107d5ae33b277b4bca3a8f8218c8
6
+ metadata.gz: 949b3bce253b5517eab405243f681ffb9851ea514386ef1cf3d4b117777245e4b90c018840307fcc66afa8716449ac78a7d795fd33b53b345a8b3b1f06253060
7
+ data.tar.gz: 537b3af24a0ce7cfa5bb4909b102c81d4c4ca5cb86e0e0003c2e458d96fba375fd5d14ab3a8235f2438e53e6b164e86ba095a036369056f3b9712e408c1fa0fe
@@ -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
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/speaker'
3
+ require 'eac_ruby_utils/core_ext'
4
4
  require 'eac_ruby_utils/settings_provider'
5
5
 
6
6
  module EacRubyBase0
7
7
  module JobsRunner
8
8
  common_concern do
9
- include ::EacCli::Speaker
9
+ enable_speaker
10
10
  include ::EacRubyUtils::SettingsProvider
11
11
  end
12
12
 
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/runner_with/help'
4
- require 'eac_cli/runner_with/subcommands'
5
- require 'eac_ruby_utils/core_ext'
3
+ require 'eac_cli/core_ext'
4
+ require 'eac_cli/speaker'
5
+ require 'eac_config/node'
6
+ require 'eac_ruby_utils/speaker'
6
7
 
7
8
  module EacRubyBase0
8
9
  module Runner
@@ -22,13 +23,13 @@ module EacRubyBase0
22
23
  end
23
24
 
24
25
  def run
25
- on_speaker_node do |node|
26
- node.stderr = ::StringIO.new if parsed.quiet?
27
- node.stdin = FailIfRequestInput.new if parsed.no_input?
28
- if parsed.version?
29
- show_version
30
- else
31
- run_with_subcommand
26
+ ::EacRubyUtils::Speaker.context.on(build_speaker) do
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
32
33
  end
33
34
  end
34
35
  end
@@ -50,5 +51,14 @@ module EacRubyBase0
50
51
  end
51
52
  end
52
53
  end
54
+
55
+ private
56
+
57
+ def build_speaker
58
+ options = {}
59
+ options[:err_out] = ::StringIO.new if parsed.quiet?
60
+ options[:in_in] = FailIfRequestInput.new if parsed.no_input?
61
+ ::EacCli::Speaker.new(options)
62
+ end
53
63
  end
54
64
  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.'
@@ -22,7 +23,7 @@ module EacRubyBase0
22
23
  return false if parsed.no?
23
24
  return true if parsed.yes?
24
25
 
25
- request_input(
26
+ input(
26
27
  message || setting_value(:confirm_question_text, default: DEFAULT_CONFIRM_QUESTION_TEXT),
27
28
  bool: true
28
29
  )
@@ -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.2'
4
+ VERSION = '0.10.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.2
4
+ version: 0.10.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-05-23 00:00:00.000000000 Z
11
+ date: 2021-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_cli
@@ -16,20 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.15'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.15.1
19
+ version: '0.20'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '0.15'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 0.15.1
26
+ version: '0.20'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: eac_ruby_gems_utils
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -50,14 +44,14 @@ dependencies:
50
44
  requirements:
51
45
  - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '0.64'
47
+ version: '0.67'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
52
  - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: '0.64'
54
+ version: '0.67'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: eac_ruby_gem_support
63
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +74,7 @@ extra_rdoc_files: []
80
74
  files:
81
75
  - lib/eac_ruby_base0.rb
82
76
  - lib/eac_ruby_base0/application.rb
77
+ - lib/eac_ruby_base0/application_xdg.rb
83
78
  - lib/eac_ruby_base0/core_ext.rb
84
79
  - lib/eac_ruby_base0/jobs_runner.rb
85
80
  - lib/eac_ruby_base0/patches.rb