Skip to content

Commit e12232c

Browse files
eelcojeelco
andauthored
Extracted most non-Rails logic into the icons gem (#97)
* Extracted most non-Rails logic into the icons gem Rails Icons has been, as the name implies, Rails only. But there are many other great frameworks and Ruby apps that can benefit from the Rails Icons' core: pulling SVG icons from their GitHub repos, easily sync them and offer a class to render them, with various attributes as SVG. Find the [icons gem](https://github.com/rails-designer/icons) here. * Updated Appraisal gemfiles --------- Co-authored-by: eelco <git@eelcoj.com>
1 parent da77f73 commit e12232c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+76
-1473
lines changed

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ source "https://rubygems.org"
55
# Specify your gem's dependencies in rails_icons.gemspec
66
gemspec
77

8-
# gem "rails", "~> 7.0.6"
98
gem "appraisal"
109
gem "propshaft"
1110

Gemfile.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ PATH
22
remote: .
33
specs:
44
rails_icons (1.6.1)
5-
nokogiri (~> 1.16, >= 1.16.4)
5+
icons (~> 0.6.0)
66
rails (>= 7.0)
77

88
GEM
@@ -102,6 +102,8 @@ GEM
102102
activesupport (>= 6.1)
103103
i18n (1.14.7)
104104
concurrent-ruby (~> 1.0)
105+
icons (0.6.0)
106+
nokogiri (~> 1.16, >= 1.16.4)
105107
io-console (0.8.1)
106108
irb (1.15.2)
107109
pp (>= 0.6.0)

gemfiles/rails_7_0.gemfile.lock

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: ..
33
specs:
4-
rails_icons (1.6.0)
5-
nokogiri (~> 1.16, >= 1.16.4)
4+
rails_icons (1.6.1)
5+
icons (~> 0.6.0)
66
rails (>= 7.0)
77

88
GEM
@@ -96,6 +96,8 @@ GEM
9696
activesupport (>= 6.1)
9797
i18n (1.14.7)
9898
concurrent-ruby (~> 1.0)
99+
icons (0.6.0)
100+
nokogiri (~> 1.16, >= 1.16.4)
99101
io-console (0.8.1)
100102
irb (1.15.2)
101103
pp (>= 0.6.0)

gemfiles/rails_7_1.gemfile.lock

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: ..
33
specs:
4-
rails_icons (1.6.0)
5-
nokogiri (~> 1.16, >= 1.16.4)
4+
rails_icons (1.6.1)
5+
icons (~> 0.6.0)
66
rails (>= 7.0)
77

88
GEM
@@ -110,6 +110,8 @@ GEM
110110
activesupport (>= 6.1)
111111
i18n (1.14.7)
112112
concurrent-ruby (~> 1.0)
113+
icons (0.6.0)
114+
nokogiri (~> 1.16, >= 1.16.4)
113115
io-console (0.8.1)
114116
irb (1.15.2)
115117
pp (>= 0.6.0)

gemfiles/rails_7_2.gemfile.lock

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: ..
33
specs:
4-
rails_icons (1.6.0)
5-
nokogiri (~> 1.16, >= 1.16.4)
4+
rails_icons (1.6.1)
5+
icons (~> 0.6.0)
66
rails (>= 7.0)
77

88
GEM
@@ -104,6 +104,8 @@ GEM
104104
activesupport (>= 6.1)
105105
i18n (1.14.7)
106106
concurrent-ruby (~> 1.0)
107+
icons (0.6.0)
108+
nokogiri (~> 1.16, >= 1.16.4)
107109
io-console (0.8.1)
108110
irb (1.15.2)
109111
pp (>= 0.6.0)

gemfiles/rails_8_0.gemfile.lock

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: ..
33
specs:
4-
rails_icons (1.6.0)
5-
nokogiri (~> 1.16, >= 1.16.4)
4+
rails_icons (1.6.1)
5+
icons (~> 0.6.0)
66
rails (>= 7.0)
77

88
GEM
@@ -102,6 +102,8 @@ GEM
102102
activesupport (>= 6.1)
103103
i18n (1.14.7)
104104
concurrent-ruby (~> 1.0)
105+
icons (0.6.0)
106+
nokogiri (~> 1.16, >= 1.16.4)
105107
io-console (0.8.1)
106108
irb (1.15.2)
107109
pp (>= 0.6.0)

gemfiles/rails_main.gemfile.lock

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ GIT
102102
PATH
103103
remote: ..
104104
specs:
105-
rails_icons (1.6.0)
106-
nokogiri (~> 1.16, >= 1.16.4)
105+
rails_icons (1.6.1)
106+
icons (~> 0.6.0)
107107
rails (>= 7.0)
108108

109109
GEM
@@ -134,6 +134,8 @@ GEM
134134
activesupport (>= 6.1)
135135
i18n (1.14.7)
136136
concurrent-ruby (~> 1.0)
137+
icons (0.6.0)
138+
nokogiri (~> 1.16, >= 1.16.4)
137139
io-console (0.8.1)
138140
irb (1.15.2)
139141
pp (>= 0.6.0)

lib/generators/rails_icons/initializer_generator.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def insert_custom_configuration
7575
def create_custom_directory = FileUtils.mkdir_p(File.join(options[:destination], options[:custom]))
7676

7777
def library_configuration
78-
libraries.map { RailsIcons.libraries[_1.to_sym].initializer_config }.join("\n")
78+
libraries.map { |library| RailsIcons.libraries[library.to_sym].initializer_config }.join("\n")
7979
end
8080

8181
def custom_configuration
@@ -92,7 +92,7 @@ def custom_configuration
9292
def default_configuration_exists?
9393
line = /^\s*config\.default_library\s*=/
9494

95-
File.readlines(INITIALIZER).any? { _1.match?(line) }
95+
File.readlines(INITIALIZER).any? { |file_line| file_line.match?(line) }
9696
end
9797

9898
def libraries

lib/generators/rails_icons/sync_generator.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# frozen_string_literal: true
22

33
require "rails_icons/base_generator"
4-
require "rails_icons/sync/engine"
54

65
module RailsIcons
76
class SyncGenerator < RailsIcons::BaseGenerator
@@ -12,7 +11,9 @@ class SyncGenerator < RailsIcons::BaseGenerator
1211
class_option :library, type: :string, desc: "Choose a library (#{RailsIcons.libraries.keys.join("/")})"
1312
class_option :libraries, type: :array, default: [], desc: "Choose libraries (#{RailsIcons.libraries.keys.join("/")})"
1413

15-
def sync_icons = libraries.each { Sync::Engine.new(_1).sync }
14+
def sync_icons
15+
libraries.each { |library| Icons::Sync.new(library).now }
16+
end
1617

1718
private
1819

lib/rails_icons.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
# frozen_string_literal: true
22

3+
require "icons"
4+
35
require_relative "rails_icons/version"
4-
require_relative "rails_icons/libraries"
5-
require_relative "rails_icons/configuration"
66
require_relative "rails_icons/engine"
7-
require_relative "rails_icons/errors"
8-
require_relative "rails_icons/icon"
97

108
module RailsIcons
9+
class << self
10+
def configure(&block) = Icons.configure(&block)
11+
12+
def configuration = Icons.configuration
13+
alias_method :config, :configuration
14+
15+
def libraries = Icons.libraries
16+
end
1117
end

0 commit comments

Comments
 (0)