guard-entangle 0.0.4.4 → 0.0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/guard/entangle/entangler.rb +1 -0
- data/lib/guard/entangle/formatter.rb +9 -0
- data/lib/guard/entangle/runner.rb +1 -1
- data/lib/guard/entangle/version.rb +1 -1
- data/lib/guard/entangle/writer.rb +55 -1
- data/lib/guard/entangle.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bd715421e7ff970ad10a17252452ab066f39516
|
4
|
+
data.tar.gz: 8418706babf13d2fdd2a3be47b5d17f450ecbce2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dc56b08fc7803137b446463201992df0a27f50fe9ae954ee829f2770573006a6c5ec49495c4d30192d5130027912899942fd1a80b1319d5dc4d1c817d4e5bfa
|
7
|
+
data.tar.gz: b2179c62004954e691049058363898d4d128dd9103d03379d85f662f1c4690e78e5b6a139c5430fbe1f50d23653d3fc4a04aa8426aad0c9ed1dba77938779973
|
@@ -57,6 +57,15 @@ module Guard
|
|
57
57
|
::Guard::Notifier.notify(message, options)
|
58
58
|
end
|
59
59
|
|
60
|
+
# Output raw string, as Guard UI adds [#XXXXXXX] memory address to string
|
61
|
+
#
|
62
|
+
# @param [String] text the text to colorize
|
63
|
+
# @param [String] color_code the color code
|
64
|
+
#
|
65
|
+
def colorize(text, color_code)
|
66
|
+
return "\e[#{color_code}m#{text}\e[0m"
|
67
|
+
end
|
68
|
+
|
60
69
|
private
|
61
70
|
|
62
71
|
# Print a info message to the console.
|
@@ -43,6 +43,7 @@ module Guard
|
|
43
43
|
else
|
44
44
|
path.gsub! "#{cwd}/", ''
|
45
45
|
message = "The path #{ rel } is not writable."
|
46
|
+
puts "here"
|
46
47
|
@formatter.error(message)
|
47
48
|
return
|
48
49
|
end
|
@@ -62,7 +63,7 @@ module Guard
|
|
62
63
|
if File.extname(path) == '.js'
|
63
64
|
min = path.gsub(/\.[^.]+$/, '.min.js')
|
64
65
|
begin
|
65
|
-
if
|
66
|
+
if options[:force_utf8]
|
66
67
|
content.encoding
|
67
68
|
content.force_encoding 'utf-8'
|
68
69
|
end
|
@@ -71,7 +72,12 @@ module Guard
|
|
71
72
|
rescue Exception => e
|
72
73
|
# Get a readable message
|
73
74
|
message = e.message.split(/[\n\r]/).first
|
75
|
+
lines = error_lines(content, message)
|
74
76
|
@formatter.error("Uglifier - #{message}")
|
77
|
+
if lines
|
78
|
+
@formatter.error("Surrounding lines:")
|
79
|
+
puts lines
|
80
|
+
end
|
75
81
|
return nil
|
76
82
|
end
|
77
83
|
|
@@ -84,6 +90,54 @@ module Guard
|
|
84
90
|
end
|
85
91
|
end
|
86
92
|
|
93
|
+
# Get the error lines for an uglifier error
|
94
|
+
#
|
95
|
+
# @param [String] content The content that is being parsed
|
96
|
+
# @param [String] message The error message from uglifier
|
97
|
+
#
|
98
|
+
# @return [mixed] error lines or false
|
99
|
+
#
|
100
|
+
def error_lines(content, message)
|
101
|
+
line = error_line_number(message)
|
102
|
+
|
103
|
+
# The line number is set, we can now get the lines from the file
|
104
|
+
if line
|
105
|
+
counter = 2
|
106
|
+
first = line - options[:error_lines]
|
107
|
+
last = line + options[:error_lines]
|
108
|
+
file_lines = []
|
109
|
+
|
110
|
+
content.each_line do |item|
|
111
|
+
if counter >= first && counter <= last
|
112
|
+
item.sub! "\n", ''
|
113
|
+
if counter == line
|
114
|
+
file_lines << @formatter.colorize("line #{counter}: #{item}", 31)
|
115
|
+
else
|
116
|
+
file_lines << @formatter.colorize("line #{counter}: #{item}", 33)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
counter += 1
|
120
|
+
end
|
121
|
+
|
122
|
+
if not file_lines.empty?
|
123
|
+
return file_lines.join("\n")
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# Get the line number for an error message
|
129
|
+
#
|
130
|
+
# @param [String] message The error message generated by Uglifier
|
131
|
+
#
|
132
|
+
# @return [String] The error line number
|
133
|
+
#
|
134
|
+
def error_line_number(message)
|
135
|
+
lines = message.match(/line:\s?(\d+),/)
|
136
|
+
|
137
|
+
if lines.kind_of?(MatchData) && lines[1]
|
138
|
+
return lines[1].to_i
|
139
|
+
end
|
140
|
+
end
|
87
141
|
|
88
142
|
# Save the file
|
89
143
|
#
|
data/lib/guard/entangle.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guard-entangle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Deshi Rahim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: guard
|