eac_ruby_base0 0.7.0 → 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: f2ae142d31cfaa28f6d870e2a2401624770c2cb16a56e82b0140a0451367b708
4
- data.tar.gz: f1715aca8f09e2cdb9ad2e795498d591a32c6c3fdccdab592f7185a2e9e3f7f7
3
+ metadata.gz: 10ee625f182f3829966f72f31ca5a5f8fd0e3014754ae85bcb77a4e0ddff1c34
4
+ data.tar.gz: 27cc3c2e2b5b60d294eb225a67aac634774b73611ff4246d3f0929815664a407
5
5
  SHA512:
6
- metadata.gz: 62c88b779246c825454b48b225b9367ff7d0dedb8ff64d5e2208128929054c98ff7c459d6c864f859c8deeb7171abfc9c356a28156b647d6e3b91be819f1c094
7
- data.tar.gz: a772912235c747dbb35224429c1870172c3aeb2a8763c2a0364a340f565b0f651bee91f910f93372e6e47cc57ed5e0f7f1bd0bcb22ff477072a6117da03a5323
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
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_ruby_utils/console/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 ::EacRubyUtils::Console::Speaker
9
+ enable_speaker
10
10
  include ::EacRubyUtils::SettingsProvider
11
11
  end
12
12
 
@@ -1,13 +1,13 @@
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_ruby_utils/speaker'
6
6
 
7
7
  module EacRubyBase0
8
8
  module Runner
9
9
  require_sub __FILE__
10
- enable_console_speaker
10
+ enable_speaker
11
11
  common_concern do
12
12
  include ::EacCli::RunnerWith::Help
13
13
  include ::EacCli::RunnerWith::Subcommands
@@ -22,9 +22,7 @@ module EacRubyBase0
22
22
  end
23
23
 
24
24
  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?
25
+ ::EacRubyUtils::Speaker.context.on(build_speaker) do
28
26
  if parsed.version?
29
27
  show_version
30
28
  else
@@ -42,7 +40,7 @@ module EacRubyBase0
42
40
  end
43
41
 
44
42
  class FailIfRequestInput
45
- enable_console_speaker
43
+ enable_speaker
46
44
 
47
45
  %w[gets noecho].each do |method|
48
46
  define_method(method) do
@@ -50,5 +48,14 @@ module EacRubyBase0
50
48
  end
51
49
  end
52
50
  end
51
+
52
+ private
53
+
54
+ def build_speaker
55
+ options = {}
56
+ options[:err_out] = ::StringIO.new if parsed.quiet?
57
+ options[:in_in] = FailIfRequestInput.new if parsed.no_input?
58
+ ::EacCli::Speaker.new(options)
59
+ end
53
60
  end
54
61
  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.0'
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.0
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-04-02 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
@@ -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,34 +44,28 @@ dependencies:
50
44
  requirements:
51
45
  - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '0.60'
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.60'
54
+ version: '0.67'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: eac_ruby_gem_support
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - "~>"
66
60
  - !ruby/object:Gem::Version
67
- version: '0.1'
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: 0.1.2
61
+ version: '0.2'
71
62
  type: :development
72
63
  prerelease: false
73
64
  version_requirements: !ruby/object:Gem::Requirement
74
65
  requirements:
75
66
  - - "~>"
76
67
  - !ruby/object:Gem::Version
77
- version: '0.1'
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: 0.1.2
68
+ version: '0.2'
81
69
  description:
82
70
  email:
83
71
  executables: []
@@ -86,6 +74,7 @@ extra_rdoc_files: []
86
74
  files:
87
75
  - lib/eac_ruby_base0.rb
88
76
  - lib/eac_ruby_base0/application.rb
77
+ - lib/eac_ruby_base0/application_xdg.rb
89
78
  - lib/eac_ruby_base0/core_ext.rb
90
79
  - lib/eac_ruby_base0/jobs_runner.rb
91
80
  - lib/eac_ruby_base0/patches.rb