undraw 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +17 -21
- data/lib/undraw/engine.rb +9 -9
- data/lib/undraw/helper.rb +24 -26
- data/lib/undraw/version.rb +1 -1
- data/lib/undraw.rb +4 -14
- metadata +5 -37
- data/.gitignore +0 -10
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/undraw.gemspec +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c802e76ae03099a6136d0b75403e974979b142f44996e4f4f2c21b0f9926dad
|
4
|
+
data.tar.gz: fb74b805974e42db9477db9e03f295ba02b6ef3a7b5d8731528c4d21e8e49af6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
5
|
-
inline_svg (~> 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 (
|
10
|
+
activesupport (7.0.2.2)
|
11
11
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
-
i18n (>=
|
13
|
-
minitest (
|
14
|
-
tzinfo (~>
|
15
|
-
concurrent-ruby (1.1.
|
16
|
-
i18n (1.
|
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.
|
18
|
+
inline_svg (1.8.0)
|
19
19
|
activesupport (>= 3.0)
|
20
20
|
nokogiri (>= 1.6)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
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
|
-
|
35
|
+
2.3.7
|
data/lib/undraw/engine.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
data/lib/undraw/version.rb
CHANGED
data/lib/undraw.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
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(
|
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.
|
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:
|
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.
|
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.
|
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.
|
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
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
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
|