url_to_image_path 0.1.1 → 0.1.2
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 +4 -4
- data/lib/url_to_image_path/version.rb +1 -1
- data/lib/url_to_image_path.rb +4 -3
- data/url_to_image_path-0.1.1.gem +0 -0
- metadata +2 -2
- data/lib/convert_urls.rake +0 -39
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ed41572d7bcd3a15507e1efefdd11fa0317b356f
|
|
4
|
+
data.tar.gz: 14a8e728023fdf0c1f1f8646d0b7ca1914b32d1b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ffb1aa10db77979d93f814f33b33ab9143c40d2759bf24b05f6fa55e9af882100e6d4a10ffc320b6d46f1bb31133babf4cb3be6befef1c98f8d7ff907b7aeb00
|
|
7
|
+
data.tar.gz: a5fb225357e1b947b12b8586c6003b5d83f4ea813c27849d59676922e42ef72367a446bbbcb321fee46ec461cd74733427633801d52c1c21c59fe3d4230472c0
|
data/lib/url_to_image_path.rb
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: url_to_image_path
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Neven Rakonić
|
|
@@ -70,11 +70,11 @@ files:
|
|
|
70
70
|
- Rakefile
|
|
71
71
|
- bin/console
|
|
72
72
|
- bin/setup
|
|
73
|
-
- lib/convert_urls.rake
|
|
74
73
|
- lib/url_to_image_path.rb
|
|
75
74
|
- lib/url_to_image_path/version.rb
|
|
76
75
|
- tasks/convert_urls.rake
|
|
77
76
|
- tasks/rspec.rake
|
|
77
|
+
- url_to_image_path-0.1.1.gem
|
|
78
78
|
- url_to_image_path.gemspec
|
|
79
79
|
homepage: https://github.com/nevenRakonic/url_to_image_path
|
|
80
80
|
licenses:
|
data/lib/convert_urls.rake
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
require 'rake'
|
|
2
|
-
require 'tempfile'
|
|
3
|
-
|
|
4
|
-
desc "receives a css file and returns an scss file with url links changed to
|
|
5
|
-
asset pipeline helpers"
|
|
6
|
-
|
|
7
|
-
task :urlify, [:filename] do |title, args|
|
|
8
|
-
file_name = args[:filename]
|
|
9
|
-
assets_path = Rails.root.join('app/assets/stylesheets/')
|
|
10
|
-
|
|
11
|
-
# looks for either end of parenthesis and the slash sign
|
|
12
|
-
split_pattern = /[\(\)\/]/
|
|
13
|
-
image_extension = /(\.png)|(\.jpg)|(\.gif)/
|
|
14
|
-
|
|
15
|
-
#we create a temporary file
|
|
16
|
-
tmp = Tempfile.new("tmp")
|
|
17
|
-
|
|
18
|
-
css = File.open(assets_path + file_name, "r+")
|
|
19
|
-
css.each do |line|
|
|
20
|
-
# find lines with css url property
|
|
21
|
-
if /url/.match(line)
|
|
22
|
-
matches = line.split(split_pattern)
|
|
23
|
-
matches.each do |part|
|
|
24
|
-
# extract art of the line that contains image name with extension
|
|
25
|
-
if image_extension.match(part)
|
|
26
|
-
part.gsub!(/[^0-9a-z_\-\.]/i, '')
|
|
27
|
-
line.gsub!(/url\(.*\)/, "url(image_path(\"#{part}\"))")
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
tmp << line
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
tmp.close
|
|
35
|
-
css.close
|
|
36
|
-
|
|
37
|
-
# we move the temporary file to the assets directory
|
|
38
|
-
mv(tmp.path, assets_path.join(file_name + ".scss"))
|
|
39
|
-
end
|