sass-resrcify 0.1.0
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 +7 -0
- data/.gitignore +4 -0
- data/CHANGELOG.markdown +3 -0
- data/Gemfile +5 -0
- data/README.markdown +1 -0
- data/Rakefile +2 -0
- data/lib/sass/resrcify/monkey_patches.rb +81 -0
- data/lib/sass/resrcify/version.rb +5 -0
- data/lib/sass/resrcify.rb +6 -0
- data/lib/sass-resrcify.rb +1 -0
- data/sass-resrcify.gemspec +20 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a13d2f4ba3080028eaedcec4a0ada1dc7e00f212
|
4
|
+
data.tar.gz: 0b3709b875f3e662a982f404f85d2a076986e6f0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f6238738365ade3d7436456e23041b501cc9ae92bc0ce91bb65424509a68dd71e422dc95eb1f188bd491bbb2308a4bf213a59298edc90b17da03ba87cd0f8ea9
|
7
|
+
data.tar.gz: 9e68166a42174accabb62c250393305dd0d4d50c5892efa64fe3b6f75bfd7b5bc5909c3d9ba96741b01210f21c8ccc4bae2e6756a99030beb403e3606accc57c
|
data/.gitignore
ADDED
data/CHANGELOG.markdown
ADDED
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
SASS Resrcify Plugin
|
data/Rakefile
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require "sass"
|
2
|
+
require "uri"
|
3
|
+
require "digest/sha1"
|
4
|
+
|
5
|
+
module Sass
|
6
|
+
module Importers
|
7
|
+
class Resrcify
|
8
|
+
def initialize
|
9
|
+
@processed = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def resrc(asset, file, opts = {})
|
13
|
+
dest_dir = opts[:dest] || ""
|
14
|
+
prefix = opts[:prefix] || ""
|
15
|
+
|
16
|
+
url = URI.parse(asset)
|
17
|
+
return asset if url.scheme
|
18
|
+
|
19
|
+
asset = url.path
|
20
|
+
|
21
|
+
base_dir = File.dirname(file)
|
22
|
+
src_file = File.expand_path(asset, base_dir)
|
23
|
+
|
24
|
+
return @processed[src_file] if @processed.key?(src_file)
|
25
|
+
|
26
|
+
begin
|
27
|
+
hash = Digest::SHA1.file(src_file).hexdigest[0...16]
|
28
|
+
rescue
|
29
|
+
return asset
|
30
|
+
end
|
31
|
+
|
32
|
+
ext = File.extname(asset)
|
33
|
+
orig_name = File.basename(asset, ext)
|
34
|
+
name = "#{orig_name}-#{hash}#{ext}"
|
35
|
+
dest_file = File.join(dest_dir, name)
|
36
|
+
|
37
|
+
FileUtils.mkdir_p(dest_dir)
|
38
|
+
FileUtils.cp(src_file, dest_file)
|
39
|
+
|
40
|
+
@processed[src_file] = File.join(prefix, name)
|
41
|
+
@processed[src_file]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
module Sass
|
48
|
+
module Importers
|
49
|
+
class Filesystem
|
50
|
+
REGEX = /url\([\"\'](.*?)[\"\']\)/
|
51
|
+
|
52
|
+
alias old_initialize initialize
|
53
|
+
|
54
|
+
def initialize(root)
|
55
|
+
old_initialize(root)
|
56
|
+
@resrcify = Resrcify.new
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def _find(dir, name, options)
|
62
|
+
full_filename, syntax = Sass::Util.destructure(find_real_file(dir, name, options))
|
63
|
+
return unless full_filename && File.readable?(full_filename)
|
64
|
+
|
65
|
+
options[:syntax] = syntax
|
66
|
+
options[:filename] = full_filename
|
67
|
+
options[:importer] = self
|
68
|
+
|
69
|
+
puts full_filename
|
70
|
+
|
71
|
+
content = File.read(full_filename)
|
72
|
+
content.gsub!(REGEX) do |s|
|
73
|
+
asset = @resrcify.resrc($1, full_filename, dest: "static/assets", prefix: "/assets")
|
74
|
+
"url(#{asset})"
|
75
|
+
end
|
76
|
+
|
77
|
+
Sass::Engine.new(content, options)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "sass/resrcify"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "sass/resrcify/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "sass-resrcify"
|
7
|
+
s.version = Sass::Resrcify::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Karan Misra"]
|
10
|
+
s.email = ["kidoman@gmail.com"]
|
11
|
+
s.homepage = "http://kidoman.io/"
|
12
|
+
s.summary = %q{Allows resrcifying asset paths}
|
13
|
+
s.description = %q{Allows resrcifying asset paths}
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_runtime_dependency 'sass', '>= 3.1'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sass-resrcify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Karan Misra
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sass
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
description: Allows resrcifying asset paths
|
28
|
+
email:
|
29
|
+
- kidoman@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- CHANGELOG.markdown
|
36
|
+
- Gemfile
|
37
|
+
- README.markdown
|
38
|
+
- Rakefile
|
39
|
+
- lib/sass-resrcify.rb
|
40
|
+
- lib/sass/resrcify.rb
|
41
|
+
- lib/sass/resrcify/monkey_patches.rb
|
42
|
+
- lib/sass/resrcify/version.rb
|
43
|
+
- sass-resrcify.gemspec
|
44
|
+
homepage: http://kidoman.io/
|
45
|
+
licenses: []
|
46
|
+
metadata: {}
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 2.2.2
|
64
|
+
signing_key:
|
65
|
+
specification_version: 4
|
66
|
+
summary: Allows resrcifying asset paths
|
67
|
+
test_files: []
|