bundler-prehistoric 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (284) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +100 -0
  5. data/CHANGELOG.md +1640 -0
  6. data/CONTRIBUTING.md +32 -0
  7. data/DEVELOPMENT.md +117 -0
  8. data/Gemfile +3 -0
  9. data/ISSUES.md +96 -0
  10. data/LICENSE.md +23 -0
  11. data/README.md +46 -0
  12. data/Rakefile +256 -0
  13. data/UPGRADING.md +103 -0
  14. data/bin/bundle +21 -0
  15. data/bin/bundle_ruby +56 -0
  16. data/bin/bundler +21 -0
  17. data/bundler.gemspec +33 -0
  18. data/lib/bundler.rb +442 -0
  19. data/lib/bundler/backports/time.rb +7 -0
  20. data/lib/bundler/capistrano.rb +16 -0
  21. data/lib/bundler/cli.rb +395 -0
  22. data/lib/bundler/cli/binstubs.rb +38 -0
  23. data/lib/bundler/cli/cache.rb +34 -0
  24. data/lib/bundler/cli/check.rb +35 -0
  25. data/lib/bundler/cli/clean.rb +19 -0
  26. data/lib/bundler/cli/common.rb +54 -0
  27. data/lib/bundler/cli/config.rb +84 -0
  28. data/lib/bundler/cli/console.rb +39 -0
  29. data/lib/bundler/cli/exec.rb +37 -0
  30. data/lib/bundler/cli/gem.rb +101 -0
  31. data/lib/bundler/cli/init.rb +33 -0
  32. data/lib/bundler/cli/inject.rb +33 -0
  33. data/lib/bundler/cli/install.rb +133 -0
  34. data/lib/bundler/cli/open.rb +23 -0
  35. data/lib/bundler/cli/outdated.rb +80 -0
  36. data/lib/bundler/cli/package.rb +36 -0
  37. data/lib/bundler/cli/platform.rb +43 -0
  38. data/lib/bundler/cli/show.rb +48 -0
  39. data/lib/bundler/cli/update.rb +73 -0
  40. data/lib/bundler/cli/viz.rb +27 -0
  41. data/lib/bundler/constants.rb +5 -0
  42. data/lib/bundler/current_ruby.rb +155 -0
  43. data/lib/bundler/definition.rb +604 -0
  44. data/lib/bundler/dep_proxy.rb +43 -0
  45. data/lib/bundler/dependency.rb +106 -0
  46. data/lib/bundler/deployment.rb +59 -0
  47. data/lib/bundler/deprecate.rb +15 -0
  48. data/lib/bundler/dsl.rb +305 -0
  49. data/lib/bundler/endpoint_specification.rb +76 -0
  50. data/lib/bundler/env.rb +56 -0
  51. data/lib/bundler/environment.rb +42 -0
  52. data/lib/bundler/fetcher.rb +396 -0
  53. data/lib/bundler/friendly_errors.rb +42 -0
  54. data/lib/bundler/gem_helper.rb +169 -0
  55. data/lib/bundler/gem_helpers.rb +25 -0
  56. data/lib/bundler/gem_installer.rb +9 -0
  57. data/lib/bundler/gem_path_manipulation.rb +8 -0
  58. data/lib/bundler/gem_tasks.rb +2 -0
  59. data/lib/bundler/graph.rb +169 -0
  60. data/lib/bundler/index.rb +184 -0
  61. data/lib/bundler/injector.rb +64 -0
  62. data/lib/bundler/installer.rb +332 -0
  63. data/lib/bundler/lazy_specification.rb +83 -0
  64. data/lib/bundler/lockfile_parser.rb +146 -0
  65. data/lib/bundler/match_platform.rb +13 -0
  66. data/lib/bundler/parallel_workers.rb +18 -0
  67. data/lib/bundler/parallel_workers/thread_worker.rb +30 -0
  68. data/lib/bundler/parallel_workers/unix_worker.rb +101 -0
  69. data/lib/bundler/parallel_workers/worker.rb +69 -0
  70. data/lib/bundler/psyched_yaml.rb +26 -0
  71. data/lib/bundler/remote_specification.rb +57 -0
  72. data/lib/bundler/resolver.rb +534 -0
  73. data/lib/bundler/retry.rb +60 -0
  74. data/lib/bundler/ruby_dsl.rb +11 -0
  75. data/lib/bundler/ruby_version.rb +117 -0
  76. data/lib/bundler/rubygems_ext.rb +171 -0
  77. data/lib/bundler/rubygems_integration.rb +578 -0
  78. data/lib/bundler/runtime.rb +310 -0
  79. data/lib/bundler/settings.rb +176 -0
  80. data/lib/bundler/setup.rb +23 -0
  81. data/lib/bundler/shared_helpers.rb +110 -0
  82. data/lib/bundler/similarity_detector.rb +63 -0
  83. data/lib/bundler/source.rb +29 -0
  84. data/lib/bundler/source/git.rb +289 -0
  85. data/lib/bundler/source/git/git_proxy.rb +158 -0
  86. data/lib/bundler/source/path.rb +225 -0
  87. data/lib/bundler/source/path/installer.rb +38 -0
  88. data/lib/bundler/source/rubygems.rb +334 -0
  89. data/lib/bundler/source/svn.rb +260 -0
  90. data/lib/bundler/source/svn/svn_proxy.rb +110 -0
  91. data/lib/bundler/spec_set.rb +154 -0
  92. data/lib/bundler/ssl_certs/.document +1 -0
  93. data/lib/bundler/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +14 -0
  94. data/lib/bundler/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +23 -0
  95. data/lib/bundler/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +28 -0
  96. data/lib/bundler/ssl_certs/GeoTrustGlobalCA.pem +20 -0
  97. data/lib/bundler/ssl_certs/certificate_manager.rb +41 -0
  98. data/lib/bundler/templates/Executable +16 -0
  99. data/lib/bundler/templates/Executable.standalone +12 -0
  100. data/lib/bundler/templates/Gemfile +4 -0
  101. data/lib/bundler/templates/newgem/.travis.yml.tt +3 -0
  102. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  103. data/lib/bundler/templates/newgem/LICENSE.txt.tt +22 -0
  104. data/lib/bundler/templates/newgem/README.md.tt +31 -0
  105. data/lib/bundler/templates/newgem/Rakefile.tt +26 -0
  106. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  107. data/lib/bundler/templates/newgem/consolerc.tt +3 -0
  108. data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +3 -0
  109. data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
  110. data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
  111. data/lib/bundler/templates/newgem/gitignore.tt +16 -0
  112. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +12 -0
  113. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  114. data/lib/bundler/templates/newgem/newgem.gemspec.tt +38 -0
  115. data/lib/bundler/templates/newgem/rspec.tt +2 -0
  116. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +11 -0
  117. data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -0
  118. data/lib/bundler/templates/newgem/test/minitest_helper.rb.tt +4 -0
  119. data/lib/bundler/templates/newgem/test/test_newgem.rb.tt +11 -0
  120. data/lib/bundler/ui.rb +7 -0
  121. data/lib/bundler/ui/rg_proxy.rb +21 -0
  122. data/lib/bundler/ui/shell.rb +98 -0
  123. data/lib/bundler/ui/silent.rb +44 -0
  124. data/lib/bundler/vendor/.document +0 -0
  125. data/lib/bundler/vendor/net/http/faster.rb +26 -0
  126. data/lib/bundler/vendor/net/http/persistent.rb +1230 -0
  127. data/lib/bundler/vendor/net/http/persistent/ssl_reuse.rb +128 -0
  128. data/lib/bundler/vendor/thor.rb +480 -0
  129. data/lib/bundler/vendor/thor/actions.rb +319 -0
  130. data/lib/bundler/vendor/thor/actions/create_file.rb +103 -0
  131. data/lib/bundler/vendor/thor/actions/create_link.rb +59 -0
  132. data/lib/bundler/vendor/thor/actions/directory.rb +118 -0
  133. data/lib/bundler/vendor/thor/actions/empty_directory.rb +135 -0
  134. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +316 -0
  135. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +107 -0
  136. data/lib/bundler/vendor/thor/base.rb +656 -0
  137. data/lib/bundler/vendor/thor/command.rb +133 -0
  138. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +77 -0
  139. data/lib/bundler/vendor/thor/core_ext/io_binary_read.rb +10 -0
  140. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +98 -0
  141. data/lib/bundler/vendor/thor/error.rb +32 -0
  142. data/lib/bundler/vendor/thor/group.rb +281 -0
  143. data/lib/bundler/vendor/thor/invocation.rb +173 -0
  144. data/lib/bundler/vendor/thor/line_editor.rb +17 -0
  145. data/lib/bundler/vendor/thor/line_editor/basic.rb +35 -0
  146. data/lib/bundler/vendor/thor/line_editor/readline.rb +88 -0
  147. data/lib/bundler/vendor/thor/parser.rb +4 -0
  148. data/lib/bundler/vendor/thor/parser/argument.rb +73 -0
  149. data/lib/bundler/vendor/thor/parser/arguments.rb +175 -0
  150. data/lib/bundler/vendor/thor/parser/option.rb +121 -0
  151. data/lib/bundler/vendor/thor/parser/options.rb +218 -0
  152. data/lib/bundler/vendor/thor/rake_compat.rb +71 -0
  153. data/lib/bundler/vendor/thor/runner.rb +322 -0
  154. data/lib/bundler/vendor/thor/shell.rb +81 -0
  155. data/lib/bundler/vendor/thor/shell/basic.rb +420 -0
  156. data/lib/bundler/vendor/thor/shell/color.rb +149 -0
  157. data/lib/bundler/vendor/thor/shell/html.rb +126 -0
  158. data/lib/bundler/vendor/thor/util.rb +267 -0
  159. data/lib/bundler/vendor/thor/version.rb +3 -0
  160. data/lib/bundler/vendored_persistent.rb +3 -0
  161. data/lib/bundler/vendored_thor.rb +8 -0
  162. data/lib/bundler/version.rb +6 -0
  163. data/lib/bundler/vlad.rb +11 -0
  164. data/man/bundle-config.ronn +155 -0
  165. data/man/bundle-exec.ronn +136 -0
  166. data/man/bundle-install.ronn +372 -0
  167. data/man/bundle-package.ronn +59 -0
  168. data/man/bundle-platform.ronn +42 -0
  169. data/man/bundle-update.ronn +179 -0
  170. data/man/bundle.ronn +92 -0
  171. data/man/gemfile.5.ronn +369 -0
  172. data/man/index.txt +7 -0
  173. data/spec/bundler/bundler_spec.rb +74 -0
  174. data/spec/bundler/cli_spec.rb +16 -0
  175. data/spec/bundler/definition_spec.rb +21 -0
  176. data/spec/bundler/dsl_spec.rb +108 -0
  177. data/spec/bundler/friendly_errors_spec.rb +13 -0
  178. data/spec/bundler/gem_helper_spec.rb +225 -0
  179. data/spec/bundler/psyched_yaml_spec.rb +8 -0
  180. data/spec/bundler/retry_spec.rb +59 -0
  181. data/spec/bundler/settings_spec.rb +13 -0
  182. data/spec/bundler/source_spec.rb +25 -0
  183. data/spec/cache/gems_spec.rb +316 -0
  184. data/spec/cache/git_spec.rb +188 -0
  185. data/spec/cache/path_spec.rb +121 -0
  186. data/spec/cache/platform_spec.rb +53 -0
  187. data/spec/cache/svn_spec.rb +82 -0
  188. data/spec/commands/binstubs_spec.rb +246 -0
  189. data/spec/commands/check_spec.rb +278 -0
  190. data/spec/commands/clean_spec.rb +652 -0
  191. data/spec/commands/config_spec.rb +227 -0
  192. data/spec/commands/console_spec.rb +102 -0
  193. data/spec/commands/exec_spec.rb +367 -0
  194. data/spec/commands/help_spec.rb +39 -0
  195. data/spec/commands/init_spec.rb +39 -0
  196. data/spec/commands/inject_spec.rb +78 -0
  197. data/spec/commands/licenses_spec.rb +31 -0
  198. data/spec/commands/newgem_spec.rb +451 -0
  199. data/spec/commands/open_spec.rb +80 -0
  200. data/spec/commands/outdated_spec.rb +168 -0
  201. data/spec/commands/package_spec.rb +128 -0
  202. data/spec/commands/show_spec.rb +152 -0
  203. data/spec/install/binstubs_spec.rb +24 -0
  204. data/spec/install/bundler_spec.rb +146 -0
  205. data/spec/install/deploy_spec.rb +237 -0
  206. data/spec/install/gemfile/gemspec_spec.rb +170 -0
  207. data/spec/install/gemfile/git_spec.rb +967 -0
  208. data/spec/install/gemfile/path_spec.rb +480 -0
  209. data/spec/install/gemfile/svn_spec.rb +582 -0
  210. data/spec/install/gemfile_spec.rb +44 -0
  211. data/spec/install/gems/c_ext_spec.rb +48 -0
  212. data/spec/install/gems/dependency_api_spec.rb +580 -0
  213. data/spec/install/gems/env_spec.rb +107 -0
  214. data/spec/install/gems/flex_spec.rb +314 -0
  215. data/spec/install/gems/groups_spec.rb +308 -0
  216. data/spec/install/gems/mirror_spec.rb +39 -0
  217. data/spec/install/gems/platform_spec.rb +221 -0
  218. data/spec/install/gems/post_install_spec.rb +121 -0
  219. data/spec/install/gems/resolving_spec.rb +124 -0
  220. data/spec/install/gems/simple_case_spec.rb +386 -0
  221. data/spec/install/gems/standalone_spec.rb +260 -0
  222. data/spec/install/gems/sudo_spec.rb +136 -0
  223. data/spec/install/gems/win32_spec.rb +26 -0
  224. data/spec/install/gemspecs_spec.rb +50 -0
  225. data/spec/install/path_spec.rb +150 -0
  226. data/spec/install/post_bundle_message_spec.rb +142 -0
  227. data/spec/install/prereleases_spec.rb +43 -0
  228. data/spec/install/security_policy_spec.rb +77 -0
  229. data/spec/install/upgrade_spec.rb +26 -0
  230. data/spec/lock/git_spec.rb +34 -0
  231. data/spec/lock/lockfile_spec.rb +912 -0
  232. data/spec/lock/svn_spec.rb +35 -0
  233. data/spec/other/bundle_ruby_spec.rb +142 -0
  234. data/spec/other/cli_dispatch_spec.rb +21 -0
  235. data/spec/other/ext_spec.rb +60 -0
  236. data/spec/other/platform_spec.rb +1285 -0
  237. data/spec/other/ssl_cert_spec.rb +10 -0
  238. data/spec/quality_spec.rb +88 -0
  239. data/spec/realworld/dependency_api_spec.rb +60 -0
  240. data/spec/realworld/edgecases_spec.rb +177 -0
  241. data/spec/realworld/parallel_spec.rb +69 -0
  242. data/spec/resolver/basic_spec.rb +66 -0
  243. data/spec/resolver/platform_spec.rb +88 -0
  244. data/spec/runtime/executable_spec.rb +149 -0
  245. data/spec/runtime/load_spec.rb +107 -0
  246. data/spec/runtime/platform_spec.rb +90 -0
  247. data/spec/runtime/require_spec.rb +332 -0
  248. data/spec/runtime/setup_spec.rb +856 -0
  249. data/spec/runtime/with_clean_env_spec.rb +91 -0
  250. data/spec/spec_helper.rb +114 -0
  251. data/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +13 -0
  252. data/spec/support/artifice/endpoint.rb +71 -0
  253. data/spec/support/artifice/endpoint_500.rb +37 -0
  254. data/spec/support/artifice/endpoint_api_missing.rb +16 -0
  255. data/spec/support/artifice/endpoint_basic_authentication.rb +13 -0
  256. data/spec/support/artifice/endpoint_creds_diff_host.rb +38 -0
  257. data/spec/support/artifice/endpoint_extra.rb +31 -0
  258. data/spec/support/artifice/endpoint_extra_missing.rb +15 -0
  259. data/spec/support/artifice/endpoint_fallback.rb +17 -0
  260. data/spec/support/artifice/endpoint_host_redirect.rb +15 -0
  261. data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
  262. data/spec/support/artifice/endpoint_redirect.rb +15 -0
  263. data/spec/support/artifice/endpoint_strict_basic_authentication.rb +18 -0
  264. data/spec/support/artifice/endpoint_timeout.rb +13 -0
  265. data/spec/support/builders.rb +748 -0
  266. data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
  267. data/spec/support/fakeweb/windows.rb +23 -0
  268. data/spec/support/hax.rb +22 -0
  269. data/spec/support/helpers.rb +348 -0
  270. data/spec/support/indexes.rb +280 -0
  271. data/spec/support/less_than_proc.rb +14 -0
  272. data/spec/support/matchers.rb +77 -0
  273. data/spec/support/path.rb +81 -0
  274. data/spec/support/permissions.rb +10 -0
  275. data/spec/support/platforms.rb +94 -0
  276. data/spec/support/ruby_ext.rb +20 -0
  277. data/spec/support/rubygems_ext.rb +39 -0
  278. data/spec/support/streams.rb +13 -0
  279. data/spec/support/sudo.rb +16 -0
  280. data/spec/update/gems_spec.rb +201 -0
  281. data/spec/update/git_spec.rb +236 -0
  282. data/spec/update/source_spec.rb +63 -0
  283. data/spec/update/svn_spec.rb +100 -0
  284. metadata +486 -0
@@ -0,0 +1,43 @@
1
+ module Bundler
2
+ class DepProxy
3
+
4
+ attr_reader :required_by, :__platform, :dep
5
+
6
+ def initialize(dep, platform)
7
+ @dep, @__platform, @required_by = dep, platform, []
8
+ end
9
+
10
+ def hash
11
+ @hash ||= dep.hash
12
+ end
13
+
14
+ def ==(o)
15
+ dep == o.dep && __platform == o.__platform
16
+ end
17
+
18
+ alias eql? ==
19
+
20
+ def type
21
+ @dep.type
22
+ end
23
+
24
+ def name
25
+ @dep.name
26
+ end
27
+
28
+ def requirement
29
+ @dep.requirement
30
+ end
31
+
32
+ def to_s
33
+ "#{name} (#{requirement}) #{__platform}"
34
+ end
35
+
36
+ private
37
+
38
+ def method_missing(*args)
39
+ @dep.send(*args)
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,106 @@
1
+ require 'rubygems/dependency'
2
+ require 'bundler/shared_helpers'
3
+ require 'bundler/rubygems_ext'
4
+
5
+ module Bundler
6
+ class Dependency < Gem::Dependency
7
+ attr_reader :autorequire
8
+ attr_reader :groups
9
+ attr_reader :platforms
10
+
11
+ PLATFORM_MAP = {
12
+ :ruby => Gem::Platform::RUBY,
13
+ :ruby_18 => Gem::Platform::RUBY,
14
+ :ruby_19 => Gem::Platform::RUBY,
15
+ :ruby_20 => Gem::Platform::RUBY,
16
+ :ruby_21 => Gem::Platform::RUBY,
17
+ :mri => Gem::Platform::RUBY,
18
+ :mri_18 => Gem::Platform::RUBY,
19
+ :mri_19 => Gem::Platform::RUBY,
20
+ :mri_20 => Gem::Platform::RUBY,
21
+ :mri_21 => Gem::Platform::RUBY,
22
+ :rbx => Gem::Platform::RUBY,
23
+ :jruby => Gem::Platform::JAVA,
24
+ :jruby_18 => Gem::Platform::JAVA,
25
+ :jruby_19 => Gem::Platform::JAVA,
26
+ :mswin => Gem::Platform::MSWIN,
27
+ :mswin_18 => Gem::Platform::MSWIN,
28
+ :mswin_19 => Gem::Platform::MSWIN,
29
+ :mswin_20 => Gem::Platform::MSWIN,
30
+ :mswin_21 => Gem::Platform::MSWIN,
31
+ :mswin64 => Gem::Platform::MSWIN64,
32
+ :mswin64_19 => Gem::Platform::MSWIN64,
33
+ :mswin64_20 => Gem::Platform::MSWIN64,
34
+ :mswin64_21 => Gem::Platform::MSWIN64,
35
+ :mingw => Gem::Platform::MINGW,
36
+ :mingw_18 => Gem::Platform::MINGW,
37
+ :mingw_19 => Gem::Platform::MINGW,
38
+ :mingw_20 => Gem::Platform::MINGW,
39
+ :mingw_21 => Gem::Platform::MINGW,
40
+ :x64_mingw => Gem::Platform::X64_MINGW,
41
+ :x64_mingw_20 => Gem::Platform::X64_MINGW,
42
+ :x64_mingw_21 => Gem::Platform::X64_MINGW
43
+ }.freeze
44
+
45
+ def initialize(name, version, options = {}, &blk)
46
+ type = options["type"] || :runtime
47
+ super(name, version, type)
48
+
49
+ @autorequire = nil
50
+ @groups = Array(options["group"] || :default).map { |g| g.to_sym }
51
+ @source = options["source"]
52
+ @platforms = Array(options["platforms"])
53
+ @env = options["env"]
54
+
55
+ if options.key?('require')
56
+ @autorequire = Array(options['require'] || [])
57
+ end
58
+ end
59
+
60
+ def gem_platforms(valid_platforms)
61
+ return valid_platforms if @platforms.empty?
62
+
63
+ platforms = []
64
+ @platforms.each do |p|
65
+ platform = PLATFORM_MAP[p]
66
+ next unless valid_platforms.include?(platform)
67
+ platforms |= [platform]
68
+ end
69
+ platforms
70
+ end
71
+
72
+ def should_include?
73
+ current_env? && current_platform?
74
+ end
75
+
76
+ def current_env?
77
+ return true unless @env
78
+ if @env.is_a?(Hash)
79
+ @env.all? do |key, val|
80
+ ENV[key.to_s] && (val.is_a?(String) ? ENV[key.to_s] == val : ENV[key.to_s] =~ val)
81
+ end
82
+ else
83
+ ENV[@env.to_s]
84
+ end
85
+ end
86
+
87
+ def current_platform?
88
+ return true if @platforms.empty?
89
+ @platforms.any? { |p|
90
+ Bundler.current_ruby.send("#{p}?")
91
+ }
92
+ end
93
+
94
+ def to_lock
95
+ out = super
96
+ out << '!' if source
97
+ out << "\n"
98
+ end
99
+
100
+ def specific?
101
+ super
102
+ rescue NoMethodError
103
+ requirement != ">= 0"
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,59 @@
1
+ module Bundler
2
+ class Deployment
3
+ def self.define_task(context, task_method = :task, opts = {})
4
+ if defined?(Capistrano) && context.is_a?(Capistrano::Configuration)
5
+ context_name = "capistrano"
6
+ role_default = "{:except => {:no_release => true}}"
7
+ error_type = ::Capistrano::CommandError
8
+ else
9
+ context_name = "vlad"
10
+ role_default = "[:app]"
11
+ error_type = ::Rake::CommandFailedError
12
+ end
13
+
14
+ roles = context.fetch(:bundle_roles, false)
15
+ opts[:roles] = roles if roles
16
+
17
+ context.send :namespace, :bundle do
18
+ send :desc, <<-DESC
19
+ Install the current Bundler environment. By default, gems will be \
20
+ installed to the shared/bundle path. Gems in the development and \
21
+ test group will not be installed. The install command is executed \
22
+ with the --deployment and --quiet flags. If the bundle cmd cannot \
23
+ be found then you can override the bundle_cmd variable to specify \
24
+ which one it should use. The base path to the app is fetched from \
25
+ the :latest_release variable. Set it for custom deploy layouts.
26
+
27
+ You can override any of these defaults by setting the variables shown below.
28
+
29
+ N.B. bundle_roles must be defined before you require 'bundler/#{context_name}' \
30
+ in your deploy.rb file.
31
+
32
+ set :bundle_gemfile, "Gemfile"
33
+ set :bundle_dir, File.join(fetch(:shared_path), 'bundle')
34
+ set :bundle_flags, "--deployment --quiet"
35
+ set :bundle_without, [:development, :test]
36
+ set :bundle_cmd, "bundle" # e.g. "/opt/ruby/bin/bundle"
37
+ set :bundle_roles, #{role_default} # e.g. [:app, :batch]
38
+ DESC
39
+ send task_method, :install, opts do
40
+ bundle_cmd = context.fetch(:bundle_cmd, "bundle")
41
+ bundle_flags = context.fetch(:bundle_flags, "--deployment --quiet")
42
+ bundle_dir = context.fetch(:bundle_dir, File.join(context.fetch(:shared_path), 'bundle'))
43
+ bundle_gemfile = context.fetch(:bundle_gemfile, "Gemfile")
44
+ bundle_without = [*context.fetch(:bundle_without, [:development, :test])].compact
45
+ app_path = context.fetch(:latest_release)
46
+ if app_path.to_s.empty?
47
+ raise error_type.new("Cannot detect current release path - make sure you have deployed at least once.")
48
+ end
49
+ args = ["--gemfile #{File.join(app_path, bundle_gemfile)}"]
50
+ args << "--path #{bundle_dir}" unless bundle_dir.to_s.empty?
51
+ args << bundle_flags.to_s
52
+ args << "--without #{bundle_without.join(" ")}" unless bundle_without.empty?
53
+
54
+ run "cd #{app_path} && #{bundle_cmd} install #{args.join(' ')}"
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,15 @@
1
+ module Bundler
2
+
3
+ if defined? ::Deprecate
4
+ Deprecate = ::Deprecate
5
+ elsif defined? Gem::Deprecate
6
+ Deprecate = Gem::Deprecate
7
+ else
8
+ class Deprecate; end
9
+ end
10
+
11
+ unless Deprecate.respond_to?(:skip_during)
12
+ def Deprecate.skip_during; yield; end
13
+ end
14
+
15
+ end
@@ -0,0 +1,305 @@
1
+ require 'bundler/dependency'
2
+ require 'bundler/ruby_dsl'
3
+
4
+ module Bundler
5
+ class Dsl
6
+ include RubyDsl
7
+
8
+ def self.evaluate(gemfile, lockfile, unlock)
9
+ builder = new
10
+ builder.eval_gemfile(gemfile)
11
+ builder.to_definition(lockfile, unlock)
12
+ end
13
+
14
+ VALID_PLATFORMS = Bundler::Dependency::PLATFORM_MAP.keys.freeze
15
+
16
+ attr_accessor :dependencies
17
+
18
+ def initialize
19
+ @source = nil
20
+ @sources = []
21
+ @git_sources = {}
22
+ @dependencies = []
23
+ @groups = []
24
+ @platforms = []
25
+ @env = nil
26
+ @ruby_version = nil
27
+ add_git_sources
28
+ end
29
+
30
+ def rubygems_source
31
+ @rubygems_source ||= Source::Rubygems.new
32
+ end
33
+
34
+ def eval_gemfile(gemfile, contents = nil)
35
+ contents ||= Bundler.read_file(gemfile.to_s)
36
+ instance_eval(contents, gemfile.to_s, 1)
37
+ rescue SyntaxError => e
38
+ syntax_msg = e.message.gsub("#{gemfile.to_s}:", 'on line ')
39
+ raise GemfileError, "Gemfile syntax error #{syntax_msg}"
40
+ rescue ScriptError, RegexpError, NameError, ArgumentError => e
41
+ e.backtrace[0] = "#{e.backtrace[0]}: #{e.message} (#{e.class})"
42
+ Bundler.ui.warn e.backtrace.join("\n ")
43
+ raise GemfileError, "There was an error in your Gemfile," \
44
+ " and Bundler cannot continue."
45
+ end
46
+
47
+ def gemspec(opts = nil)
48
+ path = opts && opts[:path] || '.'
49
+ name = opts && opts[:name] || '{,*}'
50
+ development_group = opts && opts[:development_group] || :development
51
+ expanded_path = File.expand_path(path, Bundler.default_gemfile.dirname)
52
+
53
+ gemspecs = Dir[File.join(expanded_path, "#{name}.gemspec")]
54
+
55
+ case gemspecs.size
56
+ when 1
57
+ spec = Bundler.load_gemspec(gemspecs.first)
58
+ raise InvalidOption, "There was an error loading the gemspec at #{gemspecs.first}." unless spec
59
+ gem spec.name, :path => path
60
+ group(development_group) do
61
+ spec.development_dependencies.each do |dep|
62
+ gem dep.name, *(dep.requirement.as_list + [:type => :development])
63
+ end
64
+ end
65
+ when 0
66
+ raise InvalidOption, "There are no gemspecs at #{expanded_path}."
67
+ else
68
+ raise InvalidOption, "There are multiple gemspecs at #{expanded_path}. Please use the :name option to specify which one."
69
+ end
70
+ end
71
+
72
+ def gem(name, *args)
73
+ if name.is_a?(Symbol)
74
+ raise GemfileError, %{You need to specify gem names as Strings. Use 'gem "#{name.to_s}"' instead.}
75
+ end
76
+
77
+ options = args.last.is_a?(Hash) ? args.pop.dup : {}
78
+ version = args
79
+
80
+ normalize_options(name, version, options)
81
+
82
+ dep = Dependency.new(name, version, options)
83
+
84
+ # if there's already a dependency with this name we try to prefer one
85
+ if current = @dependencies.find { |d| d.name == dep.name }
86
+ if current.requirement != dep.requirement
87
+ if current.type == :development
88
+ @dependencies.delete current
89
+ elsif dep.type == :development
90
+ return
91
+ else
92
+ raise GemfileError, "You cannot specify the same gem twice with different version requirements.\n" \
93
+ "You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})"
94
+ end
95
+
96
+ else
97
+ Bundler.ui.warn "Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once.\n" \
98
+ "You should probably keep only one of them.\n" \
99
+ "While it's not a problem now, it could cause errors if you change the version of just one of them later."
100
+ end
101
+
102
+ if current.source != dep.source
103
+ if current.type == :development
104
+ @dependencies.delete current
105
+ elsif dep.type == :development
106
+ return
107
+ else
108
+ raise GemfileError, "You cannot specify the same gem twice coming from different sources.\n" \
109
+ "You specified that #{dep.name} (#{dep.requirement}) should come from " \
110
+ "#{current.source || 'an unspecified source'} and #{dep.source}\n"
111
+ end
112
+ end
113
+ end
114
+
115
+ @dependencies << dep
116
+ end
117
+
118
+ def source(source, options = {})
119
+ case source
120
+ when :gemcutter, :rubygems, :rubyforge then
121
+ Bundler.ui.warn "The source :#{source} is deprecated because HTTP " \
122
+ "requests are insecure.\nPlease change your source to 'https://" \
123
+ "rubygems.org' if possible, or 'http://rubygems.org' if not."
124
+ rubygems_source.add_remote "http://rubygems.org"
125
+ return
126
+ when String
127
+ rubygems_source.add_remote source
128
+ return
129
+ else
130
+ @source = source
131
+ if options[:prepend]
132
+ @sources = [@source] | @sources
133
+ else
134
+ @sources = @sources | [@source]
135
+ end
136
+
137
+ yield if block_given?
138
+ return @source
139
+ end
140
+ ensure
141
+ @source = nil
142
+ end
143
+
144
+ def git_source(name, &block)
145
+ unless block_given?
146
+ raise InvalidOption, "You need to pass a block to #git_source"
147
+ end
148
+
149
+ if valid_keys.include?(name.to_s)
150
+ raise InvalidOption, "You cannot use #{name} as a git source. It " \
151
+ "is a reserved key. Reserved keys are: #{valid_keys.join(", ")}"
152
+ end
153
+
154
+ @git_sources[name.to_s] = block
155
+ end
156
+
157
+ def path(path, options = {}, source_options = {}, &blk)
158
+ source Source::Path.new(normalize_hash(options).merge("path" => Pathname.new(path))), source_options, &blk
159
+ end
160
+
161
+ def git(uri, options = {}, source_options = {}, &blk)
162
+ unless block_given?
163
+ msg = "You can no longer specify a git source by itself. Instead, \n" \
164
+ "either use the :git option on a gem, or specify the gems that \n" \
165
+ "bundler should find in the git source by passing a block to \n" \
166
+ "the git method, like: \n\n" \
167
+ " git 'git://github.com/rails/rails.git' do\n" \
168
+ " gem 'rails'\n" \
169
+ " end"
170
+ raise DeprecatedError, msg
171
+ end
172
+
173
+ source Source::Git.new(normalize_hash(options).merge("uri" => uri)), source_options, &blk
174
+ end
175
+
176
+ def svn(uri, options = {}, source_options = {}, &blk)
177
+ unless block_given?
178
+ msg = "You can no longer specify a svn source by itself. Instead, \n" \
179
+ "either use the :svn option on a gem, or specify the gems that \n" \
180
+ "bundler should find in the svn source by passing a block to \n" \
181
+ "the svn method."
182
+ raise DeprecatedError, msg
183
+ end
184
+
185
+ source Source::SVN.new(normalize_hash(options).merge("uri" => uri)), source_options, &blk
186
+ end
187
+
188
+ def to_definition(lockfile, unlock)
189
+ @sources << rubygems_source unless @sources.include?(rubygems_source)
190
+ Definition.new(lockfile, @dependencies, @sources, unlock, @ruby_version)
191
+ end
192
+
193
+ def group(*args, &blk)
194
+ @groups.concat args
195
+ yield
196
+ ensure
197
+ args.each { @groups.pop }
198
+ end
199
+
200
+ def platforms(*platforms)
201
+ @platforms.concat platforms
202
+ yield
203
+ ensure
204
+ platforms.each { @platforms.pop }
205
+ end
206
+ alias_method :platform, :platforms
207
+
208
+ def env(name)
209
+ @env, old = name, @env
210
+ yield
211
+ ensure
212
+ @env = old
213
+ end
214
+
215
+ def method_missing(name, *args)
216
+ location = caller[0].split(':')[0..1].join(':')
217
+ raise GemfileError, "Undefined local variable or method `#{name}' for Gemfile\n" \
218
+ " from #{location}"
219
+ end
220
+
221
+ private
222
+
223
+ def add_git_sources
224
+ git_source(:github) do |repo_name|
225
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
226
+ "git://github.com/#{repo_name}.git"
227
+ end
228
+
229
+ git_source(:gist){ |repo_name| "https://gist.github.com/#{repo_name}.git" }
230
+
231
+ git_source(:bitbucket) do |repo_name|
232
+ user_name, repo_name = repo_name.split '/'
233
+ repo_name ||= user_name
234
+ "https://#{user_name}@bitbucket.org/#{user_name}/#{repo_name}.git"
235
+ end
236
+ end
237
+
238
+ def normalize_hash(opts)
239
+ opts.keys.each do |k|
240
+ opts[k.to_s] = opts.delete(k) unless k.is_a?(String)
241
+ end
242
+ opts
243
+ end
244
+
245
+ def valid_keys
246
+ @valid_keys ||= %w(group groups git svn path name branch ref tag require submodules platform platforms type)
247
+ end
248
+
249
+ def normalize_options(name, version, opts)
250
+ normalize_hash(opts)
251
+
252
+ git_names = @git_sources.keys.map(&:to_s)
253
+
254
+ invalid_keys = opts.keys - (valid_keys + git_names)
255
+ if invalid_keys.any?
256
+ message = "You passed #{invalid_keys.map{|k| ':'+k }.join(", ")} "
257
+ message << if invalid_keys.size > 1
258
+ "as options for gem '#{name}', but they are invalid."
259
+ else
260
+ "as an option for gem '#{name}', but it is invalid."
261
+ end
262
+
263
+ message << " Valid options are: #{valid_keys.join(", ")}"
264
+ raise InvalidOption, message
265
+ end
266
+
267
+ groups = @groups.dup
268
+ opts["group"] = opts.delete("groups") || opts["group"]
269
+ groups.concat Array(opts.delete("group"))
270
+ groups = [:default] if groups.empty?
271
+
272
+ platforms = @platforms.dup
273
+ opts["platforms"] = opts["platform"] || opts["platforms"]
274
+ platforms.concat Array(opts.delete("platforms"))
275
+ platforms.map! { |p| p.to_sym }
276
+ platforms.each do |p|
277
+ next if VALID_PLATFORMS.include?(p)
278
+ raise GemfileError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}"
279
+ end
280
+
281
+ git_name = (git_names & opts.keys).last
282
+ if @git_sources[git_name]
283
+ opts["git"] = @git_sources[git_name].call(opts[git_name])
284
+ end
285
+
286
+ ["git", "path", "svn"].each do |type|
287
+ if param = opts[type]
288
+ if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/
289
+ options = opts.merge("name" => name, "version" => $1)
290
+ else
291
+ options = opts.dup
292
+ end
293
+ source = send(type, param, options, :prepend => true) {}
294
+ opts["source"] = source
295
+ end
296
+ end
297
+
298
+ opts["source"] ||= @source
299
+ opts["env"] ||= @env
300
+ opts["platforms"] = platforms.dup
301
+ opts["group"] = groups
302
+ end
303
+
304
+ end
305
+ end