action_view-use 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: cbf0c84f05ecc492d4c3ff00c898295d611f0091a8f7a6d2146e37b25b023320
4
+ data.tar.gz: 64f1e49551636448ee9d226551248213d3a466683cf1206bd3c2bcb3c577a46e
5
+ SHA512:
6
+ metadata.gz: d7ecb297189a1c997bd66e4dcd3728642f9a2564fe104a9b1f7b46a0c5ff1f16fba83399dbbd7cdac8ac6c47bbbf3e69d1b3fb207abf47fd7f1227038182a765
7
+ data.tar.gz: e2e208c33c5298b0339eb5be802a3be69630c3dde9f917605d52f9b5f06de58bd1e358f94a46d0f7ef7c21393da472727cbf270e216ff8556ddc17f4af579dc9
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ inherit_gem:
2
+ rubocop-rails_config:
3
+ - config/rails.yml
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.7
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-11-08
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Hartley McGuire
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,61 @@
1
+ # ActionView::Use
2
+
3
+ An Action View extension for rendering inline SVGs
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ ```shell
10
+ $ bundle add action_view-use
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Add `all_used_symbols` to the end of the `<body>` in
16
+ `app/views/layouts/application.html.erb`:
17
+
18
+ ```erb
19
+ <%= all_used_symbols %>
20
+ </body>
21
+ </html>
22
+ ```
23
+
24
+ Create SVG symbols to use in your views:
25
+
26
+ ```erb
27
+ <%# app/views/symbols/logo.svg.erb %>
28
+ <svg>
29
+ <!--- logo content -->
30
+ </svg>
31
+ ```
32
+
33
+ And then render symbols in your views:
34
+
35
+ ```erb
36
+ <%= use_symbol "logo" %>
37
+ ```
38
+
39
+ That's it!
40
+
41
+ ## Development
42
+
43
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run
44
+ `rake test` to run the tests. You can also run `bin/console` for an interactive
45
+ prompt that will allow you to experiment.
46
+
47
+ To install this gem onto your local machine, run `bundle exec rake install`. To
48
+ release a new version, update the version number in `version.rb`, and then run
49
+ `bundle exec rake release`, which will create a git tag for the version, push
50
+ git commits and the created tag, and push the `.gem` file to
51
+ [rubygems.org](https://rubygems.org).
52
+
53
+ ## Contributing
54
+
55
+ Bug reports and pull requests are welcome on GitHub at
56
+ https://github.com/skipkayhil/action_view-use.
57
+
58
+ ## License
59
+
60
+ The gem is available as open source under the terms of the [MIT
61
+ License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Use
5
+ module Helpers
6
+ def use_symbol(name)
7
+ used_symbol_set << name
8
+
9
+ <<~HTML.html_safe
10
+ <svg xmlns="http://www.w3.org/2000/svg">
11
+ <use href="##{name}" />
12
+ </svg>
13
+ HTML
14
+ end
15
+
16
+ def all_used_symbols
17
+ html = +"" << '<svg xmlns="http://www.w3.org/2000/svg">'
18
+
19
+ used_symbol_set.each do |name|
20
+ html << '<symbol id="' << name << '">'
21
+ html << render(partial: +"symbols/" << name, formats: [:svg])
22
+ html << "</symbol>"
23
+ end
24
+
25
+ html << "</svg>"
26
+ html.html_safe
27
+ end
28
+
29
+ private
30
+ def used_symbol_set
31
+ @used_symbol_set ||= Set.new
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActionView
4
+ module Use
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "action_view"
4
+ require_relative "use/version"
5
+ require_relative "use/helpers"
6
+
7
+ module ActionView
8
+ module Use
9
+ end
10
+ end
11
+
12
+ ActiveSupport.on_load(:action_view) do
13
+ include ActionView::Use::Helpers
14
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: action_view-use
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hartley McGuire
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-11-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionview
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '7.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '7.0'
27
+ description:
28
+ email:
29
+ - skipkayhil@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".rubocop.yml"
35
+ - CHANGELOG.md
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - lib/action_view/use.rb
40
+ - lib/action_view/use/helpers.rb
41
+ - lib/action_view/use/version.rb
42
+ homepage: https://github.com/skipkayhil/action_view-use
43
+ licenses:
44
+ - MIT
45
+ metadata:
46
+ homepage_uri: https://github.com/skipkayhil/action_view-use
47
+ source_code_uri: https://github.com/skipkayhil/action_view-use
48
+ changelog_uri: https://github.com/skipkayhil/action_view-use
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 2.6.0
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubygems_version: 3.4.21
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: An Action View extension for using inline SVGs
68
+ test_files: []