puppet 3.5.1-x86-mingw32 → 3.6.0.rc1-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of puppet might be problematic. Click here for more details.
- data/CONTRIBUTING.md +5 -0
- data/Gemfile +17 -9
- data/README.md +1 -0
- data/conf/fileserver.conf +4 -3
- data/ext/README.environment +8 -0
- data/ext/build_defaults.yaml +1 -1
- data/ext/debian/control +2 -2
- data/ext/debian/puppet-common.dirs +4 -0
- data/ext/debian/rules +4 -0
- data/ext/emacs/puppet-mode-init.el +1 -1
- data/ext/emacs/puppet-mode.el +36 -17
- data/ext/redhat/client.init +3 -3
- data/ext/redhat/puppet.spec.erb +9 -0
- data/ext/systemd/puppet.service +3 -4
- data/ext/systemd/puppetmaster.service +1 -3
- data/install.rb +1 -1
- data/lib/puppet.rb +2 -1
- data/lib/puppet/agent.rb +1 -1
- data/lib/puppet/application.rb +17 -17
- data/lib/puppet/application/doc.rb +1 -1
- data/lib/puppet/configurer.rb +4 -1
- data/lib/puppet/configurer/downloader.rb +13 -12
- data/lib/puppet/configurer/plugin_handler.rb +3 -3
- data/lib/puppet/context.rb +6 -1
- data/lib/puppet/defaults.rb +82 -12
- data/lib/puppet/environments.rb +169 -13
- data/lib/puppet/external/nagios/grammar.ry +2 -0
- data/lib/puppet/external/nagios/parser.rb +28 -19
- data/lib/puppet/face/config.rb +19 -6
- data/lib/puppet/face/module/generate.rb +209 -7
- data/lib/puppet/face/module/install.rb +17 -16
- data/lib/puppet/face/module/list.rb +83 -82
- data/lib/puppet/face/module/search.rb +1 -1
- data/lib/puppet/face/module/upgrade.rb +10 -9
- data/lib/puppet/face/parser.rb +3 -2
- data/lib/puppet/face/plugin.rb +8 -4
- data/lib/puppet/file_bucket/dipper.rb +6 -3
- data/lib/puppet/file_bucket/file.rb +4 -2
- data/lib/puppet/file_serving/metadata.rb +1 -1
- data/lib/puppet/file_system/memory_file.rb +27 -1
- data/lib/puppet/file_system/memory_impl.rb +15 -1
- data/lib/puppet/forge.rb +148 -52
- data/lib/puppet/forge/cache.rb +5 -1
- data/lib/puppet/forge/errors.rb +10 -0
- data/lib/puppet/forge/repository.rb +61 -26
- data/lib/puppet/functions.rb +548 -0
- data/lib/puppet/functions/assert_type.rb +42 -0
- data/lib/puppet/functions/import.rb +7 -0
- data/lib/puppet/indirector/facts/facter.rb +1 -1
- data/lib/puppet/indirector/file_bucket_file/file.rb +3 -2
- data/lib/puppet/indirector/rest.rb +18 -0
- data/lib/puppet/loaders.rb +20 -0
- data/lib/puppet/module.rb +2 -2
- data/lib/puppet/module_tool.rb +40 -14
- data/lib/puppet/module_tool/applications.rb +0 -1
- data/lib/puppet/module_tool/applications/application.rb +35 -26
- data/lib/puppet/module_tool/applications/builder.rb +16 -6
- data/lib/puppet/module_tool/applications/checksummer.rb +25 -19
- data/lib/puppet/module_tool/applications/installer.rb +196 -35
- data/lib/puppet/module_tool/applications/searcher.rb +1 -0
- data/lib/puppet/module_tool/applications/uninstaller.rb +7 -1
- data/lib/puppet/module_tool/applications/unpacker.rb +57 -31
- data/lib/puppet/module_tool/applications/upgrader.rb +221 -65
- data/lib/puppet/module_tool/checksums.rb +5 -8
- data/lib/puppet/module_tool/errors/installer.rb +12 -44
- data/lib/puppet/module_tool/errors/shared.rb +84 -11
- data/lib/puppet/module_tool/errors/upgrader.rb +16 -45
- data/lib/puppet/module_tool/install_directory.rb +7 -6
- data/lib/puppet/module_tool/installed_modules.rb +92 -0
- data/lib/puppet/module_tool/local_tarball.rb +91 -0
- data/lib/puppet/module_tool/metadata.rb +119 -115
- data/lib/puppet/module_tool/modulefile.rb +9 -9
- data/lib/puppet/module_tool/shared_behaviors.rb +19 -7
- data/lib/puppet/module_tool/skeleton/templates/generator/README.md.erb +79 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/Rakefile +18 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/metadata.json.erb +1 -0
- data/lib/puppet/module_tool/skeleton/templates/generator/spec/classes/init_spec.rb.erb +7 -0
- data/lib/puppet/module_tool/tar.rb +3 -7
- data/lib/puppet/module_tool/tar/gnu.rb +21 -9
- data/lib/puppet/module_tool/tar/mini.rb +2 -8
- data/lib/puppet/network/http/api/v1.rb +1 -1
- data/lib/puppet/network/http/api/v2/authorization.rb +4 -2
- data/lib/puppet/network/http/issues.rb +1 -0
- data/lib/puppet/network/http_pool.rb +15 -6
- data/lib/puppet/node/environment.rb +91 -20
- data/lib/puppet/parser/ast/pops_bridge.rb +44 -3
- data/lib/puppet/parser/collector.rb +1 -1
- data/lib/puppet/parser/compiler.rb +50 -7
- data/lib/puppet/parser/functions.rb +6 -0
- data/lib/puppet/parser/functions/generate.rb +1 -1
- data/lib/puppet/parser/resource.rb +1 -1
- data/lib/puppet/pops.rb +22 -1
- data/lib/puppet/pops/adapters.rb +8 -1
- data/lib/puppet/pops/binder/bindings_composer.rb +1 -1
- data/lib/puppet/pops/binder/bindings_factory.rb +1 -1
- data/lib/puppet/pops/binder/config/binder_config_checker.rb +1 -1
- data/lib/puppet/pops/binder/producers.rb +2 -2
- data/lib/puppet/pops/evaluator/access_operator.rb +65 -25
- data/lib/puppet/pops/evaluator/callable_signature.rb +101 -0
- data/lib/puppet/pops/evaluator/closure.rb +57 -2
- data/lib/puppet/pops/evaluator/compare_operator.rb +1 -1
- data/lib/puppet/pops/evaluator/evaluator_impl.rb +9 -11
- data/lib/puppet/pops/evaluator/runtime3_support.rb +72 -21
- data/lib/puppet/pops/functions/dispatch.rb +71 -0
- data/lib/puppet/pops/functions/dispatcher.rb +237 -0
- data/lib/puppet/pops/functions/function.rb +77 -0
- data/lib/puppet/pops/issues.rb +12 -0
- data/lib/puppet/pops/loader/base_loader.rb +102 -0
- data/lib/puppet/pops/loader/dependency_loader.rb +60 -0
- data/lib/puppet/pops/loader/gem_support.rb +49 -0
- data/lib/puppet/pops/loader/loader.rb +180 -0
- data/lib/puppet/pops/loader/loader_paths.rb +137 -0
- data/lib/puppet/pops/loader/module_loaders.rb +242 -0
- data/lib/puppet/pops/loader/null_loader.rb +44 -0
- data/lib/puppet/pops/loader/ruby_function_instantiator.rb +34 -0
- data/lib/puppet/pops/loader/ruby_legacy_function_instantiator.rb +109 -0
- data/lib/puppet/pops/loader/simple_environment_loader.rb +20 -0
- data/lib/puppet/pops/loader/static_loader.rb +69 -0
- data/lib/puppet/pops/loader/uri_helper.rb +22 -0
- data/lib/puppet/pops/loaders.rb +240 -0
- data/lib/puppet/pops/model/factory.rb +13 -5
- data/lib/puppet/pops/model/model_tree_dumper.rb +12 -4
- data/lib/puppet/pops/parser/egrammar.ra +31 -18
- data/lib/puppet/pops/parser/eparser.rb +1137 -1106
- data/lib/puppet/pops/parser/lexer2.rb +17 -16
- data/lib/puppet/pops/semantic_error.rb +17 -0
- data/lib/puppet/pops/types/type_calculator.rb +150 -15
- data/lib/puppet/pops/types/type_factory.rb +69 -0
- data/lib/puppet/pops/types/type_parser.rb +9 -0
- data/lib/puppet/pops/types/types.rb +65 -4
- data/lib/puppet/pops/validation/checker4_0.rb +1 -1
- data/lib/puppet/pops/validation/validator_factory_4_0.rb +1 -1
- data/lib/puppet/property/list.rb +1 -1
- data/lib/puppet/provider/augeas/augeas.rb +2 -2
- data/lib/puppet/provider/cron/crontab.rb +13 -2
- data/lib/puppet/provider/package.rb +24 -0
- data/lib/puppet/provider/package/apt.rb +6 -1
- data/lib/puppet/provider/package/gem.rb +8 -2
- data/lib/puppet/provider/package/msi.rb +0 -15
- data/lib/puppet/provider/package/openbsd.rb +0 -24
- data/lib/puppet/provider/package/rpm.rb +3 -29
- data/lib/puppet/provider/package/windows.rb +0 -15
- data/lib/puppet/provider/package/yum.rb +101 -24
- data/lib/puppet/provider/package/yumhelper.py +31 -1
- data/lib/puppet/provider/package/zypper.rb +10 -28
- data/lib/puppet/provider/service/debian.rb +1 -1
- data/lib/puppet/provider/service/init.rb +3 -0
- data/lib/puppet/provider/service/openbsd.rb +318 -0
- data/lib/puppet/provider/service/redhat.rb +6 -3
- data/lib/puppet/provider/service/systemd.rb +2 -2
- data/lib/puppet/provider/yumrepo/inifile.rb +115 -42
- data/lib/puppet/resource.rb +13 -9
- data/lib/puppet/resource/catalog.rb +12 -6
- data/lib/puppet/resource/type_collection.rb +3 -3
- data/lib/puppet/settings.rb +57 -36
- data/lib/puppet/settings/config_file.rb +5 -0
- data/lib/puppet/settings/environment_conf.rb +147 -0
- data/lib/puppet/settings/ttl_setting.rb +48 -0
- data/lib/puppet/ssl/certificate_authority.rb +2 -3
- data/lib/puppet/ssl/certificate_authority/autosign_command.rb +1 -1
- data/lib/puppet/ssl/certificate_request.rb +4 -4
- data/lib/puppet/ssl/validator/default_validator.rb +2 -2
- data/lib/puppet/status.rb +1 -1
- data/lib/puppet/test/test_helper.rb +1 -0
- data/lib/puppet/type/augeas.rb +13 -1
- data/lib/puppet/type/cron.rb +32 -18
- data/lib/puppet/type/file.rb +4 -2
- data/lib/puppet/type/file/checksum.rb +15 -5
- data/lib/puppet/type/file/content.rb +3 -1
- data/lib/puppet/type/file/source.rb +5 -5
- data/lib/puppet/type/package.rb +12 -17
- data/lib/puppet/type/resources.rb +3 -1
- data/lib/puppet/type/scheduled_task.rb +4 -5
- data/lib/puppet/type/service.rb +12 -2
- data/lib/puppet/type/user.rb +106 -0
- data/lib/puppet/type/yumrepo.rb +9 -1
- data/lib/puppet/util/checksums.rb +60 -1
- data/lib/puppet/util/diff.rb +3 -1
- data/lib/puppet/util/execution.rb +20 -16
- data/lib/puppet/util/feature.rb +3 -0
- data/lib/puppet/util/logging.rb +19 -12
- data/lib/puppet/util/rubygems.rb +10 -0
- data/lib/puppet/util/watched_file.rb +1 -1
- data/lib/puppet/util/windows/security.rb +5 -3
- data/lib/puppet/vendor/load_semantic.rb +1 -0
- data/lib/puppet/vendor/require_vendored.rb +2 -0
- data/lib/puppet/vendor/semantic/Gemfile +20 -0
- data/lib/puppet/vendor/semantic/Rakefile +69 -0
- data/lib/puppet/vendor/semantic/lib/semantic.rb +7 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency.rb +181 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph.rb +60 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/graph_node.rb +117 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/module_release.rb +46 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/source.rb +25 -0
- data/lib/puppet/vendor/semantic/lib/semantic/dependency/unsatisfiable_graph.rb +31 -0
- data/lib/puppet/vendor/semantic/lib/semantic/version.rb +168 -0
- data/lib/puppet/vendor/semantic/lib/semantic/version_range.rb +424 -0
- data/lib/puppet/vendor/semantic/spec/spec_helper.rb +24 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_node_spec.rb +141 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/graph_spec.rb +162 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/module_release_spec.rb +143 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/source_spec.rb +5 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency/unsatisfiable_graph_spec.rb +44 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/dependency_spec.rb +383 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/version_range_spec.rb +307 -0
- data/lib/puppet/vendor/semantic/spec/unit/semantic/version_spec.rb +608 -0
- data/lib/puppet/version.rb +1 -1
- data/spec/fixtures/java.tgz +0 -0
- data/spec/fixtures/stdlib.tgz +0 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/usee/lib/puppet/functions/usee/callee.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/lib/puppet/functions/user/caller.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/dependent_modules_with_metadata/user/metadata.json +9 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/modulea/rb_func_a.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/lib/puppet/functions/rb_func_a.rb +5 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/manifests/init.pp +3 -0
- data/spec/fixtures/unit/pops/loaders/loaders/single_module/modules/modulea/metadata.json +19 -0
- data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/lib/puppet/functions/moduleb/rb_func_b.rb +6 -0
- data/spec/fixtures/unit/pops/loaders/loaders/wo_metadata_module/modules/moduleb/manifests/init.pp +3 -0
- data/spec/fixtures/unit/provider/naginator/define_empty_param +6 -0
- data/spec/fixtures/unit/provider/service/systemd/list_unit_files_services +7 -0
- data/spec/fixtures/unit/type/user/authorized_keys +5 -0
- data/spec/integration/application/apply_spec.rb +1 -2
- data/spec/integration/configurer_spec.rb +2 -2
- data/spec/integration/faces/plugin_spec.rb +62 -0
- data/spec/integration/indirector/catalog/compiler_spec.rb +1 -1
- data/spec/integration/indirector/catalog/queue_spec.rb +1 -1
- data/spec/integration/node/environment_spec.rb +2 -2
- data/spec/integration/parser/future_compiler_spec.rb +96 -142
- data/spec/integration/parser/ruby_manifest_spec.rb +0 -5
- data/spec/integration/provider/cron/crontab_spec.rb +35 -0
- data/spec/integration/type/file_spec.rb +74 -72
- data/spec/integration/util/windows/security_spec.rb +17 -0
- data/spec/lib/matchers/resource.rb +45 -13
- data/spec/lib/puppet_spec/files.rb +18 -0
- data/spec/lib/puppet_spec/module_tool/shared_functions.rb +56 -0
- data/spec/lib/puppet_spec/module_tool/stub_source.rb +133 -0
- data/spec/shared_contexts/checksums.rb +55 -0
- data/spec/unit/application/apply_spec.rb +10 -7
- data/spec/unit/application/doc_spec.rb +17 -10
- data/spec/unit/application/indirection_base_spec.rb +18 -10
- data/spec/unit/application/inspect_spec.rb +22 -20
- data/spec/unit/configurer/downloader_spec.rb +7 -6
- data/spec/unit/configurer/plugin_handler_spec.rb +5 -8
- data/spec/unit/configurer_spec.rb +1 -1
- data/spec/unit/context_spec.rb +23 -0
- data/spec/unit/environments_spec.rb +274 -16
- data/spec/unit/face/config_spec.rb +111 -11
- data/spec/unit/face/module/install_spec.rb +14 -85
- data/spec/unit/face/module/list_spec.rb +108 -62
- data/spec/unit/face/module/search_spec.rb +1 -1
- data/spec/unit/face/module/uninstall_spec.rb +21 -42
- data/spec/unit/face/parser_spec.rb +5 -2
- data/spec/unit/file_bucket/dipper_spec.rb +92 -86
- data/spec/unit/file_bucket/file_spec.rb +23 -75
- data/spec/unit/file_serving/metadata_spec.rb +74 -74
- data/spec/unit/forge/module_release_spec.rb +131 -0
- data/spec/unit/forge/repository_spec.rb +21 -20
- data/spec/unit/forge_spec.rb +99 -23
- data/spec/unit/functions/assert_type_spec.rb +59 -0
- data/spec/unit/functions4_spec.rb +671 -0
- data/spec/unit/indirector/catalog/static_compiler_spec.rb +2 -2
- data/spec/unit/indirector/facts/facter_spec.rb +9 -3
- data/spec/unit/indirector/file_bucket_file/file_spec.rb +156 -155
- data/spec/unit/indirector/rest_spec.rb +8 -0
- data/spec/unit/interface/face_collection_spec.rb +35 -23
- data/spec/unit/module_spec.rb +20 -8
- data/spec/unit/module_tool/applications/builder_spec.rb +40 -12
- data/spec/unit/module_tool/applications/checksummer_spec.rb +86 -105
- data/spec/unit/module_tool/applications/installer_spec.rb +293 -261
- data/spec/unit/module_tool/applications/searcher_spec.rb +1 -1
- data/spec/unit/module_tool/applications/uninstaller_spec.rb +90 -154
- data/spec/unit/module_tool/applications/unpacker_spec.rb +12 -12
- data/spec/unit/module_tool/applications/upgrader_spec.rb +286 -18
- data/spec/unit/module_tool/metadata_spec.rb +223 -14
- data/spec/unit/module_tool/tar/gnu_spec.rb +12 -9
- data/spec/unit/module_tool/tar/mini_spec.rb +1 -1
- data/spec/unit/module_tool/tar_spec.rb +4 -18
- data/spec/unit/module_tool_spec.rb +123 -27
- data/spec/unit/network/formats_spec.rb +2 -2
- data/spec/unit/network/http_pool_spec.rb +21 -0
- data/spec/unit/network/rights_spec.rb +10 -8
- data/spec/unit/node/environment_spec.rb +27 -2
- data/spec/unit/parser/collector_spec.rb +1 -1
- data/spec/unit/parser/compiler_spec.rb +1 -1
- data/spec/unit/parser/functions/generate_spec.rb +4 -0
- data/spec/unit/pops/evaluator/access_ops_spec.rb +50 -11
- data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +25 -0
- data/spec/unit/pops/loaders/dependency_loader_spec.rb +44 -0
- data/spec/unit/pops/loaders/loader_paths_spec.rb +66 -0
- data/spec/unit/pops/loaders/loaders_spec.rb +105 -0
- data/spec/unit/pops/loaders/module_loaders_spec.rb +119 -0
- data/spec/unit/pops/loaders/static_loader_spec.rb +46 -0
- data/spec/unit/pops/types/type_calculator_spec.rb +145 -10
- data/spec/unit/pops/types/type_factory_spec.rb +101 -0
- data/spec/unit/pops/types/type_parser_spec.rb +22 -0
- data/spec/unit/property/list_spec.rb +9 -1
- data/spec/unit/provider/augeas/augeas_spec.rb +58 -11
- data/spec/unit/provider/cron/crontab_spec.rb +1 -0
- data/spec/unit/provider/cron/parsed_spec.rb +15 -0
- data/spec/unit/provider/naginator_spec.rb +14 -0
- data/spec/unit/provider/package/apt_spec.rb +78 -64
- data/spec/unit/provider/package/gem_spec.rb +15 -0
- data/spec/unit/provider/package/rpm_spec.rb +6 -6
- data/spec/unit/provider/package/windows_spec.rb +1 -1
- data/spec/unit/provider/package/yum_spec.rb +199 -104
- data/spec/unit/provider/package/zypper_spec.rb +41 -15
- data/spec/unit/provider/service/openbsd_spec.rb +129 -22
- data/spec/unit/provider/service/redhat_spec.rb +18 -4
- data/spec/unit/provider/service/systemd_spec.rb +5 -9
- data/spec/unit/provider/service/upstart_spec.rb +1 -1
- data/spec/unit/provider/user/directoryservice_spec.rb +10 -0
- data/spec/unit/provider/yumrepo/inifile_spec.rb +171 -15
- data/spec/unit/resource/catalog_spec.rb +20 -104
- data/spec/unit/resource/type_collection_spec.rb +10 -9
- data/spec/unit/settings/config_file_spec.rb +29 -6
- data/spec/unit/settings/environment_conf_spec.rb +51 -0
- data/spec/unit/settings_spec.rb +97 -12
- data/spec/unit/ssl/certificate_authority_spec.rb +2 -0
- data/spec/unit/type/augeas_spec.rb +1 -1
- data/spec/unit/type/cron_spec.rb +6 -7
- data/spec/unit/type/file/checksum_spec.rb +6 -0
- data/spec/unit/type/file/content_spec.rb +277 -207
- data/spec/unit/type/file_spec.rb +9 -7
- data/spec/unit/type/user_spec.rb +106 -18
- data/spec/unit/type/yumrepo_spec.rb +8 -0
- data/spec/unit/util/checksums_spec.rb +12 -5
- data/spec/unit/util/diff_spec.rb +8 -0
- data/spec/unit/util/execution_spec.rb +4 -4
- data/spec/unit/util/feature_spec.rb +2 -0
- data/spec/unit/util/logging_spec.rb +14 -4
- data/spec/unit/util/rdoc/parser_spec.rb +5 -4
- data/spec/unit/util/rubygems_spec.rb +14 -0
- data/tasks/parallel.rake +2 -2
- metadata +154 -21
- checksums.yaml +0 -7
- data/lib/puppet/module_tool/applications/generator.rb +0 -142
- data/lib/puppet/module_tool/skeleton.rb +0 -37
- data/lib/puppet/module_tool/skeleton/templates/generator/Modulefile.erb +0 -11
- data/lib/puppet/module_tool/skeleton/templates/generator/README.erb +0 -16
- data/lib/puppet/module_tool/tar/solaris.rb +0 -5
- data/spec/fixtures/unit/provider/service/systemd/list_units_services +0 -17
- data/spec/unit/module_tool/tar/solaris_spec.rb +0 -22
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'semantic/dependency'
|
2
|
+
|
3
|
+
module Semantic
|
4
|
+
module Dependency
|
5
|
+
class Graph
|
6
|
+
include GraphNode
|
7
|
+
|
8
|
+
attr_reader :modules
|
9
|
+
|
10
|
+
# Create a new instance of a dependency graph.
|
11
|
+
#
|
12
|
+
# @param modules [{String => VersionRange}] the required module
|
13
|
+
# set and their version constraints
|
14
|
+
def initialize(modules = {})
|
15
|
+
@modules = modules.keys
|
16
|
+
|
17
|
+
modules.each do |name, range|
|
18
|
+
add_constraint('initialize', name, range.to_s) do |node|
|
19
|
+
range === node.version
|
20
|
+
end
|
21
|
+
|
22
|
+
add_dependency(name)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Constrains graph solutions based on the given block. Graph constraints
|
27
|
+
# are used to describe fundamental truths about the tooling or module
|
28
|
+
# system (e.g.: module names contain a namespace component which is
|
29
|
+
# dropped during install, so module names must be unique excluding the
|
30
|
+
# namespace).
|
31
|
+
#
|
32
|
+
# @example Ensuring a single source for all modules
|
33
|
+
# @graph.add_constraint('installed', mod.name) do |nodes|
|
34
|
+
# nodes.count { |node| node.source } == 1
|
35
|
+
# end
|
36
|
+
#
|
37
|
+
# @see #considering_solution?
|
38
|
+
#
|
39
|
+
# @param source [String, Symbol] a name describing the source of the
|
40
|
+
# constraint
|
41
|
+
# @yieldparam nodes [Array<GraphNode>] the nodes to test the constraint
|
42
|
+
# against
|
43
|
+
# @yieldreturn [Boolean] whether the node passed the constraint
|
44
|
+
# @return [void]
|
45
|
+
def add_graph_constraint(source, &block)
|
46
|
+
constraints[:graph] << [ source, block ]
|
47
|
+
end
|
48
|
+
|
49
|
+
# Checks the proposed solution (or partial solution) against the graph's
|
50
|
+
# constraints.
|
51
|
+
#
|
52
|
+
# @see #add_graph_constraint
|
53
|
+
#
|
54
|
+
# @return [Boolean] true if none of the graph constraints are violated
|
55
|
+
def satisfies_graph?(solution)
|
56
|
+
constraints[:graph].all? { |_, check| check[solution] }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'semantic/dependency'
|
2
|
+
require 'set'
|
3
|
+
|
4
|
+
module Semantic
|
5
|
+
module Dependency
|
6
|
+
module GraphNode
|
7
|
+
include Comparable
|
8
|
+
|
9
|
+
def name
|
10
|
+
end
|
11
|
+
|
12
|
+
# Determines whether the modules dependencies are satisfied by the known
|
13
|
+
# releases.
|
14
|
+
#
|
15
|
+
# @return [Boolean] true if all dependencies are satisfied
|
16
|
+
def satisfied?
|
17
|
+
dependencies.none? { |_, v| v.empty? }
|
18
|
+
end
|
19
|
+
|
20
|
+
def children
|
21
|
+
@_children ||= {}
|
22
|
+
end
|
23
|
+
|
24
|
+
def populate_children(nodes)
|
25
|
+
if children.empty?
|
26
|
+
nodes = nodes.select { |node| satisfies_dependency?(node) }
|
27
|
+
nodes.each do |node|
|
28
|
+
children[node.name] = node
|
29
|
+
node.populate_children(nodes)
|
30
|
+
end
|
31
|
+
self.freeze
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# @api internal
|
36
|
+
# @return [{ String => SortedSet<GraphNode> }] the satisfactory
|
37
|
+
# dependency nodes
|
38
|
+
def dependencies
|
39
|
+
@_dependencies ||= Hash.new { |h, k| h[k] = SortedSet.new }
|
40
|
+
end
|
41
|
+
|
42
|
+
# Adds the given dependency name to the list of dependencies.
|
43
|
+
#
|
44
|
+
# @param name [String] the dependency name
|
45
|
+
# @return [void]
|
46
|
+
def add_dependency(name)
|
47
|
+
dependencies[name]
|
48
|
+
end
|
49
|
+
|
50
|
+
# @return [Array<String>] the list of dependency names
|
51
|
+
def dependency_names
|
52
|
+
dependencies.keys
|
53
|
+
end
|
54
|
+
|
55
|
+
def constraints
|
56
|
+
@_constraints ||= Hash.new { |h, k| h[k] = [] }
|
57
|
+
end
|
58
|
+
|
59
|
+
def constraints_for(name)
|
60
|
+
return [] unless constraints.has_key?(name)
|
61
|
+
|
62
|
+
constraints[name].map do |constraint|
|
63
|
+
{
|
64
|
+
:source => constraint[0],
|
65
|
+
:description => constraint[1],
|
66
|
+
:test => constraint[2],
|
67
|
+
}
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# Constrains the named module to suitable releases, as determined by the
|
72
|
+
# given block.
|
73
|
+
#
|
74
|
+
# @example Version-locking currently installed modules
|
75
|
+
# installed_modules.each do |m|
|
76
|
+
# @graph.add_constraint('installed', m.name, m.version) do |node|
|
77
|
+
# m.version == node.version
|
78
|
+
# end
|
79
|
+
# end
|
80
|
+
#
|
81
|
+
# @param source [String, Symbol] a name describing the source of the
|
82
|
+
# constraint
|
83
|
+
# @param mod [String] the name of the module
|
84
|
+
# @param desc [String] a description of the enforced constraint
|
85
|
+
# @yieldparam node [GraphNode] the node to test the constraint against
|
86
|
+
# @yieldreturn [Boolean] whether the node passed the constraint
|
87
|
+
# @return [void]
|
88
|
+
def add_constraint(source, mod, desc, &block)
|
89
|
+
constraints["#{mod}"] << [ source, desc, block ]
|
90
|
+
end
|
91
|
+
|
92
|
+
def satisfies_dependency?(node)
|
93
|
+
dependencies.key?(node.name) && satisfies_constraints?(node)
|
94
|
+
end
|
95
|
+
|
96
|
+
# @param release [ModuleRelease] the release to test
|
97
|
+
def satisfies_constraints?(release)
|
98
|
+
constraints_for(release.name).all? { |x| x[:test].call(release) }
|
99
|
+
end
|
100
|
+
|
101
|
+
def << (nodes)
|
102
|
+
Array(nodes).each do |node|
|
103
|
+
next unless dependencies.key?(node.name)
|
104
|
+
if satisfies_dependency?(node)
|
105
|
+
dependencies[node.name] << node
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
return self
|
110
|
+
end
|
111
|
+
|
112
|
+
def <=>(other)
|
113
|
+
name <=> other.name
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'semantic/dependency'
|
2
|
+
|
3
|
+
module Semantic
|
4
|
+
module Dependency
|
5
|
+
class ModuleRelease
|
6
|
+
include GraphNode
|
7
|
+
|
8
|
+
attr_reader :name, :version
|
9
|
+
|
10
|
+
# Create a new instance of a module release.
|
11
|
+
#
|
12
|
+
# @param source [Semantic::Dependency::Source]
|
13
|
+
# @param name [String]
|
14
|
+
# @param version [Semantic::Version]
|
15
|
+
# @param dependencies [{String => Semantic::VersionRange}]
|
16
|
+
def initialize(source, name, version, dependencies = {})
|
17
|
+
@source = source
|
18
|
+
@name = name.freeze
|
19
|
+
@version = version.freeze
|
20
|
+
|
21
|
+
dependencies.each do |name, range|
|
22
|
+
add_constraint('initialize', name, range.to_s) do |node|
|
23
|
+
range === node.version
|
24
|
+
end
|
25
|
+
|
26
|
+
add_dependency(name)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def priority
|
31
|
+
@source.priority
|
32
|
+
end
|
33
|
+
|
34
|
+
def <=>(oth)
|
35
|
+
our_key = [ priority, name, version ]
|
36
|
+
their_key = [ oth.priority, oth.name, oth.version ]
|
37
|
+
|
38
|
+
return our_key <=> their_key
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_s
|
42
|
+
"#<#{self.class} #{name}@#{version}>"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'semantic/dependency'
|
2
|
+
|
3
|
+
module Semantic
|
4
|
+
module Dependency
|
5
|
+
class Source
|
6
|
+
def self.priority
|
7
|
+
0
|
8
|
+
end
|
9
|
+
|
10
|
+
def priority
|
11
|
+
self.class.priority
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_release(name, version, dependencies = {})
|
15
|
+
version = Version.parse(version) if version.is_a? String
|
16
|
+
dependencies = dependencies.inject({}) do |hash, (key, value)|
|
17
|
+
hash[key] = VersionRange.parse(value || '>= 0')
|
18
|
+
hash[key] ||= VersionRange::EMPTY_RANGE
|
19
|
+
hash
|
20
|
+
end
|
21
|
+
ModuleRelease.new(self, name, version, dependencies)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'semantic/dependency'
|
2
|
+
|
3
|
+
module Semantic
|
4
|
+
module Dependency
|
5
|
+
class UnsatisfiableGraph < StandardError
|
6
|
+
attr_reader :graph
|
7
|
+
|
8
|
+
def initialize(graph)
|
9
|
+
@graph = graph
|
10
|
+
|
11
|
+
deps = sentence_from_list(graph.modules)
|
12
|
+
super "Could not find satisfying releases for #{deps}"
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def sentence_from_list(list)
|
18
|
+
case list.length
|
19
|
+
when 1
|
20
|
+
list.first
|
21
|
+
when 2
|
22
|
+
list.join(' and ')
|
23
|
+
else
|
24
|
+
list = list.dup
|
25
|
+
list.push("and #{list.pop}")
|
26
|
+
list.join(', ')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,168 @@
|
|
1
|
+
require 'semantic'
|
2
|
+
|
3
|
+
module Semantic
|
4
|
+
|
5
|
+
# @note Semantic::Version subclasses Numeric so that it has sane Range
|
6
|
+
# semantics in Ruby 1.9+.
|
7
|
+
class Version < Numeric
|
8
|
+
include Comparable
|
9
|
+
|
10
|
+
class ValidationFailure < ArgumentError; end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
LOOSE_REGEX = /
|
14
|
+
\A
|
15
|
+
(\d+)[.](\d+)[.](\d+) # Major . Minor . Patch
|
16
|
+
(?: [-](.*?))? # Prerelease
|
17
|
+
(?: [+](.*?))? # Build
|
18
|
+
\Z
|
19
|
+
/x
|
20
|
+
|
21
|
+
# Parse a Semantic Version string.
|
22
|
+
#
|
23
|
+
# @param ver [String] the version string to parse
|
24
|
+
# @return [Version] a comparable {Version} object
|
25
|
+
def parse(ver)
|
26
|
+
match, major, minor, patch, prerelease, build = *ver.match(LOOSE_REGEX)
|
27
|
+
|
28
|
+
if match.nil?
|
29
|
+
raise 'Version numbers MUST begin with three dot-separated numbers'
|
30
|
+
elsif [major, minor, patch].any? { |x| x =~ /^0\d+/ }
|
31
|
+
raise 'Version numbers MUST NOT contain leading zeroes'
|
32
|
+
end
|
33
|
+
|
34
|
+
prerelease = parse_prerelease(prerelease) if prerelease
|
35
|
+
build = parse_build_metadata(build) if build
|
36
|
+
|
37
|
+
self.new(major.to_i, minor.to_i, patch.to_i, prerelease, build)
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
def parse_prerelease(prerelease)
|
42
|
+
subject = 'Prerelease identifiers'
|
43
|
+
prerelease = prerelease.split('.', -1)
|
44
|
+
|
45
|
+
if prerelease.empty? or prerelease.any? { |x| x.empty? }
|
46
|
+
raise "#{subject} MUST NOT be empty"
|
47
|
+
elsif prerelease.any? { |x| x =~ /[^0-9a-zA-Z-]/ }
|
48
|
+
raise "#{subject} MUST use only ASCII alphanumerics and hyphens"
|
49
|
+
elsif prerelease.any? { |x| x =~ /^0\d+$/ }
|
50
|
+
raise "#{subject} MUST NOT contain leading zeroes"
|
51
|
+
end
|
52
|
+
|
53
|
+
return prerelease.map { |x| x =~ /^\d+$/ ? x.to_i : x }
|
54
|
+
end
|
55
|
+
|
56
|
+
def parse_build_metadata(build)
|
57
|
+
subject = 'Build identifiers'
|
58
|
+
build = build.split('.', -1)
|
59
|
+
|
60
|
+
if build.empty? or build.any? { |x| x.empty? }
|
61
|
+
raise "#{subject} MUST NOT be empty"
|
62
|
+
elsif build.any? { |x| x =~ /[^0-9a-zA-Z-]/ }
|
63
|
+
raise "#{subject} MUST use only ASCII alphanumerics and hyphens"
|
64
|
+
end
|
65
|
+
|
66
|
+
return build
|
67
|
+
end
|
68
|
+
|
69
|
+
def raise(msg)
|
70
|
+
super ValidationFailure, msg, caller.drop_while { |x| x !~ /\bparse\b/ }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
attr_reader :major, :minor, :patch
|
75
|
+
|
76
|
+
def initialize(major, minor, patch, prerelease = nil, build = nil)
|
77
|
+
@major = major
|
78
|
+
@minor = minor
|
79
|
+
@patch = patch
|
80
|
+
@prerelease = prerelease
|
81
|
+
@build = build
|
82
|
+
end
|
83
|
+
|
84
|
+
def next(part)
|
85
|
+
case part
|
86
|
+
when :major
|
87
|
+
self.class.new(@major.next, 0, 0)
|
88
|
+
when :minor
|
89
|
+
self.class.new(@major, @minor.next, 0)
|
90
|
+
when :patch
|
91
|
+
self.class.new(@major, @minor, @patch.next)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def prerelease
|
96
|
+
@prerelease && @prerelease.join('.')
|
97
|
+
end
|
98
|
+
|
99
|
+
# @return [Boolean] true if this is a stable release
|
100
|
+
def stable?
|
101
|
+
@prerelease.nil?
|
102
|
+
end
|
103
|
+
|
104
|
+
def build
|
105
|
+
@build && @build.join('.')
|
106
|
+
end
|
107
|
+
|
108
|
+
def <=>(other)
|
109
|
+
return self.major <=> other.major unless self.major == other.major
|
110
|
+
return self.minor <=> other.minor unless self.minor == other.minor
|
111
|
+
return self.patch <=> other.patch unless self.patch == other.patch
|
112
|
+
return compare_prerelease(other)
|
113
|
+
end
|
114
|
+
|
115
|
+
def to_s
|
116
|
+
"#{major}.#{minor}.#{patch}" +
|
117
|
+
(@prerelease.nil? || prerelease.empty? ? '' : "-" + prerelease) +
|
118
|
+
(@build.nil? || build.empty? ? '' : "+" + build )
|
119
|
+
end
|
120
|
+
|
121
|
+
def hash
|
122
|
+
self.to_s.hash
|
123
|
+
end
|
124
|
+
|
125
|
+
private
|
126
|
+
# This is a hack; tildes sort later than any valid identifier. The
|
127
|
+
# advantage is that we don't need to handle stable vs. prerelease
|
128
|
+
# comparisons separately.
|
129
|
+
@@STABLE_RELEASE = [ '~' ].freeze
|
130
|
+
|
131
|
+
def compare_prerelease(other)
|
132
|
+
all_mine = @prerelease || @@STABLE_RELEASE
|
133
|
+
all_yours = other.instance_variable_get(:@prerelease) || @@STABLE_RELEASE
|
134
|
+
|
135
|
+
# Precedence is determined by comparing each dot separated identifier from
|
136
|
+
# left to right...
|
137
|
+
size = [ all_mine.size, all_yours.size ].max
|
138
|
+
Array.new(size).zip(all_mine, all_yours) do |_, mine, yours|
|
139
|
+
|
140
|
+
# ...until a difference is found.
|
141
|
+
next if mine == yours
|
142
|
+
|
143
|
+
# Numbers are compared numerically, strings are compared ASCIIbetically.
|
144
|
+
if mine.class == yours.class
|
145
|
+
return mine <=> yours
|
146
|
+
|
147
|
+
# A larger set of pre-release fields has a higher precedence.
|
148
|
+
elsif mine.nil?
|
149
|
+
return -1
|
150
|
+
elsif yours.nil?
|
151
|
+
return 1
|
152
|
+
|
153
|
+
# Numeric identifiers always have lower precedence than non-numeric.
|
154
|
+
elsif mine.is_a? Numeric
|
155
|
+
return -1
|
156
|
+
elsif yours.is_a? Numeric
|
157
|
+
return 1
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
return 0
|
162
|
+
end
|
163
|
+
|
164
|
+
def first_prerelease
|
165
|
+
self.class.new(@major, @minor, @patch, [])
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|