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
@@ -1,33 +1,41 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'baltix/source'
2
4
  require 'baltix/log'
3
5
 
6
+ # Collects common source metadata, dependency views and file trees.
4
7
  class Baltix::Source::Base
5
8
  extend ::Baltix::Log
6
9
 
7
- OPTION_KEYS = %i(source_file source_names replace_list aliases alias_names)
10
+ OPTION_KEYS = %i[source_file source_names replace_list aliases alias_names loader].freeze
11
+ TREE_CACHE_SUFFIXES = %w[tree files].freeze
12
+ TREE_VIEWS = %i[files tree].freeze
13
+ DEFAULT_FILES = %i[readme contrib history changelog license copying code_of_conduct].freeze
14
+ README_FILE_RE = /\Areadme(?:\.(?:md|markdown|rdoc|txt|rst|adoc|asciidoc|textile))?\z/i
8
15
 
9
16
  DL_DIRS = ->(s) { ".so.#{s.name}#{RbConfig::CONFIG['sitearchdir']}" }
10
- RI_DIRS = ->(s) { [ s.default_ridir, 'ri' ] }
11
- INC_DIRS = %w(ext)
12
- EXT_DIRS = %w(ext)
13
- LIB_DIRS = %w(lib)
14
- APP_DIRS = %w(app webpack script public)
15
- EXE_DIRS = %w(bin exe)
16
- CONF_DIRS = %w(etc config conf)
17
- TEST_DIRS = %w(tests test spec features acceptance autotest)
18
- MAN_DIRS = %w(doc docs Documentation man docs-source)
19
- SUP_DIRS = %w(util yardoc benchmarks examples .git vendor sample)
20
- LOG_DIRS = %w(log)
21
- DATA_DIRS = %w(.)
22
- STATE_DIRS = %w(tmp)
17
+ RI_DIRS = ->(s) { [s.default_ridir, 'ri'] }
18
+ INC_DIRS = %w[ext].freeze
19
+ EXT_DIRS = %w[ext].freeze
20
+ LIB_DIRS = %w[lib].freeze
21
+ APP_DIRS = %w[app webpack script public].freeze
22
+ EXE_DIRS = %w[bin exe].freeze
23
+ CONF_DIRS = %w[etc config conf].freeze
24
+ TEST_DIRS = %w[tests test spec features acceptance autotest].freeze
25
+ MAN_DIRS = %w[doc docs Documentation man docs-source].freeze
26
+ SUP_DIRS = %w[util yardoc benchmarks examples .git vendor sample].freeze
27
+ LOG_DIRS = %w[log].freeze
28
+ DATA_DIRS = %w[.].freeze
29
+ STATE_DIRS = %w[tmp].freeze
23
30
  DOCSRC_DIRS = ->(s) { s.libdirs | s.appdirs | s.exedirs | s.confdirs }
24
31
 
25
32
  DL_RE = ->(_) { /\.(#{RbConfig::CONFIG['DLEXT']}|build_complete)$/ }
26
33
  RI_RE = /\.ri$/
27
34
  INC_RE = /\.(h|hpp)$/
28
- MAN_RE = /\.[1-8](.ronn)?$/
35
+ MAN_RE = /\.[1-8](?:\.ronn)?\z/
29
36
  EXT_RE = /\b(.*\.rb|rakefile(\.rb)?)$/i
30
- DATA_RE = ->(s) do
37
+ DATA_RE =
38
+ lambda do |s|
31
39
  dirs = s.extdirs | s.libdirs | s.appdirs | s.exedirs |
32
40
  s.confdirs | s.testdirs | s.mandirs | s.supdirs |
33
41
  s.ridirs | s.dldirs | s.incdirs | s.logdirs | s.statedirs
@@ -36,394 +44,90 @@ class Baltix::Source::Base
36
44
  end
37
45
  DOCSRC_RE = /\.rb$/
38
46
 
39
- GROUPS = constants.select { |c| c =~ /_DIRS/ }.map { |c| c.to_s.sub('_DIRS', '').downcase }
47
+ GROUPS = constants.grep(/_DIRS/).map {|c| c.to_s.sub('_DIRS', '').downcase }
40
48
 
41
49
  OPTIONS_IN = {
42
- aliases: ->(o, name) { o.is_a?(Hash) && [ o[nil], o[name], o.values.map {|x|x.flatten}.select {|x|x.include?(name)}.map {|x|x.first}.flatten ].flatten.compact.uniq || o },
43
- alias_names: ->(o, name) { o.is_a?(Hash) && [ o[nil], o[name], o.values.map {|x|x.flatten}.select {|x|x.include?(name)}.map {|x|x.first}.flatten ].flatten.compact.uniq || o },
50
+ source_rootdir: true,
51
+ dsl: true,
52
+ aliases: ->(value, name) { alias_option_value(value, name) },
53
+ alias_names: ->(value, name) { alias_option_value(value, name) },
54
+ replace_list: true,
44
55
  version_replaces: true,
45
56
  gem_version_replace: true,
46
- source_file: ->(file, _name) { file.is_a?(String) && File.file?(file) && file || nil },
57
+ skip_platforms: true,
58
+ target_arch: true,
59
+ source_file: ->(file, _name) { file.is_a?(String) ? file : nil },
47
60
  loader: true,
48
61
  gemspec: true,
49
62
  source_names: true,
50
63
  name: true,
51
64
  version: true,
52
- "source-ri-folder-lists": :name_or_default,
53
- "source-inc-folder-lists": :name_or_default,
54
- "source-ext-folder-lists": :name_or_default,
55
- "source-lib-folder-lists": :name_or_default,
56
- "source-app-folder-lists": :name_or_default,
57
- "source-exe-folder-lists": :name_or_default,
58
- "source-conf-folder-lists": :name_or_default,
59
- "source-test-folder-lists": :name_or_default,
60
- "source-man-folder-lists": :name_or_default,
61
- "source-sup-folder-lists": :name_or_default,
62
- "source-data-folder-lists": :name_or_default,
63
- "source-docsrc-folder-lists": :name_or_default,
64
- "source-log-folder-lists": :name_or_default,
65
- "source-state-folder-lists": :name_or_default,
66
- "source-ri-folders": true,
67
- "source-inc-folders": true,
68
- "source-ext-folders": true,
69
- "source-lib-folders": true,
70
- "source-app-folders": true,
71
- "source-exe-folders": true,
72
- "source-conf-folders": true,
73
- "source-test-folders": true,
74
- "source-man-folders": true,
75
- "source-sup-folders": true,
76
- "source-data-folders": true,
77
- "source-docsrc-folders": true,
78
- "source-log-folders": true,
79
- "source-state-folders": true,
80
- }
81
-
82
- attr_reader :options, :source_file, :loader
65
+ 'source-ri-folder-lists': :name_or_default,
66
+ 'source-inc-folder-lists': :name_or_default,
67
+ 'source-ext-folder-lists': :name_or_default,
68
+ 'source-lib-folder-lists': :name_or_default,
69
+ 'source-app-folder-lists': :name_or_default,
70
+ 'source-exe-folder-lists': :name_or_default,
71
+ 'source-conf-folder-lists': :name_or_default,
72
+ 'source-test-folder-lists': :name_or_default,
73
+ 'source-man-folder-lists': :name_or_default,
74
+ 'source-sup-folder-lists': :name_or_default,
75
+ 'source-data-folder-lists': :name_or_default,
76
+ 'source-docsrc-folder-lists': :name_or_default,
77
+ 'source-log-folder-lists': :name_or_default,
78
+ 'source-state-folder-lists': :name_or_default,
79
+ 'source-ri-folders': true,
80
+ 'source-inc-folders': true,
81
+ 'source-ext-folders': true,
82
+ 'source-lib-folders': true,
83
+ 'source-app-folders': true,
84
+ 'source-exe-folders': true,
85
+ 'source-conf-folders': true,
86
+ 'source-test-folders': true,
87
+ 'source-man-folders': true,
88
+ 'source-sup-folders': true,
89
+ 'source-data-folders': true,
90
+ 'source-docsrc-folders': true,
91
+ 'source-log-folders': true,
92
+ 'source-state-folders': true
93
+ }.freeze
94
+
95
+ attr_reader :source_file, :loader
83
96
  attr_writer :replace_list, :source_names
84
97
 
85
- class << self
86
- def opts
87
- @opts ||= ancestors.reverse.map do |a|
88
- a.constants.include?(:OPTIONS_IN) &&
89
- a.const_get(:OPTIONS_IN).to_a ||
90
- nil
91
- end.compact.flatten(1).to_os
92
- end
93
-
94
- def name_for options_in
95
- fullname = (options_in[:rootdir] || "").split('/').last
96
- /^(?<name>.*)-([\d\.]+)$/ =~ fullname
97
- name || fullname
98
- end
99
-
100
- def source_options options_in = {}.to_os
101
- source_name = name_for(options_in)
102
-
103
- opts.map do |name_in, rule|
104
- value_in = options_in[name_in.to_s]
105
-
106
- name, value = case rule
107
- when true
108
- [name_in, value_in]
109
- when Proc
110
- [name_in, rule[value_in, source_name] ]
111
- when Symbol
112
- method(rule)[value_in, name_in, source_name]
113
- else
114
- nil
115
- end
116
-
117
- value
118
- end.compact.to_os
119
- end
120
-
121
- def name_or_default value_in, name, source_name
122
- value = value_in && (value_in[source_name] || value_in[nil]) || nil
123
-
124
- value && [ name.make_singular, value ] || nil
125
- end
126
-
127
- def rootdir_or_default value_in, name, _
128
- [ name, value_in || Dir.pwd ]
129
- end
98
+ # Updates platform hints shared with this source's dependency DSL.
99
+ # @param platforms [Hash<String, Array<Gem::Platform>>] inferred platforms by dependency name
100
+ # @return [Hash<String, Array<Gem::Platform>>] the updated platform hints
101
+ def dependency_platforms= platforms
102
+ (@dependency_platforms ||= {}).replace(platforms)
130
103
  end
131
104
 
132
105
  def options
133
106
  @options ||= {}
134
107
  end
135
108
 
136
- # +fullname+ returns full name of the source, by default it is the name of the current folder,
137
- # if it is the root folder the name is "root".
138
- # A mixin can redefine the method to return the proper value
139
- #
140
- # source.name #=> "source_name"
141
- #
142
- def fullname
143
- @fullname ||= rootdir.split('/').last || "root"
144
- end
145
-
146
- # +name+ returns dynamically detected name of the source base on the fullname,
147
- # in case the fullname is detected in a format of <name-version>, the <name> is returned,
148
- # otherwise the full name is returned itself.
149
- # A mixin can redefine the method to return the proper value
150
- #
151
- # source.name #=> "source_name"
152
- #
153
- def name
154
- return @name if @name
155
-
156
- if /^(?<name>.*)-([\d\.]+)$/ =~ fullname
157
- name
158
- else
159
- fullname || rootdir.split("/").last || "root"
160
- end
161
- end
162
-
163
- # +version+ returns version of the source by default it is the daystamp for today,
164
- # A subslass can redefine the method to return the proper value
165
- #
166
- # source.version #=> "20000101"
167
- # source.version #=> "2.1.0"
168
- #
169
- def version
170
- return @version if @version
171
-
172
- if /-(?<version>[\d\.]+)$/ =~ fullname
173
- version
174
- end
175
- end
176
-
177
- # ruby platform is default for non-gem sources
178
- def platform
179
- 'ruby'
180
- end
181
-
182
- def rootdir
183
- @rootdir ||= detect_root
184
- end
185
-
186
- def source_names
187
- @source_names ||= options[:source_names] || source_file && [File.basename(source_file)] || []
188
- end
189
-
190
- def dsl
191
- @dsl ||= options[:dsl] ||
192
- Baltix::DSL.new(source_file,
193
- spec: spec,
194
- replace_list: replace_list,
195
- skip_list: (options[:gem_skip_list] || []) | [name],
196
- append_list: options[:gem_append_list])
197
- end
198
-
199
- def replace_list
200
- @gem_version_replace ||= {}
201
- end
202
-
203
- def alias_names
204
- @alias_names ||= options[:alias_names] || []
205
- end
206
-
207
- # dirs
208
- #
209
- GROUPS.each do |kind|
210
- func = <<-DEF
211
- def #{kind}dirs &block
212
- @#{kind}dirs ||= dirs(:#{kind}, options[:src#{kind}dirs], &block)
213
- end
214
- DEF
215
-
216
- eval(func)
217
- end
218
-
219
- # files
220
- #
221
- GROUPS.each do |kind|
222
- func = <<-DEF
223
- def #{kind}files &block
224
- @#{kind}files ||= files(:#{kind}, &block)
225
- end
226
- DEF
227
-
228
- eval(func)
229
- end
230
-
231
- # tree
232
- #
109
+ # Cache directory, file and tree views without evaluating generated Ruby.
233
110
  GROUPS.each do |kind|
234
- func = <<-DEF
235
- def #{kind}tree &block
236
- @#{kind}tree ||= tree(:#{kind}, &block)
237
- end
238
- DEF
239
-
240
- eval(func)
241
- end
242
-
243
- # questionaries
244
-
245
- def valid?
246
- false
247
- end
248
-
249
- def compilable?
250
- extfiles.any?
251
- end
252
-
253
- def to_os
254
- options.merge(type: type, source_names: source_names)
255
- end
256
-
257
- def type
258
- self.class.to_s.split('::').last.downcase
259
- end
260
-
261
- def required_ruby
262
- dsl.required_ruby
263
- end
264
-
265
- def required_ruby_version
266
- dsl.required_ruby_version
267
- end
111
+ define_method("#{kind}dirs") do |&block|
112
+ variable = :"@#{kind}dirs"
268
113
 
269
- def required_rubygems_version
270
- dsl.required_rubygems_version
271
- end
272
-
273
- def definition
274
- dsl.definition
275
- end
276
-
277
- def deps groups_in = nil
278
- dsl.deps_for(groups_in)
279
- end
280
-
281
- def has_name? name
282
- self.name == name || alias_names.include?(name)
283
- end
284
-
285
- def if_file file
286
- File.file?(File.join(rootdir, file)) && file || nil
287
- end
288
-
289
- def if_exist file
290
- File.exist?(File.join(rootdir, file)) && file || nil
291
- end
292
-
293
- def if_dir dir
294
- File.directory?(File.join(rootdir, dir)) && dir || nil
295
- end
296
-
297
- def default_ridir
298
- ".ri.#{name}"
299
- end
300
-
301
- def trees &block
302
- GROUPS.map do |set|
303
- yield(set, send("#{set}tree"))
114
+ instance_variable_get(variable) ||
115
+ instance_variable_set(variable, dirs(kind, options[:"src#{kind}dirs"], &block))
304
116
  end
305
- end
306
-
307
- def compilables
308
- # TODO make compilables from ext
309
- extfiles
310
- end
311
-
312
- def provide
313
- Gem::Dependency.new(name, "= #{version || "0"}")
314
- end
315
-
316
- # +summaries+ returns an open-struct formatted summaries with a default locale as a key
317
- # in the spec defined if any, otherwise returns blank open struct.
318
- #
319
- # source.summaries # => #<OpenStruct en_US.UTF-8: ...>
320
- #
321
- def summaries
322
- if spec&.summary
323
- { Baltix::I18n.default_locale => spec&.summary }.to_os
324
- else
325
- {}.to_os
326
- end
327
- end
328
-
329
- def dependencies *types
330
- if definition
331
- definition.dependencies.select {|dep| types.empty? || types.include?(dep.type) }
332
- else
333
- []
334
- end
335
- end
336
-
337
- def development_dependencies
338
- Baltix::DSL.merge_dependencies(*Baltix::DSL.filter_dependencies(:development, definition.dependencies, spec.dependencies))
339
- end
340
-
341
- def licenses
342
- []
343
- end
344
-
345
- def + other
346
- self.replace_list = replace_list.merge(other.replace_list)
347
- self.source_names = source_names | other.source_names
348
- self.dsl.merge_in(other.dsl)
349
117
 
350
- self
351
- end
352
-
353
- def aliases
354
- @aliases ||= []
355
- end
356
-
357
- def alias_to *sources
358
- @aliases = aliases | sources.flatten
359
- end
118
+ TREE_VIEWS.each do |view|
119
+ define_method("#{kind}#{view}") do |&block|
120
+ variable = :"@#{kind}#{view}"
360
121
 
361
- # rebases source_file to path base and returns.
362
- def source_path_from path
363
- file =
364
- if source_file.include?(path)
365
- source_file[path.size + 1..-1]
366
- else
367
- source_file
122
+ instance_variable_get(variable) || instance_variable_set(variable, send(view, kind, &block))
368
123
  end
369
-
370
- File.dirname(file)
371
- end
372
-
373
- protected
374
-
375
- def exedir
376
- @exedir ||= if_exist('exe')
377
- end
378
-
379
- def dirs kind, dirs_in = nil, &block
380
- dirlist_am = [
381
- dirs_in,
382
- options[:"src#{kind}dirs"],
383
- self.class.const_get("#{kind.upcase}_DIRS")
384
- ].compact.first
385
-
386
- [ dirlist_am ].flatten.map do |dir_am|
387
- file = dir_am.is_a?(Proc) ? dir_am[self] : dir_am
388
- end.flatten.compact.select { |file| if_dir(file) }
389
- end
390
-
391
- def tree kind, &block
392
- re_in = self.class.const_get("#{kind.upcase}_RE") rescue nil
393
- prc = self.class.const_get("#{kind.upcase}_FILTER") rescue nil
394
- re = re_in.is_a?(Proc) && re_in[self] || re_in || /.*/
395
-
396
- tree_in = send("#{kind}dirs").map do |dir|
397
- [ dir, Dir.chdir(File.join(rootdir, dir)) { Dir.glob('**/**/*') } ]
398
- end.to_h
399
-
400
- if block_given?
401
- # TODO deep_merge
402
- tree_in = tree_in.merge(yield)
403
124
  end
404
-
405
- tree_in.map do |dir, files_in|
406
- files = Dir.chdir(File.join(rootdir, dir)) do
407
- files_in.select do |file|
408
- re =~ file && File.file?(file) && (!prc || prc[self, file, dir])
409
- end
410
- end
411
-
412
- # require 'pry';binding.pry if kind == :exe
413
-
414
- [ dir, files ]
415
- end.to_h
416
125
  end
417
126
 
418
- def detect_root
419
- source_file && File.dirname(source_file) || Dir.pwd
420
- end
127
+ # questionaries
421
128
 
422
- def files kind, &block
423
- send("#{kind}tree", &block).map { |(_, values)| values }.flatten
424
- end
129
+ protected
425
130
 
426
- #
427
131
  def initialize options_in = {}
428
132
  parse(options_in)
429
133
 
@@ -431,8 +135,22 @@ class Baltix::Source::Base
431
135
  end
432
136
 
433
137
  def parse options_in
434
- self.class.source_options(options_in).each do |option, value|
138
+ @options = self.class.source_options(options_in).to_h
139
+
140
+ @options.each do |option, value|
435
141
  instance_variable_set(:"@#{option}", value)
436
142
  end
437
143
  end
438
144
  end
145
+
146
+ require 'baltix/source/base/options'
147
+
148
+ require 'baltix/source/base/roots'
149
+
150
+ require 'baltix/source/base/file_tree'
151
+
152
+ require 'baltix/source/base/file_queries'
153
+
154
+ require 'baltix/source/base/dependencies'
155
+
156
+ require 'baltix/source/base/metadata'
@@ -1,17 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+
5
+ # Supplies repository metadata when no explicit metadata exists.
1
6
  class Baltix::Source::Fake < Baltix::Source::Base
2
7
  OPTIONS_IN = {
3
8
  source_file: true,
4
- }
9
+ valid: ->(value_in, _source_name) { value_in.nil? || value_in }
10
+ }.freeze
5
11
 
6
12
  def dsl
7
13
  @dsl ||=
8
14
  Baltix::DSL.new(source_file,
9
- replace_list: replace_list,
10
- skip_list: (options[:gem_skip_list] || []) | [self.name],
11
- append_list: options[:gem_append_list])
15
+ replace_list: replace_list,
16
+ skip_list: (options[:gem_skip_list] || []) | [name],
17
+ append_list: options[:gem_append_list])
18
+ end
19
+
20
+ def to_h
21
+ super.merge('valid' => valid? || false)
12
22
  end
13
23
 
14
24
  def valid?
15
- true
25
+ @valid
26
+ end
27
+
28
+ def build_tool_dependencies
29
+ []
30
+ end
31
+
32
+ # Supplies the repository title for a synthetic package without gem metadata.
33
+ # @return [OpenStruct] default-locale summary, or an empty struct without a title
34
+ def summaries
35
+ title = repository_metadata.first
36
+
37
+ title ? { Baltix::I18n.default_locale => title }.to_os : {}.to_os
38
+ end
39
+
40
+ # Supplies repository prose without borrowing a child gem's description.
41
+ # @return [OpenStruct] default-locale description, falling back to the summary
42
+ def descriptions
43
+ description = repository_metadata.last || summaries[Baltix::I18n.default_locale]
44
+
45
+ description ? { Baltix::I18n.default_locale => description }.to_os : {}.to_os
46
+ end
47
+
48
+ # Reads the configured origin without executing project code or a shell.
49
+ # @return [String, nil] HTTP(S) repository URL, or nil for missing/unsupported origins
50
+ # SSH GitHub-style origins are converted to HTTPS; other non-HTTP schemes are ignored.
51
+ def vcs
52
+ return @repository_vcs if defined?(@repository_vcs)
53
+ return @repository_vcs = nil unless source_file && File.exist?(File.join(rootdir, '.git'))
54
+
55
+ output, status = Open3.capture2e('git', '-C', rootdir, 'config', '--get', 'remote.origin.url')
56
+ url = status.success? ? output.strip : ''
57
+ url = url.sub(/\Agit@([^:]+):/, 'https://\1/')
58
+ @repository_vcs = url.match?(%r{\Ahttps?://[^\s]+\z}) ? url : nil
59
+ rescue Errno::ENOENT
60
+ @repository_vcs = nil
61
+ end
62
+
63
+ # Derives the repository homepage from an explicitly configured Git origin.
64
+ # @return [String, nil] homepage without the .git suffix, or nil if origin is unknown
65
+ def uri
66
+ vcs&.delete_suffix('.git')
67
+ end
68
+
69
+ # Reads a README title and its first prose paragraph for synthetic root metadata.
70
+ # @return [Array<String, nil>] title and description, or nil entries without readable prose
71
+ # Supported README names share the RPM documentation whitelist. Leading badges,
72
+ # blank lines and headings are skipped; lists/code blocks never become descriptions.
73
+ # An unreadable or absent README leaves parsed/caller-supplied metadata in charge.
74
+ def repository_metadata
75
+ return @repository_metadata if defined?(@repository_metadata)
76
+
77
+ file = default_files.grep(README_FILE_RE).min if source_file
78
+
79
+ @repository_metadata = file ? read_repository_metadata(file) : [nil, nil]
80
+ rescue SystemCallError, EncodingError, ArgumentError
81
+ @repository_metadata = [nil, nil]
82
+ end
83
+
84
+ def read_repository_metadata file
85
+ text = File.read(File.join(rootdir, file), encoding: 'UTF-8')
86
+ heading = text.match(/^\#\s+([^\n]+)|^([^\n]+)\n={3,}\s*$/)
87
+ title = heading && (heading[1] || heading[2]).strip
88
+ body = heading ? text[heading.end(0)..] : text
89
+
90
+ [title, repository_paragraph(body)]
91
+ end
92
+
93
+ def repository_paragraph body
94
+ paragraph =
95
+ body.split(/\n\s*\n/).map(&:strip).find do |part|
96
+ !part.empty? && !part.match?(/\A(?:[\[!#<`*-]|\d+\.)/)
97
+ end
98
+
99
+ paragraph&.gsub(/\s*\n\s*/, ' ')
16
100
  end
17
101
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Implements optional metadata forwarding to aliases and RubyGems.
4
+ class Baltix::Source::Gem
5
+ protected
6
+
7
+ def with_lock &block
8
+ return if aliased_locks[name]
9
+
10
+ aliased_locks[name] = true
11
+
12
+ block[]
13
+
14
+ aliased_locks[name] = false
15
+ end
16
+
17
+ def respond_to_missing? name, include_private = false
18
+ name.to_s.start_with?('aliased_') || spec.respond_to?(name, include_private) || super
19
+ end
20
+
21
+ def method_missing name, *args
22
+ if /^aliased_(?<method>.*)/ =~ name
23
+ with_lock { aliased {|a| a.send(method, *args) }}
24
+ elsif spec.respond_to?(name)
25
+ spec.send(name, *args)
26
+ else
27
+ super
28
+ end
29
+ rescue NoMethodError
30
+ nil # An absent optional metadata value is allowed.
31
+ end
32
+ end