eac_ruby_base0 0.1.0 → 0.3.2

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: 48042393058f1ed14fb727e9689e820afd91bbbea1316a3dfc470bbd1c27276f
4
- data.tar.gz: '009483ad302a73c9de908708a5983faa4e2c351be9a1efc200c545ce4fe89fad'
3
+ metadata.gz: c33caa20ce5698a75e3cced324d2a33982183fa7ce00e8f1b8e49ce96330c843
4
+ data.tar.gz: 4bc3cb6a780f50348596e94085073f345ff0e52ee5c5c14f3077ff54edd2dc60
5
5
  SHA512:
6
- metadata.gz: fec3a21aea1fd9702724e46f0ff0e5d25b53a39f13dcbc2000a91583ff12cb39c4bcd15bba2eb286cc633f53a49064ee140f42fd9909e7b6380613a5610c5d18
7
- data.tar.gz: f23aac7253a3615099c47d5a211fb49c898db5bfbd803d80fd28845a450190c14c22aab1a483b041eaed470e512bdb2fcabdb5e0e0d870121a289a7ca30532f5
6
+ metadata.gz: 7253c7709e4d7860d7a58b95fd467ed3d899b7404e6c876337a0ff9fe9e5f62b375690fd2cf8f115e76f3d8fdb3ad45eab70d28082a54eee025469ed065b530e
7
+ data.tar.gz: 5218e12bbd24b4664370625cfaed4b47eaed2bd46840b0dab23037a51f011772557500a9a895803cc89fcd6c0c290136018e94ce9bb4bd43c902cbf2ea048bab
@@ -1,12 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_gems_utils/gem'
3
4
  require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/filesystem_cache'
4
6
 
5
7
  module EacRubyBase0
6
8
  class Application
7
9
  enable_simple_cache
8
- common_constructor :gemspec_dir do
10
+ enable_listable
11
+ lists.add_symbol :option, :name, :home_dir
12
+
13
+ common_constructor :gemspec_dir, :options, default: [{}] do
9
14
  self.gemspec_dir = gemspec_dir.to_pathname
15
+ self.options = options.symbolize_keys.assert_valid_keys(self.class.lists.option.values).freeze
10
16
  end
11
17
 
12
18
  delegate :version, to: :self_gem
@@ -15,6 +21,32 @@ module EacRubyBase0
15
21
  vendor_gems + [self_gem]
16
22
  end
17
23
 
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
34
+ end
35
+
36
+ def fs_cache
37
+ @fs_cache ||= ::EacRubyUtils::FilesystemCache.new(
38
+ cache_dir.join(::EacRubyUtils::FilesystemCache.name.parameterize)
39
+ )
40
+ end
41
+
42
+ def home_dir
43
+ @home_dir ||= (options[OPTION_HOME_DIR] || ENV.fetch('HOME')).to_pathname
44
+ end
45
+
46
+ def name
47
+ options[OPTION_NAME] || self_gem.name
48
+ end
49
+
18
50
  def vendor_dir
19
51
  gemspec_dir.join('vendor')
20
52
  end
@@ -1,26 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/default_runner'
3
+ require 'eac_cli/runner_with/help'
4
+ require 'eac_cli/runner_with/subcommands'
4
5
  require 'eac_ruby_utils/core_ext'
5
6
 
6
7
  module EacRubyBase0
7
8
  module Runner
8
9
  require_sub __FILE__
10
+ enable_console_speaker
9
11
  common_concern do
10
- include ::EacCli::DefaultRunner
12
+ include ::EacCli::RunnerWith::Help
13
+ include ::EacCli::RunnerWith::Subcommands
11
14
  runner_definition do
12
15
  bool_opt '-q', '--quiet', 'Quiet mode.'
16
+ bool_opt '-I', '--no-input', 'Fail if a input is requested.'
13
17
  subcommands
14
18
  alt do
15
- bool_opt '-V', '--version', 'Show version.'
19
+ bool_opt '-V', '--version', 'Show version.', usage: true, required: true
16
20
  end
17
21
  end
18
22
  end
19
23
 
20
24
  def run
21
25
  on_speaker_node do |node|
22
- node.stderr = ::StringIO.new if options.fetch('--quiet')
23
- if options.fetch('--version')
26
+ node.stderr = ::StringIO.new if parsed.quiet?
27
+ node.stdin = FailIfRequestInput.new if parsed.no_input?
28
+ if parsed.version?
24
29
  show_version
25
30
  else
26
31
  run_with_subcommand
@@ -28,8 +33,22 @@ module EacRubyBase0
28
33
  end
29
34
  end
30
35
 
36
+ def application_version
37
+ runner_context.call(:application).version.to_s
38
+ end
39
+
31
40
  def show_version
32
- out(context(:application).version + "\n")
41
+ out("#{application_version}\n")
42
+ end
43
+
44
+ class FailIfRequestInput
45
+ enable_console_speaker
46
+
47
+ %w[gets noecho].each do |method|
48
+ define_method(method) do
49
+ raise "Input method requested (\"#{method}\") and option --no-input is set"
50
+ end
51
+ end
33
52
  end
34
53
  end
35
54
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyBase0
4
- VERSION = '0.1.0'
4
+ VERSION = '0.3.2'
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.1.0
4
+ version: 0.3.2
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: 2020-07-09 00:00:00.000000000 Z
11
+ date: 2021-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_cli
@@ -16,42 +16,48 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.3'
19
+ version: '0.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.3'
26
+ version: '0.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: eac_ruby_gems_utils
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.6'
33
+ version: '0.7'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.7.2
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
41
  - - "~>"
39
42
  - !ruby/object:Gem::Version
40
- version: '0.6'
43
+ version: '0.7'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.7.2
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: eac_ruby_utils
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '0.39'
53
+ version: '0.46'
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '0.39'
60
+ version: '0.46'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: eac_ruby_gem_support
57
63
  requirement: !ruby/object:Gem::Requirement
@@ -101,8 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
107
  - !ruby/object:Gem::Version
102
108
  version: '0'
103
109
  requirements: []
104
- rubyforge_project:
105
- rubygems_version: 2.7.7
110
+ rubygems_version: 3.0.8
106
111
  signing_key:
107
112
  specification_version: 4
108
113
  summary: Put here de description.