undraw 0.3.3 → 0.3.4

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: 461d8f0b985f1b1fde5e56eb1c20e47df84eb7480f5e91628fd2b5d018af2353
4
- data.tar.gz: 5b2cfec3950b43c938f46b83d7c9cf7026dd0f5f370b7cea4f744d473cd7706a
3
+ metadata.gz: 0c802e76ae03099a6136d0b75403e974979b142f44996e4f4f2c21b0f9926dad
4
+ data.tar.gz: fb74b805974e42db9477db9e03f295ba02b6ef3a7b5d8731528c4d21e8e49af6
5
5
  SHA512:
6
- metadata.gz: 31aa52e5a0a0ce8aac73cc703b16503f1ee19b8a90b1db4c55ba81d4a04247bc50924dd5248b2229192532e5db3af99e67f5856634ef25f34f1a132682a7d90c
7
- data.tar.gz: 9809411cf274edf9dfdc1150047dfaab697a159ac009be8587fcccb1fae060ab74279e344897a6c29f81b4a6597fe3f210a156f5dfd2bfd75ca763d90810ef88
6
+ metadata.gz: '0297d27395d95e8bf3f5f1891f5dc45df854b4058f05736391cd9182241cbcb87f07e310ecedf624c682e6328fa816108b143d31e1b01bb80d30608561d73823'
7
+ data.tar.gz: 2ba484fd3276cdeb30ca0152eabb439bb11eb61fe4d65eb8633bdda06267bc1cf7ddc9dfbfeb692a03d8a8ecfbdc96118e5565fad26c47014270c63f8bbbb1d6
data/Gemfile.lock CHANGED
@@ -1,39 +1,35 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- undraw (0.3.3)
5
- inline_svg (~> 1.3.1)
4
+ undraw (0.3.4)
5
+ inline_svg (~> 1.8.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (5.2.3)
10
+ activesupport (7.0.2.2)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
- i18n (>= 0.7, < 2)
13
- minitest (~> 5.1)
14
- tzinfo (~> 1.1)
15
- concurrent-ruby (1.1.5)
16
- i18n (1.6.0)
12
+ i18n (>= 1.6, < 2)
13
+ minitest (>= 5.1)
14
+ tzinfo (~> 2.0)
15
+ concurrent-ruby (1.1.9)
16
+ i18n (1.10.0)
17
17
  concurrent-ruby (~> 1.0)
18
- inline_svg (1.3.1)
18
+ inline_svg (1.8.0)
19
19
  activesupport (>= 3.0)
20
20
  nokogiri (>= 1.6)
21
- mini_portile2 (2.4.0)
22
- minitest (5.11.3)
23
- nokogiri (1.10.3)
24
- mini_portile2 (~> 2.4.0)
25
- rake (10.5.0)
26
- thread_safe (0.3.6)
27
- tzinfo (1.2.5)
28
- thread_safe (~> 0.1)
21
+ minitest (5.15.0)
22
+ nokogiri (1.13.3-x86_64-linux)
23
+ racc (~> 1.4)
24
+ racc (1.6.0)
25
+ tzinfo (2.0.4)
26
+ concurrent-ruby (~> 1.0)
29
27
 
30
28
  PLATFORMS
31
- ruby
29
+ x86_64-linux
32
30
 
33
31
  DEPENDENCIES
34
- bundler (~> 1.16)
35
- rake (~> 10.0)
36
32
  undraw!
37
33
 
38
34
  BUNDLED WITH
39
- 1.17.2
35
+ 2.3.7
data/lib/undraw/engine.rb CHANGED
@@ -1,14 +1,14 @@
1
- require "undraw/helper"
1
+ require 'inline_svg'
2
+ require 'undraw/helper'
2
3
 
3
4
  module Undraw
4
5
  class FileNotFound < IOError; end
5
-
6
+
6
7
  class Engine < ::Rails::Engine
7
- # initializer 'undraw.assets' do |app|
8
- # %w(stylesheets javascripts).each do |sub|
9
- # app.config.assets.paths << root.join('vendor/assets', sub).to_s
10
- # end
11
- # end
12
- ActionController::Base.send(:helper, Undraw::Helper)
8
+ initializer 'undraw.assets' do |_app|
9
+ ActiveSupport.on_load(:action_controller) do
10
+ ActionController::Base.send(:helper, Undraw::Helper)
11
+ end
12
+ end
13
13
  end
14
- end
14
+ end
data/lib/undraw/helper.rb CHANGED
@@ -1,35 +1,33 @@
1
1
  module Undraw
2
2
  module Helper
3
+ def undraw(filename, options = {})
4
+ svg_file = read_svg(filename)
5
+ color = options.delete(:color)
6
+ output = recolor(svg_file, color)
7
+ InlineSvg::TransformPipeline.generate_html_from(output, options).html_safe
8
+ rescue Errno::ENOENT => e
9
+ raise Undraw::FileNotFound,
10
+ "Asset not found: #{filename}, you can manually download and place svg file in this path #{e.message.split('-').last}"
11
+ end
3
12
 
4
- def undraw(filename, transform_params={})
5
- asset_path = "#{Undraw.root}/vendor/assets/images/undraw/#{filename}.svg"
6
- vendor_path = "#{Rails.root}/vendor/assets/images/undraw/#{filename}.svg"
7
- begin
8
-
9
- if File.exist?(vendor_path)
10
- svg_file = File.read(vendor_path)
11
- else
12
- svg_file = File.read(asset_path)
13
- end
13
+ private
14
14
 
15
- color = transform_params.delete(:color)
16
-
17
- if color.is_a?(Hash)
18
- #:todo:
19
- #= undraw("building", color: {primary: #ff6347, hair: black}, class: 'undraw-features', size: "350*150")
20
- primary = color[:primary]
21
- else
22
- primary = color
23
- end
15
+ def read_svg(filename)
16
+ asset_path = "#{Undraw.root}/vendor/assets/images/undraw/#{filename}.svg"
17
+ vendor_path = "#{Rails.root}/vendor/assets/images/undraw/#{filename}.svg"
18
+ File.read(File.exist?(vendor_path) ? vendor_path : asset_path)
19
+ end
24
20
 
25
- svg_file.gsub!(/#6c63ff/, primary) if primary
26
- #inline_svg svg_file, class: 'some-class'
27
- InlineSvg::TransformPipeline.generate_html_from(svg_file, transform_params).html_safe
28
- rescue Errno::ENOENT
29
- raise Undraw::FileNotFound.new("Asset not found: #{filename}, you can manually download and place svg in #{vendor_path}")
21
+ def recolor(svg_file, color)
22
+ if color.is_a?(Hash)
23
+ # :todo:
24
+ # = undraw("building", color: { primary: #ff6347, hair: black }, class: 'undraw-features', size: "350*150")
25
+ primary = color[:primary]
26
+ else
27
+ primary = color
30
28
  end
29
+ svg_file.gsub!(/#6c63ff/, primary) if primary
30
+ svg_file
31
31
  end
32
-
33
32
  end
34
-
35
33
  end
@@ -1,3 +1,3 @@
1
1
  module Undraw
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
data/lib/undraw.rb CHANGED
@@ -1,7 +1,6 @@
1
- require "undraw/version"
1
+ require 'undraw/version'
2
2
 
3
3
  module Undraw
4
-
5
4
  class << self
6
5
  def load!
7
6
  if rails?
@@ -14,20 +13,12 @@ module Undraw
14
13
  def root
15
14
  File.dirname __dir__
16
15
  end
17
-
16
+
18
17
  # Paths
19
18
  def gem_path
20
19
  @gem_path ||= File.expand_path '..', File.dirname(__FILE__)
21
20
  end
22
21
 
23
- def stylesheets_path
24
- File.join assets_path, 'stylesheets'
25
- end
26
-
27
- def javascripts_path
28
- File.join assets_path, 'javascripts'
29
- end
30
-
31
22
  def assets_path
32
23
  @assets_path ||= File.join gem_path, 'vendor/assets'
33
24
  end
@@ -48,10 +39,9 @@ module Undraw
48
39
  end
49
40
 
50
41
  def register_sprockets
51
- Sprockets.append_path(stylesheets_path)
52
- #Sprockets.append_path(javascripts_path)
42
+ Sprockets.append_path(assets_path)
53
43
  end
54
44
  end
55
45
  end
56
46
 
57
- Undraw.load!
47
+ Undraw.load!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: undraw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - mkhairi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-24 00:00:00.000000000 Z
11
+ date: 2022-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: inline_svg
@@ -16,42 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.3.1
19
+ version: 1.8.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.3.1
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.16'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.16'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '10.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '10.0'
26
+ version: 1.8.0
55
27
  description: Embed an SVG illustrations by unDraw https://undraw.co/illustrations
56
28
  into your rails app. Take advantage of the on-the-fly color image generation to
57
29
  match your brand identity.
@@ -61,20 +33,16 @@ executables: []
61
33
  extensions: []
62
34
  extra_rdoc_files: []
63
35
  files:
64
- - ".gitignore"
65
36
  - CODE_OF_CONDUCT.md
66
37
  - Gemfile
67
38
  - Gemfile.lock
68
39
  - LICENSE.txt
69
40
  - README.md
70
41
  - Rakefile
71
- - bin/console
72
- - bin/setup
73
42
  - lib/undraw.rb
74
43
  - lib/undraw/engine.rb
75
44
  - lib/undraw/helper.rb
76
45
  - lib/undraw/version.rb
77
- - undraw.gemspec
78
46
  - vendor/assets/images/undraw/3d_modeling.svg
79
47
  - vendor/assets/images/undraw/a_day_at_the_park.svg
80
48
  - vendor/assets/images/undraw/a_whole_year.svg
@@ -792,7 +760,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
792
760
  - !ruby/object:Gem::Version
793
761
  version: '0'
794
762
  requirements: []
795
- rubygems_version: 3.0.1
763
+ rubygems_version: 3.3.7
796
764
  signing_key:
797
765
  specification_version: 4
798
766
  summary: MIT licensed illustrations by unDraw for your rails projects, https://undraw.co/illustrations
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- *.gem
10
- scrap.rb
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "undraw"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/undraw.gemspec DELETED
@@ -1,30 +0,0 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "undraw/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "undraw"
8
- spec.version = Undraw::VERSION
9
- spec.authors = ["mkhairi"]
10
- spec.email = ["khairi@labs.my"]
11
-
12
- spec.summary = %q{MIT licensed illustrations by unDraw for your rails projects, https://undraw.co/illustrations}
13
- spec.description = %q{Embed an SVG illustrations by unDraw https://undraw.co/illustrations into your rails app. Take advantage of the on-the-fly color image generation to match your brand identity.}
14
- spec.homepage = "https://github.com/mkhairi/undraw"
15
- spec.license = "MIT"
16
-
17
- # Specify which files should be added to the gem when it is released.
18
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
- end
22
- spec.bindir = "exe"
23
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
- spec.require_paths = ["lib"]
25
-
26
- spec.add_runtime_dependency "inline_svg", "~>1.3.1"
27
-
28
- spec.add_development_dependency "bundler", "~> 1.16"
29
- spec.add_development_dependency "rake", "~> 10.0"
30
- end