baltix 0.1.1 → 0.2

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.
Files changed (308) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -2
  3. data/README.md +136 -10
  4. data/Rakefile +8 -3
  5. data/baltix.gemspec +47 -29
  6. data/bin/console +4 -3
  7. data/data/alt-licenses/README.md +26 -0
  8. data/data/alt-licenses/licenses.json +2991 -0
  9. data/data/alt-rpm/README.md +21 -0
  10. data/data/alt-rpm/architectures.json +613 -0
  11. data/data/spdx/README.md +22 -0
  12. data/data/spdx/licenses.json +9287 -0
  13. data/docs/action-flow.md +42 -0
  14. data/docs/actor-integration.md +71 -0
  15. data/docs/alt-architectures.md +27 -0
  16. data/docs/cleanup-actors.md +14 -0
  17. data/docs/dependency-actions.md +22 -0
  18. data/docs/installation-actors.md +35 -0
  19. data/docs/pkglist.md +56 -0
  20. data/docs/plans/revision-003.md +328 -0
  21. data/docs/plans/revision-004.md +416 -0
  22. data/docs/plans/revision-005.md +431 -0
  23. data/docs/plans/revision-006.md +439 -0
  24. data/docs/plans/revision-007.md +441 -0
  25. data/docs/plans/revision-008.md +445 -0
  26. data/docs/plans/revision-009.md +450 -0
  27. data/docs/plans/revision-010.md +486 -0
  28. data/docs/plans/revision-011.md +500 -0
  29. data/docs/plans/revision-012.md +501 -0
  30. data/docs/plans/revision-013.md +501 -0
  31. data/docs/plans/revision-014.md +501 -0
  32. data/docs/plans/revision-015.md +502 -0
  33. data/docs/plans/revision-016.md +503 -0
  34. data/docs/plans/revision-017.md +504 -0
  35. data/docs/plans/revision-018.md +505 -0
  36. data/docs/plans/revision-019.md +510 -0
  37. data/docs/plans/revision-020.md +524 -0
  38. data/docs/plans/revision-021.md +542 -0
  39. data/docs/plans/revision-022.md +542 -0
  40. data/docs/plans/revision-023.md +545 -0
  41. data/docs/plans/revision-024.md +567 -0
  42. data/docs/plans/revision-025.md +583 -0
  43. data/docs/plans/revision-026.md +241 -0
  44. data/docs/plans/revision-027.md +305 -0
  45. data/docs/plans/revision-028.md +298 -0
  46. data/docs/plans/revision-029.md +288 -0
  47. data/docs/rpm-action-macros.md +52 -0
  48. data/docs/rpm-parts.md +53 -0
  49. data/docs/ruby-dependencies.md +217 -0
  50. data/docs/ruby-policy-2.1.md +28 -0
  51. data/docs/ruby-versioning.md +61 -0
  52. data/docs/space-format.md +58 -0
  53. data/exe/baltix +1 -0
  54. data/lib/baltix/action_flow/files.rb +49 -0
  55. data/lib/baltix/action_flow/inputs.rb +60 -0
  56. data/lib/baltix/action_flow/journal.rb +60 -0
  57. data/lib/baltix/action_flow/options.rb +60 -0
  58. data/lib/baltix/action_flow.rb +65 -0
  59. data/lib/baltix/actor/build/collect.rb +72 -0
  60. data/lib/baltix/actor/build/compile.rb +25 -0
  61. data/lib/baltix/actor/build/extconf.rb +14 -0
  62. data/lib/baltix/actor/build/make.rb +18 -0
  63. data/lib/baltix/actor/build/postprocess.rb +14 -0
  64. data/lib/baltix/actor/build/rake.rb +18 -0
  65. data/lib/baltix/actor/build/ronn.rb +55 -0
  66. data/lib/baltix/actor/build.rb +87 -0
  67. data/lib/baltix/actor/clean/remove.rb +45 -0
  68. data/lib/baltix/actor/clean.rb +37 -0
  69. data/lib/baltix/actor/config.rb +12 -0
  70. data/lib/baltix/actor/copy.rb +22 -7
  71. data/lib/baltix/actor/distclean.rb +20 -0
  72. data/lib/baltix/actor/doc/collect.rb +39 -0
  73. data/lib/baltix/actor/doc/generate.rb +47 -0
  74. data/lib/baltix/actor/doc/inputs.rb +25 -0
  75. data/lib/baltix/actor/doc.rb +70 -0
  76. data/lib/baltix/actor/gen.rb +19 -0
  77. data/lib/baltix/actor/install/data.rb +18 -0
  78. data/lib/baltix/actor/install/documentation.rb +48 -0
  79. data/lib/baltix/actor/install/executable.rb +27 -0
  80. data/lib/baltix/actor/install/extension.rb +44 -0
  81. data/lib/baltix/actor/install/headers.rb +10 -0
  82. data/lib/baltix/actor/install/library.rb +13 -0
  83. data/lib/baltix/actor/install/metadata.rb +21 -0
  84. data/lib/baltix/actor/install/paths.rb +73 -0
  85. data/lib/baltix/actor/install/plugin.rb +25 -0
  86. data/lib/baltix/actor/install/record.rb +48 -0
  87. data/lib/baltix/actor/install/shebang.rb +29 -0
  88. data/lib/baltix/actor/install/transfer.rb +64 -0
  89. data/lib/baltix/actor/install/trees.rb +34 -0
  90. data/lib/baltix/actor/install.rb +71 -0
  91. data/lib/baltix/actor/link.rb +15 -6
  92. data/lib/baltix/actor/make.rb +14 -0
  93. data/lib/baltix/actor/predeps/write.rb +51 -0
  94. data/lib/baltix/actor/predeps.rb +41 -0
  95. data/lib/baltix/actor/provides.rb +12 -0
  96. data/lib/baltix/actor/requires.rb +12 -0
  97. data/lib/baltix/actor/show.rb +26 -0
  98. data/lib/baltix/actor/spec.rb +6 -3
  99. data/lib/baltix/actor/test/record.rb +8 -0
  100. data/lib/baltix/actor/test/run.rb +30 -0
  101. data/lib/baltix/actor/test/select.rb +16 -0
  102. data/lib/baltix/actor/test.rb +41 -0
  103. data/lib/baltix/actor/touch.rb +14 -5
  104. data/lib/baltix/actor.rb +43 -26
  105. data/lib/baltix/cli/dependency_options.rb +63 -0
  106. data/lib/baltix/cli/options/action.rb +32 -0
  107. data/lib/baltix/cli/options.rb +280 -0
  108. data/lib/baltix/cli/output_options.rb +56 -0
  109. data/lib/baltix/cli/rake_tasks.rb +59 -0
  110. data/lib/baltix/cli/source_options.rb +52 -0
  111. data/lib/baltix/cli.rb +130 -116
  112. data/lib/baltix/concerns/command.rb +52 -0
  113. data/lib/baltix/concerns/configuration.rb +39 -0
  114. data/lib/baltix/concerns/dependency_output.rb +21 -0
  115. data/lib/baltix/concerns/extension_metadata.rb +44 -0
  116. data/lib/baltix/concerns/file_destination.rb +14 -0
  117. data/lib/baltix/concerns/inspection.rb +27 -0
  118. data/lib/baltix/concerns/parts.rb +16 -0
  119. data/lib/baltix/concerns/target_paths.rb +57 -0
  120. data/lib/baltix/concerns.rb +11 -0
  121. data/lib/baltix/core_extensions/gem_dependency.rb +24 -0
  122. data/lib/baltix/core_extensions/gem_requirement.rb +45 -0
  123. data/lib/baltix/core_extensions/open_struct_merge.rb +62 -0
  124. data/lib/baltix/deps/executables.rb +30 -0
  125. data/lib/baltix/deps/packages.rb +32 -0
  126. data/lib/baltix/deps.rb +103 -194
  127. data/lib/baltix/dsl/dependency_groups.rb +77 -0
  128. data/lib/baltix/dsl/dependency_sources.rb +100 -0
  129. data/lib/baltix/dsl/filtering.rb +26 -0
  130. data/lib/baltix/dsl/loading.rb +72 -0
  131. data/lib/baltix/dsl/merging.rb +74 -0
  132. data/lib/baltix/dsl/rendering.rb +54 -0
  133. data/lib/baltix/dsl/requirements.rb +77 -0
  134. data/lib/baltix/dsl/temporary_files.rb +36 -0
  135. data/lib/baltix/dsl.rb +66 -273
  136. data/lib/baltix/executable_dependencies/features.rb +53 -0
  137. data/lib/baltix/executable_dependencies/library.rb +21 -0
  138. data/lib/baltix/executable_dependencies/library_features.rb +34 -0
  139. data/lib/baltix/executable_dependencies/syntax.rb +102 -0
  140. data/lib/baltix/executable_dependencies.rb +102 -0
  141. data/lib/baltix/extensions/bones.rb +173 -0
  142. data/lib/baltix/extensions/echoe.rb +143 -0
  143. data/lib/baltix/extensions/hoe/metadata.rb +89 -0
  144. data/lib/baltix/extensions/hoe/options.rb +84 -0
  145. data/lib/baltix/extensions/hoe/readme.rb +29 -0
  146. data/lib/baltix/extensions/hoe.rb +146 -0
  147. data/lib/baltix/extensions/jeweler.rb +95 -0
  148. data/lib/baltix/extensions/levitate.rb +74 -0
  149. data/lib/baltix/extensions/olddoc.rb +42 -0
  150. data/lib/baltix/extensions.rb +340 -419
  151. data/lib/baltix/i18n.rb +22 -19
  152. data/lib/baltix/license/catalog/capture.rb +58 -0
  153. data/lib/baltix/license/catalog.rb +75 -0
  154. data/lib/baltix/license.rb +76 -0
  155. data/lib/baltix/loader/capture.rb +91 -0
  156. data/lib/baltix/loader/cmake.rb +6 -3
  157. data/lib/baltix/loader/evaluation.rb +49 -0
  158. data/lib/baltix/loader/extconf.rb +27 -0
  159. data/lib/baltix/loader/feature_loading.rb +54 -0
  160. data/lib/baltix/loader/git-version-gen.rb +36 -21
  161. data/lib/baltix/loader/mast/properties.rb +58 -0
  162. data/lib/baltix/loader/mast.rb +97 -109
  163. data/lib/baltix/loader/object_capture.rb +27 -0
  164. data/lib/baltix/loader/olddoc.gemspec.erb +31 -0
  165. data/lib/baltix/loader/pom.rb +36 -16
  166. data/lib/baltix/loader/rookbook.rb +19 -14
  167. data/lib/baltix/loader/yaml.rb +9 -5
  168. data/lib/baltix/loader.rb +85 -132
  169. data/lib/baltix/log.rb +26 -27
  170. data/lib/baltix/rake/metadata_adapter.rb +30 -0
  171. data/lib/baltix/rake/task_context.rb +59 -0
  172. data/lib/baltix/rake/task_libraries.rb +73 -0
  173. data/lib/baltix/rake.rb +62 -12
  174. data/lib/baltix/source/base/dependencies.rb +81 -0
  175. data/lib/baltix/source/base/file_queries.rb +67 -0
  176. data/lib/baltix/source/base/file_tree.rb +70 -0
  177. data/lib/baltix/source/base/metadata.rb +140 -0
  178. data/lib/baltix/source/base/options.rb +71 -0
  179. data/lib/baltix/source/base/roots.rb +53 -0
  180. data/lib/baltix/source/base.rb +95 -377
  181. data/lib/baltix/source/fake.rb +89 -5
  182. data/lib/baltix/source/gem/delegation.rb +32 -0
  183. data/lib/baltix/source/gem/dependencies.rb +69 -0
  184. data/lib/baltix/source/gem/discovery.rb +72 -0
  185. data/lib/baltix/source/gem/file_trees.rb +114 -0
  186. data/lib/baltix/source/gem/forwarding.rb +12 -0
  187. data/lib/baltix/source/gem/metadata.rb +104 -0
  188. data/lib/baltix/source/gem/specification.rb +65 -0
  189. data/lib/baltix/source/gem.rb +65 -312
  190. data/lib/baltix/source/gemfile.rb +55 -5
  191. data/lib/baltix/source/rakefile.rb +12 -5
  192. data/lib/baltix/source.rb +36 -24
  193. data/lib/baltix/space/configuration.rb +54 -0
  194. data/lib/baltix/space/data/collections.rb +33 -0
  195. data/lib/baltix/space/data/gem_metadata.rb +79 -0
  196. data/lib/baltix/space/data/models.rb +20 -0
  197. data/lib/baltix/space/data/values.rb +72 -0
  198. data/lib/baltix/space/data.rb +53 -0
  199. data/lib/baltix/space/dependencies.rb +53 -0
  200. data/lib/baltix/space/filters.rb +96 -0
  201. data/lib/baltix/space/initialization.rb +124 -0
  202. data/lib/baltix/space/metadata.rb +130 -0
  203. data/lib/baltix/space/source_order.rb +43 -0
  204. data/lib/baltix/space/source_selection.rb +136 -0
  205. data/lib/baltix/space/source_status.rb +114 -0
  206. data/lib/baltix/space/spec.rb +3 -0
  207. data/lib/baltix/space.rb +87 -367
  208. data/lib/baltix/spec/rpm/aliases.rb +79 -0
  209. data/lib/baltix/spec/rpm/arch.rb +119 -0
  210. data/lib/baltix/spec/rpm/available_overrides.rb +106 -0
  211. data/lib/baltix/spec/rpm/build_dependencies.rb +132 -0
  212. data/lib/baltix/spec/rpm/build_queries.rb +61 -0
  213. data/lib/baltix/spec/rpm/changelog.rb +115 -0
  214. data/lib/baltix/spec/rpm/dependency_overrides.rb +83 -0
  215. data/lib/baltix/spec/rpm/dependency_policy.rb +69 -0
  216. data/lib/baltix/spec/rpm/deps.rb +113 -0
  217. data/lib/baltix/spec/rpm/env/requirements.rb +20 -0
  218. data/lib/baltix/spec/rpm/env.rb +76 -0
  219. data/lib/baltix/spec/rpm/executable_packages.rb +49 -0
  220. data/lib/baltix/spec/rpm/file_manifest.rb +72 -0
  221. data/lib/baltix/spec/rpm/guard_compilation.rb +95 -0
  222. data/lib/baltix/spec/rpm/imported_secondaries.rb +26 -0
  223. data/lib/baltix/spec/rpm/layout.rb +14 -0
  224. data/lib/baltix/spec/rpm/manpages.rb +71 -0
  225. data/lib/baltix/spec/rpm/metadata.rb +78 -0
  226. data/lib/baltix/spec/rpm/name/equality.rb +68 -0
  227. data/lib/baltix/spec/rpm/name/formatting.rb +33 -0
  228. data/lib/baltix/spec/rpm/name/parsing.rb +58 -0
  229. data/lib/baltix/spec/rpm/name.rb +77 -108
  230. data/lib/baltix/spec/rpm/packaged_versions.rb +107 -0
  231. data/lib/baltix/spec/rpm/parser/comments.rb +35 -0
  232. data/lib/baltix/spec/rpm/parser/context.rb +50 -0
  233. data/lib/baltix/spec/rpm/parser/dependencies.rb +91 -0
  234. data/lib/baltix/spec/rpm/parser/file_sections.rb +68 -0
  235. data/lib/baltix/spec/rpm/parser/flow.rb +84 -0
  236. data/lib/baltix/spec/rpm/parser/header_dependencies.rb +36 -0
  237. data/lib/baltix/spec/rpm/parser/macros.rb +43 -0
  238. data/lib/baltix/spec/rpm/parser/metadata.rb +106 -0
  239. data/lib/baltix/spec/rpm/parser/sections.rb +88 -0
  240. data/lib/baltix/spec/rpm/parser/values.rb +85 -0
  241. data/lib/baltix/spec/rpm/parser.rb +124 -269
  242. data/lib/baltix/spec/rpm/part_files.rb +64 -0
  243. data/lib/baltix/spec/rpm/part_prelude.rb +43 -0
  244. data/lib/baltix/spec/rpm/part_scripts.rb +52 -0
  245. data/lib/baltix/spec/rpm/part_switches.rb +65 -0
  246. data/lib/baltix/spec/rpm/pkglist/header.rb +73 -0
  247. data/lib/baltix/spec/rpm/pkglist/provides.rb +57 -0
  248. data/lib/baltix/spec/rpm/pkglist.rb +116 -0
  249. data/lib/baltix/spec/rpm/preparation.rb +73 -0
  250. data/lib/baltix/spec/rpm/rendering.rb +66 -0
  251. data/lib/baltix/spec/rpm/repository_application.rb +33 -0
  252. data/lib/baltix/spec/rpm/revision.rb +58 -0
  253. data/lib/baltix/spec/rpm/root_source.rb +48 -0
  254. data/lib/baltix/spec/rpm/scripts.rb +85 -0
  255. data/lib/baltix/spec/rpm/secondaries.rb +82 -0
  256. data/lib/baltix/spec/rpm/secondary.rb +117 -64
  257. data/lib/baltix/spec/rpm/secondary_parts.rb +84 -0
  258. data/lib/baltix/spec/rpm/section_document.rb +84 -0
  259. data/lib/baltix/spec/rpm/section_guards.rb +116 -0
  260. data/lib/baltix/spec/rpm/source_selection.rb +82 -0
  261. data/lib/baltix/spec/rpm/spec_core/architecture.rb +28 -0
  262. data/lib/baltix/spec/rpm/spec_core/attributes.rb +89 -0
  263. data/lib/baltix/spec/rpm/spec_core/availability.rb +60 -0
  264. data/lib/baltix/spec/rpm/spec_core/dependency_rendering.rb +83 -0
  265. data/lib/baltix/spec/rpm/spec_core/descriptions.rb +77 -0
  266. data/lib/baltix/spec/rpm/spec_core/documentation.rb +48 -0
  267. data/lib/baltix/spec/rpm/spec_core/executable_names.rb +37 -0
  268. data/lib/baltix/spec/rpm/spec_core/host_names.rb +60 -0
  269. data/lib/baltix/spec/rpm/spec_core/interpreters.rb +103 -0
  270. data/lib/baltix/spec/rpm/spec_core/names.rb +80 -0
  271. data/lib/baltix/spec/rpm/spec_core/obsoletes.rb +38 -0
  272. data/lib/baltix/spec/rpm/spec_core/package_dependencies.rb +74 -0
  273. data/lib/baltix/spec/rpm/spec_core/plain_dependencies.rb +60 -0
  274. data/lib/baltix/spec/rpm/spec_core/pre_name.rb +23 -0
  275. data/lib/baltix/spec/rpm/spec_core/provides.rb +104 -0
  276. data/lib/baltix/spec/rpm/spec_core/readme.rb +78 -0
  277. data/lib/baltix/spec/rpm/spec_core/registration.rb +18 -0
  278. data/lib/baltix/spec/rpm/spec_core/runtime_dependencies.rb +81 -0
  279. data/lib/baltix/spec/rpm/spec_core/summaries.rb +64 -0
  280. data/lib/baltix/spec/rpm/spec_core/text_wrapping.rb +36 -0
  281. data/lib/baltix/spec/rpm/spec_core/versioning.rb +75 -0
  282. data/lib/baltix/spec/rpm/spec_core/versions.rb +94 -0
  283. data/lib/baltix/spec/rpm/spec_core.rb +75 -527
  284. data/lib/baltix/spec/{rpm.erb → rpm/template.erb} +131 -31
  285. data/lib/baltix/spec/rpm.rb +253 -644
  286. data/lib/baltix/spec.rb +16 -14
  287. data/lib/baltix/target/gem.rb +61 -0
  288. data/lib/baltix/target/site.rb +40 -0
  289. data/lib/baltix/target.rb +16 -0
  290. data/lib/baltix/version.rb +3 -1
  291. data/lib/baltix.rb +77 -5
  292. data/locale/en_US.UTF-8.yaml +4 -1
  293. data/locale/ru_RU.UTF-8.yaml +7 -1
  294. data/rpm/baltix.env +4 -0
  295. data/rpm/baltix.prov +8 -0
  296. data/rpm/baltix.prov.files +6 -0
  297. data/rpm/baltix.req +8 -0
  298. data/rpm/baltix.req.files +6 -0
  299. data/rpm/macros.baltix +24 -0
  300. data/utils/rubocop/compact_block_braces.rb +39 -0
  301. data/utils/rubocop/spacing.rb +96 -0
  302. data/utils/update_alt_architectures.rb +57 -0
  303. data/utils/update_alt_licenses.rb +19 -0
  304. data/utils/update_spdx_licenses.rb +21 -0
  305. metadata +526 -17
  306. data/.github/workflows/ci.yml +0 -44
  307. data/.gitignore +0 -10
  308. data/TODO +0 -84
data/lib/baltix/space.rb CHANGED
@@ -1,45 +1,80 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rubygems'
4
+ require 'pathname'
5
+ require 'stringio'
2
6
 
3
7
  require 'baltix/version'
4
8
  require 'baltix/log'
5
9
  require 'baltix/source'
6
10
  require 'baltix/spec'
7
11
  require 'baltix/cli'
12
+ require 'baltix/spec/rpm/arch'
13
+ require 'baltix/concerns'
8
14
 
15
+ # Combines project sources, persisted state and caller configuration.
9
16
  class Baltix::Space
10
17
  include Baltix::Log
18
+ include Baltix::Concerns::Configuration
11
19
 
12
20
  class InvalidSpaceFileError < StandardError; end
13
21
 
14
22
  TYPES = {
15
23
  sources: Baltix::Source
16
- }
24
+ }.freeze
17
25
 
18
26
  STATES = {
19
- invalid: ->(_, source, _) { !source.valid? },
20
- disabled: ->(space, source, _) { space.is_disabled?(source) },
21
- duplicated: ->(_, _, dup) { dup },
22
- }
27
+ invalid: ->(_, source, _, _) { !source.valid? },
28
+ disabled: ->(space, source, _, _) { space.is_disabled?(source) },
29
+ obsoleted: ->(_, _, dup, obsoleted) { !dup && obsoleted },
30
+ duplicated: ->(_, _, dup, _) { dup }
31
+ }.freeze
23
32
 
24
33
  TYPE_CHARS = {
25
34
  fake: '·',
26
35
  gem: '*',
27
36
  gemfile: '&',
28
- rakefile: '^',
29
- }
37
+ rakefile: '^'
38
+ }.freeze
30
39
 
31
40
  STATUS_CHARS = {
32
41
  invalid: 'X',
33
42
  disabled: '-',
43
+ obsoleted: '\\',
34
44
  duplicated: '=',
35
- valid: 'V',
36
- }
37
-
38
-
39
- Gem.load_yaml
40
-
41
- @@space = {}
42
- @@options = {}
45
+ regarded: 'R',
46
+ valid: 'V'
47
+ }.freeze
48
+
49
+ DEFAULT_IGNORE_PATH_TOKES =
50
+ %w[templates example examples sample samples spec test tests testdata features
51
+ fixtures doc docs contrib demo acceptance conformance myapp website benchmarks benchmark
52
+ gemfiles misc steep] |
53
+ # Also match compound directory names, e.g. kitchen-tests and ruby-testdata.
54
+ [/(?<![[:alnum:]])(?:tests|testdata)(?![[:alnum:]])/]
55
+
56
+ PLATFORMS = {
57
+ ruby: true,
58
+ jruby: false,
59
+ mingw: false
60
+ }.freeze
61
+
62
+ VERSIONS = {
63
+ /nonrelease/ => false
64
+ }.freeze
65
+
66
+ # tags:
67
+ # default,test,development,production,etc for gemfile
68
+ # runtime,development for gemspec
69
+ #
70
+ # for spec:
71
+ # library: gemspec:runtime
72
+ # binary: gemfile:default
73
+ # devel: gemfile:* + gemspec:runtime + gemspec:development
74
+ # build: 1) marked as required from extconf 2) marked by macro as build in spec
75
+ # check: devel - build
76
+
77
+ @spaces = {}
43
78
 
44
79
  # +options+ property returns the hash of the loaded options if any
45
80
  #
@@ -47,378 +82,63 @@ class Baltix::Space
47
82
  #
48
83
  attr_reader :options, :state
49
84
 
50
- # +name+ returns a default name of the space with a prefix if any. It returns name of a source when
51
- # its root is the same as the space's root, or returns name defined in the spec if any.
52
- # If no spec defined returns name of last folder in rootdir or "root" as a default main source name.
53
- #
54
- # space.name # => space-name
55
- #
56
- def name
57
- return @name if @name
58
-
59
- @name = spec&.name || main_source&.name
60
- end
61
-
62
- # +version+ returns a default version for the space. Returns version of a source when
63
- # its root is the same as the space's root, or returns version defined in the spec if any,
64
- # or returns default one.
65
- #
66
- # space.version # => 2.1.1
67
- #
68
- def version
69
- return @version if @version
70
-
71
- @version ||= main_source&.version || spec&.version
72
- end
73
-
74
85
  attr_writer :rootdir
75
86
 
76
- # +rootdir+ returns the root dir for the space got from the options,
77
- # defaulting to the current folder.
78
- #
79
- # rootdir #=> /root/dir/for/the/space
80
- #
81
- def rootdir
82
- @rootdir ||= read_attribute(:rootdir) || Dir.pwd
83
- end
87
+ # def is_regarded? source
88
+ # regarded_names.any? {|i| i === source.name } ||
89
+ # !ignored_names.any? {|i| i === source.name } &&
90
+ # !ignored_path_tokens.any? {|t| /\/#{t}\// =~ source.source_file }
91
+ # end
84
92
 
85
- # +main_source+ selects main source from the list of sources when source root dir is the space's one and
86
- # source's name contains minimum name size among the matching sources
87
- #
88
- def main_source
89
- return @main_source if @main_source
90
-
91
- reals = valid_sources.select { |source| !source.is_a?(Baltix::Source::Fake) }
92
- if spec && !spec.state.blank?
93
- specen_source = reals.find { |real| spec.state["name"] === real.name }
94
- end
95
-
96
- root_source ||= valid_sources.sort {|x, y| x.name.size <=> y.name.size }.find { |source| source.rootdir == rootdir }
97
- @main_source =
98
- specen_source || root_source.is_a?(Baltix::Source::Fake) && reals.size == 1 && reals.first || root_source
99
- end
100
-
101
- def time_stamp
102
- Time.now.strftime("%Y%m%d")
103
- end
104
-
105
- # +changes+ returns a list of open-struct formatted changes in the space or
106
- # spec defined if any, otherwise returns blank array.
107
- #
108
- # space.changes # => []
109
- #
110
- def changes
111
- @changes ||= spec&.changes || main_source&.respond_to?(:changes) && main_source.changes || []
112
- end
113
-
114
- # +summaries+ returns an open-struct formatted summaries with locales as keys
115
- # in the space or spec defined if any, otherwise returns blank open struct.
116
- #
117
- # space.summaries # => #<OpenStruct en_US.UTF-8: ...>
118
- #
119
- def summaries
120
- return @summaries if @summaries
93
+ class << self
94
+ def load_from! state: Dir['.space'].first, options: {}
95
+ state_tmp = loaded_space_state(state).to_os
121
96
 
122
- if summaries = spec&.summaries || state.summaries
123
- summaries
124
- elsif summary = main_source&.summary
125
- { Baltix::I18n.default_locale => summary }.to_os
97
+ @spaces[state_tmp.name] = new(state_in: state_tmp, options: options)
126
98
  end
127
- end
128
99
 
129
- # +licenses+ returns license list defined in all the valid sources found in the space.
130
- #
131
- # space.licenses => # ["MIT"]
132
- #
133
- def licenses
134
- return @licenses if @licenses
135
-
136
- licenses = valid_sources.map { |source| source.licenses rescue [] }.flatten.uniq
137
-
138
- @licenses = !licenses.blank? && licenses || spec&.licenses || []
139
- end
140
-
141
- # +dependencies+ returns all the valid source dependencies list as an array of Gem::Dependency
142
- # objects, otherwise returning blank array.
143
- def dependencies
144
- @dependencies ||= valid_sources.map do |source|
145
- source.respond_to?(:dependencies) && source.dependencies || []
146
- end.flatten.reject do |dep|
147
- match_platform?(dep) || sources.any? do |s|
148
- dep.name == s.name &&
149
- dep.requirement.satisfied_by?(Gem::Version.new(s.version))
100
+ def loaded_space_state state
101
+ case state
102
+ when Hash then Data.from_h(state)
103
+ when OpenStruct then state
104
+ when IO, StringIO
105
+ Data.load(state.readlines.join)
106
+ when String then loaded_space_file(state)
107
+ when NilClass
108
+ nil
109
+ else
110
+ raise(InvalidSpaceFileError)
150
111
  end
151
112
  end
152
- end
153
-
154
- def match_platform? dep
155
- if dep.respond_to?(:platforms)
156
- (dep.platforms & options.skip_platforms).any?
157
- end
158
- end
159
-
160
- def files
161
- @files ||= valid_sources.map { |s| s.files rescue [] }.flatten.uniq
162
- end
163
-
164
- def executables
165
- @executables ||= valid_sources.map { |s| s.executables rescue [] }.flatten.uniq
166
- end
167
-
168
- def docs
169
- @docs ||= valid_sources.map { |s| s.docs rescue [] }.flatten.uniq
170
- end
171
-
172
- def compilables
173
- @compilables ||= valid_sources.map { |s| s.extensions rescue [] }.flatten.uniq
174
- end
175
-
176
- # +sources+ returns all the sources in the space. It will load from the space sources,
177
- # or by default will search sources in the provided folder or the current one.
178
- #
179
- # space.sources => # [#<Baltix::Source:...>, #<...>]
180
- #
181
- def sources
182
- @sources ||= stat_sources.map { |x| x.first }
183
- end
184
-
185
- # +valid_sources+ returns all the valid sources based on the current source list.
186
- #
187
- # space.valid_sources => # [#<Baltix::Source:...>, #<...>]
188
- #
189
- # def valid_sources
190
- # @valid_sources ||= sources.select do |source|
191
- # source.valid? && is_regarded?(source)
192
- # end
193
- # end
194
- def valid_sources
195
- @valid_sources = stat_sources.map {|(source, status)| status == :valid && source || nil }.compact
196
- end
197
-
198
- # def is_regarded? source
199
- # regarded_names.any? {|i| i === source.name } ||
200
- # !ignored_names.any? {|i| i === source.name } &&
201
- # !ignored_path_tokens.any? {|t| /\/#{t}\// =~ source.source_file }
202
- # end
203
-
204
- def ignored_names
205
- @ignored_names ||= (read_attribute(:ignored_names) || [])
206
- end
207
-
208
- def regarded_names
209
- @regarded_names ||= read_attribute(:regarded_names) || []
210
- end
211
113
 
212
- def ignored_path_tokens
213
- @ignored_path_tokens ||= (read_attribute(:ignored_path_tokens) || [])
214
- end
215
-
216
- def spec_type
217
- @spec_type ||= read_attribute(:spec_type) || spec && spec.class.to_s.split("::").last.downcase
218
- end
219
-
220
- def read_attribute attr
221
- options.send(attr) || state.send(attr)
222
- end
223
-
224
- def options_for type
225
- @@options[type] = type::OPTIONS.map do |option|
226
- value = self.options[option] || self.respond_to?(option) && self.send(option) || nil
227
-
228
- [ option, value ]
229
- end.compact.to_os
230
- end
231
-
232
- # +spec+ property returns the hash of the loaded spec if any, it can be freely
233
- # reassigned.
234
- #
235
- # spec #=> {...}
236
- #
237
- def spec
238
- @spec ||= gen_spec
239
- end
240
-
241
- def spec= value
242
- gen_spec(value)
243
- end
244
-
245
- def is_disabled? source
246
- options.ignored_path_tokens.any? { |t| /\/#{t}\// =~ source.source_file } ||
247
- options.regarded_names.all? { |i| !i.match?(source.name) } &&
248
- options.ignored_names.any? { |i| i === source.name }
249
- end
250
-
251
- protected
114
+ def loaded_space_file file
115
+ raise(InvalidSpaceFileError.new(state: file)) unless File.file?(file)
252
116
 
253
- def gen_spec spec_in = nil
254
- spec_pre = spec_in || state.spec
255
-
256
- @spec =
257
- if spec_pre.is_a?(Baltix::Spec::Rpm)
258
- spec_pre
259
- elsif spec_pre.is_a?(String)
260
- self.class.load(spec_pre)
261
- elsif options&.spec_file
262
- Baltix::Spec.load_from(source: IO.read(options.spec_file), options: options, space: self)
263
- elsif @spec_type || options&.spec_type
264
- Baltix::Spec.find(@spec_type || options.spec_type).new(options: options, space: self)
265
- end
266
-
267
- @spec.assign_space(self) if @spec
268
-
269
- @spec
270
- end
271
-
272
- def initialize state_in = {}, options = {}
273
- @options = Baltix::CLI::DEFAULT_OPTIONS.merge(options || {})
274
- @state = (state_in || {}).to_os
275
-
276
- baltix_log
277
- end
278
-
279
- # init log
280
- def baltix_log
281
- ios = DEFAULT_IO_NAMES.merge(%i(error warn info debug).map {|k| [k, options["#{k}_io"]]}.to_h)
282
- Baltix::Log.setup(options.log_level.to_sym, ios)
283
- end
284
-
285
- def show_tree
286
- info("Sources:")
287
- stat_source_tree.each do |(path_in, stated_sources)|
288
- stated_sources.each do |(source, status)|
289
- path = source.source_path_from(rootdir) if source.source_file
290
- stat = [STATUS_CHARS[status], TYPE_CHARS[source.type.to_sym]].join(" ")
291
- namever = [source.name, source.version].compact.join(":")
292
- info_in = "#{stat}#{namever} [#{path}]"
293
-
294
- info(info_in)
295
- end
117
+ Data.load(File.read(file, encoding: 'UTF-8'))
296
118
  end
297
- end
298
-
299
- # returns all the sources with their statuses, and sorted by a its rootdir value
300
- #
301
- def stat_sources &block
302
- return @stat_sources if @stat_sources
303
119
 
304
- @stat_sources =
305
- read_attribute(:stat_sources) || Baltix::Source.search_in(rootdir, options).group_by do |x|
306
- [x.name, x.version].compact.join(":")
307
- end.map do |(full_name, v)|
308
- sorten =
309
- v.sort do |x,y|
310
- c0 = ::Baltix::Source.loaders.index(x.loader) <=> ::Baltix::Source.loaders.index(y.loader)
311
- c1 = c0 == 0 && x.name <=> y.name || c0
312
- c2 = c1 == 0 && y.version <=> x.version || c1
313
- c3 = c2 == 0 && y.platform <=> x.platform || c2
314
- c4 = c3 == 0 && y.source_names.grep(/gemspec/).count <=> x.source_names.grep(/gemspec/).count
315
-
316
- c2 == 0 && c3 == 0 && c4 == 0 && x.rootdir.size <=> y.rootdir.size || c4 != 0 && c4 || c3 != 0 && c3 || c2
317
- end.reduce([[], 0]) do |(res, index), source|
318
- dup = source.valid? && index > 0
319
- dup_index = source.valid? && index + 1 || index
320
-
321
- [res | [[source, source_status(source, dup)]], dup_index]
322
- end.first
323
-
324
- sorten[1..-1].each { |x| sorten.first.first.alias_to(x.first) }
325
-
326
- sorten
327
- end.flatten(1).sort_by {|(x, _)| x.rootdir.size }.each do |(source, status)|
328
- block[source, status] if block_given?
329
- end
330
-
331
- show_tree
332
-
333
- @stat_sources
334
- end
335
-
336
- # returns source tree, and sorted, and then grouped by a its rootdir value
337
- #
338
- def stat_source_tree
339
- @stat_source_tree ||=
340
- stat_sources.group_by {|(x, _)| x.rootdir }.map do |(path, sources)|
341
- [File.join('.', path[rootdir.size..-1] || ''), sources]
342
- end.to_h
343
- end
344
-
345
- # returns status for the source for the project
346
- #
347
- def source_status source, dup
348
- %i(valid duplicated disabled invalid).reduce() do |res, status|
349
- STATES[status][self, source, dup] && status || res
120
+ def load_from state: Dir['.space'].first, options: {}
121
+ load_from!(state: state, options: options)
122
+ rescue InvalidSpaceFileError
123
+ @spaces[nil] = new(options: options)
350
124
  end
351
125
  end
126
+ end
352
127
 
353
- def context
354
- @context ||= options[:context] || spec&.context || {}
355
- end
356
-
357
- def method_missing method, *args
358
- value =
359
- instance_variable_get(:"@#{method}") ||
360
- (spec.send(method) rescue nil) ||
361
- options&.[](method) ||
362
- spec&.options&.[](method.to_s) ||
363
- state[method]
364
-
365
- instance_variable_set(:"@#{method}", value || super)
128
+ require 'baltix/space/spec'
366
129
 
367
- value
368
- end
130
+ require 'baltix/space/source_selection'
369
131
 
370
- class << self
371
- def load string
372
- if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("4.0.0")
373
- YAML.load(string,
374
- aliases: true,
375
- permitted_classes: [
376
- Baltix::Source::Fake,
377
- Baltix::Source::Rakefile,
378
- Baltix::Source::Gemfile,
379
- Baltix::Source::Gem,
380
- Baltix::Spec::Rpm,
381
- Baltix::Spec::Rpm::Name,
382
- Baltix::Spec::Rpm::Secondary,
383
- Gem::Specification,
384
- Gem::Version,
385
- Gem::Dependency,
386
- Gem::Requirement,
387
- OpenStruct,
388
- Symbol,
389
- Time,
390
- Date
391
- ])
392
- else
393
- YAML.load(string)
394
- end
395
- end
132
+ require 'baltix/space/source_status'
396
133
 
397
- def load_from! state: Dir[".space"].first, options: {}
398
- # system_path_check # TODO required to generate spec rubocop
134
+ require 'baltix/space/filters'
399
135
 
400
- state_tmp =
401
- case state
402
- when IO, StringIO
403
- load(state.readlines.join(""))
404
- when String
405
- raise InvalidSpaceFileError.new(state: state) if !File.file?(state)
136
+ require 'baltix/space/dependencies'
406
137
 
407
- load(IO.read(state))
408
- when NilClass
409
- else
410
- raise InvalidSpaceFileError
411
- end.to_os
138
+ require 'baltix/space/metadata'
412
139
 
413
- @@space[state_tmp.name] = self.new(state_tmp, options)
414
- end
140
+ require 'baltix/space/configuration'
415
141
 
416
- def load_from state: Dir[".space"].first, options: {}
417
- load_from!(state: state, options: options)
418
- rescue InvalidSpaceFileError
419
- @@space[nil] = new(nil, options)
420
- end
421
- end
422
- end
142
+ require 'baltix/space/initialization'
423
143
 
424
- require 'baltix/space/spec'
144
+ require 'baltix/space/data'
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Restores name aliases and legacy ruby_build mappings without changing their precedence.
4
+ class Baltix::Spec::Rpm
5
+ protected
6
+
7
+ def ruby_build
8
+ @ruby_build ||= variables.ruby_build&.split(/\s+/) || []
9
+ end
10
+
11
+ def _global_rename value_in
12
+ case source
13
+ when Baltix::Source::Gem
14
+ value_in.class.parse(value_in, prefix: value_in.class.default_prefix)
15
+ when Baltix::Source::Gemfile, Baltix::Source::Rakefile, Baltix::Source::Fake
16
+ global_application_name(value_in)
17
+ else
18
+ value_in
19
+ end
20
+ end
21
+
22
+ def autoaliases
23
+ @autoaliases =
24
+ secondaries.filter_map do |sec|
25
+ case sec.kind
26
+ when :exec, :app, :lib
27
+ sec.name.alias_for(sec.name.kind)
28
+ end
29
+ end.flatten
30
+ end
31
+
32
+ # Deduplicates name filters after configured and saved lists are merged.
33
+ # @param value_in [Array<String, Regexp>, nil] merged source name filters
34
+ # @return [Array<String, Regexp>] first filter for each canonical string form
35
+ # Regexp objects retain their matching behavior; only the comparison key is
36
+ # converted to a string. A missing list produces an empty array.
37
+ def _name_filters value_in
38
+ Array(value_in).uniq(&:to_s)
39
+ end
40
+
41
+ def _ruby_alias_names value_in
42
+ @ruby_alias_names ||= (value_in || []) | build_alias_groups.map {|aliases| expanded_alias_group(aliases) }
43
+ end
44
+
45
+ def build_alias_groups
46
+ ruby_build.reduce([]) do |result, line|
47
+ case line
48
+ when /--use=(.*)/
49
+ result << [::Regexp.last_match(1)]
50
+ when /--alias=(.*)/
51
+ result.last << ::Regexp.last_match(1)
52
+ end
53
+
54
+ result
55
+ end
56
+ end
57
+
58
+ def expanded_alias_group aliases
59
+ additions = [aliased_names, [autoaliases]].map {|group| group.reject {|names| (names & aliases).blank? }}
60
+
61
+ aliases | additions.flatten!
62
+ end
63
+
64
+ def _ruby_alias_names_local value_in
65
+ return @ruby_alias_names_local if @ruby_alias_names_local
66
+
67
+ names = local_alias_names.compact.tap(&:uniq!)
68
+
69
+ @ruby_alias_names_local = value_in | (names.size > 1 && [names] || [])
70
+ end
71
+
72
+ def local_alias_names
73
+ if source.is_a?(Baltix::Source::Gem)
74
+ [source&.name, name&.name, name.alias_map['app']].flatten
75
+ else
76
+ [source&.name, name&.fullname]
77
+ end
78
+ end
79
+ end