avm-eac_ruby_base1 0.33.2 → 0.34.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: bfb9953ef8eb61c9805e7ec553a2f7d9337c505b9b0ddb07d82e837cd3c0d928
4
- data.tar.gz: ecdff3c27a2078416f3a888a0838af86f0fa1d72d05e15b513f572abba624976
3
+ metadata.gz: ba1b2ccbba6af68c7a620b57f52799eab587b01c612b4a469bbd755e0506652b
4
+ data.tar.gz: dc698a77abe634b26197ceb28241a15988d99c45bcd2d130c3b3a60ed2e2507d
5
5
  SHA512:
6
- metadata.gz: 8156b5a96757b7102ed5dbba4ed565b14e9ef4a0b28cbb27f77b5866131fc923a156f18ef2f708f25874f57cdef25784c1b8d66cf2940533713f20d744d9c83f
7
- data.tar.gz: 6fb495664de6628608090b06d8f87b2520bcdc0a5e0e14840c29acb7f6676aa82cf53f00d1e46bd6b0b44aff3df352ea12297aada2f7ca64765b248433040218
6
+ metadata.gz: 6203de727473926431355e4e945198b91a3566163649ed1fda516a0f8be0f273aab3de661cc7bc782cdafa457d2bae10e801fa60f99924a2327870f7244cd80b
7
+ data.tar.gz: 5fdf7b83ea6cb8c8113cb84357d3c8a571f539aed4bc6d9cbfb2a1f0114d368a8e01cc7fb4d87192b1c147a9a9dc2e9a6bb22b15d2a393c4b177d8a7d512ba78
@@ -14,7 +14,7 @@ module Avm
14
14
 
15
15
  def internal_apply(files)
16
16
  ::Avm::EacRubyBase1::Rubocop.new('.', ['-a', '--ignore-parent-exclusion'] + files).run
17
- super(files)
17
+ super
18
18
  end
19
19
  end
20
20
  end
@@ -3,11 +3,10 @@
3
3
  require 'eac_ruby_utils/simple_cache'
4
4
  require 'rubygems'
5
5
  require 'eac_cli/speaker'
6
+ require 'avm/eac_ruby_base1/rubygems/remote'
6
7
  require 'avm/launcher/publish/base'
7
8
  require 'avm/launcher/publish/check_result'
8
9
  require 'avm/eac_ruby_base1/launcher/gem'
9
- require 'eac_envs/http/request'
10
- require 'eac_envs/http/response'
11
10
 
12
11
  module Avm
13
12
  module EacRubyBase1
@@ -98,16 +97,17 @@ module Avm
98
97
  end
99
98
 
100
99
  # @return [Array]
101
- def gem_versions_uncached
102
- ::EacEnvs::Http::Request.new
103
- .url("https://rubygems.org/api/v1/versions/#{gem_spec.name}.json")
104
- .response.body_data_or_raise
105
- rescue EacEnvs::Http::Response => e
106
- e.status == 404 ? [] : raise(e)
100
+ def gem_versions
101
+ remote_gem.versions
107
102
  end
108
103
 
109
- def gem_version_max_uncached
110
- gem_versions.map { |v| ::Gem::Version.new(v['number']) }.max
104
+ def gem_version_max
105
+ remote_gem.maximum_number
106
+ end
107
+
108
+ # @return [Avm::EacRubyBase1::Rubygems::Remote]
109
+ def remote_gem_uncached
110
+ ::Avm::EacRubyBase1::Rubygems::Remote.new(gem_spec.name)
111
111
  end
112
112
 
113
113
  def push_gem
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_envs/http/request'
5
+
6
+ module Avm
7
+ module EacRubyBase1
8
+ module Rubygems
9
+ class Remote
10
+ enable_simple_cache
11
+ common_constructor :name
12
+
13
+ # @return [Gem::Version, nil]
14
+ def maximum_number
15
+ numbers.max.if_present { |v| ::Gem::Version.new(v) }
16
+ end
17
+
18
+ # @return [Array<Gem::Version>]
19
+ def numbers
20
+ versions.map { |v| ::Gem::Version.new(v.fetch('number')) }
21
+ end
22
+
23
+ protected
24
+
25
+ # @return [Array<Hash>]
26
+ def versions_uncached
27
+ ::EacEnvs::Http::Request.new
28
+ .url("https://rubygems.org/api/v1/versions/#{name}.json")
29
+ .response.body_data_or_raise
30
+ rescue EacEnvs::Http::Response => e
31
+ e.status == 404 ? [] : raise(e)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -9,17 +9,53 @@ module Avm
9
9
  module SourceGenerators
10
10
  class Base < ::Avm::SourceGenerators::Base
11
11
  module Dependencies
12
- def eac_ruby_gem_support_version
13
- dependency_version('eac_ruby_gem_support')
12
+ common_concern
13
+
14
+ COMMON_DEPENDENCY_GEMS = %w[eac_ruby_utils].freeze
15
+ DEVELOPMENT_DEPENDENCY_GEMS = %w[eac_ruby_gem_support].freeze
16
+
17
+ module ClassMethods
18
+ # @return [Array<String>]
19
+ def common_dependency_gems
20
+ COMMON_DEPENDENCY_GEMS
21
+ end
22
+
23
+ # @return [Array<String>]
24
+ def development_dependency_gems
25
+ DEVELOPMENT_DEPENDENCY_GEMS
26
+ end
14
27
  end
15
28
 
16
- def eac_ruby_utils_version
17
- dependency_version('eac_ruby_utils')
29
+ # @return [String]
30
+ def common_dependencies
31
+ dependencies_section(:common_dependency_gems, '')
18
32
  end
19
33
 
20
34
  def dependency_version(gem_name)
21
35
  ::Avm::EacRubyBase1::SourceGenerators::Base::VersionBuilder.new(gem_name, options).to_s
22
36
  end
37
+
38
+ # @return [String]
39
+ def development_dependencies
40
+ dependencies_section(:development_dependency_gems, 'development_')
41
+ end
42
+
43
+ protected
44
+
45
+ # @param gem_name [String]
46
+ # @param prefix [String]
47
+ # @return [String]
48
+ def dependency_line(gem_name, prefix)
49
+ "#{IDENT}s.add_#{prefix}dependency '#{gem_name}', #{dependency_version(gem_name)}\n"
50
+ end
51
+
52
+ # @param setting_key [Symbol]
53
+ # @param prefix [String]
54
+ # @return [String]
55
+ def dependencies_section(gems_method, prefix)
56
+ self.class.send(gems_method).sort.map { |gem_name| dependency_line(gem_name, prefix) }
57
+ .join.rstrip
58
+ end
23
59
  end
24
60
  end
25
61
  end
@@ -13,14 +13,19 @@ module Avm
13
13
  GEMFILE_LOCK_OPTION = :'gemfile-lock'
14
14
 
15
15
  OPTIONS = {
16
- :'eac-ruby-utils-version' => 'Version for "eac_ruby_utils" gem.',
17
- :'eac-ruby-gem-support-version' => 'Version for "eac_ruby_gem_support" gem.',
18
16
  GEMFILE_LOCK_OPTION => 'Run "bundle install" at the end'
19
17
  }.freeze
20
18
 
21
19
  module ClassMethods
22
20
  def option_list
23
- OPTIONS.inject(super) { |a, e| a.option(*e) }
21
+ OPTIONS.merge(dependency_version_options).inject(super) { |a, e| a.option(*e) }
22
+ end
23
+
24
+ # @return [Hash<Symbol, String>]
25
+ def dependency_version_options
26
+ (common_dependency_gems + development_dependency_gems).sort.to_h do |gem_name|
27
+ ["#{gem_name}_version".dasherize.to_sym, "Version for \"#{gem_name}\" gem."]
28
+ end
24
29
  end
25
30
  end
26
31
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/source_generators/base'
4
+ require 'avm/eac_ruby_base1/rubygems/remote'
4
5
  require 'eac_ruby_utils/core_ext'
5
6
 
6
7
  module Avm
@@ -19,7 +20,7 @@ module Avm
19
20
 
20
21
  # @return [Gem::Version]
21
22
  def version
22
- options_version || default_version
23
+ options_version || loaded_version || maximum_version
23
24
  end
24
25
 
25
26
  def two_segments
@@ -32,12 +33,21 @@ module Avm
32
33
 
33
34
  private
34
35
 
36
+ # @return [Gem::Version]
37
+ def maximum_version
38
+ r = ::Avm::EacRubyBase1::Rubygems::Remote.new(gem_name).maximum_number
39
+ return ::Gem::Version.new(r) if r.present?
40
+
41
+ raise "None version found for gem \"#{gem_name}\""
42
+ end
43
+
35
44
  def segments_uncached
36
45
  version.release.to_s.split('.').map(&:to_i)
37
46
  end
38
47
 
39
- def default_version
40
- ::Gem.loaded_specs[gem_name].version
48
+ # @return [Gem::Version, nil]
49
+ def loaded_version
50
+ ::Gem.loaded_specs[gem_name].if_present(&:version)
41
51
  end
42
52
 
43
53
  def options_version
@@ -9,33 +9,49 @@ module Avm
9
9
  module EacRubyBase1
10
10
  module SourceGenerators
11
11
  class Base < ::Avm::SourceGenerators::Base
12
+ GEMSPEC_FILES_DIRECTORY_PATHS = %w[lib].freeze
13
+ GEMSPEC_FILES_FILE_PATHS = [].freeze
12
14
  IDENT = ' '
13
- JOBS = %w[root_directory gemspec root_lib version_lib static gemfile_lock].freeze
15
+ JOBS = %w[gemspec root_lib version_lib gemfile_lock].freeze
14
16
  TEMPLATE_VARIABLES = %w[lib_path name root_module].freeze
15
17
 
16
18
  enable_speaker
17
19
  enable_simple_cache
18
20
  require_sub __FILE__, include_modules: true
19
21
 
20
- def root_directory
21
- target_path
22
+ # @return [String]
23
+ def gemspec_extra
24
+ gemspec_extra_lines.map { |line| "\n#{IDENT}#{line}" }.join
22
25
  end
23
26
 
24
- def name
25
- root_directory.basename.to_s
27
+ # @return [Array<String>]
28
+ def gemspec_extra_lines
29
+ []
26
30
  end
27
31
 
28
- def lib_path
29
- name.split('-').join('/')
32
+ # @return [String]
33
+ def gemspec_files_value
34
+ "Dir[#{gemspec_files_paths.map { |path| "'#{path}'" }.join(', ')}]"
30
35
  end
31
36
 
32
- def perform
33
- infov 'Root directory', root_directory
34
- infov 'Gem name', name
35
- JOBS.each do |job|
36
- infom "Generating #{job.humanize}..."
37
- send("generate_#{job}")
38
- end
37
+ # @return [Array<String>]
38
+ def gemspec_files_paths
39
+ ["{#{gemspec_files_directory_paths.sort.join(',')}}/**/*"] +
40
+ gemspec_files_file_paths.sort
41
+ end
42
+
43
+ # @return [Array<String>]
44
+ def gemspec_files_directory_paths
45
+ GEMSPEC_FILES_DIRECTORY_PATHS
46
+ end
47
+
48
+ # @return [Array<String>]
49
+ def gemspec_files_file_paths
50
+ GEMSPEC_FILES_FILE_PATHS
51
+ end
52
+
53
+ def lib_path
54
+ name.split('-').join('/')
39
55
  end
40
56
 
41
57
  def root_module
@@ -64,46 +80,31 @@ module Avm
64
80
 
65
81
  protected
66
82
 
67
- def apply_to_root_directory(template, subpath)
68
- if template.is_a?(::EacTemplates::Variables::Directory)
69
- template.children.each do |child|
70
- apply_to_root_directory(child, subpath.join(child.basename))
71
- end
72
- elsif template.is_a?(::EacTemplates::Variables::File)
73
- template.apply_to_file(template_variables, root_directory.join(subpath))
74
- else
75
- raise "Unknown template object: #{template}"
76
- end
77
- end
78
-
79
83
  def generate_gemspec
80
84
  template_apply('gemspec', "#{name}.gemspec")
81
85
  end
82
86
 
83
- def generate_root_directory
84
- root_directory.mkpath
85
- end
86
-
87
87
  def generate_root_lib
88
88
  template_apply('root_lib', "lib/#{lib_path}.rb")
89
89
  end
90
90
 
91
- def generate_static
92
- template.child('static').apply(self, root_directory)
93
- end
94
-
95
91
  def generate_version_lib
96
92
  template_apply('version', "lib/#{lib_path}/version.rb")
97
93
  end
98
94
 
95
+ # @return [EacTemplates::Modules::Base]
96
+ def root_template
97
+ template.child('static')
98
+ end
99
+
99
100
  def self_gem_uncached
100
- ::Avm::EacRubyBase1::Sources::Base.new(root_directory)
101
+ ::Avm::EacRubyBase1::Sources::Base.new(target_path)
101
102
  end
102
103
 
103
104
  def template_apply(from, to)
104
- target = root_directory.join(to)
105
+ target = target_path.join(to)
105
106
  target.dirname.mkpath
106
- template.child("#{from}.template").apply_to_file(self, target.to_path)
107
+ template.child(from).apply_to_file(self, target.to_path)
107
108
  end
108
109
  end
109
110
  end
@@ -29,7 +29,7 @@ module Avm
29
29
 
30
30
  # @return [String]
31
31
  def condition_content
32
- "::File.directory?('#{gemspec_relative_path}')"
32
+ "::File.file?(::File.expand_path('#{gemspec_relative_path}', __dir__))"
33
33
  end
34
34
 
35
35
  # @return [String]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRubyBase1
5
- VERSION = '0.33.2'
5
+ VERSION = '0.34.1'
6
6
  end
7
7
  end
@@ -10,10 +10,10 @@ Gem::Specification.new do |s|
10
10
  s.authors = ['Put here the authors']
11
11
  s.summary = 'Put here de description.'
12
12
 
13
- s.files = Dir['{lib}/**/*']
14
- s.required_ruby_version = '>= 2.7'
13
+ s.files = %%gemspec_files_value%%
14
+ s.required_ruby_version = '>= 2.7'%%gemspec_extra%%
15
15
 
16
- s.add_dependency 'eac_ruby_utils', %%EAC_RUBY_UTILS_VERSION%%
16
+ %%COMMON_DEPENDENCIES%%
17
17
 
18
- s.add_development_dependency 'eac_ruby_gem_support', %%EAC_RUBY_GEM_SUPPORT_VERSION%%
18
+ %%DEVELOPMENT_DEPENDENCIES%%
19
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-eac_ruby_base1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.33.2
4
+ version: 0.34.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: 2024-05-20 00:00:00.000000000 Z
11
+ date: 2024-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.91'
19
+ version: '0.92'
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.91'
26
+ version: '0.92'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: avm-eac_generic_base0
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -131,6 +131,7 @@ files:
131
131
  - lib/avm/eac_ruby_base1/rubygems/gemspec.rb
132
132
  - lib/avm/eac_ruby_base1/rubygems/gemspec/add_or_replace_gem_line.rb
133
133
  - lib/avm/eac_ruby_base1/rubygems/gemspec/dependency.rb
134
+ - lib/avm/eac_ruby_base1/rubygems/remote.rb
134
135
  - lib/avm/eac_ruby_base1/rubygems/version_file.rb
135
136
  - lib/avm/eac_ruby_base1/runners.rb
136
137
  - lib/avm/eac_ruby_base1/runners/base.rb