bundler-download 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c510e683dd2ec94c94ac33ae12c2e5776ac48cb2bba048eaa996a26910e35c94
4
- data.tar.gz: 22c912fc084b77506db7170abdbc6292742f294b7ade309ce4c17a770b0fcff2
3
+ metadata.gz: f64d8149b156977c05751eaecef7826a3ee378ebdb5d529f0875597b11d4a5d9
4
+ data.tar.gz: 41bb7ad2e11cd1bcd47f0557c0d512ae5312a6193f2a518cfb7de7e1c0f7639d
5
5
  SHA512:
6
- metadata.gz: f9b624db4e06692595b0a9b5e430d0e7ceb299ad7de6a27d18b6611c28484bcae7bad9e1771c4beffd45e1a586f667920e46ba9d2a3fe86e2bfe1fc8bc8cc229
7
- data.tar.gz: c0503acbebf26d166709d97051cfea861f9256799fadd08d5226d5ad84be1ef47617bcd65990d1b57b74ae55a2913e9b179ffdf85ff6263cb01e516f52b5dcb5
6
+ metadata.gz: 1c8ff5f7452e4c1e4e0a2a118ce0e899f0334a0695a0ffa31c9f6458d12e7ca46c119af843dade3c27812f65cec7c1fa3b4ef31ae4dcfbb3553acec471329c22
7
+ data.tar.gz: a8f98b7bd09a75514558b09a22f5a9026c72214d7eefcb408c8e267feca121a828fa2651ef82c67cba4e9f203cc0bedfd8334f8222c0f1ec296bdee2cc6389c2
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.2.0
4
+
5
+ - Get rid of httparty
6
+ - Only download files for Gemfile gems
7
+
3
8
  ## 1.1.0
4
9
 
5
10
  - Add a post install message
data/README.md CHANGED
@@ -3,6 +3,14 @@
3
3
 
4
4
  Bundler plugin for auto-downloading extra gem files (e.g. large file downloads) specified in [`Downloadfile`](#downloadfile) after `bundle install`.
5
5
 
6
+ ## Background
7
+
8
+ The RubyGem ecosystem, famous for gems like Rails for web development, Devise for authentication, and Pundit for authorization, enables productivity via code reuse. As such, it is great for quickly adding libraries to your project to automate part of the work or reuse other people's solutions to solved problems.
9
+
10
+ That said, you would not want to package extremely large files, like the OpenAI GPT-3 175 billion parameter models, in a RubyGem.
11
+
12
+ Enter [bundler-download](https://rubygems.org/gems/bundler-download), a Bundler Plugin that enables downloading extra gem files after installing with with `bundle install` by declaring gem downloads in a [Downloadfile](#downloadfile)
13
+
6
14
  ## How It Works
7
15
 
8
16
  Gems can add a [`Downloadfile`](#downloadfile) at the root to declare the need for extra downloads upon install by Bundler.
@@ -13,7 +21,7 @@ If a Ruby Gem needs to depend on one of those gems, it can declare as a standard
13
21
 
14
22
  ## Gem Instructions
15
23
 
16
- Add [bundler-download](https://rubygems.org/gems/bundler-download) as a standard .gemspec dependency (and mention in its [instructions](#app-instructions) that apps must add `plugin bundler-download` in "Gemfile" to get the extra downloads):
24
+ Add [bundler-download](https://rubygems.org/gems/bundler-download) as a standard .gemspec dependency:
17
25
 
18
26
  ```ruby
19
27
  s.add_dependency('bundler-download', [">= 1.1.0"])
@@ -29,10 +37,20 @@ Afterwards, ensure there is a [`Downloadfile`](#downloadfile) at the root direct
29
37
  ]
30
38
  ```
31
39
 
40
+ Finally, follow one of two options for having applications obtain downloads:
41
+ 1. Advertise that apps must install `bundler-download` as a Bundler plugin as per the [App Bundler Plugin Instructions](#app-bundler-plugin-instructions) below.
42
+ 2. Use the [API](#api) to automatically trigger downloads on first use of your gem features.
43
+
32
44
  ### Downloadfile
33
45
 
34
46
  A gem `Downloadfile` contains `download` links for files that need to be downloaded relative to the gem directory after `bundle install`.
35
47
 
48
+ Downloadfile entries follow this format (keyword args are optional):
49
+
50
+ ```
51
+ download url, to: gem_subdirectory, os: os
52
+ ```
53
+
36
54
  Example `Downloadfile`:
37
55
 
38
56
  ```
@@ -48,12 +66,13 @@ The keyword `download` declares a file to download and takes the following argum
48
66
  2. `to:` keyword arg: mentions a local download path relative to the gem installation directory (e.g. 'vendor' or 'lib/ai/data'). It automatically creates the path with all its subdirectories if it does not already exist. If left empty, then the file is downloaded to the gem directory root path.
49
67
  3. `os:` keyword arg (value: `mac` / `windows` / `linux`): limits the operating system under which the download is made. It is `nil` by default, allowing the download to occur in all operating systems.
50
68
 
51
- ## App Instructions
69
+ ## App Bundler Plugin Instructions
52
70
 
53
71
  An app can depend on a gem that has a `Downloadfile` by adding the `bundler-download` plugin first (or manually installing via `bundle plugin install bundler-download`) and then including the gem in `Gemfile` like it normally would:
54
72
 
55
73
  ```
56
74
  plugin 'bundler-download'
75
+
57
76
  gem 'some_gem_with_downloadfile'
58
77
  ```
59
78
 
@@ -205,6 +224,18 @@ Showing downloaded files for /Users/User/.rvm/gems/ruby-2.7.1@bundler-download/g
205
224
  54070695 /Users/User/.rvm/gems/ruby-2.7.1@bundler-download/gems/glimmer-cw-browser-chromium-1.0.0/vendor/jars/mac/com.make.chromium.cef.cocoa.macosx.x86_64_0.4.0.202005172227.jar
206
225
  ```
207
226
 
227
+ ### API
228
+
229
+ Apps may choose to integrate with the [bundler-download](https://rubygems.org/gems/bundler-download) gem directly to trigger downloads instead of relying on the plugin.
230
+ This can be useful when wanting to trigger downloads only on first use while staying transparent should the gem features not be used.
231
+
232
+ To do so, simply include this Ruby code to trigger downloads:
233
+
234
+ ```ruby
235
+ require 'bundler-download'
236
+ Bundler::Download.new.exec('download', [])
237
+ ```
238
+
208
239
  ## Contributing to bundler-download
209
240
 
210
241
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -1,17 +1,17 @@
1
- # Generated by jeweler
1
+ # Generated by juwelier
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
3
+ # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: bundler-download 1.1.0 ruby lib
5
+ # stub: bundler-download 1.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "bundler-download".freeze
9
- s.version = "1.1.0"
9
+ s.version = "1.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["AndyMaleh".freeze]
14
- s.date = "2020-09-23"
14
+ s.date = "2020-09-25"
15
15
  s.description = "bundler-download is a Bundler plugin for auto-downloading gem-specified extra files (e.g. large file downloads) on `bundle install` from a `Downloadfile`".freeze
16
16
  s.email = "andy.am@gmail.com".freeze
17
17
  s.executables = ["bundler-download".freeze]
@@ -46,11 +46,10 @@ Gem::Specification.new do |s|
46
46
  if s.respond_to? :add_runtime_dependency then
47
47
  s.add_runtime_dependency(%q<bundler>.freeze, [">= 2.0.0", "< 3.0.0"])
48
48
  s.add_runtime_dependency(%q<download>.freeze, [">= 1.1.0", "< 2.0.0"])
49
- s.add_runtime_dependency(%q<httparty>.freeze, [">= 0.18.1", "< 2.0.0"])
50
49
  s.add_runtime_dependency(%q<os>.freeze, [">= 1.1.1", "< 2.0.0"])
51
50
  s.add_runtime_dependency(%q<tty-progressbar>.freeze, [">= 0.17.0", "< 2.0.0"])
52
51
  s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
53
- s.add_development_dependency(%q<jeweler>.freeze, [">= 2.3.5"])
52
+ s.add_development_dependency(%q<juwelier>.freeze, [">= 2.4.9"])
54
53
  s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
55
54
  s.add_development_dependency(%q<puts_debuggerer>.freeze, [">= 0"])
56
55
  s.add_development_dependency(%q<pessimize>.freeze, [">= 0"])
@@ -58,11 +57,10 @@ Gem::Specification.new do |s|
58
57
  else
59
58
  s.add_dependency(%q<bundler>.freeze, [">= 2.0.0", "< 3.0.0"])
60
59
  s.add_dependency(%q<download>.freeze, [">= 1.1.0", "< 2.0.0"])
61
- s.add_dependency(%q<httparty>.freeze, [">= 0.18.1", "< 2.0.0"])
62
60
  s.add_dependency(%q<os>.freeze, [">= 1.1.1", "< 2.0.0"])
63
61
  s.add_dependency(%q<tty-progressbar>.freeze, [">= 0.17.0", "< 2.0.0"])
64
62
  s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
65
- s.add_dependency(%q<jeweler>.freeze, [">= 2.3.5"])
63
+ s.add_dependency(%q<juwelier>.freeze, [">= 2.4.9"])
66
64
  s.add_dependency(%q<simplecov>.freeze, [">= 0"])
67
65
  s.add_dependency(%q<puts_debuggerer>.freeze, [">= 0"])
68
66
  s.add_dependency(%q<pessimize>.freeze, [">= 0"])
@@ -20,9 +20,9 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'bundler'
23
+ require 'bundler/setup'
23
24
  require 'download'
24
25
  require 'fileutils'
25
- require 'httparty'
26
26
  require 'os'
27
27
  require 'tty-progressbar'
28
28
 
@@ -35,13 +35,27 @@ module Download
35
35
  File.delete(file_path) if File.exist?(file_path)
36
36
  end
37
37
 
38
+ def final_uri_and_head_response
39
+ location = url
40
+ head_response = nil
41
+ begin
42
+ uri = URI(location)
43
+ options = {}
44
+ options.merge!(use_ssl: true) if location.start_with?('https:')
45
+ head_response = Net::HTTP.start(uri.hostname, uri.port, options) do |http|
46
+ http.head(uri)
47
+ end
48
+ location = head_response['location'] if head_response['location']
49
+ end while head_response.is_a?(Net::HTTPRedirection)
50
+ [uri, head_response]
51
+ end
52
+
38
53
  def start(hash={})
39
54
  set_multi(hash)
40
55
  return puts("Download '#{file_path}' already exists! (run `bundle download` to redownload)") if options.keys.include?('--keep_existing') && File.exist?(file_path)
41
56
 
42
- head_response = HTTParty.head(url)
43
- uri = head_response.request.uri
44
- content_length = head_response.headers["content-length"]
57
+ uri, head_response = final_uri_and_head_response
58
+ content_length = head_response["content-length"]
45
59
  puts "Download URL: #{uri.to_s}"
46
60
  puts "Download size: #{content_length}"
47
61
  puts "Download path: #{file_path}"
@@ -27,7 +27,9 @@ module Bundler
27
27
  begin
28
28
  subcommand = extract_subcommand(args) || 'start'
29
29
  return puts("Invalid subcommand: #{subcommand} \nValid `bundle download` subcommands are: #{Bundler::Downloadfile::SUBCOMMANDS.join(' / ')}") unless Bundler::Downloadfile::SUBCOMMANDS.include?(subcommand)
30
- downloadfiles = Dir.glob(File.join(Gem.dir, 'gems', '**', 'Downloadfile')).to_a
30
+ downloadfiles = Dir.glob(File.join(Gem.dir, 'gems', '**', 'Downloadfile')).to_a
31
+ loaded_gems = Gem.loaded_specs.keys
32
+ downloadfiles = downloadfiles.select {|df| loaded_gems.detect {|gem| File.basename(File.dirname(df)).include?(gem)} }
31
33
  puts 'No gems were found with Downloadfile.' if downloadfiles.empty?
32
34
  downloadfiles.each do |downloadfile|
33
35
  bundler_downloadfile = Bundler::Downloadfile.new(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler-download
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndyMaleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-23 00:00:00.000000000 Z
11
+ date: 2020-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -50,26 +50,6 @@ dependencies:
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: 2.0.0
53
- - !ruby/object:Gem::Dependency
54
- name: httparty
55
- requirement: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- version: 0.18.1
60
- - - "<"
61
- - !ruby/object:Gem::Version
62
- version: 2.0.0
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: 0.18.1
70
- - - "<"
71
- - !ruby/object:Gem::Version
72
- version: 2.0.0
73
53
  - !ruby/object:Gem::Dependency
74
54
  name: os
75
55
  requirement: !ruby/object:Gem::Requirement
@@ -125,19 +105,19 @@ dependencies:
125
105
  - !ruby/object:Gem::Version
126
106
  version: 3.5.0
127
107
  - !ruby/object:Gem::Dependency
128
- name: jeweler
108
+ name: juwelier
129
109
  requirement: !ruby/object:Gem::Requirement
130
110
  requirements:
131
111
  - - ">="
132
112
  - !ruby/object:Gem::Version
133
- version: 2.3.5
113
+ version: 2.4.9
134
114
  type: :development
135
115
  prerelease: false
136
116
  version_requirements: !ruby/object:Gem::Requirement
137
117
  requirements:
138
118
  - - ">="
139
119
  - !ruby/object:Gem::Version
140
- version: 2.3.5
120
+ version: 2.4.9
141
121
  - !ruby/object:Gem::Dependency
142
122
  name: simplecov
143
123
  requirement: !ruby/object:Gem::Requirement