file_downloader 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +13 -13
- data/lib/file_downloader/service.rb +3 -1
- data/lib/file_downloader/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bad1a78b15f2aaf4c42b9c16d14526235ac1e3e64483178f78a05fd246562091
|
4
|
+
data.tar.gz: 718d34dac09ff4b6d2011637a978e549e29789544a0b57829501438cf56ca6dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f9367eabf3458bbf279db02c970a355d33cd994ec1dce15756ba2213cd630561e48b2ab0fe63bb17b80754e42fd7ef4986eef06a230070e708a4e668ce66f2a
|
7
|
+
data.tar.gz: acfafc40c9efe2035785662173e0fa6b48590d7e286b4cdd7785fa4b941de7d58e67d84d6615df27bc1854afd1844d287f370c23c1de33d568f98831f4c6e785
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -26,6 +26,9 @@ AllCops:
|
|
26
26
|
|
27
27
|
#################### Layout ################################
|
28
28
|
|
29
|
+
Layout/EmptyLineBetweenDefs:
|
30
|
+
Enabled: false
|
31
|
+
|
29
32
|
# .の位置指定、テストの.to hogehogeも見られてしまう
|
30
33
|
Layout/DotPosition:
|
31
34
|
Enabled: false
|
@@ -154,6 +157,9 @@ RSpec/SharedExamples:
|
|
154
157
|
RSpec/VerifiedDoubles:
|
155
158
|
Enabled: false
|
156
159
|
|
160
|
+
RSpec/MultipleMemoizedHelpers:
|
161
|
+
Enabled: false
|
162
|
+
|
157
163
|
##################### Style ##################################
|
158
164
|
|
159
165
|
# 日本語コメントを許可する
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# FileDownloader
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Complete downloading huge file even if connection interrupted few times.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -14,25 +12,27 @@ gem 'file_downloader'
|
|
14
12
|
|
15
13
|
And then execute:
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
$ gem install file_downloader
|
15
|
+
```
|
16
|
+
$ bundle install
|
17
|
+
```
|
22
18
|
|
23
19
|
## Usage
|
24
20
|
|
25
|
-
|
21
|
+
Specify access url and filepath to download, like below.
|
26
22
|
|
27
|
-
|
23
|
+
```ruby
|
24
|
+
FileDownloader.download(url: file_url, filepath: 'path/to/downloaded_file.csv')
|
25
|
+
```
|
28
26
|
|
29
|
-
|
27
|
+
## Development
|
30
28
|
|
31
|
-
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies & run rspec.
|
30
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
31
|
+
You can also run `bundle exec rspec` to test with RSpec.
|
32
32
|
|
33
33
|
## Contributing
|
34
34
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/sukechannnn/file_downloader. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
36
|
|
37
37
|
## License
|
38
38
|
|
@@ -2,9 +2,10 @@ require 'file_downloader/status'
|
|
2
2
|
require 'logger'
|
3
3
|
|
4
4
|
module FileDownloader
|
5
|
+
class NoResponseBodyError < StandardError; end
|
5
6
|
class NotEofError < StandardError; end
|
6
|
-
class Service
|
7
7
|
|
8
|
+
class Service
|
8
9
|
def initialize(url, filepath, logger: nil)
|
9
10
|
@url = url
|
10
11
|
@filepath = filepath
|
@@ -17,6 +18,7 @@ module FileDownloader
|
|
17
18
|
http = Net::HTTP.new(uri.host, uri.port)
|
18
19
|
|
19
20
|
content_length = fetch_content_length(http, uri)
|
21
|
+
raise NoResponseBodyError if content_length.to_i.zero?
|
20
22
|
download_file(http, uri, content_length)
|
21
23
|
filepath
|
22
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file_downloader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sukechannnn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|