url_to_image_path 0.1.0 → 0.1.1
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/.DS_Store +0 -0
- data/.gitignore +1 -0
- data/lib/url_to_image_path/version.rb +1 -1
- data/tasks/convert_urls.rake +41 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cd582154aa9f5cdb63de778cf279fc46d5c5bf59
|
|
4
|
+
data.tar.gz: b3bc2604671a17e56e74038e8080e6e6fdaa7d03
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7bb099900120ba39d9da1a7cfedc518a5ef329698381242f89a8db4d219a4b7654257e9abc8b301c35a3a9ce116265a9f679600bfaadcfdda50bf8c181aebafc
|
|
7
|
+
data.tar.gz: 0e05cb36d1ad2050853534251215bb23dbcb0a2d6d9cc8068e5e88e7fb267edf33d9a8060c11a76cb7392c455e73a2c0d6b7a4dae03fc2883c07eac8aeacd417
|
data/.DS_Store
ADDED
|
Binary file
|
data/.gitignore
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
namespace :test do
|
|
8
|
+
task :urlify, [:filename] do |title, args|
|
|
9
|
+
file_name = args[:filename]
|
|
10
|
+
assets_path = Rails.root.join('app/assets/stylesheets/')
|
|
11
|
+
|
|
12
|
+
# looks for either end of parenthesis and the slash sign
|
|
13
|
+
split_pattern = /[\(\)\/]/
|
|
14
|
+
image_extension = /(\.png)|(\.jpg)|(\.gif)/
|
|
15
|
+
|
|
16
|
+
#we create a temporary file
|
|
17
|
+
tmp = Tempfile.new("tmp")
|
|
18
|
+
|
|
19
|
+
css = File.open(assets_path + file_name, "r+")
|
|
20
|
+
css.each do |line|
|
|
21
|
+
# find lines with css url property
|
|
22
|
+
if /url/.match(line)
|
|
23
|
+
matches = line.split(split_pattern)
|
|
24
|
+
matches.each do |part|
|
|
25
|
+
# extract art of the line that contains image name with extension
|
|
26
|
+
if image_extension.match(part)
|
|
27
|
+
part.gsub!(/[^0-9a-z_\-\.]/i, '')
|
|
28
|
+
line.gsub!(/url\(.*\)/, "url(image_path(\"#{part}\"))")
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
tmp << line
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
tmp.close
|
|
36
|
+
css.close
|
|
37
|
+
|
|
38
|
+
# we move the temporary file to the assets directory
|
|
39
|
+
mv(tmp.path, assets_path.join(file_name + ".scss"))
|
|
40
|
+
end
|
|
41
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Neven Rakonić
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-04-
|
|
11
|
+
date: 2015-04-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -59,6 +59,7 @@ executables: []
|
|
|
59
59
|
extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
|
61
61
|
files:
|
|
62
|
+
- ".DS_Store"
|
|
62
63
|
- ".gitignore"
|
|
63
64
|
- ".rspec"
|
|
64
65
|
- ".travis.yml"
|
|
@@ -72,6 +73,7 @@ files:
|
|
|
72
73
|
- lib/convert_urls.rake
|
|
73
74
|
- lib/url_to_image_path.rb
|
|
74
75
|
- lib/url_to_image_path/version.rb
|
|
76
|
+
- tasks/convert_urls.rake
|
|
75
77
|
- tasks/rspec.rake
|
|
76
78
|
- url_to_image_path.gemspec
|
|
77
79
|
homepage: https://github.com/nevenRakonic/url_to_image_path
|