undraw 0.3.2 → 0.3.5

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: e1a009ebd4fa6a9f1bd0de8b591ebd844dc5dd68b3471675a01d7700828044c0
4
- data.tar.gz: e709c62511471c9364268ac41c07be3cc03452a98bee975d62e99b502d6555b2
3
+ metadata.gz: b52688b98b807bf1c3849a9c570c5a04546f39d8aef8d0d3bd24f92d150a38ea
4
+ data.tar.gz: 9c5be8741beaac9e606a0d470073b3cb3603ed8e95a4e22ab96356e67b32e389
5
5
  SHA512:
6
- metadata.gz: ee88f402d3a0d4b4c86558739facbb1e426a612986498481b8599823371003c662408076bd7a61f6465d5e9c6afcef2044589439249e20410a5e5fe404e18d3f
7
- data.tar.gz: 0d08935413caf51f41069fc93fec99901f5e4d059a1aa29d69f8a19e7699cebaad2a0793178371ae6c8cefdde5fc5180420dcd6feef5cf8167533e3f67b7a5a6
6
+ metadata.gz: 116705151d9904f8d02c386b6140438251a928f9516f7b2ecc0fb188bb1ebbc00222a2cdfad7aa07e8a197133883807ece58a5230e5bc82307864c3c6adbc89d
7
+ data.tar.gz: 0db9810af88c5cf9d01d68b2b46a45d437b788727141229501a8d5f1fe6e19b3c36d18bdc95a55440f40f54a04002c2c48624ebe82ae0ccb9541e58fe7495bff
data/Gemfile.lock CHANGED
@@ -1,39 +1,35 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- undraw (0.2.0)
5
- inline_svg (~> 1.3.1)
4
+ undraw (0.3.5)
5
+ inline_svg (~> 1.8.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (5.2.2)
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.4)
16
- i18n (1.4.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.9.1)
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.1
35
+ 2.3.7
data/README.md CHANGED
@@ -45,18 +45,26 @@ Browse to find the [images](https://undraw.co/illustrations) that fit your needs
45
45
  <%= undraw("designer_life", color: "#ff6347", class: "undraw-designer-life") %>
46
46
  ```
47
47
 
48
- **Note:
49
-
50
-
51
- This gem will often update assets perhaps weekly. You need to manually update your installed gem to support new svg released.
52
-
53
- $ bundle update undraw
54
-
48
+ ## Update
49
+ Run bundle update to latest gem released
55
50
 
56
- DEMO: http://materialize.labs.my/undraw
57
- ## Development
51
+ ```$ bundle update undraw```
52
+
53
+ Due the license issue, any new illustrations released are no longer added to this gems and existing assets might be removed in a future release.
54
+ You need to manually download preferred svg file and put on:
55
+
56
+ ```\vendor\images\undraw\<asset_name>.svg```
57
+
58
+
59
+ ```ruby
60
+ # default color
61
+ <%= undraw("<asset_name>") %>
62
+ ```
58
63
 
59
64
 
65
+ ## Development
66
+ DEMO: http://materialize.labs.my/undraw
67
+
60
68
 
61
69
  ## Contributing
62
70
 
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,28 +1,33 @@
1
1
  module Undraw
2
2
  module Helper
3
+ def undraw(filename, options = {})
4
+ svg_file = read_undraw_svg(filename)
5
+ color = options.delete(:color)
6
+ output = recolor_undraw_svg(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
12
+
13
+ private
3
14
 
4
- def undraw(filename, transform_params={})
15
+ def read_undraw_svg(filename)
5
16
  asset_path = "#{Undraw.root}/vendor/assets/images/undraw/#{filename}.svg"
6
- begin
7
- svg_file = File.read(asset_path)
8
- color = transform_params.delete(:color)
9
-
10
- if color.is_a?(Hash)
11
- #:todo:
12
- #= undraw("building", color: {primary: #ff6347, hair: black}, class: 'undraw-features', size: "350*150")
13
- primary = color[:primary]
14
- else
15
- primary = color
16
- end
17
+ vendor_path = "#{Rails.root}/vendor/assets/images/undraw/#{filename}.svg"
18
+ File.read(File.exist?(vendor_path) ? vendor_path : asset_path)
19
+ end
17
20
 
18
- svg_file.gsub!(/#6c63ff/, primary) if primary
19
- #inline_svg svg_file, class: 'some-class'
20
- InlineSvg::TransformPipeline.generate_html_from(svg_file, transform_params).html_safe
21
- rescue Errno::ENOENT
22
- raise Undraw::FileNotFound.new("Asset not found: #{asset_path}")
21
+ def recolor_undraw_svg(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
23
28
  end
29
+ svg_file.gsub!(/#6c63ff/, primary) if primary
30
+ svg_file
24
31
  end
25
-
26
32
  end
27
-
28
33
  end
@@ -1,3 +1,3 @@
1
1
  module Undraw
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.5"
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.2
4
+ version: 0.3.5
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-18 00:00:00.000000000 Z
11
+ date: 2022-03-03 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