avm-eac_ruby_base1 0.11.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74263f6916ed27a4645b81b1f2643644b4346dc51ddef62a1b800bc4e8cb2d54
4
- data.tar.gz: 622ce928924bd87f16343fbb39dd96a1a69458d19b4c2762e92e177fdd287601
3
+ metadata.gz: d998e1a738a8b6ff66e1c1b386201de3b9a23d790e7c5d9178eced111bfb997c
4
+ data.tar.gz: 2fcb8e8d90e99639732b645751803a8c97c03d8485e67b497d4c975cf4462ae5
5
5
  SHA512:
6
- metadata.gz: 8e0c3a9caec7ea2fcbdcc89201cdec1a559753018cbc90e0e6adba47339d96a7961e0d0fc479f2d5a85b462363273b16ae993940822d6a995aa3a6ea1dbcf367
7
- data.tar.gz: 5deda87284f69b8a90e97bb5023be2211a9539b39ccdb1110d8585ab4bce9d0da86717fc711552ade41622c380ea1454b6bfcda08197cad51befa7ddb3d81cbd
6
+ metadata.gz: 61b70292057fcc31581ac7ab06d648fb66c1599c4fbdd32be2d64afbdbf2c4fbeb380c7ffb8f33993b6fe5810e2faa183444d49697cc1334e0852c4be5c55d2c
7
+ data.tar.gz: 90e49b0129671bb8a660f7264edab2d5674f22f8259075a7b47b1b3ede650200b47693079db33d477669544fd340e092d419ae8335864e94e9448791c44c3d65
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ module Rubygems
8
+ class Gemspec
9
+ class AddOrReplaceGemLine
10
+ enable_method_class
11
+ common_constructor :sender, :gem_name, :gem_specs
12
+ delegate :lines, to: :sender
13
+
14
+ DEPENDENCY_PREFIX = ' s.add_dependency'
15
+
16
+ def existing_gem_line_index
17
+ lines.index { |line| line.start_with?(gem_line_prefix) }
18
+ end
19
+
20
+ def result
21
+ if existing_gem_line_index.present?
22
+ replace_line
23
+ else
24
+ add_line
25
+ end
26
+ end
27
+
28
+ def add_line
29
+ lines.insert(add_line_index, new_gem_line)
30
+ end
31
+
32
+ def add_line_index
33
+ (gems_lines_start_index..(lines.count - 1)).each do |e|
34
+ return e if new_gem_line < lines[e]
35
+ end
36
+ lines.count
37
+ end
38
+
39
+ def gems_lines_start_index
40
+ lines.index { |line| line.start_with?(DEPENDENCY_PREFIX) } || lines.count
41
+ end
42
+
43
+ def new_gem_line
44
+ ([gem_line_prefix] + quoted_gem_specs).join(', ')
45
+ end
46
+
47
+ def gem_line_prefix
48
+ "#{DEPENDENCY_PREFIX} '#{gem_name}'"
49
+ end
50
+
51
+ def replace_line
52
+ lines[existing_gem_line_index] = new_gem_line
53
+ end
54
+
55
+ def quoted_gem_specs
56
+ gem_specs.map { |gem_spec| "'#{gem_spec}'" }
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ module Rubygems
8
+ class Gemspec
9
+ class Dependency
10
+ common_constructor :gemspec, :gem_name
11
+
12
+ def version_specs=(version_specs)
13
+ gemspec.add_or_replace_gem_line(gem_name, version_specs)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ module Rubygems
8
+ class Gemspec
9
+ require_sub __FILE__, require_dependency: true
10
+
11
+ DEPENDENCY_LINE_PARSER = /s\.add_dependency\s*'(\S+)'/.to_parser { |m| m[1] }
12
+
13
+ class << self
14
+ def from_file(path)
15
+ new(path.read.each_line.map(&:rstrip))
16
+ end
17
+ end
18
+
19
+ common_constructor :lines
20
+
21
+ # @return [Avm::EacRubyBase1::Bundler::Gemfile::Dependency]
22
+ def dependency(gem_name)
23
+ ::Avm::EacRubyBase1::Rubygems::Gemspec::Dependency.new(self, gem_name)
24
+ end
25
+
26
+ # @return [Array<Avm::EacRubyBase1::Bundler::Gemfile::Dependency>]
27
+ def dependencies
28
+ lines.lazy.map { |line| DEPENDENCY_LINE_PARSER.parse(line) }.reject(&:blank?)
29
+ .map { |gem_name| dependency(gem_name) }.to_a
30
+ end
31
+
32
+ def write(path)
33
+ path.to_pathname.write(to_text)
34
+ end
35
+
36
+ def to_text
37
+ lines.map { |line| "#{line}\n" }.join
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,176 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_ruby_base1/sources/base'
4
+ require 'avm/source_generators/base'
5
+ require 'eac_templates/core_ext'
6
+ require 'eac_ruby_utils/core_ext'
7
+
8
+ module Avm
9
+ module EacRubyBase1
10
+ module SourceGenerators
11
+ class Base < ::Avm::SourceGenerators::Base
12
+ IDENT = ' '
13
+ JOBS = %w[root_directory gemspec root_lib version_lib static gemfile_lock].freeze
14
+ TEMPLATE_VARIABLES = %w[lib_path name root_module].freeze
15
+ OPTIONS = {
16
+ 'eac-ruby-utils-version'.to_sym => 'Version for "eac_ruby_utils" gem.',
17
+ 'eac-ruby-gem-support-version'.to_sym => 'Version for "eac_ruby_gem_support" gem.'
18
+ }.freeze
19
+
20
+ enable_speaker
21
+ enable_simple_cache
22
+
23
+ class << self
24
+ def option_list
25
+ OPTIONS.inject(super) { |a, e| a.option(*e) }
26
+ end
27
+ end
28
+
29
+ def root_directory
30
+ target_path
31
+ end
32
+
33
+ def eac_ruby_gem_support_version
34
+ dependency_version('eac_ruby_gem_support')
35
+ end
36
+
37
+ def eac_ruby_utils_version
38
+ dependency_version('eac_ruby_utils')
39
+ end
40
+
41
+ def name
42
+ root_directory.basename.to_s
43
+ end
44
+
45
+ def lib_path
46
+ name.split('-').join('/')
47
+ end
48
+
49
+ def perform
50
+ infov 'Root directory', root_directory
51
+ infov 'Gem name', name
52
+ JOBS.each do |job|
53
+ infom "Generating #{job.humanize}..."
54
+ send("generate_#{job}")
55
+ end
56
+ end
57
+
58
+ def root_module
59
+ lib_path.camelize
60
+ end
61
+
62
+ def root_module_close
63
+ root_module_components.count.times.map do |index|
64
+ (IDENT * index) + 'end'
65
+ end.reverse.join("\n")
66
+ end
67
+
68
+ def root_module_inner_identation
69
+ IDENT * root_module_components.count
70
+ end
71
+
72
+ def root_module_open
73
+ root_module_components.each_with_index.map do |component, index|
74
+ (IDENT * index) + 'module ' + component
75
+ end.join("\n")
76
+ end
77
+
78
+ def root_module_components
79
+ root_module.split('::')
80
+ end
81
+
82
+ protected
83
+
84
+ def apply_to_root_directory(template, subpath)
85
+ if template.is_a?(::EacTemplates::Directory)
86
+ template.children.each do |child|
87
+ apply_to_root_directory(child, subpath.join(child.basename))
88
+ end
89
+ elsif template.is_a?(::EacTemplates::File)
90
+ template.apply_to_file(template_variables, root_directory.join(subpath))
91
+ else
92
+ raise "Unknown template object: #{template}"
93
+ end
94
+ end
95
+
96
+ def dependency_version(gem_name)
97
+ VersionBuilder.new(gem_name, options).to_s
98
+ end
99
+
100
+ def generate_gemspec
101
+ template_apply('gemspec', "#{name}.gemspec")
102
+ end
103
+
104
+ def generate_gemfile_lock
105
+ self_gem.bundle('install').chdir_root.execute!
106
+ end
107
+
108
+ def generate_root_directory
109
+ root_directory.mkpath
110
+ end
111
+
112
+ def generate_root_lib
113
+ template_apply('root_lib', "lib/#{lib_path}.rb")
114
+ end
115
+
116
+ def generate_static
117
+ template.child('static').apply(self, root_directory)
118
+ end
119
+
120
+ def generate_version_lib
121
+ template_apply('version', "lib/#{lib_path}/version.rb")
122
+ end
123
+
124
+ def self_gem_uncached
125
+ ::Avm::EacRubyBase1::Sources::Base.new(root_directory)
126
+ end
127
+
128
+ def template_apply(from, to)
129
+ target = root_directory.join(to)
130
+ target.dirname.mkpath
131
+ template.child("#{from}.template").apply_to_file(self, target.to_path)
132
+ end
133
+
134
+ class VersionBuilder
135
+ enable_simple_cache
136
+ common_constructor :gem_name, :options
137
+
138
+ def to_s
139
+ r = "'~> #{two_segments}'"
140
+ r += ", '>= #{three_segments}'" if segments.count >= 3 && segments[2].positive?
141
+ r
142
+ end
143
+
144
+ # @return [Gem::Version]
145
+ def version
146
+ (options_version || default_version)
147
+ end
148
+
149
+ def two_segments
150
+ segments.first(2).join('.')
151
+ end
152
+
153
+ def three_segments
154
+ segments.first(3).join('.')
155
+ end
156
+
157
+ private
158
+
159
+ def segments_uncached
160
+ version.release.to_s.split('.').map(&:to_i)
161
+ end
162
+
163
+ def default_version
164
+ ::Gem.loaded_specs[gem_name].version
165
+ end
166
+
167
+ def options_version
168
+ options["#{gem_name}_version".dasherize.to_sym].if_present do |v|
169
+ ::Gem::Version.new(v)
170
+ end
171
+ end
172
+ end
173
+ end
174
+ end
175
+ end
176
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ module SourceGenerators
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRubyBase1
5
- VERSION = '0.11.0'
5
+ VERSION = '0.15.0'
6
6
  end
7
7
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
4
+
5
+ require '%%LIB_PATH%%/version'
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = '%%NAME%%'
9
+ s.version = %%ROOT_MODULE%%::VERSION
10
+ s.authors = ['Put here the authors']
11
+ s.summary = 'Put here de description.'
12
+
13
+ s.files = Dir['{lib}/**/*']
14
+
15
+ s.add_dependency 'eac_ruby_utils', %%EAC_RUBY_UTILS_VERSION%%
16
+
17
+ s.add_development_dependency 'eac_ruby_gem_support', %%EAC_RUBY_GEM_SUPPORT_VERSION%%
18
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ %%ROOT_MODULE_OPEN%%
6
+ %%ROOT_MODULE_INNER_IDENTATION%%require_sub __FILE__
7
+ %%ROOT_MODULE_CLOSE%%
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ local_gemfile = ::File.join(::File.dirname(__FILE__), 'Gemfile.local')
8
+ eval_gemfile local_gemfile if ::File.exist?(local_gemfile)
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ ::EacRubyUtils::Rspec.default_setup.describe_rubocop
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/rspec/default_setup'
4
+ ::EacRubyUtils::Rspec.default_setup_create(::File.expand_path('..', __dir__))
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ %%ROOT_MODULE_OPEN%%
4
+ %%ROOT_MODULE_INNER_IDENTATION%%VERSION = '0.0.0'
5
+ %%ROOT_MODULE_CLOSE%%
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.11.0
4
+ version: 0.15.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: 2022-07-21 00:00:00.000000000 Z
11
+ date: 2022-08-05 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.26'
19
+ version: '0.34'
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.26'
26
+ version: '0.34'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: avm-eac_generic_base0
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -116,7 +116,12 @@ files:
116
116
  - lib/avm/eac_ruby_base1/rubocop/envvar.rb
117
117
  - lib/avm/eac_ruby_base1/rubocop/gemfile.rb
118
118
  - lib/avm/eac_ruby_base1/rubygems.rb
119
+ - lib/avm/eac_ruby_base1/rubygems/gemspec.rb
120
+ - lib/avm/eac_ruby_base1/rubygems/gemspec/add_or_replace_gem_line.rb
121
+ - lib/avm/eac_ruby_base1/rubygems/gemspec/dependency.rb
119
122
  - lib/avm/eac_ruby_base1/rubygems/version_file.rb
123
+ - lib/avm/eac_ruby_base1/source_generators.rb
124
+ - lib/avm/eac_ruby_base1/source_generators/base.rb
120
125
  - lib/avm/eac_ruby_base1/sources.rb
121
126
  - lib/avm/eac_ruby_base1/sources/base.rb
122
127
  - lib/avm/eac_ruby_base1/sources/base/bundle_command.rb
@@ -139,6 +144,12 @@ files:
139
144
  - lib/avm/eac_ruby_base1/version.rb
140
145
  - locale/en.yml
141
146
  - locale/pt-BR.yml
147
+ - template/avm/eac_ruby_base1/source_generators/base/gemspec.template
148
+ - template/avm/eac_ruby_base1/source_generators/base/root_lib.template
149
+ - template/avm/eac_ruby_base1/source_generators/base/static/Gemfile
150
+ - template/avm/eac_ruby_base1/source_generators/base/static/spec/rubocop_spec.rb
151
+ - template/avm/eac_ruby_base1/source_generators/base/static/spec/spec_helper.rb
152
+ - template/avm/eac_ruby_base1/source_generators/base/version.template
142
153
  homepage:
143
154
  licenses: []
144
155
  metadata: {}