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,16 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/dependency'
2
4
  require 'tempfile'
3
5
  require 'date'
4
6
 
5
7
  require 'baltix/source/base'
8
+ require 'baltix/spec/rpm/arch'
6
9
  require 'baltix/loader'
10
+ require 'baltix/rake'
7
11
  require 'baltix/loader/yaml'
8
12
  require 'baltix/loader/pom'
9
13
  require 'baltix/loader/rookbook'
10
14
  require 'baltix/loader/cmake'
11
15
  require 'baltix/loader/mast'
16
+ require 'baltix/loader/extconf'
12
17
  require 'baltix/loader/git-version-gen'
13
18
 
19
+ # Combines gemspec metadata with Gemfile requirements and packaged files.
14
20
  class Baltix::Source::Gem < Baltix::Source::Base
15
21
  extend ::Baltix::Loader
16
22
  extend ::Baltix::Loader::Yaml
@@ -18,164 +24,64 @@ class Baltix::Source::Gem < Baltix::Source::Base
18
24
  extend ::Baltix::Loader::Mast
19
25
  extend ::Baltix::Loader::Rookbook
20
26
  extend ::Baltix::Loader::Cmake
27
+ extend ::Baltix::Loader::Extconf
21
28
  extend ::Baltix::Loader::GitVersionGen
22
29
 
23
30
  TYPE = 'Gem::Specification'
24
- BIN_IGNORES = %w(test)
25
- OPTION_KEYS = %i(source_file source_names gemspec spec version replace_list aliases alias_names)
31
+ BIN_IGNORES = %w[test].freeze
32
+ OPTION_KEYS = %i[source_file source_names gemspec spec version replace_list aliases alias_names loader].freeze
26
33
 
27
34
  EXE_DIRS = ->(s) { s.spec.bindir || s.exedir || nil }
28
- EXT_DIRS = ->(s) do
29
- s.spec.extensions.map do |file|
30
- File.dirname(file)
31
- end.uniq
32
- end
33
- LIB_DIRS = ->(s) { s.require_pure_paths }
34
- DOCSRC_DIRS = ->(s) { s.require_pure_paths }
35
+ EXT_DIRS =
36
+ lambda do |s|
37
+ s.spec.extensions.map {|file| File.dirname(file) }.tap(&:uniq!)
38
+ end
39
+ LIB_DIRS = lambda(&:require_pure_paths)
40
+ DOCSRC_DIRS = lambda(&:require_pure_paths)
35
41
 
36
42
  INC_FILTER = ->(s, f, dir) { s.spec.files.include?(File.join(dir, f)) }
37
43
 
38
- OPTIONS_IN = {
39
- spec: true,
40
- }
41
-
42
- LOADERS = {
43
- /\/pom.xml$/ => :pom,
44
- /\/(cmake|CMakeLists.txt)$/ => :cmake,
45
- /\/Rookbook.props$/ => :rookbook,
46
- /\/GIT-VERSION-GEN$/ => :git_version_gen,
47
- /\/(MANIFEST|Manifest.txt)$/ => :manifest,
48
- /\/(#{Rake::Application::DEFAULT_RAKEFILES.join("|")})$/i => :app_file,
49
- /\.gemspec$/i => [:app_file, :yaml],
50
- }
51
-
52
- attr_reader :gem_version_replace
53
-
54
- Gem.load_yaml
55
-
56
- class << self
57
- def load spec_in
58
- Kernel.yaml_load(spec_in)
59
- end
60
-
61
- def spec_for options_in = {}
62
- spec_in = options_in["spec"]
63
- spec = spec_in.is_a?(String) && load(spec_in) || spec_in
64
- version =
65
- if options_in[:version_replaces] && options_in[:version_replaces][spec.name]
66
- options_in[:version_replaces][spec.name]
67
- elsif options_in[:gem_version_replace] && !options_in[:gem_version_replace].empty?
68
- prever = options_in[:gem_version_replace].find {|(n,v)| n == spec.name }&.last
69
- /([=><]+\s*)?(?<version>.*)/ =~ prever
70
- version
71
- end
72
-
73
- if version
74
- spec.version = Gem::Version.new(version)
44
+ # Documentation follows the gem's packaged file list. Root entries include
45
+ # explicit extra_rdoc_files and packaged native Ruby extension sources.
46
+ DOCSRC_FILTER =
47
+ lambda do |source, file, directory|
48
+ if directory == '.'
49
+ source.spec.extra_rdoc_files.include?(file) || source.packaged_native_documentation_file?(file)
50
+ else
51
+ source.spec.files.include?(File.join(directory, file))
75
52
  end
76
- spec.require_paths = options_in["source-lib-folders"] if options_in["source-lib-folders"]
77
-
78
- spec
79
53
  end
80
54
 
81
- def name_for options_in = {}
82
- spec_for(options_in).name
83
- end
84
-
85
- def search dir, options_in = {}
86
- files = Dir.glob("#{dir}/**/*", File::FNM_DOTMATCH).select {|f| File.file?(f) }.map do |f|
87
- LOADERS.reduce(nil) { |res, (re, _method_name)| res || re =~ f && [re, f] || nil }
88
- end.compact.sort do |x,y|
89
- c = LOADERS.keys.index(x.first) <=> LOADERS.keys.index(y.first)
55
+ OPTIONS_IN = {
56
+ spec: true
57
+ }.freeze
90
58
 
91
- c == 0 && x.last <=> y.last || c
92
- end
59
+ LOADERS = {
60
+ %r{/pom.xml$} => :pom,
61
+ %r{/(CMakeLists.txt)$} => :cmake,
62
+ %r{/Rookbook.props$} => :rookbook,
63
+ %r{/GIT-VERSION-GEN$} => :git_version_gen,
64
+ %r{/(MANIFEST|Manifest.txt)$} => :manifest,
65
+ %r{/(#{Rake::Application::DEFAULT_RAKEFILES.join('|')})$}i => :app_file,
66
+ %r{/extconf.rb$}i => :ext_file,
67
+ /\.gemspec$/i => %i[app_file yaml]
68
+ }.freeze
93
69
 
94
- debug("Found source file list: " + files.map {|(_, x)| x }.join("\n\t"))
95
-
96
- specs = files.reduce({}) do |res, (re, f)|
97
- load_result =
98
- [LOADERS[re]].flatten.reduce(nil) do |res, method_name|
99
- next res if res
100
-
101
- result = send(method_name, f)
102
-
103
- result && result.objects.any? && [result, method_name]
104
- end
105
-
106
- if load_result
107
- gemspecs = load_result.first.objects.reject do |s|
108
- s.loaded_from && s.loaded_from !~ /#{dir}/
109
- end.each {|x| x.loaded_from = f }.compact
110
- debug("load messages:\n\t" + load_result.first.log.join("\n\t")) if !load_result.first.log.blank?
111
- debug("Load errors:\n\t" + load_result.errlog.join("\n\t")) if !load_result.first.errlog.blank?
112
-
113
- res.merge({ f => { gemspecs: gemspecs, loader: load_result.last }})
114
- else
115
- res
116
- end
117
- end.map do |(f, data)|
118
- gemspecs = data[:gemspecs]
119
- gemspecs.map do |gemspec|
120
- self.new(source_options(options_in.merge(spec: gemspec, source_file: f, loader: data[:loader])))
121
- end
122
- end.flatten.compact
123
- end
124
- end
70
+ attr_reader :gem_version_replace
125
71
 
126
72
  def gemfile
127
73
  @gemfile ||= Baltix::Source::Gemfile.new({
128
74
  source_file: gemfile_name && File.join(rootdir, gemfile_name) || dsl.fake_gemfile_path,
129
75
  gem_version_replace: gem_version_replace,
130
- gem_skip_list: [],# dsl.deps.map(&:name) | [name],
131
- gem_append_list: [ self.dep ]}.to_os)
76
+ gem_skip_list: [], # dsl.deps.map(&:name) | [name],
77
+ gem_append_list: [dep]
78
+ }.to_os)
132
79
  end
133
80
 
134
81
  def gemfile_name
135
82
  source_names.find {|x| x =~ /gemfile/i }
136
83
  end
137
84
 
138
- def dep
139
- Bundler::Dependency.new("#{name}", Gem::Requirement.new(["~> #{version}"]), options: { type: :runtime })
140
- end
141
-
142
- def fullname
143
- [ name, version ].compact.join('-')
144
- end
145
-
146
- def original_spec
147
- return @original_spec if @original_spec.is_a?(Gem::Specification)
148
-
149
- @original_spec =
150
- if @original_spec.is_a?(String)
151
- YAML.load(@original_spec)
152
- else
153
- self.class.spec_for(options)
154
- end
155
- end
156
-
157
- def spec
158
- return @spec if @spec
159
-
160
- if aliases.any?
161
- @spec ||= aliases.reduce(original_spec) { |spec, als|
162
- spec.merge(als.original_spec) }
163
- else
164
- original_spec
165
- end
166
- end
167
-
168
- def name
169
- spec.name
170
- end
171
-
172
- def version
173
- version = spec&.version&.to_s || "0"
174
- parts = version.split(".")
175
-
176
- (parts[0..2] + (parts[3..-1]&.map {|x| x.to_i <= 1024 && x || nil}&.compact || [])).join(".")
177
- end
178
-
179
85
  def gemspec_path
180
86
  if @gemspec_file ||= Tempfile.create('gemspec.')
181
87
  @gemspec_file.puts(dsl.to_ruby)
@@ -186,191 +92,43 @@ class Baltix::Source::Gem < Baltix::Source::Base
186
92
  end
187
93
 
188
94
  def gemfile_path
189
- if gemfile.dsl.valid?
190
- if @gemfile_file ||= Tempfile.create('Gemfile.')
191
- @gemfile_file.puts(gemfile.dsl.to_gemfile)
192
- @gemfile_file.rewind
193
- end
95
+ return unless gemfile.dsl.valid?
194
96
 
195
- @gemfile_path ||= @gemfile_file.path
97
+ if @gemfile_file ||= Tempfile.create('Gemfile.')
98
+ @gemfile_file.puts(gemfile.dsl.to_gemfile)
99
+ @gemfile_file.rewind
196
100
  end
197
- end
198
101
 
199
- # tree
200
- def datatree
201
- # TODO deep_merge
202
- @datatree ||= super { { '.' => spec.files } }
203
- end
204
-
205
- def allfiles
206
- @allfiles = (
207
- spec.require_paths.map {|x| File.absolute_path?(x) && x || File.join(x, '**', '*') }.map {|x| Dir[x] }.flatten |
208
- spec.executables.map {|x| Dir[File.join(spec.bindir, x)] }.flatten |
209
- spec.files
210
- )
211
- end
212
-
213
- def allfiles_for list_in
214
- list_in.map do |(key, list)|
215
- [key, list & allfiles.map {|x| /^#{key}\/(?<rest>.*)/.match(x)&.[](:rest) }.compact ]
216
- end.to_h
217
- end
218
-
219
- def exttree
220
- @exttree ||= super
221
- end
222
-
223
- def testtree
224
- @testtree ||= allfiles_for(super)
225
- end
226
-
227
- def exetree
228
- @exetree ||= super { Dir.chdir(rootdir) do
229
- exedirs.map { |dir| [ dir, Dir.chdir(File.join(rootdir, dir)) { Dir.glob("{#{spec.executables.join(',')}}") } ] }.to_h
230
- end }
231
- end
232
-
233
- def docsrctree
234
- @docsrctree ||= super { { '.' => spec.extra_rdoc_files } }
235
- end
236
-
237
- def docs
238
- # TODO make docs to docdir with lib/.rb replace to .ri
239
- #require 'pry';binding.ry
240
- (!spec.rdoc_options.blank? && [ default_ridir ] || files(:lib)) | spec.extra_rdoc_files
102
+ @gemfile_path ||= @gemfile_file.path
241
103
  end
242
104
 
243
105
  # custom
244
106
 
245
- def extroot_for file
246
- extroots.find { |extroot| extroot == file[0...extroot.size] }
247
- end
248
-
249
107
  # Queries
250
108
 
251
- # +valid?+ returns state of validity of the gem: true or false
252
- # Returns true when all the conditiona are true:
253
- # * gem's name of the gem is set
254
- # * gem's name is not a system's one (has zero char)
255
- # * gem's version is present
256
- # * gem's platform is "ruby" or current one
257
- #
258
- def valid?
259
- !name.nil? &&
260
- spec.version &&
261
- (platform == 'ruby' || platform == Gem::Platform::CURRENT) &&
262
- spec.name !~ /\u0000/
263
- end
264
-
265
- def platform
266
- spec.platform
267
- end
268
-
269
- def compilable?
270
- compilables.any?
271
- end
272
-
273
- def compilables
274
- extfiles | spec.extensions
275
- end
276
-
277
109
  def to_h
278
- # TODO !ruby/array:Files strangely appeared during building the securecompare gem, what leads to exceptions on load
279
- super.merge(spec: spec.to_yaml.gsub(/!ruby\/array:Files/, ""))
280
- end
281
-
282
- def required_ruby_version
283
- spec&.required_ruby_version || super
284
- end
285
-
286
- def required_rubygems_version
287
- spec&.required_rubygems_version || super
288
- end
289
-
290
- def deps groups = nil
291
- spec&.dependencies&.select { |dep| !groups || [ groups ].flatten.include?(dep.type) }
292
- end
293
-
294
- def require_pure_paths
295
- @require_pure_paths ||= (
296
- paths = spec.require_paths.select { |path| path !~ /^\// }
297
- paths.any? && paths || ['lib'])
110
+ super.merge('spec' => spec)
298
111
  end
299
112
 
300
113
  def rake
301
- @rake ||= Baltix::Rake.new(File.join(rootdir, Dir["{#{Rake::Application::DEFAULT_RAKEFILES.join(",")}}"].first))
302
- end
303
-
304
- # Default group
305
- def group
306
- "Development/Ruby"
307
- end
308
-
309
- def summaries
310
- localize(spec.summary) || aliased {|s| s.localize(s.summary) } || descriptions
311
- end
312
-
313
- def descriptions
314
- localize(spec.description) || aliased {|s| localize(s.description) }
315
- end
316
-
317
- def aliased_locks
318
- @aliased_locks ||= {}
319
- end
320
-
321
- def aliased &block
322
- aliases.reduce(nil) {|res, a| res || a != self && block[a] }
323
- end
324
-
325
- def localize text
326
- text && OpenStruct.new(Baltix::I18n.default_locale => text)
327
- end
328
-
329
- # Default prefix "gem" for gem names
330
- def name_prefix
331
- "gem"
332
- end
333
-
334
- def uri
335
- spec.homepage || spec.metadata["homepage_uri"] || aliased_uri
336
- end
337
-
338
- def vcs
339
- spec.metadata&.[]("source_code_uri")
340
- end
341
-
342
- def dependencies type = nil
343
- (dsl.dependencies(type) | deps).group_by {|x| x.name }.reduce([]) do |res, (_name, deps)|
344
- dep =
345
- deps.reduce do |r, dep|
346
- Gem::Dependency.new(r.name, r.requirement.merge(dep.requirement), [r.type, dep.type].max)
347
- end
348
-
349
- !type || dep.type == type ? res | [dep] : res
350
- end
351
- end
352
-
353
- def provide
354
- spec.version && Gem::Dependency.new(spec.name, Gem::Requirement.new(["= #{spec.version}"]), :runtime) || Gem::Dependency.new(spec.name)
355
- end
356
-
357
- def licenses
358
- spec.licenses
114
+ @rake ||=
115
+ Baltix::Rake.new(File.join(rootdir, Dir["{#{Rake::Application::DEFAULT_RAKEFILES.join(',')}}"].first))
359
116
  end
360
117
 
361
118
  protected
362
119
 
363
120
  def detect_root
364
121
  if spec
365
- files = Dir['**/**/**']
366
- (!spec.files.any? || (spec.files - files).any?) && super || Dir.pwd
122
+ files = Dir['**/**/**']
123
+
124
+ (spec.files.none? || (spec.files - files).any?) && super || Dir.pwd
367
125
  else
368
126
  super
369
127
  end
370
128
  end
371
129
 
372
130
  def extroots
373
- @extroots ||= extfiles.map { |extfile| File.dirname(extfile) }
131
+ @extroots ||= extfiles.map {|extfile| File.dirname(extfile) }
374
132
  end
375
133
 
376
134
  def exedir
@@ -385,23 +143,18 @@ class Baltix::Source::Gem < Baltix::Source::Base
385
143
 
386
144
  gemfile
387
145
  end
146
+ end
388
147
 
389
- def with_lock &block
390
- if !aliased_locks[name]
391
- aliased_locks[name] = true
392
- block[]
393
- aliased_locks[name] = false
394
- end
395
- end
148
+ require 'baltix/source/gem/discovery'
396
149
 
397
- def method_missing name, *args
398
- if /^aliased_(?<method>.*)/ =~ name
399
- with_lock { aliased {|a| a.send(method, *args) } }
400
- elsif spec.respond_to?(name)
401
- spec.send(name, *args)
402
- else
403
- super
404
- end
405
- rescue NoMethodError
406
- end
407
- end
150
+ require 'baltix/source/gem/specification'
151
+
152
+ require 'baltix/source/gem/metadata'
153
+
154
+ require 'baltix/source/gem/dependencies'
155
+
156
+ require 'baltix/source/gem/file_trees'
157
+
158
+ require 'baltix/source/gem/forwarding'
159
+
160
+ require 'baltix/source/gem/delegation'
@@ -1,35 +1,85 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'baltix/dsl'
2
4
  require 'baltix/source/base'
3
5
 
6
+ # Represents applications and collections described by a Gemfile.
4
7
  class Baltix::Source::Gemfile < Baltix::Source::Base
5
8
  class << self
6
9
  def search dir, options_in = {}
7
- Dir.glob("#{dir}/**/Gemfile", File::FNM_DOTMATCH).select {|f| File.file?(f) }.map do |f|
8
- self.new(source_options({ source_file: f, loader: :gemfile }.to_os.merge(options_in)))
10
+ Dir.glob("#{dir}/**/Gemfile", File::FNM_DOTMATCH).filter_map do |f|
11
+ next unless File.file?(f)
12
+
13
+ new(source_options({ source_file: f, loader: :gemfile }.to_os.merge(options_in)))
9
14
  end
10
15
  end
11
16
  end
12
17
 
13
18
  def gemfile_path
14
19
  gemspec_file = Tempfile.create('Gemfile.')
20
+
15
21
  gemspec_file.puts(dsl.to_gemfile)
16
22
  gemspec_file.rewind
23
+
17
24
  gemspec_file.path
18
25
  end
19
26
 
20
27
  def dsl
21
28
  @dsl ||=
22
29
  Baltix::DSL.new(source_file,
23
- replace_list: replace_list,
24
- skip_list: (options[:gem_skip_list] || []) | [self.name],
25
- append_list: options[:gem_append_list])
30
+ replace_list: replace_list,
31
+ dependency_platforms: (@dependency_platforms ||= {}),
32
+ skip_platforms: @skip_platforms || [],
33
+ skip_list: (options[:gem_skip_list] || []) | [name],
34
+ append_list: options[:gem_append_list])
26
35
  end
27
36
 
28
37
  def valid?
29
38
  dsl.valid?
30
39
  end
31
40
 
41
+ # Supplies the repository README title for a project rooted at a Gemfile.
42
+ # Takes no parameters.
43
+ # @return [OpenStruct] summaries indexed by locale, empty without a readable title
44
+ def summaries
45
+ repository_metadata_source.summaries
46
+ end
47
+
48
+ # Supplies the repository prose for a project whose root metadata is a Gemfile.
49
+ # Takes no parameters.
50
+ # @return [OpenStruct] descriptions indexed by locale, empty without readable prose
51
+ def descriptions
52
+ repository_metadata_source.descriptions
53
+ end
54
+
55
+ # Supplies the configured repository homepage for a Gemfile project.
56
+ # Takes no parameters.
57
+ # @return [String, nil] repository homepage, or nil without a supported Git origin
58
+ def uri
59
+ repository_metadata_source.uri
60
+ end
61
+
62
+ # Supplies the configured repository origin for a Gemfile project.
63
+ # Takes no parameters.
64
+ # @return [String, nil] repository URL, or nil without a supported Git origin
65
+ def vcs
66
+ repository_metadata_source.vcs
67
+ end
68
+
32
69
  def rake
33
70
  @rake ||= Baltix::Rake.new(source_file)
34
71
  end
72
+
73
+ def docs
74
+ docsrcfiles
75
+ end
76
+
77
+ protected
78
+
79
+ # Reuses the synthetic-source reader for metadata at this repository root.
80
+ # Takes no parameters.
81
+ # @return [Baltix::Source::Fake] cached reader for the same directory
82
+ def repository_metadata_source
83
+ @repository_metadata_source ||= Baltix::Source::Fake.new(source_file: File.join(rootdir, '.fake'))
84
+ end
35
85
  end
@@ -1,11 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'baltix/source/base'
2
4
  require 'baltix/rake'
3
5
 
6
+ # Represents metadata captured from a project Rakefile.
4
7
  class Baltix::Source::Rakefile < Baltix::Source::Base
5
8
  class << self
6
9
  def search dir, options_in = {}
7
- Dir.glob("#{dir}/**/Rakefile", File::FNM_DOTMATCH).select {|f| File.file?(f) }.map do |f|
8
- self.new(source_options({ source_file: f, loader: :rakefile }.to_os.merge(options_in)))
10
+ Dir.glob("#{dir}/**/Rakefile", File::FNM_DOTMATCH).filter_map do |f|
11
+ next unless File.file?(f)
12
+
13
+ new(source_options({ source_file: f, loader: :rakefile }.to_os.merge(options_in)))
9
14
  end
10
15
  end
11
16
  end
@@ -13,9 +18,11 @@ class Baltix::Source::Rakefile < Baltix::Source::Base
13
18
  def dsl
14
19
  @dsl ||=
15
20
  Baltix::DSL.new(source_file,
16
- replace_list: replace_list,
17
- skip_list: (options[:gem_skip_list] || []) | [self.name],
18
- append_list: options[:gem_append_list])
21
+ replace_list: replace_list,
22
+ dependency_platforms: (@dependency_platforms ||= {}),
23
+ skip_platforms: @skip_platforms || [],
24
+ skip_list: (options[:gem_skip_list] || []) | [name],
25
+ append_list: options[:gem_append_list])
19
26
  end
20
27
 
21
28
  def rake
data/lib/baltix/source.rb CHANGED
@@ -1,10 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'baltix'
2
4
 
5
+ # Discovers and combines supported Ruby project metadata sources.
3
6
  module ::Baltix::Source
4
7
  attr_reader :rootdir
5
8
 
6
9
  TYPES =
7
- %w(Gem Gemfile Rakefile Fake Base).reduce({}) do |types, name|
10
+ %w[Gem Gemfile Rakefile Fake Base].reduce({}) do |types, name|
8
11
  autoload(:"#{name}", File.dirname(__FILE__) + "/source/#{name.downcase}")
9
12
  types.merge(name.downcase.to_sym => "Baltix::Source::#{name}")
10
13
  end
@@ -12,32 +15,41 @@ module ::Baltix::Source
12
15
  class << self
13
16
  def search_in dir_in, options = {}
14
17
  dir = File.expand_path(dir_in)
15
- sources_pre =
16
- TYPES.map do |(name, const)|
17
- kls = self.const_get(const)
18
- kls.respond_to?(:search) && kls.search(dir, options) || []
19
- end.flatten | [ self::Fake.new({ source_file: File.join(dir, '.fake') }.to_os) ]
20
-
21
- sources_pre.group_by do |source|
22
- source.rootdir
23
- end.map do |_a, sources_in|
24
- ina = sources_in.select {|s| TYPES.keys[-1] == s.class.to_s.split("::").last.downcase.to_sym }
25
-
26
- TYPES.keys.reverse[1..-1].reduce(ina) do |res, kind|
27
- selected =
28
- sources_in.select do |s|
29
- TYPES.keys[TYPES.keys.index(kind)] == s.class.to_s.split("::").last.downcase.to_sym
30
- end
31
-
32
- selected.any? && selected.map {|v| ([v] | res).reduce(&:+) } || res
18
+ sources = source_candidates(dir, options)
19
+
20
+ sources.group_by(&:rootdir).values.flat_map {|group| merge_source_group(group) }
21
+ end
22
+
23
+ def source_candidates dir, options
24
+ candidates =
25
+ TYPES.values.map do |constant|
26
+ klass = const_get(constant)
27
+
28
+ klass.respond_to?(:search) && klass.search(dir, options.dup) || []
33
29
  end
34
- end.flatten
30
+
31
+ candidates.flatten | [self::Fake.new({ source_file: File.join(dir, '.fake') }.to_os)]
32
+ end
33
+
34
+ def merge_source_group sources
35
+ fallback = sources_of_kind(sources, TYPES.keys.last)
36
+
37
+ TYPES.keys.reverse.drop(1).reduce(fallback) do |previous, kind|
38
+ selected = sources_of_kind(sources, kind)
39
+
40
+ selected.any? ? selected.map {|source| ([source] | previous).reduce(:+) } : previous
41
+ end
42
+ end
43
+
44
+ def sources_of_kind sources, kind
45
+ sources.select {|source| kind == source.class.to_s.split('::').last.downcase.to_sym }
35
46
  end
36
47
 
37
48
  def load_from sources_in
38
- [ sources_in ].flatten.compact.map do |source_in|
39
- type_code_in = source_in["type"].to_s.to_sym
40
- type_code = TYPES.keys.include?(type_code_in) && type_code_in || :fake
49
+ [sources_in].flatten.tap(&:compact!).map! do |source_in|
50
+ type_code_in = source_in['type'].to_s.to_sym
51
+ type_code = TYPES.key?(type_code_in) && type_code_in || :fake
52
+
41
53
  require("baltix/source/#{type_code}")
42
54
  TYPES[type_code].constantize.new(source_in)
43
55
  end
@@ -51,7 +63,7 @@ module ::Baltix::Source
51
63
  else
52
64
  type
53
65
  end
54
- end.flatten.uniq
66
+ end.tap(&:flatten!).tap(&:uniq!)
55
67
  end
56
68
  end
57
69
  end