bundler 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bundler might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3111 -0
- data/LICENSE.md +23 -0
- data/README.md +63 -0
- data/bundler.gemspec +65 -0
- data/exe/bundle +31 -0
- data/exe/bundle_ruby +60 -0
- data/exe/bundler +4 -0
- data/lib/bundler.rb +567 -0
- data/lib/bundler/build_metadata.rb +53 -0
- data/lib/bundler/capistrano.rb +22 -0
- data/lib/bundler/cli.rb +792 -0
- data/lib/bundler/cli/add.rb +35 -0
- data/lib/bundler/cli/binstubs.rb +49 -0
- data/lib/bundler/cli/cache.rb +36 -0
- data/lib/bundler/cli/check.rb +38 -0
- data/lib/bundler/cli/clean.rb +25 -0
- data/lib/bundler/cli/common.rb +102 -0
- data/lib/bundler/cli/config.rb +119 -0
- data/lib/bundler/cli/console.rb +43 -0
- data/lib/bundler/cli/doctor.rb +140 -0
- data/lib/bundler/cli/exec.rb +105 -0
- data/lib/bundler/cli/gem.rb +252 -0
- data/lib/bundler/cli/info.rb +50 -0
- data/lib/bundler/cli/init.rb +47 -0
- data/lib/bundler/cli/inject.rb +60 -0
- data/lib/bundler/cli/install.rb +218 -0
- data/lib/bundler/cli/issue.rb +40 -0
- data/lib/bundler/cli/list.rb +58 -0
- data/lib/bundler/cli/lock.rb +63 -0
- data/lib/bundler/cli/open.rb +26 -0
- data/lib/bundler/cli/outdated.rb +266 -0
- data/lib/bundler/cli/package.rb +49 -0
- data/lib/bundler/cli/platform.rb +46 -0
- data/lib/bundler/cli/plugin.rb +24 -0
- data/lib/bundler/cli/pristine.rb +47 -0
- data/lib/bundler/cli/remove.rb +18 -0
- data/lib/bundler/cli/show.rb +75 -0
- data/lib/bundler/cli/update.rb +91 -0
- data/lib/bundler/cli/viz.rb +31 -0
- data/lib/bundler/compact_index_client.rb +109 -0
- data/lib/bundler/compact_index_client/cache.rb +118 -0
- data/lib/bundler/compact_index_client/updater.rb +116 -0
- data/lib/bundler/compatibility_guard.rb +13 -0
- data/lib/bundler/constants.rb +7 -0
- data/lib/bundler/current_ruby.rb +94 -0
- data/lib/bundler/definition.rb +995 -0
- data/lib/bundler/dep_proxy.rb +48 -0
- data/lib/bundler/dependency.rb +139 -0
- data/lib/bundler/deployment.rb +69 -0
- data/lib/bundler/deprecate.rb +44 -0
- data/lib/bundler/dsl.rb +615 -0
- data/lib/bundler/endpoint_specification.rb +141 -0
- data/lib/bundler/env.rb +149 -0
- data/lib/bundler/environment_preserver.rb +59 -0
- data/lib/bundler/errors.rb +158 -0
- data/lib/bundler/feature_flag.rb +75 -0
- data/lib/bundler/fetcher.rb +312 -0
- data/lib/bundler/fetcher/base.rb +52 -0
- data/lib/bundler/fetcher/compact_index.rb +126 -0
- data/lib/bundler/fetcher/dependency.rb +82 -0
- data/lib/bundler/fetcher/downloader.rb +84 -0
- data/lib/bundler/fetcher/index.rb +52 -0
- data/lib/bundler/friendly_errors.rb +131 -0
- data/lib/bundler/gem_helper.rb +217 -0
- data/lib/bundler/gem_helpers.rb +101 -0
- data/lib/bundler/gem_remote_fetcher.rb +43 -0
- data/lib/bundler/gem_tasks.rb +7 -0
- data/lib/bundler/gem_version_promoter.rb +190 -0
- data/lib/bundler/gemdeps.rb +29 -0
- data/lib/bundler/graph.rb +152 -0
- data/lib/bundler/index.rb +213 -0
- data/lib/bundler/injector.rb +253 -0
- data/lib/bundler/inline.rb +74 -0
- data/lib/bundler/installer.rb +318 -0
- data/lib/bundler/installer/gem_installer.rb +85 -0
- data/lib/bundler/installer/parallel_installer.rb +229 -0
- data/lib/bundler/installer/standalone.rb +53 -0
- data/lib/bundler/lazy_specification.rb +123 -0
- data/lib/bundler/lockfile_generator.rb +95 -0
- data/lib/bundler/lockfile_parser.rb +256 -0
- data/lib/bundler/match_platform.rb +24 -0
- data/lib/bundler/mirror.rb +223 -0
- data/lib/bundler/plugin.rb +294 -0
- data/lib/bundler/plugin/api.rb +81 -0
- data/lib/bundler/plugin/api/source.rb +306 -0
- data/lib/bundler/plugin/dsl.rb +53 -0
- data/lib/bundler/plugin/events.rb +61 -0
- data/lib/bundler/plugin/index.rb +165 -0
- data/lib/bundler/plugin/installer.rb +96 -0
- data/lib/bundler/plugin/installer/git.rb +38 -0
- data/lib/bundler/plugin/installer/rubygems.rb +27 -0
- data/lib/bundler/plugin/source_list.rb +27 -0
- data/lib/bundler/process_lock.rb +24 -0
- data/lib/bundler/psyched_yaml.rb +37 -0
- data/lib/bundler/remote_specification.rb +114 -0
- data/lib/bundler/resolver.rb +373 -0
- data/lib/bundler/resolver/spec_group.rb +106 -0
- data/lib/bundler/retry.rb +66 -0
- data/lib/bundler/ruby_dsl.rb +18 -0
- data/lib/bundler/ruby_version.rb +152 -0
- data/lib/bundler/rubygems_ext.rb +209 -0
- data/lib/bundler/rubygems_gem_installer.rb +99 -0
- data/lib/bundler/rubygems_integration.rb +915 -0
- data/lib/bundler/runtime.rb +322 -0
- data/lib/bundler/settings.rb +464 -0
- data/lib/bundler/settings/validator.rb +102 -0
- data/lib/bundler/setup.rb +28 -0
- data/lib/bundler/shared_helpers.rb +386 -0
- data/lib/bundler/similarity_detector.rb +63 -0
- data/lib/bundler/source.rb +94 -0
- data/lib/bundler/source/gemspec.rb +18 -0
- data/lib/bundler/source/git.rb +329 -0
- data/lib/bundler/source/git/git_proxy.rb +262 -0
- data/lib/bundler/source/metadata.rb +62 -0
- data/lib/bundler/source/path.rb +249 -0
- data/lib/bundler/source/path/installer.rb +74 -0
- data/lib/bundler/source/rubygems.rb +539 -0
- data/lib/bundler/source/rubygems/remote.rb +69 -0
- data/lib/bundler/source_list.rb +186 -0
- data/lib/bundler/spec_set.rb +208 -0
- data/lib/bundler/ssl_certs/.document +1 -0
- data/lib/bundler/ssl_certs/certificate_manager.rb +66 -0
- data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +21 -0
- data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
- data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
- data/lib/bundler/stub_specification.rb +108 -0
- data/lib/bundler/templates/.document +1 -0
- data/lib/bundler/templates/Executable +29 -0
- data/lib/bundler/templates/Executable.bundler +105 -0
- data/lib/bundler/templates/Executable.standalone +14 -0
- data/lib/bundler/templates/Gemfile +7 -0
- data/lib/bundler/templates/gems.rb +8 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +74 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
- data/lib/bundler/templates/newgem/LICENSE.txt.tt +21 -0
- data/lib/bundler/templates/newgem/README.md.tt +47 -0
- data/lib/bundler/templates/newgem/Rakefile.tt +29 -0
- data/lib/bundler/templates/newgem/bin/console.tt +14 -0
- data/lib/bundler/templates/newgem/bin/setup.tt +8 -0
- data/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +3 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
- data/lib/bundler/templates/newgem/gitignore.tt +20 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +13 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +50 -0
- data/lib/bundler/templates/newgem/rspec.tt +3 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +9 -0
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +14 -0
- data/lib/bundler/templates/newgem/test/newgem_test.rb.tt +11 -0
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +8 -0
- data/lib/bundler/templates/newgem/travis.yml.tt +7 -0
- data/lib/bundler/ui.rb +9 -0
- data/lib/bundler/ui/rg_proxy.rb +19 -0
- data/lib/bundler/ui/shell.rb +146 -0
- data/lib/bundler/ui/silent.rb +69 -0
- data/lib/bundler/uri_credentials_filter.rb +37 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1741 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils/version.rb +5 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +12 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +57 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +81 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +223 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +36 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +66 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +62 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +63 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +61 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +126 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +46 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +36 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +136 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +143 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +6 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +101 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +67 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +837 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +46 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +58 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +27 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1233 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +129 -0
- data/lib/bundler/vendor/thor/lib/thor.rb +509 -0
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +331 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +104 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +60 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +118 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +143 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +373 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +109 -0
- data/lib/bundler/vendor/thor/lib/thor/base.rb +678 -0
- data/lib/bundler/vendor/thor/lib/thor/command.rb +135 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +97 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +12 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +129 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +114 -0
- data/lib/bundler/vendor/thor/lib/thor/group.rb +281 -0
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +177 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +37 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
- data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +70 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +175 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +146 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +226 -0
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +71 -0
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +324 -0
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +482 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +149 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +126 -0
- data/lib/bundler/vendor/thor/lib/thor/util.rb +268 -0
- data/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
- data/lib/bundler/vendored_fileutils.rb +9 -0
- data/lib/bundler/vendored_molinillo.rb +4 -0
- data/lib/bundler/vendored_persistent.rb +52 -0
- data/lib/bundler/vendored_thor.rb +8 -0
- data/lib/bundler/version.rb +28 -0
- data/lib/bundler/version_ranges.rb +76 -0
- data/lib/bundler/vlad.rb +17 -0
- data/lib/bundler/worker.rb +106 -0
- data/lib/bundler/yaml_serializer.rb +90 -0
- data/man/bundle-add.1 +58 -0
- data/man/bundle-add.1.txt +52 -0
- data/man/bundle-add.ronn +40 -0
- data/man/bundle-binstubs.1 +40 -0
- data/man/bundle-binstubs.1.txt +48 -0
- data/man/bundle-binstubs.ronn +43 -0
- data/man/bundle-check.1 +31 -0
- data/man/bundle-check.1.txt +33 -0
- data/man/bundle-check.ronn +26 -0
- data/man/bundle-clean.1 +24 -0
- data/man/bundle-clean.1.txt +26 -0
- data/man/bundle-clean.ronn +18 -0
- data/man/bundle-config.1 +497 -0
- data/man/bundle-config.1.txt +529 -0
- data/man/bundle-config.ronn +397 -0
- data/man/bundle-doctor.1 +44 -0
- data/man/bundle-doctor.1.txt +44 -0
- data/man/bundle-doctor.ronn +33 -0
- data/man/bundle-exec.1 +165 -0
- data/man/bundle-exec.1.txt +178 -0
- data/man/bundle-exec.ronn +152 -0
- data/man/bundle-gem.1 +80 -0
- data/man/bundle-gem.1.txt +91 -0
- data/man/bundle-gem.ronn +78 -0
- data/man/bundle-info.1 +20 -0
- data/man/bundle-info.1.txt +21 -0
- data/man/bundle-info.ronn +17 -0
- data/man/bundle-init.1 +25 -0
- data/man/bundle-init.1.txt +34 -0
- data/man/bundle-init.ronn +29 -0
- data/man/bundle-inject.1 +33 -0
- data/man/bundle-inject.1.txt +32 -0
- data/man/bundle-inject.ronn +22 -0
- data/man/bundle-install.1 +308 -0
- data/man/bundle-install.1.txt +396 -0
- data/man/bundle-install.ronn +378 -0
- data/man/bundle-list.1 +50 -0
- data/man/bundle-list.1.txt +43 -0
- data/man/bundle-list.ronn +33 -0
- data/man/bundle-lock.1 +84 -0
- data/man/bundle-lock.1.txt +93 -0
- data/man/bundle-lock.ronn +94 -0
- data/man/bundle-open.1 +32 -0
- data/man/bundle-open.1.txt +29 -0
- data/man/bundle-open.ronn +19 -0
- data/man/bundle-outdated.1 +155 -0
- data/man/bundle-outdated.1.txt +131 -0
- data/man/bundle-outdated.ronn +111 -0
- data/man/bundle-package.1 +55 -0
- data/man/bundle-package.1.txt +79 -0
- data/man/bundle-package.ronn +72 -0
- data/man/bundle-platform.1 +61 -0
- data/man/bundle-platform.1.txt +57 -0
- data/man/bundle-platform.ronn +42 -0
- data/man/bundle-pristine.1 +34 -0
- data/man/bundle-pristine.1.txt +44 -0
- data/man/bundle-pristine.ronn +34 -0
- data/man/bundle-remove.1 +31 -0
- data/man/bundle-remove.1.txt +34 -0
- data/man/bundle-remove.ronn +23 -0
- data/man/bundle-show.1 +23 -0
- data/man/bundle-show.1.txt +27 -0
- data/man/bundle-show.ronn +21 -0
- data/man/bundle-update.1 +394 -0
- data/man/bundle-update.1.txt +391 -0
- data/man/bundle-update.ronn +350 -0
- data/man/bundle-viz.1 +39 -0
- data/man/bundle-viz.1.txt +39 -0
- data/man/bundle-viz.ronn +30 -0
- data/man/bundle.1 +136 -0
- data/man/bundle.1.txt +116 -0
- data/man/bundle.ronn +111 -0
- data/man/gemfile.5 +689 -0
- data/man/gemfile.5.ronn +521 -0
- data/man/gemfile.5.txt +653 -0
- data/man/index.txt +25 -0
- metadata +463 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
require "bundler/vendor/thor/lib/thor/line_editor/basic"
|
2
|
+
require "bundler/vendor/thor/lib/thor/line_editor/readline"
|
3
|
+
|
4
|
+
class Bundler::Thor
|
5
|
+
module LineEditor
|
6
|
+
def self.readline(prompt, options = {})
|
7
|
+
best_available.new(prompt, options).readline
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.best_available
|
11
|
+
[
|
12
|
+
Bundler::Thor::LineEditor::Readline,
|
13
|
+
Bundler::Thor::LineEditor::Basic
|
14
|
+
].detect(&:available?)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class Bundler::Thor
|
2
|
+
module LineEditor
|
3
|
+
class Basic
|
4
|
+
attr_reader :prompt, :options
|
5
|
+
|
6
|
+
def self.available?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(prompt, options)
|
11
|
+
@prompt = prompt
|
12
|
+
@options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
def readline
|
16
|
+
$stdout.print(prompt)
|
17
|
+
get_input
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def get_input
|
23
|
+
if echo?
|
24
|
+
$stdin.gets
|
25
|
+
else
|
26
|
+
# Lazy-load io/console since it is gem-ified as of 2.3
|
27
|
+
require "io/console" if RUBY_VERSION > "1.9.2"
|
28
|
+
$stdin.noecho(&:gets)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def echo?
|
33
|
+
options.fetch(:echo, true)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
begin
|
2
|
+
require "readline"
|
3
|
+
rescue LoadError
|
4
|
+
end
|
5
|
+
|
6
|
+
class Bundler::Thor
|
7
|
+
module LineEditor
|
8
|
+
class Readline < Basic
|
9
|
+
def self.available?
|
10
|
+
Object.const_defined?(:Readline)
|
11
|
+
end
|
12
|
+
|
13
|
+
def readline
|
14
|
+
if echo?
|
15
|
+
::Readline.completion_append_character = nil
|
16
|
+
# Ruby 1.8.7 does not allow Readline.completion_proc= to receive nil.
|
17
|
+
if complete = completion_proc
|
18
|
+
::Readline.completion_proc = complete
|
19
|
+
end
|
20
|
+
::Readline.readline(prompt, add_to_history?)
|
21
|
+
else
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def add_to_history?
|
29
|
+
options.fetch(:add_to_history, true)
|
30
|
+
end
|
31
|
+
|
32
|
+
def completion_proc
|
33
|
+
if use_path_completion?
|
34
|
+
proc { |text| PathCompletion.new(text).matches }
|
35
|
+
elsif completion_options.any?
|
36
|
+
proc do |text|
|
37
|
+
completion_options.select { |option| option.start_with?(text) }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def completion_options
|
43
|
+
options.fetch(:limited_to, [])
|
44
|
+
end
|
45
|
+
|
46
|
+
def use_path_completion?
|
47
|
+
options.fetch(:path, false)
|
48
|
+
end
|
49
|
+
|
50
|
+
class PathCompletion
|
51
|
+
attr_reader :text
|
52
|
+
private :text
|
53
|
+
|
54
|
+
def initialize(text)
|
55
|
+
@text = text
|
56
|
+
end
|
57
|
+
|
58
|
+
def matches
|
59
|
+
relative_matches
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def relative_matches
|
65
|
+
absolute_matches.map { |path| path.sub(base_path, "") }
|
66
|
+
end
|
67
|
+
|
68
|
+
def absolute_matches
|
69
|
+
Dir[glob_pattern].map do |path|
|
70
|
+
if File.directory?(path)
|
71
|
+
"#{path}/"
|
72
|
+
else
|
73
|
+
path
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def glob_pattern
|
79
|
+
"#{base_path}#{text}*"
|
80
|
+
end
|
81
|
+
|
82
|
+
def base_path
|
83
|
+
"#{Dir.pwd}/"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
class Bundler::Thor
|
2
|
+
class Argument #:nodoc:
|
3
|
+
VALID_TYPES = [:numeric, :hash, :array, :string]
|
4
|
+
|
5
|
+
attr_reader :name, :description, :enum, :required, :type, :default, :banner
|
6
|
+
alias_method :human_name, :name
|
7
|
+
|
8
|
+
def initialize(name, options = {})
|
9
|
+
class_name = self.class.name.split("::").last
|
10
|
+
|
11
|
+
type = options[:type]
|
12
|
+
|
13
|
+
raise ArgumentError, "#{class_name} name can't be nil." if name.nil?
|
14
|
+
raise ArgumentError, "Type :#{type} is not valid for #{class_name.downcase}s." if type && !valid_type?(type)
|
15
|
+
|
16
|
+
@name = name.to_s
|
17
|
+
@description = options[:desc]
|
18
|
+
@required = options.key?(:required) ? options[:required] : true
|
19
|
+
@type = (type || :string).to_sym
|
20
|
+
@default = options[:default]
|
21
|
+
@banner = options[:banner] || default_banner
|
22
|
+
@enum = options[:enum]
|
23
|
+
|
24
|
+
validate! # Trigger specific validations
|
25
|
+
end
|
26
|
+
|
27
|
+
def usage
|
28
|
+
required? ? banner : "[#{banner}]"
|
29
|
+
end
|
30
|
+
|
31
|
+
def required?
|
32
|
+
required
|
33
|
+
end
|
34
|
+
|
35
|
+
def show_default?
|
36
|
+
case default
|
37
|
+
when Array, String, Hash
|
38
|
+
!default.empty?
|
39
|
+
else
|
40
|
+
default
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
protected
|
45
|
+
|
46
|
+
def validate!
|
47
|
+
raise ArgumentError, "An argument cannot be required and have default value." if required? && !default.nil?
|
48
|
+
raise ArgumentError, "An argument cannot have an enum other than an array." if @enum && !@enum.is_a?(Array)
|
49
|
+
end
|
50
|
+
|
51
|
+
def valid_type?(type)
|
52
|
+
self.class::VALID_TYPES.include?(type.to_sym)
|
53
|
+
end
|
54
|
+
|
55
|
+
def default_banner
|
56
|
+
case type
|
57
|
+
when :boolean
|
58
|
+
nil
|
59
|
+
when :string, :default
|
60
|
+
human_name.upcase
|
61
|
+
when :numeric
|
62
|
+
"N"
|
63
|
+
when :hash
|
64
|
+
"key:value"
|
65
|
+
when :array
|
66
|
+
"one two three"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
class Bundler::Thor
|
2
|
+
class Arguments #:nodoc: # rubocop:disable ClassLength
|
3
|
+
NUMERIC = /[-+]?(\d*\.\d+|\d+)/
|
4
|
+
|
5
|
+
# Receives an array of args and returns two arrays, one with arguments
|
6
|
+
# and one with switches.
|
7
|
+
#
|
8
|
+
def self.split(args)
|
9
|
+
arguments = []
|
10
|
+
|
11
|
+
args.each do |item|
|
12
|
+
break if item =~ /^-/
|
13
|
+
arguments << item
|
14
|
+
end
|
15
|
+
|
16
|
+
[arguments, args[Range.new(arguments.size, -1)]]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.parse(*args)
|
20
|
+
to_parse = args.pop
|
21
|
+
new(*args).parse(to_parse)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Takes an array of Bundler::Thor::Argument objects.
|
25
|
+
#
|
26
|
+
def initialize(arguments = [])
|
27
|
+
@assigns = {}
|
28
|
+
@non_assigned_required = []
|
29
|
+
@switches = arguments
|
30
|
+
|
31
|
+
arguments.each do |argument|
|
32
|
+
if !argument.default.nil?
|
33
|
+
@assigns[argument.human_name] = argument.default
|
34
|
+
elsif argument.required?
|
35
|
+
@non_assigned_required << argument
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def parse(args)
|
41
|
+
@pile = args.dup
|
42
|
+
|
43
|
+
@switches.each do |argument|
|
44
|
+
break unless peek
|
45
|
+
@non_assigned_required.delete(argument)
|
46
|
+
@assigns[argument.human_name] = send(:"parse_#{argument.type}", argument.human_name)
|
47
|
+
end
|
48
|
+
|
49
|
+
check_requirement!
|
50
|
+
@assigns
|
51
|
+
end
|
52
|
+
|
53
|
+
def remaining
|
54
|
+
@pile
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def no_or_skip?(arg)
|
60
|
+
arg =~ /^--(no|skip)-([-\w]+)$/
|
61
|
+
$2
|
62
|
+
end
|
63
|
+
|
64
|
+
def last?
|
65
|
+
@pile.empty?
|
66
|
+
end
|
67
|
+
|
68
|
+
def peek
|
69
|
+
@pile.first
|
70
|
+
end
|
71
|
+
|
72
|
+
def shift
|
73
|
+
@pile.shift
|
74
|
+
end
|
75
|
+
|
76
|
+
def unshift(arg)
|
77
|
+
if arg.is_a?(Array)
|
78
|
+
@pile = arg + @pile
|
79
|
+
else
|
80
|
+
@pile.unshift(arg)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def current_is_value?
|
85
|
+
peek && peek.to_s !~ /^-/
|
86
|
+
end
|
87
|
+
|
88
|
+
# Runs through the argument array getting strings that contains ":" and
|
89
|
+
# mark it as a hash:
|
90
|
+
#
|
91
|
+
# [ "name:string", "age:integer" ]
|
92
|
+
#
|
93
|
+
# Becomes:
|
94
|
+
#
|
95
|
+
# { "name" => "string", "age" => "integer" }
|
96
|
+
#
|
97
|
+
def parse_hash(name)
|
98
|
+
return shift if peek.is_a?(Hash)
|
99
|
+
hash = {}
|
100
|
+
|
101
|
+
while current_is_value? && peek.include?(":")
|
102
|
+
key, value = shift.split(":", 2)
|
103
|
+
raise MalformattedArgumentError, "You can't specify '#{key}' more than once in option '#{name}'; got #{key}:#{hash[key]} and #{key}:#{value}" if hash.include? key
|
104
|
+
hash[key] = value
|
105
|
+
end
|
106
|
+
hash
|
107
|
+
end
|
108
|
+
|
109
|
+
# Runs through the argument array getting all strings until no string is
|
110
|
+
# found or a switch is found.
|
111
|
+
#
|
112
|
+
# ["a", "b", "c"]
|
113
|
+
#
|
114
|
+
# And returns it as an array:
|
115
|
+
#
|
116
|
+
# ["a", "b", "c"]
|
117
|
+
#
|
118
|
+
def parse_array(name)
|
119
|
+
return shift if peek.is_a?(Array)
|
120
|
+
array = []
|
121
|
+
array << shift while current_is_value?
|
122
|
+
array
|
123
|
+
end
|
124
|
+
|
125
|
+
# Check if the peek is numeric format and return a Float or Integer.
|
126
|
+
# Check if the peek is included in enum if enum is provided.
|
127
|
+
# Otherwise raises an error.
|
128
|
+
#
|
129
|
+
def parse_numeric(name)
|
130
|
+
return shift if peek.is_a?(Numeric)
|
131
|
+
|
132
|
+
unless peek =~ NUMERIC && $& == peek
|
133
|
+
raise MalformattedArgumentError, "Expected numeric value for '#{name}'; got #{peek.inspect}"
|
134
|
+
end
|
135
|
+
|
136
|
+
value = $&.index(".") ? shift.to_f : shift.to_i
|
137
|
+
if @switches.is_a?(Hash) && switch = @switches[name]
|
138
|
+
if switch.enum && !switch.enum.include?(value)
|
139
|
+
raise MalformattedArgumentError, "Expected '#{name}' to be one of #{switch.enum.join(', ')}; got #{value}"
|
140
|
+
end
|
141
|
+
end
|
142
|
+
value
|
143
|
+
end
|
144
|
+
|
145
|
+
# Parse string:
|
146
|
+
# for --string-arg, just return the current value in the pile
|
147
|
+
# for --no-string-arg, nil
|
148
|
+
# Check if the peek is included in enum if enum is provided. Otherwise raises an error.
|
149
|
+
#
|
150
|
+
def parse_string(name)
|
151
|
+
if no_or_skip?(name)
|
152
|
+
nil
|
153
|
+
else
|
154
|
+
value = shift
|
155
|
+
if @switches.is_a?(Hash) && switch = @switches[name]
|
156
|
+
if switch.enum && !switch.enum.include?(value)
|
157
|
+
raise MalformattedArgumentError, "Expected '#{name}' to be one of #{switch.enum.join(', ')}; got #{value}"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
value
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# Raises an error if @non_assigned_required array is not empty.
|
165
|
+
#
|
166
|
+
def check_requirement!
|
167
|
+
return if @non_assigned_required.empty?
|
168
|
+
names = @non_assigned_required.map do |o|
|
169
|
+
o.respond_to?(:switch_name) ? o.switch_name : o.human_name
|
170
|
+
end.join("', '")
|
171
|
+
class_name = self.class.name.split("::").last.downcase
|
172
|
+
raise RequiredArgumentMissingError, "No value provided for required #{class_name} '#{names}'"
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
class Bundler::Thor
|
2
|
+
class Option < Argument #:nodoc:
|
3
|
+
attr_reader :aliases, :group, :lazy_default, :hide
|
4
|
+
|
5
|
+
VALID_TYPES = [:boolean, :numeric, :hash, :array, :string]
|
6
|
+
|
7
|
+
def initialize(name, options = {})
|
8
|
+
@check_default_type = options[:check_default_type]
|
9
|
+
options[:required] = false unless options.key?(:required)
|
10
|
+
super
|
11
|
+
@lazy_default = options[:lazy_default]
|
12
|
+
@group = options[:group].to_s.capitalize if options[:group]
|
13
|
+
@aliases = Array(options[:aliases])
|
14
|
+
@hide = options[:hide]
|
15
|
+
end
|
16
|
+
|
17
|
+
# This parse quick options given as method_options. It makes several
|
18
|
+
# assumptions, but you can be more specific using the option method.
|
19
|
+
#
|
20
|
+
# parse :foo => "bar"
|
21
|
+
# #=> Option foo with default value bar
|
22
|
+
#
|
23
|
+
# parse [:foo, :baz] => "bar"
|
24
|
+
# #=> Option foo with default value bar and alias :baz
|
25
|
+
#
|
26
|
+
# parse :foo => :required
|
27
|
+
# #=> Required option foo without default value
|
28
|
+
#
|
29
|
+
# parse :foo => 2
|
30
|
+
# #=> Option foo with default value 2 and type numeric
|
31
|
+
#
|
32
|
+
# parse :foo => :numeric
|
33
|
+
# #=> Option foo without default value and type numeric
|
34
|
+
#
|
35
|
+
# parse :foo => true
|
36
|
+
# #=> Option foo with default value true and type boolean
|
37
|
+
#
|
38
|
+
# The valid types are :boolean, :numeric, :hash, :array and :string. If none
|
39
|
+
# is given a default type is assumed. This default type accepts arguments as
|
40
|
+
# string (--foo=value) or booleans (just --foo).
|
41
|
+
#
|
42
|
+
# By default all options are optional, unless :required is given.
|
43
|
+
#
|
44
|
+
def self.parse(key, value)
|
45
|
+
if key.is_a?(Array)
|
46
|
+
name, *aliases = key
|
47
|
+
else
|
48
|
+
name = key
|
49
|
+
aliases = []
|
50
|
+
end
|
51
|
+
|
52
|
+
name = name.to_s
|
53
|
+
default = value
|
54
|
+
|
55
|
+
type = case value
|
56
|
+
when Symbol
|
57
|
+
default = nil
|
58
|
+
if VALID_TYPES.include?(value)
|
59
|
+
value
|
60
|
+
elsif required = (value == :required) # rubocop:disable AssignmentInCondition
|
61
|
+
:string
|
62
|
+
end
|
63
|
+
when TrueClass, FalseClass
|
64
|
+
:boolean
|
65
|
+
when Numeric
|
66
|
+
:numeric
|
67
|
+
when Hash, Array, String
|
68
|
+
value.class.name.downcase.to_sym
|
69
|
+
end
|
70
|
+
|
71
|
+
new(name.to_s, :required => required, :type => type, :default => default, :aliases => aliases)
|
72
|
+
end
|
73
|
+
|
74
|
+
def switch_name
|
75
|
+
@switch_name ||= dasherized? ? name : dasherize(name)
|
76
|
+
end
|
77
|
+
|
78
|
+
def human_name
|
79
|
+
@human_name ||= dasherized? ? undasherize(name) : name
|
80
|
+
end
|
81
|
+
|
82
|
+
def usage(padding = 0)
|
83
|
+
sample = if banner && !banner.to_s.empty?
|
84
|
+
"#{switch_name}=#{banner}".dup
|
85
|
+
else
|
86
|
+
switch_name
|
87
|
+
end
|
88
|
+
|
89
|
+
sample = "[#{sample}]".dup unless required?
|
90
|
+
|
91
|
+
if boolean?
|
92
|
+
sample << ", [#{dasherize('no-' + human_name)}]" unless (name == "force") || name.start_with?("no-")
|
93
|
+
end
|
94
|
+
|
95
|
+
if aliases.empty?
|
96
|
+
(" " * padding) << sample
|
97
|
+
else
|
98
|
+
"#{aliases.join(', ')}, #{sample}"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
VALID_TYPES.each do |type|
|
103
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
104
|
+
def #{type}?
|
105
|
+
self.type == #{type.inspect}
|
106
|
+
end
|
107
|
+
RUBY
|
108
|
+
end
|
109
|
+
|
110
|
+
protected
|
111
|
+
|
112
|
+
def validate!
|
113
|
+
raise ArgumentError, "An option cannot be boolean and required." if boolean? && required?
|
114
|
+
validate_default_type! if @check_default_type
|
115
|
+
end
|
116
|
+
|
117
|
+
def validate_default_type!
|
118
|
+
default_type = case @default
|
119
|
+
when nil
|
120
|
+
return
|
121
|
+
when TrueClass, FalseClass
|
122
|
+
required? ? :string : :boolean
|
123
|
+
when Numeric
|
124
|
+
:numeric
|
125
|
+
when Symbol
|
126
|
+
:string
|
127
|
+
when Hash, Array, String
|
128
|
+
@default.class.name.downcase.to_sym
|
129
|
+
end
|
130
|
+
|
131
|
+
raise ArgumentError, "Expected #{@type} default value for '#{switch_name}'; got #{@default.inspect} (#{default_type})" unless default_type == @type
|
132
|
+
end
|
133
|
+
|
134
|
+
def dasherized?
|
135
|
+
name.index("-") == 0
|
136
|
+
end
|
137
|
+
|
138
|
+
def undasherize(str)
|
139
|
+
str.sub(/^-{1,2}/, "")
|
140
|
+
end
|
141
|
+
|
142
|
+
def dasherize(str)
|
143
|
+
(str.length > 1 ? "--" : "-") + str.tr("_", "-")
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|