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.
- checksums.yaml +4 -4
- data/Gemfile +4 -2
- data/README.md +136 -10
- data/Rakefile +8 -3
- data/baltix.gemspec +47 -29
- data/bin/console +4 -3
- data/data/alt-licenses/README.md +26 -0
- data/data/alt-licenses/licenses.json +2991 -0
- data/data/alt-rpm/README.md +21 -0
- data/data/alt-rpm/architectures.json +613 -0
- data/data/spdx/README.md +22 -0
- data/data/spdx/licenses.json +9287 -0
- data/docs/action-flow.md +42 -0
- data/docs/actor-integration.md +71 -0
- data/docs/alt-architectures.md +27 -0
- data/docs/cleanup-actors.md +14 -0
- data/docs/dependency-actions.md +22 -0
- data/docs/installation-actors.md +35 -0
- data/docs/pkglist.md +56 -0
- data/docs/plans/revision-003.md +328 -0
- data/docs/plans/revision-004.md +416 -0
- data/docs/plans/revision-005.md +431 -0
- data/docs/plans/revision-006.md +439 -0
- data/docs/plans/revision-007.md +441 -0
- data/docs/plans/revision-008.md +445 -0
- data/docs/plans/revision-009.md +450 -0
- data/docs/plans/revision-010.md +486 -0
- data/docs/plans/revision-011.md +500 -0
- data/docs/plans/revision-012.md +501 -0
- data/docs/plans/revision-013.md +501 -0
- data/docs/plans/revision-014.md +501 -0
- data/docs/plans/revision-015.md +502 -0
- data/docs/plans/revision-016.md +503 -0
- data/docs/plans/revision-017.md +504 -0
- data/docs/plans/revision-018.md +505 -0
- data/docs/plans/revision-019.md +510 -0
- data/docs/plans/revision-020.md +524 -0
- data/docs/plans/revision-021.md +542 -0
- data/docs/plans/revision-022.md +542 -0
- data/docs/plans/revision-023.md +545 -0
- data/docs/plans/revision-024.md +567 -0
- data/docs/plans/revision-025.md +583 -0
- data/docs/plans/revision-026.md +241 -0
- data/docs/plans/revision-027.md +305 -0
- data/docs/plans/revision-028.md +298 -0
- data/docs/plans/revision-029.md +288 -0
- data/docs/rpm-action-macros.md +52 -0
- data/docs/rpm-parts.md +53 -0
- data/docs/ruby-dependencies.md +217 -0
- data/docs/ruby-policy-2.1.md +28 -0
- data/docs/ruby-versioning.md +61 -0
- data/docs/space-format.md +58 -0
- data/exe/baltix +1 -0
- data/lib/baltix/action_flow/files.rb +49 -0
- data/lib/baltix/action_flow/inputs.rb +60 -0
- data/lib/baltix/action_flow/journal.rb +60 -0
- data/lib/baltix/action_flow/options.rb +60 -0
- data/lib/baltix/action_flow.rb +65 -0
- data/lib/baltix/actor/build/collect.rb +72 -0
- data/lib/baltix/actor/build/compile.rb +25 -0
- data/lib/baltix/actor/build/extconf.rb +14 -0
- data/lib/baltix/actor/build/make.rb +18 -0
- data/lib/baltix/actor/build/postprocess.rb +14 -0
- data/lib/baltix/actor/build/rake.rb +18 -0
- data/lib/baltix/actor/build/ronn.rb +55 -0
- data/lib/baltix/actor/build.rb +87 -0
- data/lib/baltix/actor/clean/remove.rb +45 -0
- data/lib/baltix/actor/clean.rb +37 -0
- data/lib/baltix/actor/config.rb +12 -0
- data/lib/baltix/actor/copy.rb +22 -7
- data/lib/baltix/actor/distclean.rb +20 -0
- data/lib/baltix/actor/doc/collect.rb +39 -0
- data/lib/baltix/actor/doc/generate.rb +47 -0
- data/lib/baltix/actor/doc/inputs.rb +25 -0
- data/lib/baltix/actor/doc.rb +70 -0
- data/lib/baltix/actor/gen.rb +19 -0
- data/lib/baltix/actor/install/data.rb +18 -0
- data/lib/baltix/actor/install/documentation.rb +48 -0
- data/lib/baltix/actor/install/executable.rb +27 -0
- data/lib/baltix/actor/install/extension.rb +44 -0
- data/lib/baltix/actor/install/headers.rb +10 -0
- data/lib/baltix/actor/install/library.rb +13 -0
- data/lib/baltix/actor/install/metadata.rb +21 -0
- data/lib/baltix/actor/install/paths.rb +73 -0
- data/lib/baltix/actor/install/plugin.rb +25 -0
- data/lib/baltix/actor/install/record.rb +48 -0
- data/lib/baltix/actor/install/shebang.rb +29 -0
- data/lib/baltix/actor/install/transfer.rb +64 -0
- data/lib/baltix/actor/install/trees.rb +34 -0
- data/lib/baltix/actor/install.rb +71 -0
- data/lib/baltix/actor/link.rb +15 -6
- data/lib/baltix/actor/make.rb +14 -0
- data/lib/baltix/actor/predeps/write.rb +51 -0
- data/lib/baltix/actor/predeps.rb +41 -0
- data/lib/baltix/actor/provides.rb +12 -0
- data/lib/baltix/actor/requires.rb +12 -0
- data/lib/baltix/actor/show.rb +26 -0
- data/lib/baltix/actor/spec.rb +6 -3
- data/lib/baltix/actor/test/record.rb +8 -0
- data/lib/baltix/actor/test/run.rb +30 -0
- data/lib/baltix/actor/test/select.rb +16 -0
- data/lib/baltix/actor/test.rb +41 -0
- data/lib/baltix/actor/touch.rb +14 -5
- data/lib/baltix/actor.rb +43 -26
- data/lib/baltix/cli/dependency_options.rb +63 -0
- data/lib/baltix/cli/options/action.rb +32 -0
- data/lib/baltix/cli/options.rb +280 -0
- data/lib/baltix/cli/output_options.rb +56 -0
- data/lib/baltix/cli/rake_tasks.rb +59 -0
- data/lib/baltix/cli/source_options.rb +52 -0
- data/lib/baltix/cli.rb +130 -116
- data/lib/baltix/concerns/command.rb +52 -0
- data/lib/baltix/concerns/configuration.rb +39 -0
- data/lib/baltix/concerns/dependency_output.rb +21 -0
- data/lib/baltix/concerns/extension_metadata.rb +44 -0
- data/lib/baltix/concerns/file_destination.rb +14 -0
- data/lib/baltix/concerns/inspection.rb +27 -0
- data/lib/baltix/concerns/parts.rb +16 -0
- data/lib/baltix/concerns/target_paths.rb +57 -0
- data/lib/baltix/concerns.rb +11 -0
- data/lib/baltix/core_extensions/gem_dependency.rb +24 -0
- data/lib/baltix/core_extensions/gem_requirement.rb +45 -0
- data/lib/baltix/core_extensions/open_struct_merge.rb +62 -0
- data/lib/baltix/deps/executables.rb +30 -0
- data/lib/baltix/deps/packages.rb +32 -0
- data/lib/baltix/deps.rb +103 -194
- data/lib/baltix/dsl/dependency_groups.rb +77 -0
- data/lib/baltix/dsl/dependency_sources.rb +100 -0
- data/lib/baltix/dsl/filtering.rb +26 -0
- data/lib/baltix/dsl/loading.rb +72 -0
- data/lib/baltix/dsl/merging.rb +74 -0
- data/lib/baltix/dsl/rendering.rb +54 -0
- data/lib/baltix/dsl/requirements.rb +77 -0
- data/lib/baltix/dsl/temporary_files.rb +36 -0
- data/lib/baltix/dsl.rb +66 -273
- data/lib/baltix/executable_dependencies/features.rb +53 -0
- data/lib/baltix/executable_dependencies/library.rb +21 -0
- data/lib/baltix/executable_dependencies/library_features.rb +34 -0
- data/lib/baltix/executable_dependencies/syntax.rb +102 -0
- data/lib/baltix/executable_dependencies.rb +102 -0
- data/lib/baltix/extensions/bones.rb +173 -0
- data/lib/baltix/extensions/echoe.rb +143 -0
- data/lib/baltix/extensions/hoe/metadata.rb +89 -0
- data/lib/baltix/extensions/hoe/options.rb +84 -0
- data/lib/baltix/extensions/hoe/readme.rb +29 -0
- data/lib/baltix/extensions/hoe.rb +146 -0
- data/lib/baltix/extensions/jeweler.rb +95 -0
- data/lib/baltix/extensions/levitate.rb +74 -0
- data/lib/baltix/extensions/olddoc.rb +42 -0
- data/lib/baltix/extensions.rb +340 -419
- data/lib/baltix/i18n.rb +22 -19
- data/lib/baltix/license/catalog/capture.rb +58 -0
- data/lib/baltix/license/catalog.rb +75 -0
- data/lib/baltix/license.rb +76 -0
- data/lib/baltix/loader/capture.rb +91 -0
- data/lib/baltix/loader/cmake.rb +6 -3
- data/lib/baltix/loader/evaluation.rb +49 -0
- data/lib/baltix/loader/extconf.rb +27 -0
- data/lib/baltix/loader/feature_loading.rb +54 -0
- data/lib/baltix/loader/git-version-gen.rb +36 -21
- data/lib/baltix/loader/mast/properties.rb +58 -0
- data/lib/baltix/loader/mast.rb +97 -109
- data/lib/baltix/loader/object_capture.rb +27 -0
- data/lib/baltix/loader/olddoc.gemspec.erb +31 -0
- data/lib/baltix/loader/pom.rb +36 -16
- data/lib/baltix/loader/rookbook.rb +19 -14
- data/lib/baltix/loader/yaml.rb +9 -5
- data/lib/baltix/loader.rb +85 -132
- data/lib/baltix/log.rb +26 -27
- data/lib/baltix/rake/metadata_adapter.rb +30 -0
- data/lib/baltix/rake/task_context.rb +59 -0
- data/lib/baltix/rake/task_libraries.rb +73 -0
- data/lib/baltix/rake.rb +62 -12
- data/lib/baltix/source/base/dependencies.rb +81 -0
- data/lib/baltix/source/base/file_queries.rb +67 -0
- data/lib/baltix/source/base/file_tree.rb +70 -0
- data/lib/baltix/source/base/metadata.rb +140 -0
- data/lib/baltix/source/base/options.rb +71 -0
- data/lib/baltix/source/base/roots.rb +53 -0
- data/lib/baltix/source/base.rb +95 -377
- data/lib/baltix/source/fake.rb +89 -5
- data/lib/baltix/source/gem/delegation.rb +32 -0
- data/lib/baltix/source/gem/dependencies.rb +69 -0
- data/lib/baltix/source/gem/discovery.rb +72 -0
- data/lib/baltix/source/gem/file_trees.rb +114 -0
- data/lib/baltix/source/gem/forwarding.rb +12 -0
- data/lib/baltix/source/gem/metadata.rb +104 -0
- data/lib/baltix/source/gem/specification.rb +65 -0
- data/lib/baltix/source/gem.rb +65 -312
- data/lib/baltix/source/gemfile.rb +55 -5
- data/lib/baltix/source/rakefile.rb +12 -5
- data/lib/baltix/source.rb +36 -24
- data/lib/baltix/space/configuration.rb +54 -0
- data/lib/baltix/space/data/collections.rb +33 -0
- data/lib/baltix/space/data/gem_metadata.rb +79 -0
- data/lib/baltix/space/data/models.rb +20 -0
- data/lib/baltix/space/data/values.rb +72 -0
- data/lib/baltix/space/data.rb +53 -0
- data/lib/baltix/space/dependencies.rb +53 -0
- data/lib/baltix/space/filters.rb +96 -0
- data/lib/baltix/space/initialization.rb +124 -0
- data/lib/baltix/space/metadata.rb +130 -0
- data/lib/baltix/space/source_order.rb +43 -0
- data/lib/baltix/space/source_selection.rb +136 -0
- data/lib/baltix/space/source_status.rb +114 -0
- data/lib/baltix/space/spec.rb +3 -0
- data/lib/baltix/space.rb +87 -367
- data/lib/baltix/spec/rpm/aliases.rb +79 -0
- data/lib/baltix/spec/rpm/arch.rb +119 -0
- data/lib/baltix/spec/rpm/available_overrides.rb +106 -0
- data/lib/baltix/spec/rpm/build_dependencies.rb +132 -0
- data/lib/baltix/spec/rpm/build_queries.rb +61 -0
- data/lib/baltix/spec/rpm/changelog.rb +115 -0
- data/lib/baltix/spec/rpm/dependency_overrides.rb +83 -0
- data/lib/baltix/spec/rpm/dependency_policy.rb +69 -0
- data/lib/baltix/spec/rpm/deps.rb +113 -0
- data/lib/baltix/spec/rpm/env/requirements.rb +20 -0
- data/lib/baltix/spec/rpm/env.rb +76 -0
- data/lib/baltix/spec/rpm/executable_packages.rb +49 -0
- data/lib/baltix/spec/rpm/file_manifest.rb +72 -0
- data/lib/baltix/spec/rpm/guard_compilation.rb +95 -0
- data/lib/baltix/spec/rpm/imported_secondaries.rb +26 -0
- data/lib/baltix/spec/rpm/layout.rb +14 -0
- data/lib/baltix/spec/rpm/manpages.rb +71 -0
- data/lib/baltix/spec/rpm/metadata.rb +78 -0
- data/lib/baltix/spec/rpm/name/equality.rb +68 -0
- data/lib/baltix/spec/rpm/name/formatting.rb +33 -0
- data/lib/baltix/spec/rpm/name/parsing.rb +58 -0
- data/lib/baltix/spec/rpm/name.rb +77 -108
- data/lib/baltix/spec/rpm/packaged_versions.rb +107 -0
- data/lib/baltix/spec/rpm/parser/comments.rb +35 -0
- data/lib/baltix/spec/rpm/parser/context.rb +50 -0
- data/lib/baltix/spec/rpm/parser/dependencies.rb +91 -0
- data/lib/baltix/spec/rpm/parser/file_sections.rb +68 -0
- data/lib/baltix/spec/rpm/parser/flow.rb +84 -0
- data/lib/baltix/spec/rpm/parser/header_dependencies.rb +36 -0
- data/lib/baltix/spec/rpm/parser/macros.rb +43 -0
- data/lib/baltix/spec/rpm/parser/metadata.rb +106 -0
- data/lib/baltix/spec/rpm/parser/sections.rb +88 -0
- data/lib/baltix/spec/rpm/parser/values.rb +85 -0
- data/lib/baltix/spec/rpm/parser.rb +124 -269
- data/lib/baltix/spec/rpm/part_files.rb +64 -0
- data/lib/baltix/spec/rpm/part_prelude.rb +43 -0
- data/lib/baltix/spec/rpm/part_scripts.rb +52 -0
- data/lib/baltix/spec/rpm/part_switches.rb +65 -0
- data/lib/baltix/spec/rpm/pkglist/header.rb +73 -0
- data/lib/baltix/spec/rpm/pkglist/provides.rb +57 -0
- data/lib/baltix/spec/rpm/pkglist.rb +116 -0
- data/lib/baltix/spec/rpm/preparation.rb +73 -0
- data/lib/baltix/spec/rpm/rendering.rb +66 -0
- data/lib/baltix/spec/rpm/repository_application.rb +33 -0
- data/lib/baltix/spec/rpm/revision.rb +58 -0
- data/lib/baltix/spec/rpm/root_source.rb +48 -0
- data/lib/baltix/spec/rpm/scripts.rb +85 -0
- data/lib/baltix/spec/rpm/secondaries.rb +82 -0
- data/lib/baltix/spec/rpm/secondary.rb +117 -64
- data/lib/baltix/spec/rpm/secondary_parts.rb +84 -0
- data/lib/baltix/spec/rpm/section_document.rb +84 -0
- data/lib/baltix/spec/rpm/section_guards.rb +116 -0
- data/lib/baltix/spec/rpm/source_selection.rb +82 -0
- data/lib/baltix/spec/rpm/spec_core/architecture.rb +28 -0
- data/lib/baltix/spec/rpm/spec_core/attributes.rb +89 -0
- data/lib/baltix/spec/rpm/spec_core/availability.rb +60 -0
- data/lib/baltix/spec/rpm/spec_core/dependency_rendering.rb +83 -0
- data/lib/baltix/spec/rpm/spec_core/descriptions.rb +77 -0
- data/lib/baltix/spec/rpm/spec_core/documentation.rb +48 -0
- data/lib/baltix/spec/rpm/spec_core/executable_names.rb +37 -0
- data/lib/baltix/spec/rpm/spec_core/host_names.rb +60 -0
- data/lib/baltix/spec/rpm/spec_core/interpreters.rb +103 -0
- data/lib/baltix/spec/rpm/spec_core/names.rb +80 -0
- data/lib/baltix/spec/rpm/spec_core/obsoletes.rb +38 -0
- data/lib/baltix/spec/rpm/spec_core/package_dependencies.rb +74 -0
- data/lib/baltix/spec/rpm/spec_core/plain_dependencies.rb +60 -0
- data/lib/baltix/spec/rpm/spec_core/pre_name.rb +23 -0
- data/lib/baltix/spec/rpm/spec_core/provides.rb +104 -0
- data/lib/baltix/spec/rpm/spec_core/readme.rb +78 -0
- data/lib/baltix/spec/rpm/spec_core/registration.rb +18 -0
- data/lib/baltix/spec/rpm/spec_core/runtime_dependencies.rb +81 -0
- data/lib/baltix/spec/rpm/spec_core/summaries.rb +64 -0
- data/lib/baltix/spec/rpm/spec_core/text_wrapping.rb +36 -0
- data/lib/baltix/spec/rpm/spec_core/versioning.rb +75 -0
- data/lib/baltix/spec/rpm/spec_core/versions.rb +94 -0
- data/lib/baltix/spec/rpm/spec_core.rb +75 -527
- data/lib/baltix/spec/{rpm.erb → rpm/template.erb} +131 -31
- data/lib/baltix/spec/rpm.rb +253 -644
- data/lib/baltix/spec.rb +16 -14
- data/lib/baltix/target/gem.rb +61 -0
- data/lib/baltix/target/site.rb +40 -0
- data/lib/baltix/target.rb +16 -0
- data/lib/baltix/version.rb +3 -1
- data/lib/baltix.rb +77 -5
- data/locale/en_US.UTF-8.yaml +4 -1
- data/locale/ru_RU.UTF-8.yaml +7 -1
- data/rpm/baltix.env +4 -0
- data/rpm/baltix.prov +8 -0
- data/rpm/baltix.prov.files +6 -0
- data/rpm/baltix.req +8 -0
- data/rpm/baltix.req.files +6 -0
- data/rpm/macros.baltix +24 -0
- data/utils/rubocop/compact_block_braces.rb +39 -0
- data/utils/rubocop/spacing.rb +96 -0
- data/utils/update_alt_architectures.rb +57 -0
- data/utils/update_alt_licenses.rb +19 -0
- data/utils/update_spdx_licenses.rb +21 -0
- metadata +526 -17
- data/.github/workflows/ci.yml +0 -44
- data/.gitignore +0 -10
- data/TODO +0 -84
data/lib/baltix/source/gem.rb
CHANGED
|
@@ -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
|
|
25
|
-
OPTION_KEYS = %i
|
|
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 =
|
|
29
|
-
|
|
30
|
-
File.dirname(file)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
92
|
-
|
|
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
|
-
|
|
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: []
|
|
131
|
-
gem_append_list: [
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 ||=
|
|
302
|
-
|
|
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
|
-
|
|
366
|
-
|
|
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 {
|
|
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
|
-
|
|
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
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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).
|
|
8
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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).
|
|
8
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
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
|
-
[
|
|
39
|
-
type_code_in = source_in[
|
|
40
|
-
type_code = TYPES.
|
|
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
|