classy-yaml 0.6.0 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -2
- data/lib/classy/yaml/component_helpers.rb +6 -4
- data/lib/classy/yaml/engine.rb +3 -6
- data/lib/classy/yaml/helpers.rb +2 -2
- data/lib/classy/yaml/version.rb +1 -1
- metadata +32 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a317b7d0d4d98ba75bede21873cab424ae0238336fbd61a3425240d9972824a
|
4
|
+
data.tar.gz: e42bba9cb118a3805da435e1737bad5000ca1b181104eb5ddfabc194f7472ebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dce1e8ae1e7174381890149634d25b820f46d786451cc128437a8b5e960bc6f5729d9b38de6ad7ceb712494dee3237d04d3b5658b27730c9110de0608dbea26
|
7
|
+
data.tar.gz: 15740e73a3143adc07ef903f7dfebf31e3bb20ef89b621776f207b1e9afa5874b314be84dc8df1ebf90f48fb9a7603ac956cf8c02f0327ee399711e73557c45a
|
data/README.md
CHANGED
@@ -46,7 +46,7 @@ btn:
|
|
46
46
|
|
47
47
|
# app/components/example_component/example_component.html.erb
|
48
48
|
|
49
|
-
<button class="<%=
|
49
|
+
<button class="<%=yass(btn: :purple)%>">Classy Button</button>
|
50
50
|
|
51
51
|
# will add the classes "px-3 py-2 text-purple-200 bg-blue-500"
|
52
52
|
```
|
@@ -68,7 +68,7 @@ btn:
|
|
68
68
|
|
69
69
|
# app/components/example_component/example_component.html.erb
|
70
70
|
|
71
|
-
<button class="<%=
|
71
|
+
<button class="<%=yass(btn: :purple)%>">Classy Button</button>
|
72
72
|
|
73
73
|
# will add the classes "px-3 py-2 text-blue-50"
|
74
74
|
```
|
@@ -90,6 +90,13 @@ Or install it yourself as:
|
|
90
90
|
$ gem install classy-yaml
|
91
91
|
```
|
92
92
|
|
93
|
+
If using purging for styles, be sure to add the YAML files to the purge directories. For example, below is a tailwind.config.js:
|
94
|
+
```
|
95
|
+
purge: [
|
96
|
+
"./config/utility_classes.yml",
|
97
|
+
"./app/components/**/*.yml" // If using view component sidecar assets
|
98
|
+
]
|
99
|
+
```
|
93
100
|
## Contributing
|
94
101
|
This is my first attempt at an actual gem usable for all. Any and all suggestions are absolutely welcome. I'm not the cleanest programmer, so code quality suggestions are welcome too 👍 I extracted this logic from my private work and I felt it was useful enought to be worth publishing.
|
95
102
|
|
@@ -2,10 +2,12 @@ module Classy
|
|
2
2
|
module Yaml
|
3
3
|
module ComponentHelpers
|
4
4
|
def yass(*args)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
calling_path = self.class.source_location.split("/")[0...-1].join("/")
|
6
|
+
calling_file = self.class.source_location.split("/").last.split(".").first
|
7
|
+
component_name = self.class.name.underscore.split("/").last.split(".").first
|
8
|
+
|
9
|
+
classy_file = if Dir.exist?("#{calling_path}/#{calling_file}")
|
10
|
+
"#{calling_path}/#{calling_file}/#{component_name}.yml"
|
9
11
|
else
|
10
12
|
"#{calling_path}/#{component_name}.yml"
|
11
13
|
end
|
data/lib/classy/yaml/engine.rb
CHANGED
@@ -1,14 +1,11 @@
|
|
1
|
+
require "rails"
|
2
|
+
|
1
3
|
module Classy
|
2
4
|
module Yaml
|
3
|
-
class Engine <
|
4
|
-
paths["lib/classy/yaml"]
|
5
|
+
class Engine < Rails::Railtie
|
5
6
|
config.to_prepare do
|
6
7
|
ApplicationController.helper(Classy::Yaml::Helpers)
|
7
8
|
end
|
8
|
-
|
9
|
-
Gem.loaded_specs['classy-yaml'].dependencies.each do |d|
|
10
|
-
require d.name if Rails.env.test?
|
11
|
-
end
|
12
9
|
end
|
13
10
|
end
|
14
11
|
end
|
data/lib/classy/yaml/helpers.rb
CHANGED
@@ -3,12 +3,12 @@ module Classy
|
|
3
3
|
module Helpers
|
4
4
|
def yass(*args)
|
5
5
|
classy_yamls = []
|
6
|
-
classy_yamls << YAML.load_file(Rails.root.join("config/utility_classes.yml")) if File.
|
6
|
+
classy_yamls << YAML.load_file(Rails.root.join("config/utility_classes.yml")) if File.exist?(Rails.root.join("config/utility_classes.yml"))
|
7
7
|
|
8
8
|
classy_files_hash = args.find { |arg| arg.is_a?(Hash) && arg.keys.include?(:classy_files) }
|
9
9
|
if classy_files_hash.present?
|
10
10
|
classy_files_hash[:classy_files].each do |file|
|
11
|
-
if File.
|
11
|
+
if File.exist?(file) && YAML.load_file(file)
|
12
12
|
file = YAML.load_file(file)
|
13
13
|
classy_yamls << file if file
|
14
14
|
end
|
data/lib/classy/yaml/version.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,45 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: classy-yaml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tonksthebear
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: actionpack
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: railties
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
16
44
|
requirements:
|
17
45
|
- - ">="
|
@@ -92,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
120
|
- !ruby/object:Gem::Version
|
93
121
|
version: '0'
|
94
122
|
requirements: []
|
95
|
-
rubygems_version: 3.
|
123
|
+
rubygems_version: 3.2.26
|
96
124
|
signing_key:
|
97
125
|
specification_version: 4
|
98
126
|
summary: Rails helper to allow yaml configuration of utility css classes
|