rails_picture 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fd4140b9acfe949a1136ddac2aea263a8a41b9c7a8debacd3f6bcf4ddd29d1ae
4
+ data.tar.gz: de1e24091ae6463f7411b54211a3825fddd0bf9128b714d47a7c4f6256d915a0
5
+ SHA512:
6
+ metadata.gz: e33635308b8eb1e57c3d68920256c60678e5526efbc13f6e91be25309d28a5004751db1e7c315465e88f3ecb5f2c00cd94ed0c123178b07ab2651108284d6bdc
7
+ data.tar.gz: 1b839f929c3df94113f30f28e89ce7670505ccb0624ee37304a527fd213143b152bae091f389250381508513878eee5f5c732ff1bc676c3fe88b473f03e4834c
data/.deepsource.toml ADDED
@@ -0,0 +1,7 @@
1
+ version = 1
2
+
3
+ test_patterns = ["spec/**/*", "spec/*"]
4
+
5
+ [[analyzers]]
6
+ name = "ruby"
7
+ enabled = true
@@ -0,0 +1,25 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.0
14
+ - name: Cache Ruby Gems
15
+ uses: actions/cache@v2
16
+ with:
17
+ path: vendor/bundle
18
+ key: gems-${{ hashFiles('**/Gemfile.lock') }}
19
+ restore-keys: gems-
20
+ - name: Run the default task
21
+ run: |
22
+ gem install bundler -v 2.2.3
23
+ bundle config path vendor/bundle
24
+ bundle install --jobs 4 --retry 3
25
+ bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,60 @@
1
+ # rspec failure tracking
2
+ .rspec_status
3
+
4
+ *.gem
5
+ *.rbc
6
+ /.config
7
+ /coverage/
8
+ /InstalledFiles
9
+ /pkg/
10
+ /spec/reports/
11
+ /spec/examples.txt
12
+ /test/tmp/
13
+ /test/version_tmp/
14
+ /tmp/
15
+
16
+ # Used by dotenv library to load environment variables.
17
+ .env
18
+
19
+ # Ignore Byebug command history file.
20
+ .byebug_history
21
+
22
+ ## Specific to RubyMotion:
23
+ .dat*
24
+ .repl_history
25
+ build/
26
+ *.bridgesupport
27
+ build-iPhoneOS/
28
+ build-iPhoneSimulator/
29
+
30
+ ## Documentation cache and generated files:
31
+ /.yardoc/
32
+ /_yardoc/
33
+ /doc/
34
+ /rdoc/
35
+
36
+ ## Environment normalization:
37
+ /.bundle/
38
+ /vendor/bundle
39
+ /lib/bundler/man/
40
+
41
+ .rvmrc
42
+
43
+ /spec/dummy/db/*.sqlite3
44
+ /spec/dummy/db/*.sqlite3-journal
45
+ /spec/dummy/db/*.sqlite3-[0-9]*
46
+ /spec/dummy/public/system
47
+ /coverage/
48
+ /spec/tmp
49
+
50
+ # Ignore all logfiles and tempfiles.
51
+ spec/dummy/log/*
52
+ spec/dummy/tmp/*
53
+ !/spec/dummy/log/.keep
54
+ !/spec/dummy/tmp/.keep
55
+
56
+ # Ignore precompiled javascript packs
57
+ /spec/dummy/public/packs
58
+ /spec/dummy/public/packs-test
59
+ /spec/dummy/public/assets
60
+
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,30 @@
1
+ inherit_gem:
2
+ prettier: rubocop.yml
3
+
4
+ require:
5
+ - rubocop-rails
6
+ - rubocop-rspec
7
+ - rubocop-rake
8
+
9
+ AllCops:
10
+ TargetRubyVersion: 3.0.0
11
+ NewCops: enable
12
+
13
+ Style/StringLiterals:
14
+ Enabled: true
15
+ EnforcedStyle: single_quotes
16
+
17
+ Style/StringLiteralsInInterpolation:
18
+ Enabled: true
19
+ EnforcedStyle: single_quotes
20
+
21
+ Layout/LineLength:
22
+ Max: 120
23
+
24
+ Style/Documentation:
25
+ Enabled: false
26
+
27
+ Metrics/BlockLength:
28
+ Exclude:
29
+ - 'spec/**/*'
30
+ - 'rails_picture.gemspec'
data/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ <!-- TODO: -->
@@ -0,0 +1,51 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
44
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
45
+
46
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
47
+
48
+ [homepage]: https://www.contributor-covenant.org
49
+
50
+ For answers to common questions about this code of conduct, see the FAQ at
51
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
+
6
+ # Specify your gem's dependencies in rails_picture.gemspec
7
+ gemspec
8
+
9
+ gem 'awesome_print'
10
+ gem 'brakeman'
11
+ gem 'prettier'
12
+ gem 'pry'
13
+ gem 'pry-doc'
14
+ gem 'pry-rails'
15
+ gem 'rails'
16
+ gem 'rake'
17
+ gem 'rubocop'
18
+ gem 'rubocop-rails'
19
+ gem 'rubocop-rake'
20
+ gem 'rubocop-rspec'
21
+ gem 'sqlite3'
data/Gemfile.lock ADDED
@@ -0,0 +1,263 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rails_picture (0.1.0)
5
+ rails (~> 6.1.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (6.1.3)
11
+ actionpack (= 6.1.3)
12
+ activesupport (= 6.1.3)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (6.1.3)
16
+ actionpack (= 6.1.3)
17
+ activejob (= 6.1.3)
18
+ activerecord (= 6.1.3)
19
+ activestorage (= 6.1.3)
20
+ activesupport (= 6.1.3)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.1.3)
23
+ actionpack (= 6.1.3)
24
+ actionview (= 6.1.3)
25
+ activejob (= 6.1.3)
26
+ activesupport (= 6.1.3)
27
+ mail (~> 2.5, >= 2.5.4)
28
+ rails-dom-testing (~> 2.0)
29
+ actionpack (6.1.3)
30
+ actionview (= 6.1.3)
31
+ activesupport (= 6.1.3)
32
+ rack (~> 2.0, >= 2.0.9)
33
+ rack-test (>= 0.6.3)
34
+ rails-dom-testing (~> 2.0)
35
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
+ actiontext (6.1.3)
37
+ actionpack (= 6.1.3)
38
+ activerecord (= 6.1.3)
39
+ activestorage (= 6.1.3)
40
+ activesupport (= 6.1.3)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (6.1.3)
43
+ activesupport (= 6.1.3)
44
+ builder (~> 3.1)
45
+ erubi (~> 1.4)
46
+ rails-dom-testing (~> 2.0)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (6.1.3)
49
+ activesupport (= 6.1.3)
50
+ globalid (>= 0.3.6)
51
+ activemodel (6.1.3)
52
+ activesupport (= 6.1.3)
53
+ activerecord (6.1.3)
54
+ activemodel (= 6.1.3)
55
+ activesupport (= 6.1.3)
56
+ activestorage (6.1.3)
57
+ actionpack (= 6.1.3)
58
+ activejob (= 6.1.3)
59
+ activerecord (= 6.1.3)
60
+ activesupport (= 6.1.3)
61
+ marcel (~> 0.3.1)
62
+ mimemagic (~> 0.3.2)
63
+ activesupport (6.1.3)
64
+ concurrent-ruby (~> 1.0, >= 1.0.2)
65
+ i18n (>= 1.6, < 2)
66
+ minitest (>= 5.1)
67
+ tzinfo (~> 2.0)
68
+ zeitwerk (~> 2.3)
69
+ addressable (2.7.0)
70
+ public_suffix (>= 2.0.2, < 5.0)
71
+ ast (2.4.2)
72
+ awesome_print (1.9.2)
73
+ brakeman (5.0.0)
74
+ builder (3.2.4)
75
+ capybara (3.35.3)
76
+ addressable
77
+ mini_mime (>= 0.1.3)
78
+ nokogiri (~> 1.8)
79
+ rack (>= 1.6.0)
80
+ rack-test (>= 0.6.3)
81
+ regexp_parser (>= 1.5, < 3.0)
82
+ xpath (~> 3.2)
83
+ capybara-screenshot (1.0.25)
84
+ capybara (>= 1.0, < 4)
85
+ launchy
86
+ cliver (0.3.2)
87
+ coderay (1.1.3)
88
+ concurrent-ruby (1.1.8)
89
+ crass (1.0.6)
90
+ cuprite (0.13)
91
+ capybara (>= 2.1, < 4)
92
+ ferrum (~> 0.11.0)
93
+ diff-lcs (1.4.4)
94
+ erubi (1.10.0)
95
+ ferrum (0.11)
96
+ addressable (~> 2.5)
97
+ cliver (~> 0.3)
98
+ concurrent-ruby (~> 1.1)
99
+ websocket-driver (>= 0.6, < 0.8)
100
+ globalid (0.4.2)
101
+ activesupport (>= 4.2.0)
102
+ i18n (1.8.9)
103
+ concurrent-ruby (~> 1.0)
104
+ launchy (2.5.0)
105
+ addressable (~> 2.7)
106
+ loofah (2.9.0)
107
+ crass (~> 1.0.2)
108
+ nokogiri (>= 1.5.9)
109
+ mail (2.7.1)
110
+ mini_mime (>= 0.1.1)
111
+ marcel (0.3.3)
112
+ mimemagic (~> 0.3.2)
113
+ method_source (1.0.0)
114
+ mimemagic (0.3.5)
115
+ mini_mime (1.0.2)
116
+ minitest (5.14.4)
117
+ nio4r (2.5.7)
118
+ nokogiri (1.11.2-x86_64-linux)
119
+ racc (~> 1.4)
120
+ parallel (1.20.1)
121
+ parser (3.0.0.0)
122
+ ast (~> 2.4.1)
123
+ prettier (1.5.3)
124
+ pry (0.14.0)
125
+ coderay (~> 1.1)
126
+ method_source (~> 1.0)
127
+ pry-doc (1.1.0)
128
+ pry (~> 0.11)
129
+ yard (~> 0.9.11)
130
+ pry-rails (0.3.9)
131
+ pry (>= 0.10.4)
132
+ public_suffix (4.0.6)
133
+ puma (5.2.2)
134
+ nio4r (~> 2.0)
135
+ racc (1.5.2)
136
+ rack (2.2.3)
137
+ rack-test (1.1.0)
138
+ rack (>= 1.0, < 3)
139
+ rails (6.1.3)
140
+ actioncable (= 6.1.3)
141
+ actionmailbox (= 6.1.3)
142
+ actionmailer (= 6.1.3)
143
+ actionpack (= 6.1.3)
144
+ actiontext (= 6.1.3)
145
+ actionview (= 6.1.3)
146
+ activejob (= 6.1.3)
147
+ activemodel (= 6.1.3)
148
+ activerecord (= 6.1.3)
149
+ activestorage (= 6.1.3)
150
+ activesupport (= 6.1.3)
151
+ bundler (>= 1.15.0)
152
+ railties (= 6.1.3)
153
+ sprockets-rails (>= 2.0.0)
154
+ rails-dom-testing (2.0.3)
155
+ activesupport (>= 4.2.0)
156
+ nokogiri (>= 1.6)
157
+ rails-html-sanitizer (1.3.0)
158
+ loofah (~> 2.3)
159
+ railties (6.1.3)
160
+ actionpack (= 6.1.3)
161
+ activesupport (= 6.1.3)
162
+ method_source
163
+ rake (>= 0.8.7)
164
+ thor (~> 1.0)
165
+ rainbow (3.0.0)
166
+ rake (13.0.3)
167
+ regexp_parser (2.1.1)
168
+ rexml (3.2.4)
169
+ rspec (3.10.0)
170
+ rspec-core (~> 3.10.0)
171
+ rspec-expectations (~> 3.10.0)
172
+ rspec-mocks (~> 3.10.0)
173
+ rspec-core (3.10.1)
174
+ rspec-support (~> 3.10.0)
175
+ rspec-expectations (3.10.1)
176
+ diff-lcs (>= 1.2.0, < 2.0)
177
+ rspec-support (~> 3.10.0)
178
+ rspec-mocks (3.10.2)
179
+ diff-lcs (>= 1.2.0, < 2.0)
180
+ rspec-support (~> 3.10.0)
181
+ rspec-rails (5.0.0)
182
+ actionpack (>= 5.2)
183
+ activesupport (>= 5.2)
184
+ railties (>= 5.2)
185
+ rspec-core (~> 3.10)
186
+ rspec-expectations (~> 3.10)
187
+ rspec-mocks (~> 3.10)
188
+ rspec-support (~> 3.10)
189
+ rspec-support (3.10.2)
190
+ rubocop (1.11.0)
191
+ parallel (~> 1.10)
192
+ parser (>= 3.0.0.0)
193
+ rainbow (>= 2.2.2, < 4.0)
194
+ regexp_parser (>= 1.8, < 3.0)
195
+ rexml
196
+ rubocop-ast (>= 1.2.0, < 2.0)
197
+ ruby-progressbar (~> 1.7)
198
+ unicode-display_width (>= 1.4.0, < 3.0)
199
+ rubocop-ast (1.4.1)
200
+ parser (>= 2.7.1.5)
201
+ rubocop-rails (2.9.1)
202
+ activesupport (>= 4.2.0)
203
+ rack (>= 1.1)
204
+ rubocop (>= 0.90.0, < 2.0)
205
+ rubocop-rake (0.5.1)
206
+ rubocop
207
+ rubocop-rspec (2.2.0)
208
+ rubocop (~> 1.0)
209
+ rubocop-ast (>= 1.1.0)
210
+ ruby-progressbar (1.11.0)
211
+ slim (4.1.0)
212
+ temple (>= 0.7.6, < 0.9)
213
+ tilt (>= 2.0.6, < 2.1)
214
+ sprockets (4.0.2)
215
+ concurrent-ruby (~> 1.0)
216
+ rack (> 1, < 3)
217
+ sprockets-rails (3.2.2)
218
+ actionpack (>= 4.0)
219
+ activesupport (>= 4.0)
220
+ sprockets (>= 3.0.0)
221
+ sqlite3 (1.4.2)
222
+ temple (0.8.2)
223
+ thor (1.1.0)
224
+ tilt (2.0.10)
225
+ tzinfo (2.0.4)
226
+ concurrent-ruby (~> 1.0)
227
+ unicode-display_width (2.0.0)
228
+ websocket-driver (0.7.3)
229
+ websocket-extensions (>= 0.1.0)
230
+ websocket-extensions (0.1.5)
231
+ xpath (3.2.0)
232
+ nokogiri (~> 1.8)
233
+ yard (0.9.26)
234
+ zeitwerk (2.4.2)
235
+
236
+ PLATFORMS
237
+ x86_64-linux
238
+
239
+ DEPENDENCIES
240
+ awesome_print
241
+ brakeman
242
+ capybara
243
+ capybara-screenshot
244
+ cuprite
245
+ prettier
246
+ pry
247
+ pry-doc
248
+ pry-rails
249
+ puma
250
+ rails
251
+ rails_picture!
252
+ rake
253
+ rspec
254
+ rspec-rails
255
+ rubocop
256
+ rubocop-rails
257
+ rubocop-rake
258
+ rubocop-rspec
259
+ slim
260
+ sqlite3
261
+
262
+ BUNDLED WITH
263
+ 2.2.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Oskars Ezerins
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,155 @@
1
+ <!-- [![Contributors][contributors-shield]][contributors-url]
2
+ [![Forks][forks-shield]][forks-url]
3
+ [![Stargazers][stars-shield]][stars-url]
4
+ [![Issues][issues-shield]][issues-url]
5
+ [![MIT License][license-shield]][license-url]
6
+ [![LinkedIn][linkedin-shield]][linkedin-url] -->
7
+
8
+ <!-- PROJECT LOGO
9
+
10
+ <br />
11
+
12
+ <p align="center">
13
+
14
+ <a href="https://github.com/OskarsEzerins/rails_picture">
15
+
16
+ <img src="images/logo.png" alt="Logo" width="80" height="80">
17
+
18
+ </a>
19
+ -->
20
+
21
+ <h3 align='center'>rails_picture</h3>
22
+
23
+ <p align='center'>Simple picture_tag helper, which can show various image formats based on browser support </p>
24
+ <p align='center'>
25
+ <a href="https://github.com/OskarsEzerins/rails_picture/issues">Report Bug</a>
26
+ /
27
+ <a href="https://github.com/OskarsEzerins/rails_picture/issues">Request Feature</a>
28
+ </p>
29
+
30
+ <!-- TABLE OF CONTENTS -->
31
+
32
+ <details>
33
+
34
+ <summary>Table of Contents</summary>
35
+
36
+ <ol>
37
+ <li><a href="#about-the-project">About The Project</a></li>
38
+ <li>
39
+ <a href="#getting-started">Getting Started</a>
40
+ <ul>
41
+ <li><a href="#installation">Installation</a></li>
42
+ </ul>
43
+ </li>
44
+ <li><a href="#usage">Usage</a></li>
45
+ <li><a href="#roadmap">Roadmap</a></li>
46
+ <li><a href="#contributing">Contributing</a></li>
47
+ <li><a href="#license">License</a></li>
48
+
49
+ <!-- <li><a href="#contact">Contact</a></li>-->
50
+ <!-- <li><a href="#acknowledgements">Acknowledgements</a></li>-->
51
+
52
+ </ol>
53
+
54
+ </details>
55
+
56
+ <!-- ABOUT THE PROJECT -->
57
+
58
+ ## About The Project
59
+
60
+ Provide a new helper method to Rails views - `picture_tag`
61
+ <br />
62
+ It generates a `<picture>` HTML tag and within it places HTML tag as `<img>` and any other available image formats as `<source>` tags.
63
+
64
+ <!-- TOOD: add image example here of generated HTML -->
65
+
66
+ Internally it uses Rails built-in method `image_tag`.
67
+
68
+ ### Installation
69
+
70
+ Add this line to your application's Gemfile:
71
+
72
+ ```ruby
73
+
74
+ gem 'rails_picture'
75
+
76
+ ```
77
+
78
+ And then execute in terminal:
79
+
80
+ ```shell
81
+ bundle install
82
+ ```
83
+
84
+ <!-- USAGE EXAMPLES -->
85
+
86
+ ## Usage
87
+
88
+ 1. Put multiple same-named images with different file formats into `app/assets/`
89
+
90
+ 2. Place following code into any Rails view. It takes the same options as Rails built in `image_tag` :
91
+
92
+ ```ruby
93
+ picture_tag(filename, **options)
94
+ ```
95
+
96
+ > Note - do not input file extension in filename
97
+
98
+ <!-- _For more examples, please refer to the [Documentation](https://example.com)_ -->
99
+
100
+ <!-- ROADMAP -->
101
+
102
+ ## Roadmap
103
+
104
+ See the [TODO](https://github.com/OskarsEzerins/rails_picture/projects/1) for status of current development.
105
+
106
+ <!-- CONTRIBUTING -->
107
+
108
+ ## Contributing
109
+
110
+ Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
111
+
112
+ 1. Fork the Project
113
+ 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
114
+ 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
115
+ 4. Push to the Branch (`git push origin feature/AmazingFeature`)
116
+ 5. Open a Pull Request
117
+
118
+ ### Development
119
+
120
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake` to run the tests, rubocop. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
121
+
122
+ <!-- LICENSE -->
123
+
124
+ ## License
125
+
126
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
127
+
128
+ <!-- CONTACT -->
129
+
130
+ ## Conduct
131
+
132
+ Project Link: [https://github.com/OskarsEzerins/rails_picture](https://github.com/OskarsEzerins/rails_picture)
133
+
134
+ Everyone interacting in the rails_picture project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rails_picture/blob/master/CODE_OF_CONDUCT.md).
135
+
136
+ <!-- ACKNOWLEDGEMENTS -->
137
+
138
+ <!-- ## Acknowledgements -->
139
+
140
+ <!-- MARKDOWN LINKS & IMAGES -->
141
+
142
+ <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
143
+
144
+ [contributors-shield]: https://img.shields.io/github/contributors/othneildrew/Best-README-Template.svg?style=for-the-badge
145
+ [contributors-url]: https://github.com/OskarsEzerins/rails_picture/graphs/contributors
146
+ [forks-shield]: https://img.shields.io/github/forks/othneildrew/Best-README-Template.svg?style=for-the-badge
147
+ [forks-url]: https://github.com/OskarsEzerins/rails_picture/network/members
148
+ [stars-shield]: https://img.shields.io/github/stars/othneildrew/Best-README-Template.svg?style=for-the-badge
149
+ [stars-url]: https://github.com/OskarsEzerins/rails_picture/stargazers
150
+ [issues-shield]: https://img.shields.io/github/issues/othneildrew/Best-README-Template.svg?style=for-the-badge
151
+ [issues-url]: https://github.com/OskarsEzerins/rails_picture/issues
152
+ [license-shield]: https://img.shields.io/github/license/othneildrew/Best-README-Template.svg?style=for-the-badge
153
+ [license-url]: https://github.com/OskarsEzerins/rails_picture/blob/master/LICENSE.txt
154
+ [linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
155
+ [linkedin-url]: https://www.linkedin.com/in/oskars-ezeri%C5%86%C5%A1-9339961a6
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'rails_picture'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ require 'pry'
11
+ Pry.start
data/bin/prettier ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ bundle exec rbprettier --write 'lib/**/*.rb' 'spec/**/*.rb'
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails'
4
+ require 'rails_picture/version'
5
+ require 'rails_picture/railtie'
6
+
7
+ module RailsPicture
8
+ class Error < StandardError
9
+ end
10
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Add a helper method to Rails views
4
+ module RailsPicture
5
+ # Add a helper method to Rails views
6
+ module RailsPictureHelper
7
+ SOURCE_FORMATS = %w[avif webp apng gif svg jxl bmp ico cur tif tiff].freeze
8
+ IMG_FORMATS = %w[jpg jpeg png jfif pjpeg pjp].freeze
9
+
10
+ def picture_tag(filename, **options)
11
+ html = []
12
+
13
+ SOURCE_FORMATS.each { |f| html << source_tag(filename, f) }
14
+
15
+ html << image_tag(filename, **options)
16
+
17
+ tag.picture { safe_join html }
18
+ end
19
+
20
+ private
21
+
22
+ def source_tag(filename, format)
23
+ tag.source(srcset: asset_path(filename, format), type: "image/#{format}")
24
+ end
25
+
26
+ def image_tag(filename, **options)
27
+ tag.img(src: find_img_format(filename), alt: filename.humanize, **options)
28
+ end
29
+
30
+ def find_img_format(filename)
31
+ IMG_FORMATS.map do |format|
32
+ asset_path(filename, format)
33
+ end.compact.first
34
+ end
35
+
36
+ def asset_path(filename, format)
37
+ path = resolve_asset_path "#{filename}.#{format}"
38
+ path && "/assets/#{path}"
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails'
4
+ require_relative 'rails_picture_helper'
5
+
6
+ module RailsPicture
7
+ class Railtie < ::Rails::Railtie
8
+ initializer 'rails_picture.view_helpers' do
9
+ ActiveSupport.on_load(:action_view) { include RailsPicture::RailsPictureHelper }
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsPicture
4
+ VERSION = '0.1.0'
5
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/rails_picture/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'rails_picture'
7
+ spec.version = RailsPicture::VERSION
8
+ spec.authors = ['Oskars Ezerins']
9
+ spec.email = ['oskarsezerins@users.noreply.github.com']
10
+
11
+ spec.summary = 'Rails picture_tag helper'
12
+ spec.description = 'Simple picture_tag helper, which can show various image formats based on browser support'
13
+ spec.homepage = 'https://github.com/OskarsEzerins/rails_picture'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 3.0.0')
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = 'https://github.com/OskarsEzerins/rails_picture'
19
+ spec.metadata['changelog_uri'] = 'https://github.com/OskarsEzerins/rails_picture/blob/main/CHANGELOG.md'
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
+ end
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ # For more information and examples about making a new gem, checkout our
31
+ # guide at: https://bundler.io/guides/creating_gem.html
32
+
33
+ spec.add_dependency 'rails', '~> 6.1.3'
34
+
35
+ spec.add_development_dependency 'capybara'
36
+ spec.add_development_dependency 'capybara-screenshot'
37
+ spec.add_development_dependency 'cuprite'
38
+ spec.add_development_dependency 'puma'
39
+ spec.add_development_dependency 'rspec'
40
+ spec.add_development_dependency 'rspec-rails'
41
+ spec.add_development_dependency 'slim'
42
+ end
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_picture
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Oskars Ezerins
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.1.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 6.1.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: capybara
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: capybara-screenshot
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: cuprite
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: puma
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: slim
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Simple picture_tag helper, which can show various image formats based
126
+ on browser support
127
+ email:
128
+ - oskarsezerins@users.noreply.github.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".deepsource.toml"
134
+ - ".github/workflows/main.yml"
135
+ - ".gitignore"
136
+ - ".rspec"
137
+ - ".rubocop.yml"
138
+ - CHANGELOG.md
139
+ - CODE_OF_CONDUCT.md
140
+ - Gemfile
141
+ - Gemfile.lock
142
+ - LICENSE.txt
143
+ - README.md
144
+ - Rakefile
145
+ - bin/console
146
+ - bin/prettier
147
+ - bin/setup
148
+ - lib/rails_picture.rb
149
+ - lib/rails_picture/rails_picture_helper.rb
150
+ - lib/rails_picture/railtie.rb
151
+ - lib/rails_picture/version.rb
152
+ - rails_picture.gemspec
153
+ homepage: https://github.com/OskarsEzerins/rails_picture
154
+ licenses:
155
+ - MIT
156
+ metadata:
157
+ homepage_uri: https://github.com/OskarsEzerins/rails_picture
158
+ source_code_uri: https://github.com/OskarsEzerins/rails_picture
159
+ changelog_uri: https://github.com/OskarsEzerins/rails_picture/blob/main/CHANGELOG.md
160
+ post_install_message:
161
+ rdoc_options: []
162
+ require_paths:
163
+ - lib
164
+ required_ruby_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: 3.0.0
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ requirements: []
175
+ rubygems_version: 3.2.3
176
+ signing_key:
177
+ specification_version: 4
178
+ summary: Rails picture_tag helper
179
+ test_files: []