FontAwesomeScrapper 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/FontAwesomeScrapper.rb +61 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ddb06c16f16d3a7ad5d0b507e2863c4cb8c81543a45fc7387a9a9bb5b89df118
4
+ data.tar.gz: 2ec9fe3fe84d3a4ae3205ff355cd920f285c199fafbe943f95c9cab2431a1237
5
+ SHA512:
6
+ metadata.gz: 5f7c65c1daf8bde9b8dd0223264a0a3417a70386deeb44f8fb653aa510e9716356e4c252bf207b700e6bed0ebfa4c68412c4f644fe1893c77bdd1d932eb2cbd2
7
+ data.tar.gz: cfb35dd7b47ccf8126ead40b0e2c390aeb3a238b7e0deb37dbbf364a166b2508d9c0db9973b7c40fc64a716c12f0d74d7ec21c5fa4c83135502b1753bd204681
@@ -0,0 +1,61 @@
1
+ =begin
2
+ Copyright (c) 2023 XAVIER Clément Antoine
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ =end
17
+
18
+ require 'algolia'
19
+
20
+ class FontAwesomeScrapper
21
+ ALGOLIA_APP_ID = 'M19DXW5X0Q'.freeze
22
+ ALGOLIA_API_KEY = 'c79b2e61519372a99fa5890db070064c'.freeze
23
+ ALGOLIA_INDEX_NAME = 'fontawesome_com-splayed-5.15.4'.freeze
24
+
25
+ # Initialize the scrapper
26
+ def initialize
27
+ @algolia_client = Algolia::Search::Client.create(ALGOLIA_APP_ID, ALGOLIA_API_KEY)
28
+
29
+ @index = @algolia_client.init_index(ALGOLIA_INDEX_NAME)
30
+
31
+ @icons = fetch_icons
32
+ end
33
+
34
+ # Return all free icons
35
+ def free_icons
36
+ free_icons = []
37
+
38
+ @icons.each do |icon|
39
+ free_icons << icon[:name] if icon[:is_free]
40
+ end
41
+
42
+ return free_icons
43
+ end
44
+
45
+ private
46
+
47
+ # Fetch all icons from Algolia
48
+ def fetch_icons
49
+ nbPages = @index.search('')[:nbPages]
50
+
51
+ icons = []
52
+
53
+ (0..nbPages).each do |page|
54
+ data = @index.search('', { page: page })
55
+
56
+ icons += data[:hits]
57
+ end
58
+
59
+ icons
60
+ end
61
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: FontAwesomeScrapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - XAVIER Clément Antoine
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-10-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: With this gem you can retrieve all Font Awesome V5 icons and their unicode
14
+ values.
15
+ email: clement-antoine.xavier@epitech.eu
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/FontAwesomeScrapper.rb
21
+ homepage: https://rubygems.org/gems/FontAwesomeScrapper
22
+ licenses:
23
+ - GPL-3.0
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubygems_version: 3.4.19
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: A Ruby gem that retrieves all Font Awesome V5 icons
44
+ test_files: []