sassificator 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 +8 -8
- data/lib/sassificator.rb +10 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODMyZjg1YmI4YzM2N2Q5YmQ2MWIyNjY1NTk4MDI2Y2ZjMDU1OGUxYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjkxZDYwMDE1MTRmYjM3OTdiMmY1ZmViNmEwZmVlMWFkZjcyYTQxNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2VlOTI2Y2FmNDc4NGRkY2MzOWY0Y2YzYWYxZDQ2OWIzOTlmNzdmZWM2MDk5
|
10
|
+
Y2Y0ODUwN2JjOThjZjRkMjY4ZGJlMDhlMjQzOGM4Yzk4MTg5MWE0MGY2NWY2
|
11
|
+
MjFiNjcyNTg5ZTI5YjcwYTFkZjIwNDcyZGI3NzE5MjhiYTQ1ZTA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmExNmEzMWVkNzQxMTI2YTkzMTI3MWQ4ZGMyOTgwMzBkNWY5MzdhMzQ5NTRi
|
14
|
+
NDU3MjYzZjgxY2UyZjk0YjU0MGZmYWVjNWNkNjgwZjk3ZTVjNTY4OWNkZmU2
|
15
|
+
YTkxYWZiOTY3ZjllMzU5YmVjYWExZDg3NTk5ZWI5ZGQ5ZDRiY2Y=
|
data/lib/sassificator.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#TODO:
|
2
2
|
# - mediaquery inside of a mediaquery
|
3
3
|
# - images formating pattern setting
|
4
|
-
# -
|
4
|
+
# - add convertor: all #_colors_ to rgb
|
5
|
+
# - MAJOR: formatting is done only for output sass_string, but not for sass_obj. Move formatting options applyment to object creation
|
5
6
|
|
6
7
|
class Sassificator
|
7
8
|
attr_accessor :colors_to_vars
|
@@ -11,6 +12,7 @@ class Sassificator
|
|
11
12
|
# @param [Boolean] colors_to_vars true : sets all color to sass variables to the top of output string
|
12
13
|
# @param [Boolean] fromat_image_declarations true : formats images declarations to asset-url (for now at least - TODO: will be unified for any format)
|
13
14
|
# @param [Boolean] download_images true : downloads images to specified @output_path
|
15
|
+
# @param [String] image_assets_path Image asstes path in application
|
14
16
|
# @param [String] output_path Output path must be specified if download_images is set to true
|
15
17
|
#
|
16
18
|
def initialize( param = {})
|
@@ -18,7 +20,8 @@ class Sassificator
|
|
18
20
|
@colors_to_vars = (param[:colors_to_vars] != false) != false
|
19
21
|
@fromat_image_declarations = (param[:fromat_image_declarations] != false) != false
|
20
22
|
@download_images = (param[:download_images] != false) != false
|
21
|
-
@
|
23
|
+
@image_assets_path = param[:image_assets_path] ? param[:image_assets_path] : ''
|
24
|
+
@output_path = param[:output_path] ? param[:output_path] : "#{ENV['HOME']}/Desktop/sassificator_output/"
|
22
25
|
end
|
23
26
|
|
24
27
|
##
|
@@ -162,9 +165,9 @@ class Sassificator
|
|
162
165
|
|
163
166
|
formated_rule = sassed_str
|
164
167
|
sassed_str.scan(/(url\((((http[s]{0,1}:\/\/)([a-z0-9].+\.[a-z]+).+)(\/.+)))\)/).each do |match|
|
165
|
-
|
166
|
-
formated_rule = formated_rule.sub(Regexp.new(match[0].gsub(/\(/,'\(').gsub(match[5],'')),'asset-url(\'
|
167
|
-
.sub( Regexp.new(match[5]),match[5]+'\',image')
|
168
|
+
#TODO: optimize this - move mathched to variables for clarification of match
|
169
|
+
formated_rule = formated_rule.sub(Regexp.new(match[0].gsub(/\(/,'\(').gsub(match[5],'')),'asset-url(\''+@image_assets_path)
|
170
|
+
.sub( Regexp.new(match[5]),match[5].sub(/\//,'')+'\',image')
|
168
171
|
|
169
172
|
Net::HTTP.start(match[4]) do |http|
|
170
173
|
resp = http.get(match[1])
|
@@ -186,13 +189,12 @@ class Sassificator
|
|
186
189
|
end
|
187
190
|
|
188
191
|
def format_color(sassed_str)
|
189
|
-
#TODO: resolve the match for colors in format #sdsd
|
190
192
|
formated_rule = sassed_str
|
191
193
|
color_hash = {}
|
192
|
-
sassed_str.scan(/rgba\([0-9\,\s\.]+\)|rgb\([0-9\,\s\.]+\)/).each do|m|
|
194
|
+
sassed_str.scan(/rgba\([0-9\,\s\.]+\)|rgb\([0-9\,\s\.]+\)|#[0-9A-Za-z]+(?=;)/).each do|m|
|
193
195
|
|
194
196
|
unless color_hash[m]
|
195
|
-
color_hash[m] = '$
|
197
|
+
color_hash[m] = '$color_'+color_hash.size.to_s
|
196
198
|
formated_rule = formated_rule.gsub( Regexp.new(m.gsub(/\(/,'\(').gsub(/\)/,'\)').gsub(/\./,'\.')), color_hash[m] )
|
197
199
|
end
|
198
200
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sassificator
|
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
|
- Roman Fromrome
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Converts Css formatted code to Sass. Generates a Sass formatted hierarchy
|
14
14
|
object, as well as properly formatted Sass code text
|