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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 416e43ead374ec83883e16d465b30918d4671e54
4
- data.tar.gz: 2799e643b148be20e4a9993321586b5a834d2a36
3
+ metadata.gz: cd582154aa9f5cdb63de778cf279fc46d5c5bf59
4
+ data.tar.gz: b3bc2604671a17e56e74038e8080e6e6fdaa7d03
5
5
  SHA512:
6
- metadata.gz: 54afeb32fc42fac383f457735b85a5b8ff4b78aa9dc306789972c70e0b6e51408c8931e594f47484f8b49352bdbdff68be424de13f3b47d29d0c0824ca189e89
7
- data.tar.gz: 9727eea4f793a225f30a37800b7ea308d5199bd31a94bf7de2f7fbeb8952a6b227bde6e8cd7a74b7cea1b742e3398f190eca0f2013a68cb825fcdb8e65a82ff3
6
+ metadata.gz: 7bb099900120ba39d9da1a7cfedc518a5ef329698381242f89a8db4d219a4b7654257e9abc8b301c35a3a9ce116265a9f679600bfaadcfdda50bf8c181aebafc
7
+ data.tar.gz: 0e05cb36d1ad2050853534251215bb23dbcb0a2d6d9cc8068e5e88e7fb267edf33d9a8060c11a76cb7392c455e73a2c0d6b7a4dae03fc2883c07eac8aeacd417
data/.DS_Store ADDED
Binary file
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .DS_Store
@@ -1,3 +1,3 @@
1
1
  module UrlToImagePath
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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.0
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-03 00:00:00.000000000 Z
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