avm-eac_ruby_base1 0.12.0 → 0.13.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/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 +5 -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 +12 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 660a216c70551ca1c3ba380e9c4b4ea6af5f9a348134bdc508357b3a0c6d63f2
|
4
|
+
data.tar.gz: 5b9853c0ae6e667615cc0b8cb17ed4173b84de60de4b0dfa67c74e6ec4fc1d45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c1a82c5c0302ad6db97ce0916daa899353e46ee77913508f4abbbd1a550dab1c44fa18b14ee97a85d9b60a57ae8301ea7b1848ed8f6fb8d9031471210776cb7
|
7
|
+
data.tar.gz: 3f4dc7a0f397db675196a9035aaa672442a4cecb70510053ba05fce2f6e53a018d4848e76269704037f77b69ac29332cd6779140eeec5e6f043cac20f3718f39
|
@@ -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,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.13.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-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.
|
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
|
@@ -142,6 +144,12 @@ files:
|
|
142
144
|
- lib/avm/eac_ruby_base1/version.rb
|
143
145
|
- locale/en.yml
|
144
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
|
145
153
|
homepage:
|
146
154
|
licenses: []
|
147
155
|
metadata: {}
|