simple-icons-rails 0.1.26 → 0.2.25

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: b7c608e4dfa9e11d1cc6a17edc824fe3495e312d90128bbad9a481eec12dc3c4
4
- data.tar.gz: 2aefd3ba724415cefc934ea35978f45d18b10b0fde27832a3f7150823b89b890
3
+ metadata.gz: 1bdedf15670ba61195be41872e4f02d709564998d1795fdc6c0fd927a5e7ff1d
4
+ data.tar.gz: d1e91f8afb9875eef0997def40a7519ef5617fb31c0ed8a04e108126b5b3ed2a
5
5
  SHA512:
6
- metadata.gz: 3c88680da51794e699f40b0f624285084b5d339d3b3bad292aa5a8380a3aa773fb72da81d8fc32af8ce78d1c7ad4f14e7a583a0b724997dc95bcc195f5851938
7
- data.tar.gz: fe09080e3dadbd2f13020e791ed979f4f93b7c53e8747f38bcb6a93433a3141e585c4c24e249f9d3037b81f482a66f724e7ec5d0182aab56c07138dbee355379
6
+ metadata.gz: 480205500d9cb2e9ccf55d1becb7569e6074182234aae8de0f38c30719bd83f0e9c0e58e388e1f24b726ec113fdd2d10e0f1e47202996d410caa158f4b3e1f88
7
+ data.tar.gz: a5158a433424b140c0ae07112dddbdaf9250bbfc5e8a3b43b313dac5ae6228188da1520168ab136bf99c2582023a62e314718e4b841d011d6bee243df568c161
data/CHANGELOG.md ADDED
@@ -0,0 +1,40 @@
1
+ ## [0.2.26] - 2024-11-08
2
+
3
+ - Removing push to GPR
4
+ - Changing naming conventions back to - instead of _ as changing on RubyGem was not approved.
5
+
6
+ ## [0.2.25] - 2024-11-08
7
+
8
+ - Adding support to Rails 8. This gem now supports from Rails 5 up to version 8.
9
+ - Updating the version number
10
+ - Upgrading the README.md
11
+
12
+ ## [Unreleased]
13
+
14
+ - 0.2.23 - 2023-07-02: change the way tests are running
15
+
16
+ ## [0.2.22] - 2023-07-01
17
+
18
+ - Adding support for app/config/initializers/simple_icons.rb to override the default CDN
19
+ - Updating the README file
20
+ - Adding more test cases
21
+
22
+ ## [0.2.16] - 2023-07-01
23
+
24
+ - Updating the README file
25
+
26
+ ## [0.2.14] - 2023-06-30
27
+
28
+ - Rename to simple_icons_rails to match Ruby gem conventions
29
+ - Adding tests via minitest
30
+ - Adding Rake task to test and build the gem
31
+ - Updated RBS
32
+ - Updated README
33
+
34
+ ## [0.1.26] - 2023-06-27
35
+
36
+ - Adding supported versions of Rails
37
+
38
+ ## [0.1.25] - 2023-06-27
39
+
40
+ - Initial release
data/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # Simple Icons Rails Gem
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/simple-icons-rails.svg)](https://badge.fury.io/rb/simple-icons-rails)
4
+
5
+ ## IMPORTANT
6
+ version 0.1.x `gem 'simple-icons-rails', '~> 0.1.0'`<br/>
7
+ version 0.2.x `gem 'simple_icons_rails', '~> 0.2.0'`
8
+
9
+ version 0.2.25 support Rails 8.
10
+
11
+ **In 2025 we will remove support to Rails 5 and Ruby 2.7** Versions following version 0.2.25 will support Rails 6 to 8 and Ruby 3.1 to 3.3 (or higher). If you need support for Rails version 5 use either 0.1.x or 0.2.22.
12
+
13
+ Thank you for your understanding.
14
+
15
+ ## Description
16
+
17
+ The Simple Icons Rails Gem is a Ruby gem designed for importing and using the icons from [Simple Icons](https://simpleicons.org/) in your Rails projects. Simple Icons provides a collection of more than 2500 SVG icons for various popular brands. <img src="https://img.shields.io/badge/dynamic/json?color=informational&label=icons&prefix=%20&logo=simpleicons&query=%24.icons.length&url=https%3A%2F%2Fraw.githubusercontent.com%2Fsimple-icons%2Fsimple-icons%2Fdevelop%2F_data%2Fsimple-icons.json" alt="Number of icons currently in the library"/>
18
+
19
+
20
+ This gem simplifies the process of rendering Simple Icons in a Rails application, allowing you to easily include the icons in your views and customize their appearance. This gem is acting as a passthrough to Simple Icons CDN. The icons are not downloaded to your Rails application. This means that when a new icon is uploaded or an existing one updated, you can access it right away without having to update this gem.
21
+
22
+ For more information about Simple Icons, please visit their website: [https://simpleicons.org/](https://simpleicons.org/). You can also explore the Simple Icons GitHub repository at [https://github.com/simple-icons](https://github.com/simple-icons).
23
+
24
+ ## Installation
25
+
26
+ To use the Simple Icons Rails Gem, follow these steps:
27
+
28
+ 1. Add the gem to your Rails application's Gemfile:
29
+
30
+ ```ruby
31
+ gem 'simple_icons_rails', '~> 0.2.0'
32
+ ```
33
+
34
+ 2. Save the Gemfile and run the following command to install the gem:
35
+
36
+ ```shell
37
+ bundle install
38
+ ```
39
+
40
+ That's it! The Simple Icons Rails Gem is now installed and ready to be used in your Rails application.
41
+
42
+ ## Usage
43
+
44
+ To render Simple Icons in your Rails views, you can utilize the `simpleicons` helper method provided by the gem. Here's an example of how to use it:
45
+
46
+ ```erb
47
+ <%= simple_icon('[ICON SLUG]', '[COLOR]', html_options = {}) %>
48
+ ```
49
+
50
+ Replace 'github' with the name of the specific icon you want to render. You can also customize the icon's appearance by passing additional options like width, height, class, and style. Use [https://simpleicons.org/](https://simpleicons.org/) to browse available icons.
51
+
52
+ [COLOR] is optional, and can be replaced by the [hex colors](https://developer.mozilla.org/en-US/docs/Web/CSS/hex-color) or [CSS keywords](https://www.w3.org/wiki/CSS/Properties/color/keywords) of the icon you want to you use. The color is defaulted to the HEX color of the icon shown in [simpleicons.org](https://simpleicons.org/) website. For example:
53
+
54
+ ```erb
55
+ <%= simple_icon('github') %>
56
+ <%= simple_icon('github', 'red') %>
57
+ <%= simple_icon('github', 'black', class: 'custom-class', style: 'color: red;') %>
58
+ <%= simple_icon('amazon', 'red', class: 'icon', height: '32', width: '32') %>
59
+ <%= simple_icon('github', '0cf', class: 'icon', height: '32', width: '32') %>
60
+ <%= simple_icon('simpleicons', '00ccff99', class: 'icon', height: '32', width: '32') %>
61
+ ```
62
+
63
+ ## Advanced configuration
64
+
65
+ **Version 0.2 and above** You can add a file, `simple_icons.rb` in your Rails `app/config/initializers` folder to change the CDN. See example below for more details.
66
+
67
+ ```ruby
68
+ # config/initializers/simple_icons.rb
69
+ SimpleIconsRails.configure do |config|
70
+ config.cdn_url = "https://new-cdn-url.com/"
71
+ end
72
+ ```
73
+
74
+ ## Development
75
+
76
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
77
+
78
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
79
+
80
+ ## Contributing
81
+
82
+ Bug reports and pull requests are welcome on GitHub at https://github.com/the-pew-inc/simple-icons-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/the-pew-inc/simple-icons-rails/blob/master/CODE_OF_CONDUCT.md).
83
+
84
+ ## License
85
+
86
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
87
+
88
+ ## Code of Conduct
89
+
90
+ Everyone interacting in the SimpleIconsRails project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/the-pew-inc/simple-icons-rails/blob/master/CODE_OF_CONDUCT.md).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleIconsRails
4
- VERSION = "0.1.26".freeze
4
+ VERSION = "0.2.25".freeze
5
5
  end
@@ -0,0 +1,54 @@
1
+ # lib/simple_icons_rails.rb
2
+ require "action_view"
3
+ require "uri"
4
+
5
+ module SimpleIconsRails
6
+ include ActionView::Helpers::TagHelper
7
+
8
+ class Configuration
9
+ attr_reader :cdn_url
10
+
11
+ def cdn_url=(url)
12
+ url = url.end_with?('/') ? url : "#{url}/"
13
+
14
+ begin
15
+ uri = URI.parse(url)
16
+
17
+ unless uri.is_a?(URI::HTTPS)
18
+ warn "WARNING: The CDN URL should be HTTPS."
19
+ end
20
+
21
+ unless uri.host
22
+ warn "WARNING: The CDN URL is not properly formatted."
23
+ end
24
+ rescue URI::InvalidURIError
25
+ warn "WARNING: The CDN URL is not properly formatted."
26
+ end
27
+
28
+ @cdn_url = url
29
+ end
30
+
31
+ def initialize
32
+ self.cdn_url = "https://cdn.simpleicons.org/"
33
+ end
34
+ end
35
+
36
+
37
+ def self.configure
38
+ yield(config)
39
+ end
40
+
41
+ def self.config
42
+ @config ||= Configuration.new
43
+ end
44
+
45
+ def simple_icon(icon_slug, color = nil, html_options = {})
46
+ svg_url = "#{SimpleIconsRails.config.cdn_url}#{icon_slug}/#{color}"
47
+ html_options[:src] = svg_url
48
+ html_options[:alt] ||= icon_slug # Optional: Set a default alt text if not provided
49
+
50
+ tag(:img, html_options)
51
+ end
52
+ end
53
+
54
+ ActionView::Base.include(SimpleIconsRails)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-icons-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.26
4
+ version: 0.2.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - spaquet
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-29 00:00:00.000000000 Z
11
+ date: 2024-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '5.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '8.0'
22
+ version: '9.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '5.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '8.0'
32
+ version: '9.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -44,6 +44,34 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '2.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: minitest
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: uri
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
47
75
  description: A gem that allows you to quickly import Simple Icons into your Rails
48
76
  project.
49
77
  email:
@@ -52,8 +80,10 @@ executables: []
52
80
  extensions: []
53
81
  extra_rdoc_files: []
54
82
  files:
55
- - lib/simple-icons-rails.rb
56
- - lib/simple-icons-rails/version.rb
83
+ - CHANGELOG.md
84
+ - README.md
85
+ - lib/simple_icons_rails.rb
86
+ - lib/simple_icons_rails/version.rb
57
87
  homepage: https://github.com/the-pew-inc/simple-icons-rails
58
88
  licenses:
59
89
  - MIT
@@ -76,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
106
  - !ruby/object:Gem::Version
77
107
  version: '0'
78
108
  requirements: []
79
- rubygems_version: 3.1.6
109
+ rubygems_version: 3.5.22
80
110
  signing_key:
81
111
  specification_version: 4
82
112
  summary: A Rails gem for importing Simple Icons
@@ -1,11 +0,0 @@
1
- module SimpleIconsRails
2
- def simple_icon(icon_slug, color = nil, html_options = {})
3
- svg_url = "https://cdn.simpleicons.org/#{icon_slug}/#{color}"
4
- html_options[:src] = svg_url
5
- html_options[:alt] ||= icon_slug # Optional: Set a default alt text if not provided
6
-
7
- tag(:img, html_options)
8
- end
9
- end
10
-
11
- ActionView::Base.include SimpleIconsRails