avm-eac_ruby_base1 0.12.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/avm/eac_ruby_base1/source_generators/base.rb +176 -0
- data/lib/avm/eac_ruby_base1/source_generators.rb +11 -0
- data/lib/avm/eac_ruby_base1/sources/runners/bundler/gemfile_local.rb +84 -0
- data/lib/avm/eac_ruby_base1/version.rb +1 -1
- data/template/avm/eac_ruby_base1/source_generators/base/gemspec.template +18 -0
- data/template/avm/eac_ruby_base1/source_generators/base/root_lib.template +7 -0
- data/template/avm/eac_ruby_base1/source_generators/base/static/Gemfile +8 -0
- data/template/avm/eac_ruby_base1/source_generators/base/static/spec/rubocop_spec.rb +3 -0
- data/template/avm/eac_ruby_base1/source_generators/base/static/spec/spec_helper.rb +4 -0
- data/template/avm/eac_ruby_base1/source_generators/base/version.template +5 -0
- metadata +13 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73cf66a72fcc24c0128fc2d9706c58ec009ecdd963b75efe0fe34000a2d4f4b3
|
4
|
+
data.tar.gz: 5a28a9b29acbf660057f7c181531cbbba8432c86294fce4c67f4d1ac136d83ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3f075d27166477bab4968a99af4af651eb3cb3445b5a549e8956f7467dbcf2ed49abbde04dc493bd582d4f3ddd51b61d22f6243a56a88de3763aca8aa228969
|
7
|
+
data.tar.gz: 026c88f853df55a243cdb78baeb43328c59472a8f2570dda7f21bf452290be0f2b8f4165fed5024e3ed9328a971d73b3d8f088ebc9f8519395aa8fe8afee2788
|
@@ -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,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/core_ext'
|
4
|
+
|
5
|
+
module Avm
|
6
|
+
module EacRubyBase1
|
7
|
+
module Sources
|
8
|
+
module Runners
|
9
|
+
class Bundler
|
10
|
+
class GemfileLocal
|
11
|
+
runner_with :help do
|
12
|
+
bool_opt '-w', '--write', 'Write the Gemfile.local file.'
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
start_banner
|
17
|
+
run_bundle
|
18
|
+
siblings_banner
|
19
|
+
write_gemfile_local
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def gemfile_local_path
|
25
|
+
the_source.path.join('Gemfile.local')
|
26
|
+
end
|
27
|
+
|
28
|
+
def gemfile_local_content
|
29
|
+
siblings.map { |s| sibling_gemfile_local_line(s) }.join
|
30
|
+
end
|
31
|
+
|
32
|
+
def run_bundle
|
33
|
+
the_source.bundle.execute!
|
34
|
+
rescue ::RuntimeError
|
35
|
+
the_source.bundle('update').execute!
|
36
|
+
end
|
37
|
+
|
38
|
+
def sibling_gemfile_local_line(sibling)
|
39
|
+
["gem '#{sibling.gem_name}'",
|
40
|
+
"path: ::File.expand_path('" +
|
41
|
+
sibling.path.relative_path_from(the_source.path).to_path +
|
42
|
+
"', __dir__)"].join(', ') + "\n"
|
43
|
+
end
|
44
|
+
|
45
|
+
def start_banner
|
46
|
+
runner_context.call(:source_banner)
|
47
|
+
infov 'Parent', the_source.parent
|
48
|
+
end
|
49
|
+
|
50
|
+
def siblings_banner
|
51
|
+
infov 'Siblings', siblings.count
|
52
|
+
siblings.each do |sibling|
|
53
|
+
infov ' * ', sibling.relative_path
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def write_gemfile_local
|
58
|
+
return unless parsed.write?
|
59
|
+
|
60
|
+
infom "Writing #{gemfile_local_path}..."
|
61
|
+
gemfile_local_path.write(gemfile_local_content)
|
62
|
+
end
|
63
|
+
|
64
|
+
def siblings_uncached
|
65
|
+
the_source.parent.if_present([]) do |v|
|
66
|
+
v.subs.select { |sub| dependency_sub?(sub) }
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def the_source
|
71
|
+
runner_context.call(:source)
|
72
|
+
end
|
73
|
+
|
74
|
+
def dependency_sub?(sub)
|
75
|
+
sub.is_a?(::Avm::EacRubyBase1::Sources::Base) &&
|
76
|
+
sub.gem_name != the_source.gem_name &&
|
77
|
+
the_source.gemfile_lock_gem_version(sub.gem_name).present?
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
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
|
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.
|
4
|
+
version: 0.16.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-08-
|
11
|
+
date: 2022-08-08 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.
|
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
|
+
version: '0.34'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: avm-eac_generic_base0
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,6 +120,8 @@ files:
|
|
120
120
|
- lib/avm/eac_ruby_base1/rubygems/gemspec/add_or_replace_gem_line.rb
|
121
121
|
- lib/avm/eac_ruby_base1/rubygems/gemspec/dependency.rb
|
122
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
|
123
125
|
- lib/avm/eac_ruby_base1/sources.rb
|
124
126
|
- lib/avm/eac_ruby_base1/sources/base.rb
|
125
127
|
- lib/avm/eac_ruby_base1/sources/base/bundle_command.rb
|
@@ -129,6 +131,7 @@ files:
|
|
129
131
|
- lib/avm/eac_ruby_base1/sources/base/version_bump.rb
|
130
132
|
- lib/avm/eac_ruby_base1/sources/runners.rb
|
131
133
|
- lib/avm/eac_ruby_base1/sources/runners/bundler.rb
|
134
|
+
- lib/avm/eac_ruby_base1/sources/runners/bundler/gemfile_local.rb
|
132
135
|
- lib/avm/eac_ruby_base1/sources/runners/bundler/incompatible.rb
|
133
136
|
- lib/avm/eac_ruby_base1/sources/tests.rb
|
134
137
|
- lib/avm/eac_ruby_base1/sources/tests/base.rb
|
@@ -142,6 +145,12 @@ files:
|
|
142
145
|
- lib/avm/eac_ruby_base1/version.rb
|
143
146
|
- locale/en.yml
|
144
147
|
- locale/pt-BR.yml
|
148
|
+
- template/avm/eac_ruby_base1/source_generators/base/gemspec.template
|
149
|
+
- template/avm/eac_ruby_base1/source_generators/base/root_lib.template
|
150
|
+
- template/avm/eac_ruby_base1/source_generators/base/static/Gemfile
|
151
|
+
- template/avm/eac_ruby_base1/source_generators/base/static/spec/rubocop_spec.rb
|
152
|
+
- template/avm/eac_ruby_base1/source_generators/base/static/spec/spec_helper.rb
|
153
|
+
- template/avm/eac_ruby_base1/source_generators/base/version.template
|
145
154
|
homepage:
|
146
155
|
licenses: []
|
147
156
|
metadata: {}
|