sassificator 0.1.3 → 0.1.4

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sassificator.rb +26 -12
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
- metadata.gz: 390fc141a58ee31ba2bb65188e62eeac0c7d826b
4
- data.tar.gz: 4b337475041f992449a2481790fc751b45689dee
3
+ metadata.gz: 3bb13895f18e7eb6ecbd503c1ad1071ddb9570df
4
+ data.tar.gz: 6bf6734ad21deb95ccb5c9ef2996b778f69f82b2
5
5
  SHA512:
6
- metadata.gz: 96fc95dabd748618691e89470bc4f7a53d8f182c62a6f3ecc05f75061a5bdecfcc1aa44f5d2f7532d9df4bae5ccc9889443e3ea74e36b027b4ab267dcaea7cb4
7
- data.tar.gz: 6ff9d0aa6539d6e14a40742738f0cf6b5884c6da74215835f214bc6e04aa3063d2e3e7ae057824422acd1dda7c6045fd9fcc579ebffc1f55b706df574174eabb
6
+ metadata.gz: 44296a5e28957a711ec8048647facf0d047f1b30451f08ac26342b596b55d20cc05866ee807eb4ace3be295b8c5675821b509f563a07fb9bc21c20905b2bbf9c
7
+ data.tar.gz: e5e6c26853e31b598f3e04b07ee6789a94c9cb0fc616800dd283f41333cc88a369754740ad2267db37ca2e6b7b9aedcdf11890677f8eef72c4559f0274e8d0d0
@@ -174,25 +174,39 @@ class Sassificator
174
174
  require 'net/http'
175
175
 
176
176
  formated_rule = sassed_str
177
+
178
+ #TODO - move this to optional feature (file downloading)
179
+ #TODO: optimise this - connect to global path
180
+ path = @output_path
181
+ Dir.mkdir(path) unless Dir.exist?(path)
182
+ FileUtils.rm_rf(Dir.glob("#{@output_path}/*"))
183
+
177
184
  sassed_str.scan(/(url\((((http[s]{0,1}:\/\/)([a-z0-9].+\.[a-z]+).+)(\/.+)))\)/).each do |match|
178
185
  #TODO: optimize this - move mathched to variables for clarification of match
179
186
  formated_rule = formated_rule.sub(Regexp.new(match[0].gsub(/\(/,'\(').gsub(match[5],'')),'asset-url(\''+@image_assets_path)
180
187
  .sub( Regexp.new(match[5]),match[5].sub(/\//,'')+'\'')
181
-
188
+
189
+ #TODO - move this to optional feature (file downloading)
182
190
  Net::HTTP.start(match[4]) do |http|
183
- resp = http.get(match[1])
184
-
185
- #TODO: optimise this - connect to global path
186
- path = @output_path
187
- Dir.mkdir(path) unless Dir.exist?(path)
188
- open(path+match[5], 'wb') do |file|
189
- begin
191
+
192
+ #TODO - test get_url
193
+ # forms relative url
194
+ get_url = match[1].sub(Regexp.new("(http:\/\/||https:\/\/){1}#{match[4]}"),'')
195
+ begin
196
+ http.read_timeout = 20
197
+ resp = http.get(get_url)
198
+
199
+ open(path+match[5], 'wb') do |file|
200
+ begin
190
201
  file.write(resp.body)
191
- ensure
202
+ ensure
192
203
  file.close()
193
- end
194
- end
195
- end
204
+ end
205
+ end
206
+ rescue
207
+ p "Fail on getting image #{match[1]}"
208
+ end
209
+ end
196
210
  end
197
211
 
198
212
  formated_rule
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.3
4
+ version: 0.1.4
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-08-09 00:00:00.000000000 Z
11
+ date: 2014-08-28 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
@@ -38,7 +38,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
38
  version: '0'
39
39
  requirements: []
40
40
  rubyforge_project:
41
- rubygems_version: 2.2.2
41
+ rubygems_version: 2.4.1
42
42
  signing_key:
43
43
  specification_version: 4
44
44
  summary: A tool for parsing Css to Sass