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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecb27c17050e3f5ca77111089257465fa14c8f92c31f88758690c3aa0c62c672
4
- data.tar.gz: cbad509cfd4a1f1dd4fb2fa99aca28c7ca9e0566eeb9596e839696d4b73b409b
3
+ metadata.gz: 1a317b7d0d4d98ba75bede21873cab424ae0238336fbd61a3425240d9972824a
4
+ data.tar.gz: e42bba9cb118a3805da435e1737bad5000ca1b181104eb5ddfabc194f7472ebd
5
5
  SHA512:
6
- metadata.gz: 01e0b9908f5ac755de537c709e4ba5ab4b214e207f93e90adffda0d7f7a770fbe8aa83160ec756ebba85e8a107bd89cdee53f2b79af86f128458067342fa792d
7
- data.tar.gz: c5022b41e6db9d44e89d05131adffb5a81c69b4a8885ae1131267cb7715e1f4af719e62a4589e7f0d4db646fb726d51461bed75fbc0e4751f5824bbf0ed08b3e
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="<%=sass(btn: :purple)%>">Classy Button</button>
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="<%=sass(btn: :purple)%>">Classy Button</button>
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
- component_name = caller.first.split("/").last.split(".").first
6
- calling_path = caller.first.split("/")[0...-1].join("/")
7
- classy_file = if Dir.exists?("#{calling_path}/#{component_name}")
8
- "#{calling_path}/#{component_name}/#{component_name}.yml"
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
@@ -1,14 +1,11 @@
1
+ require "rails"
2
+
1
3
  module Classy
2
4
  module Yaml
3
- class Engine < ::Rails::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
@@ -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.exists?(Rails.root.join("config/utility_classes.yml"))
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.exists?(file) && YAML.load_file(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
@@ -1,5 +1,5 @@
1
1
  module Classy
2
2
  module Yaml
3
- VERSION = '0.6.0'
3
+ VERSION = '0.8.5'
4
4
  end
5
5
  end
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.6.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: 2021-11-13 00:00:00.000000000 Z
11
+ date: 2022-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
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.1.2
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