rails_real_favicon 0.0.13 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 467ffac2b70a0f283a488211b48e16c124c7788b5eee7c15505f50264e9d5b74
4
- data.tar.gz: acc54c3f7e2f68a373dc5c2c0ca0fd6c14d80e2804b540410838144f610e116e
3
+ metadata.gz: e823c3c86c744d835556fbc0747b5f9ddc4f277851a9a33259602ed721292aeb
4
+ data.tar.gz: 2c3ea182d7e86b34240a57bb861420395a179e95e2edeb1dcaeadfa514068624
5
5
  SHA512:
6
- metadata.gz: f328627cf78a8cb70c0f444199d9ee8f861675d1b290fb4640d3c09abee1d1b99404e1fb147d4cf3cc6c65dca9c1ac99148097b3e86a5085d61a0ebf7ecfdb24
7
- data.tar.gz: 0d8d642baba628ce2c027114a6d53be60d73dc04f294878f4a8ff2ee49e667d4a5edd051dd351a3760d84aa066895461cb3ce68e9f8443bf940e0d00ad4ccda9
6
+ metadata.gz: 1eca3d64fefdc3cd94904b6a0893e7aad3baa8891c98f488e99132676d1b94b1bf9097882b2c38851d925a247bf5bc6d20b3c8b26088673c343b52dbde8fae9c
7
+ data.tar.gz: 7131d28b49dd8497b6fc348568ed49554c8107e1d7b6dd387a504d745e2889c99df6cc95b8b1ea8c6270c4e77a4531094d4154a21cc9bbfc54770edaf35147e2
@@ -7,9 +7,11 @@ require 'base64'
7
7
 
8
8
  class FaviconGenerator < Rails::Generators::Base
9
9
  API_KEY = '04641dc33598f5463c2f1ff49dd9e4a617559f4b'
10
-
10
+
11
11
  PATH_UNIQUE_KEY = '/Dfv87ZbNh2'
12
12
 
13
+ class_option(:timeout, type: :numeric, aliases: '-t', default: 30)
14
+
13
15
  def generate_favicon
14
16
  if File.exist?('config/favicon.yml') && defined?(Rails.application.config_for)
15
17
  req = Rails.application.config_for(:favicon)
@@ -29,11 +31,16 @@ class FaviconGenerator < Rails::Generators::Base
29
31
  req['master_picture']['content'] = Base64.encode64(File.binread(master_pic))
30
32
 
31
33
  uri = URI.parse("https://realfavicongenerator.net/api/favicon")
32
- resp = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https", read_timeout: 20) do |http|
34
+ timeout = options[:timeout]
35
+ resp = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https", read_timeout: timeout) do |http|
33
36
  request = Net::HTTP::Post.new uri
34
37
  request.body = { favicon_generation: req }.to_json
35
38
  request["Content-Type"] = "application/json"
36
- JSON.parse(http.request(request).body)
39
+ begin
40
+ JSON.parse(http.request(request).body)
41
+ rescue Net::ReadTimeout
42
+ raise RuntimeError.new("Operation timed out after #{timeout} seconds, pass a `-t` option for a longer timeout")
43
+ end
37
44
  end
38
45
 
39
46
  zip = resp['favicon_generation_result']['favicon']['package_url']
@@ -100,3 +107,4 @@ class FaviconGenerator < Rails::Generators::Base
100
107
  end
101
108
 
102
109
  end
110
+
@@ -6,5 +6,13 @@
6
6
  # to asset_path in the _favicon.html.erb partial.
7
7
 
8
8
  Rails.application.config.assets.configure do |env|
9
- env.register_mime_type('application/manifest+json', extensions: ['.webmanifest'])
9
+ mime_type = 'application/manifest+json'
10
+ extensions = ['.webmanifest']
11
+
12
+ if Sprockets::VERSION.to_i >= 4
13
+ extensions << '.webmanifest.erb'
14
+ env.register_preprocessor(mime_type, Sprockets::ERBProcessor)
15
+ end
16
+
17
+ env.register_mime_type(mime_type, extensions: extensions)
10
18
  end
@@ -1,3 +1,3 @@
1
1
  module RailsRealFavicon
2
- VERSION = "0.0.13"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_real_favicon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philippe Bernard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-23 00:00:00.000000000 Z
11
+ date: 2020-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '1'
53
+ version: '2'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '1'
60
+ version: '2'
61
61
  description: Generate and install a favicon for all platforms with RealFaviconGenerator.
62
62
  email:
63
63
  - philippe@realfavicongenerator.net