rolemodel-rails 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/generators/rolemodel/README.md +0 -1
- data/lib/generators/rolemodel/all_generator.rb +0 -1
- data/lib/generators/rolemodel/optics/icons/README.md +7 -0
- data/lib/rolemodel/optics/custom_icon_builder.rb +18 -14
- data/lib/rolemodel/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: fede781704d5a6d3f851f7dfafe1ab6a6d3be865609e009b6eaff8610c510656
|
|
4
|
+
data.tar.gz: ae9be94c16906a8ccb1bca770b9e6f385ef6f7e5e8e97a8c6c830502d567b145
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bd3700f56df8e270774d4036bdebe388d86c37bcd190fb75f39022640dee94200ae7fe7eef23474a58c2c10e5aafea2809619bc34a6b6d4e86777798287b603b
|
|
7
|
+
data.tar.gz: d75431fd64ce262417b5468ae9af0f60ec5125d499c3f2bdbb91b6278c60fe20bb3d312bce1a3b85dc2882aef931968cc499a91e5e457579667248795e603ec6
|
data/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Executable Best Practices for Rails apps, based on RoleModel's best approaches
|
|
4
4
|
|
|
5
|
+

|
|
6
|
+
|
|
5
7
|
Attempts to solve the pain of:
|
|
6
8
|
|
|
7
9
|
* Setup of a new Rails app is harder than it needs to be
|
|
@@ -69,7 +71,6 @@ bin/rails g
|
|
|
69
71
|
|
|
70
72
|
* [Core Setup](./lib/generators/rolemodel/core_setup)
|
|
71
73
|
* [Github](./lib/generators/rolemodel/github)
|
|
72
|
-
* [Semaphore](./lib/generators/rolemodel/semaphore)
|
|
73
74
|
* [Heroku](./lib/generators/rolemodel/heroku)
|
|
74
75
|
* [Readme](./lib/generators/rolemodel/readme)
|
|
75
76
|
* [Webpack](./lib/generators/rolemodel/webpack)
|
|
@@ -325,8 +326,8 @@ e.g.
|
|
|
325
326
|
bin/new_generator testing/fantasitic_specs 'A Fantastic Testing Framework'
|
|
326
327
|
```
|
|
327
328
|
|
|
328
|
-
We use the embeded Rails apps (`example_rails_current` & `example_rails_legacy`) to test generators against.
|
|
329
|
-
so you can navigate into
|
|
329
|
+
We use the embeded Rails apps (`example_rails_current` & `example_rails_legacy`) to test generators against. The specs run generators against a copy of `example_rails_current`.
|
|
330
|
+
`example_rails_legacy` references the rolemodel-rails gem by local path, so you can navigate into it and run your generator for immediate feedback while developing.
|
|
330
331
|
|
|
331
332
|
## Testing
|
|
332
333
|
|
|
@@ -10,3 +10,10 @@ Adds icon helper for handling icon generation using the provider of your choice.
|
|
|
10
10
|
|
|
11
11
|
Run the generator with the `-i` option to install the IconBuilders themselves in your
|
|
12
12
|
application's `lib/rolemodel/optics` directory.
|
|
13
|
+
|
|
14
|
+
## SVG icons (for example, Hugeicons)
|
|
15
|
+
|
|
16
|
+
Use `--custom`. Put each SVG in `app/assets/images/icons/`, and `icon('name')` inlines it with
|
|
17
|
+
Optics' `.icon--svg` modifier (Optics 2.5+), so size, weight and emphasis modifiers apply. A subfolder
|
|
18
|
+
works as part of the name: `icon('duotone-rounded/home-01')`. Draw the SVGs with `currentColor`
|
|
19
|
+
so they follow the text color.
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# CustomIconBuilder is an IconBuilder that allows for custom SVG icons to be used in the application.
|
|
4
|
+
# It inlines app/assets/images/icons/<name>.svg, so any SVG set works, including Hugeicons:
|
|
5
|
+
#
|
|
6
|
+
# icon('home-01') # icons/home-01.svg
|
|
7
|
+
# icon('duotone-rounded/home-01') # icons/duotone-rounded/home-01.svg
|
|
4
8
|
class Rolemodel::Optics::CustomIconBuilder < Rolemodel::Optics::IconBuilder
|
|
5
9
|
def self.flash_icons
|
|
6
10
|
{
|
|
@@ -15,28 +19,28 @@ class Rolemodel::Optics::CustomIconBuilder < Rolemodel::Optics::IconBuilder
|
|
|
15
19
|
:span
|
|
16
20
|
end
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
# We will need to find a way to make this work in Rails 8 with propshaft.
|
|
20
|
-
def tag_contents # rubocop:disable Metrics/AbcSize
|
|
22
|
+
def tag_contents
|
|
21
23
|
# Inspired by https://blog.cloud66.com/using-svgs-in-a-rails-stack
|
|
22
|
-
|
|
24
|
+
source = svg_source
|
|
25
|
+
return "<!-- SVG #{svg_path} not found -->".html_safe if source.nil?
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
# These SVG files can safely be marked html_safe since we created them and they are part of this app's code.
|
|
28
|
+
source.dup.force_encoding('UTF-8').html_safe
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Propshaft and Sprockets find assets differently.
|
|
32
|
+
def svg_source
|
|
33
|
+
assets = Rails.application.assets
|
|
34
|
+
if assets.respond_to?(:load_path)
|
|
35
|
+
assets.load_path.find(svg_path)&.content
|
|
29
36
|
else
|
|
30
|
-
|
|
37
|
+
Rails.application.assets_manifest.find_sources(svg_path).first&.source
|
|
31
38
|
end
|
|
32
|
-
|
|
33
|
-
# These SVG files can safely be marked html_safe since we created them and they are part of this app's code.
|
|
34
|
-
raw doc
|
|
35
39
|
end
|
|
36
40
|
|
|
37
41
|
def tag_classes
|
|
38
42
|
[
|
|
39
|
-
'
|
|
43
|
+
'icon--svg',
|
|
40
44
|
filled ? 'icon--filled' : '',
|
|
41
45
|
weight == DEFAULT_WEIGHT ? '' : "icon--weight-#{weight}",
|
|
42
46
|
emphasis == DEFAULT_EMPHASIS ? '' : "icon--#{emphasis}-emphasis"
|
data/lib/rolemodel/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rolemodel-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- RoleModel Software Inc
|
|
@@ -459,7 +459,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
459
459
|
- !ruby/object:Gem::Version
|
|
460
460
|
version: '0'
|
|
461
461
|
requirements: []
|
|
462
|
-
rubygems_version: 4.0.
|
|
462
|
+
rubygems_version: 4.0.20
|
|
463
463
|
specification_version: 4
|
|
464
464
|
summary: The RoleModel Way of building Rails apps.
|
|
465
465
|
test_files: []
|