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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aff7e304f4ee483465531fc88771ed4bcbd27a81c9eb63616510f2b2f89f6329
4
- data.tar.gz: aec856c86c69065b0ee85ad09620c11633245989bc707e5d6e6a1737928601fc
3
+ metadata.gz: bad1a78b15f2aaf4c42b9c16d14526235ac1e3e64483178f78a05fd246562091
4
+ data.tar.gz: 718d34dac09ff4b6d2011637a978e549e29789544a0b57829501438cf56ca6dd
5
5
  SHA512:
6
- metadata.gz: '082ad13685f86dbbe1d30ba18cce0eb93facc735127c3cefd87e2ec4de31046d997a4fc377a5b202c691634e71cc26a974d9c9ed20a66ac4b37f1fdc4858ebfb'
7
- data.tar.gz: 5923d9e2f336efafac6d864eb4f7f5eddd230a8044abcb5cd10b7b7533f67e7cf981b01e8b34ee79a0be82aa10bde067cf7738349b6e256e48cf364f93717282
6
+ metadata.gz: 7f9367eabf3458bbf279db02c970a355d33cd994ec1dce15756ba2213cd630561e48b2ab0fe63bb17b80754e42fd7ef4986eef06a230070e708a4e668ce66f2a
7
+ data.tar.gz: acfafc40c9efe2035785662173e0fa6b48590d7e286b4cdd7785fa4b941de7d58e67d84d6615df27bc1854afd1844d287f370c23c1de33d568f98831f4c6e785
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ *.gem
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- file_downloader (0.1.0)
4
+ file_downloader (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # FileDownloader
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/file_downloader`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install file_downloader
15
+ ```
16
+ $ bundle install
17
+ ```
22
18
 
23
19
  ## Usage
24
20
 
25
- TODO: Write usage instructions here
21
+ Specify access url and filepath to download, like below.
26
22
 
27
- ## Development
23
+ ```ruby
24
+ FileDownloader.download(url: file_url, filepath: 'path/to/downloaded_file.csv')
25
+ ```
28
26
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
27
+ ## Development
30
28
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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/[USERNAME]/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.
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
@@ -1,3 +1,3 @@
1
1
  module FileDownloader
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  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.0
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-01 00:00:00.000000000 Z
11
+ date: 2021-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler