simple-images-downloader 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +76 -0
- data/.codeclimate.yml +22 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +3 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +114 -0
- data/LICENSE.txt +21 -0
- data/README.md +94 -0
- data/Rakefile +8 -0
- data/bin/bundle +118 -0
- data/bin/console +8 -0
- data/bin/quality +5 -0
- data/bin/rspec +29 -0
- data/bin/rubocop +29 -0
- data/bin/setup +10 -0
- data/exe/simple-images-downloader +6 -0
- data/lib/simple_images_downloader.rb +31 -0
- data/lib/simple_images_downloader/configuration.rb +38 -0
- data/lib/simple_images_downloader/dispenser.rb +30 -0
- data/lib/simple_images_downloader/downloader.rb +38 -0
- data/lib/simple_images_downloader/errors.rb +56 -0
- data/lib/simple_images_downloader/file_persistance_validator.rb +13 -0
- data/lib/simple_images_downloader/image_path_validator.rb +21 -0
- data/lib/simple_images_downloader/line.rb +19 -0
- data/lib/simple_images_downloader/runner.rb +11 -0
- data/lib/simple_images_downloader/source_file.rb +26 -0
- data/lib/simple_images_downloader/stringio_to_tempfile.rb +19 -0
- data/lib/simple_images_downloader/version.rb +5 -0
- data/rubocop.yml +82 -0
- data/simple_images_downloader.gemspec +48 -0
- metadata +291 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d74a26bb02459d8c947be5eb6b65d48c66051ec16dd48e47608acd2fed73ca72
|
4
|
+
data.tar.gz: 17dcfdea734ca6e34af6d7101934ce30cdbebee1a29e4aec7c83e5a64655403e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4d77886c3fa5354f4185b63027db07d70006f4c1d91c26d7013a7e8b5e54e1f17771e946d8525d3b7a4d553db9a893c413bf8e8e3e5019c0738c4caf4932b9c4
|
7
|
+
data.tar.gz: ed38e45e846bf08a3d83c231b1cc72877740cd1be912232494cc02623bf89ba51b3bac7845ef4028394e50941f67a95963634a2ef745c7256f695e72ecef59ce
|
@@ -0,0 +1,76 @@
|
|
1
|
+
version: 2.1
|
2
|
+
orbs:
|
3
|
+
ruby: circleci/ruby@1.1.0
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
tests:
|
7
|
+
docker:
|
8
|
+
- image: circleci/ruby:2.7.1
|
9
|
+
environment:
|
10
|
+
COVERAGE_DIR: ./coverage
|
11
|
+
executor: ruby/default
|
12
|
+
steps:
|
13
|
+
- checkout
|
14
|
+
- ruby/install-deps
|
15
|
+
|
16
|
+
- restore_cache:
|
17
|
+
keys:
|
18
|
+
- code-climate-reporter-v1
|
19
|
+
|
20
|
+
- run:
|
21
|
+
name: Download cc-test-reporter
|
22
|
+
command: |
|
23
|
+
if ! [ -f ./cc-test-reporter ]; then
|
24
|
+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
25
|
+
chmod +x ./cc-test-reporter
|
26
|
+
fi
|
27
|
+
|
28
|
+
- save_cache:
|
29
|
+
key: code-climate-reporter-v1
|
30
|
+
paths:
|
31
|
+
- ./cc-test-reporter
|
32
|
+
|
33
|
+
- run:
|
34
|
+
name: Prepare Code Climate Reporter
|
35
|
+
command: ./cc-test-reporter before-build
|
36
|
+
|
37
|
+
- ruby/rspec-test
|
38
|
+
|
39
|
+
- run:
|
40
|
+
name: Code Climate Test Coverage
|
41
|
+
command: |
|
42
|
+
./cc-test-reporter format-coverage -t simplecov -o "$COVERAGE_DIR/codeclimate.$CIRCLE_NODE_INDEX.json"
|
43
|
+
|
44
|
+
- persist_to_workspace:
|
45
|
+
root: ./
|
46
|
+
paths:
|
47
|
+
- coverage/**
|
48
|
+
- cc-test-reporter
|
49
|
+
|
50
|
+
- run:
|
51
|
+
name: Run quality checks
|
52
|
+
command: bin/quality
|
53
|
+
|
54
|
+
upload-coverage:
|
55
|
+
docker:
|
56
|
+
- image: circleci/ruby:2.7.1
|
57
|
+
steps:
|
58
|
+
- checkout
|
59
|
+
|
60
|
+
- attach_workspace:
|
61
|
+
at: .
|
62
|
+
- run:
|
63
|
+
command: |
|
64
|
+
./cc-test-reporter sum-coverage --output - ./coverage/codeclimate.*.json | ./cc-test-reporter upload-coverage --debug --input -
|
65
|
+
|
66
|
+
workflows:
|
67
|
+
CD:
|
68
|
+
jobs:
|
69
|
+
- tests
|
70
|
+
- upload-coverage:
|
71
|
+
requires:
|
72
|
+
- tests
|
73
|
+
filters:
|
74
|
+
branches:
|
75
|
+
only:
|
76
|
+
- master
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
version: "2"
|
2
|
+
plugins:
|
3
|
+
brakeman:
|
4
|
+
enabled: false
|
5
|
+
bundler-audit:
|
6
|
+
enabled: true
|
7
|
+
nodesecurity:
|
8
|
+
enabled: true
|
9
|
+
coffeelint:
|
10
|
+
enabled: false
|
11
|
+
duplication:
|
12
|
+
enabled: true
|
13
|
+
config:
|
14
|
+
languages:
|
15
|
+
- ruby
|
16
|
+
fixme:
|
17
|
+
enabled: true
|
18
|
+
rubocop:
|
19
|
+
enabled: false
|
20
|
+
exclude_patterns:
|
21
|
+
- bin/
|
22
|
+
- spec/
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.1
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at ilgamgaysin@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
simple-images-downloader (1.0.0)
|
5
|
+
zeitwerk
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.7.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
ast (2.4.1)
|
13
|
+
bundler-audit (0.7.0.1)
|
14
|
+
bundler (>= 1.2.0, < 3)
|
15
|
+
thor (>= 0.18, < 2)
|
16
|
+
byebug (11.1.3)
|
17
|
+
coderay (1.1.3)
|
18
|
+
concurrent-ruby (1.1.7)
|
19
|
+
crack (0.4.4)
|
20
|
+
diff-lcs (1.4.4)
|
21
|
+
docile (1.3.2)
|
22
|
+
faker (2.14.0)
|
23
|
+
i18n (>= 1.6, < 2)
|
24
|
+
hashdiff (1.0.1)
|
25
|
+
i18n (1.8.5)
|
26
|
+
concurrent-ruby (~> 1.0)
|
27
|
+
json (2.3.1)
|
28
|
+
memory_profiler (0.9.14)
|
29
|
+
method_source (1.0.0)
|
30
|
+
parallel (1.19.2)
|
31
|
+
parser (2.7.1.4)
|
32
|
+
ast (~> 2.4.1)
|
33
|
+
pry (0.13.1)
|
34
|
+
coderay (~> 1.1)
|
35
|
+
method_source (~> 1.0)
|
36
|
+
pry-byebug (3.9.0)
|
37
|
+
byebug (~> 11.0)
|
38
|
+
pry (~> 0.13.0)
|
39
|
+
public_suffix (4.0.6)
|
40
|
+
rainbow (3.0.0)
|
41
|
+
rake (12.3.3)
|
42
|
+
regexp_parser (1.7.1)
|
43
|
+
rexml (3.2.4)
|
44
|
+
rspec (3.9.0)
|
45
|
+
rspec-core (~> 3.9.0)
|
46
|
+
rspec-expectations (~> 3.9.0)
|
47
|
+
rspec-mocks (~> 3.9.0)
|
48
|
+
rspec-core (3.9.2)
|
49
|
+
rspec-support (~> 3.9.3)
|
50
|
+
rspec-expectations (3.9.2)
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
+
rspec-support (~> 3.9.0)
|
53
|
+
rspec-mocks (3.9.1)
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
+
rspec-support (~> 3.9.0)
|
56
|
+
rspec-support (3.9.3)
|
57
|
+
rspec_junit_formatter (0.4.1)
|
58
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
59
|
+
rubocop (0.91.0)
|
60
|
+
parallel (~> 1.10)
|
61
|
+
parser (>= 2.7.1.1)
|
62
|
+
rainbow (>= 2.2.2, < 4.0)
|
63
|
+
regexp_parser (>= 1.7)
|
64
|
+
rexml
|
65
|
+
rubocop-ast (>= 0.4.0, < 1.0)
|
66
|
+
ruby-progressbar (~> 1.7)
|
67
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
68
|
+
rubocop-ast (0.4.1)
|
69
|
+
parser (>= 2.7.1.4)
|
70
|
+
rubocop-faker (1.1.0)
|
71
|
+
faker (>= 2.12.0)
|
72
|
+
rubocop (>= 0.82.0)
|
73
|
+
rubocop-rspec (1.43.2)
|
74
|
+
rubocop (~> 0.87)
|
75
|
+
ruby-progressbar (1.10.1)
|
76
|
+
simplecov (0.17.1)
|
77
|
+
docile (~> 1.1)
|
78
|
+
json (>= 1.8, < 3)
|
79
|
+
simplecov-html (~> 0.10.0)
|
80
|
+
simplecov-html (0.10.2)
|
81
|
+
thor (1.0.1)
|
82
|
+
unicode-display_width (1.7.0)
|
83
|
+
vcr (6.0.0)
|
84
|
+
webmock (3.9.1)
|
85
|
+
addressable (>= 2.3.6)
|
86
|
+
crack (>= 0.3.2)
|
87
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
88
|
+
zeitwerk (2.4.0)
|
89
|
+
|
90
|
+
PLATFORMS
|
91
|
+
ruby
|
92
|
+
|
93
|
+
DEPENDENCIES
|
94
|
+
bundler-audit
|
95
|
+
faker
|
96
|
+
memory_profiler
|
97
|
+
pry
|
98
|
+
pry-byebug
|
99
|
+
rake (~> 12.0)
|
100
|
+
rspec (~> 3.0)
|
101
|
+
rspec_junit_formatter
|
102
|
+
rubocop
|
103
|
+
rubocop-faker
|
104
|
+
rubocop-rspec
|
105
|
+
simple-images-downloader!
|
106
|
+
simplecov (~> 0.17.1)
|
107
|
+
vcr
|
108
|
+
webmock
|
109
|
+
|
110
|
+
RUBY VERSION
|
111
|
+
ruby 2.7.1p83
|
112
|
+
|
113
|
+
BUNDLED WITH
|
114
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 IlkhamGaysin
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# SimpleImagesDownloader
|
2
|
+
|
3
|
+
[![IlkhamGaysin](https://circleci.com/gh/IlkhamGaysin/simple-images-downloader.svg?style=svg)](https://circleci.com/gh/IlkhamGaysin/simple-images-downloader)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/df8b8fea5a09ad512d54/maintainability)](https://codeclimate.com/github/IlkhamGaysin/simple-images-downloader/maintainability)
|
5
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/df8b8fea5a09ad512d54/test_coverage)](https://codeclimate.com/github/IlkhamGaysin/simple-images-downloader/test_coverage)
|
6
|
+
|
7
|
+
This gem allows you download images from either source file with list of urls or plain url.
|
8
|
+
The urls must be non redirectable. For now the feature is unsupported. The gem uses `OpenURI` class under the hood and is able to download as small files less than 10KB as large files 100MB.
|
9
|
+
|
10
|
+
## Dependencies
|
11
|
+
- Ruby >= 2.7.1
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'simple-images-downloader'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle install
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install simple-images-downloader
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
The gem is provided with executable.
|
32
|
+
|
33
|
+
You can either run plain commmand with file containing list of url:
|
34
|
+
|
35
|
+
```bash
|
36
|
+
simple-images-downloader <path_to_file>
|
37
|
+
```
|
38
|
+
|
39
|
+
Or you can load gem and use public API:
|
40
|
+
|
41
|
+
- `SimpleImagesDownloader.from_file` - allows download images from file containing urls
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
[1] pry(main)> require 'simple_images_downloader'
|
45
|
+
|
46
|
+
[2] pry(main)> path = File.expand_path("./urls.txt")
|
47
|
+
|
48
|
+
[3] pry(main)> SimpleImagesDownloader.from_file(path)
|
49
|
+
Downloading https://test-for-simple-images-downloader.s3.eu-central-1.amazonaws.com/7.5MB.jpg
|
50
|
+
Downloading is finished
|
51
|
+
Downloading https://test-for-simple-images-downloader.s3.eu-central-1.amazonaws.com/less_than_10kb.png
|
52
|
+
Downloading is finished
|
53
|
+
```
|
54
|
+
|
55
|
+
- `SimpleImagesDownloader.from_url` - allows download image from url
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
[1] pry(main)> require 'simple_images_downloader'
|
59
|
+
|
60
|
+
[2] pry(main)> url = 'https://test-for-simple-images-downloader.s3.eu-central-1.amazonaws.com/7.5MB.jpg'
|
61
|
+
|
62
|
+
[3] pry(main)> SimpleImagesDownloader.from_url(url)
|
63
|
+
Downloading https://test-for-simple-images-downloader.s3.eu-central-1.amazonaws.com/7.5MB.jpg
|
64
|
+
Downloading is finished
|
65
|
+
```
|
66
|
+
|
67
|
+
You can also configure the place where the images would be stored to by using **by default the images stored in a directory the script is run**:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
[1] pry(main)> require 'simple_images_downloader'
|
71
|
+
|
72
|
+
[2] pry(main)> SimpleImagesDownloader::Configuration.configure do |config|
|
73
|
+
[2] pry(main)* config.destination = "./tmp/"
|
74
|
+
[2] pry(main)* end
|
75
|
+
```
|
76
|
+
|
77
|
+
## Development
|
78
|
+
|
79
|
+
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.
|
80
|
+
|
81
|
+
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).
|
82
|
+
|
83
|
+
## Contributing
|
84
|
+
|
85
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/IlkhamGaysin/simple-images-downloader. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/IlkhamGaysin/simple-images-downloader/blob/master/CODE_OF_CONDUCT.md).
|
86
|
+
|
87
|
+
|
88
|
+
## License
|
89
|
+
|
90
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
91
|
+
|
92
|
+
## Code of Conduct
|
93
|
+
|
94
|
+
Everyone interacting in the SimpleImagesDownloader project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/IlkhamGaysin/simple-images-downloader/blob/master/CODE_OF_CONDUCT.md).
|