mozrepl_tools 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/textmate/Support/lib/mozrepl_tools.rb +59 -3
- metadata +3 -3
@@ -1,10 +1,16 @@
|
|
1
1
|
|
2
2
|
require 'socket'
|
3
|
+
require 'cgi'
|
3
4
|
|
4
5
|
s = TCPSocket.open('localhost', 4242)
|
5
6
|
|
6
7
|
script = DATA.read
|
7
8
|
|
9
|
+
|
10
|
+
# print "asdad'asdasda"
|
11
|
+
# print "aa\"aa"
|
12
|
+
# print "aa\"aa".gsub(/["]/, '\"')
|
13
|
+
|
8
14
|
filepath = ENV["TM_FILEPATH"] || ARGV[0]
|
9
15
|
file = File.basename filepath
|
10
16
|
ext = File.extname filepath
|
@@ -16,6 +22,13 @@ if ext == ".css"
|
|
16
22
|
s.puts("reload.css('#{file}')")
|
17
23
|
puts "reloaded #{file}"
|
18
24
|
elsif ext == ".js"
|
25
|
+
# content = (IO.readlines(filename).map do |l|
|
26
|
+
# "\"" + l.gsub(/[']/, '\\\\\'').gsub(/["]/, '\"').chop() + " \\n \"" + " + \n"
|
27
|
+
# end).join("")
|
28
|
+
# content += '""'
|
29
|
+
# puts contenttoutf8 → string
|
30
|
+
|
31
|
+
# puts content
|
19
32
|
s.puts("reload.js('#{filename}')")
|
20
33
|
puts "reloaded #{filename}"
|
21
34
|
end
|
@@ -38,6 +51,27 @@ var reload = (function(content, window) {
|
|
38
51
|
}
|
39
52
|
}
|
40
53
|
})();
|
54
|
+
|
55
|
+
// TODO: refactory
|
56
|
+
function found_script(a,s) {
|
57
|
+
var t = s.split("?");
|
58
|
+
var pu = t[0].split("/").reverse();
|
59
|
+
var pc = a.split("/").reverse();
|
60
|
+
var c = 0;
|
61
|
+
for ( var i = 0; i < pu.length; i++ ) {
|
62
|
+
if ( pu[i] == pc [i] ) {
|
63
|
+
c++;
|
64
|
+
} else {
|
65
|
+
break;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
repl.print(c)
|
69
|
+
if ( c > 0 ) {
|
70
|
+
return s + ((t[1])?"&":"?") + Math.random();
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
|
41
75
|
|
42
76
|
var document = doc = window.document;
|
43
77
|
var Ext = window.Ext;
|
@@ -89,12 +123,34 @@ var reload = (function(content, window) {
|
|
89
123
|
}
|
90
124
|
}
|
91
125
|
},
|
92
|
-
|
126
|
+
jsEval:function(text) {
|
93
127
|
var script = document.createElement('script');
|
94
128
|
script.type = "text/javascript";
|
95
|
-
script.
|
96
|
-
repl.print(
|
129
|
+
script.textContent = text;
|
130
|
+
repl.print(text);
|
97
131
|
head.appendChild(script);
|
132
|
+
},
|
133
|
+
js:function(filename) {
|
134
|
+
var scripts = document.getElementsByTagName("script");
|
135
|
+
for (var i = 0; i < scripts.length; i++ ) {
|
136
|
+
repl.print(scripts[i].src);
|
137
|
+
if ( scripts[i].src ) {
|
138
|
+
var s = found_script(filename, scripts[i].src)
|
139
|
+
repl.print(filename);
|
140
|
+
repl.print("s:", s);
|
141
|
+
if ( s ) {
|
142
|
+
var script = document.createElement('script');
|
143
|
+
script.type = "text/javascript";
|
144
|
+
script.src = s;
|
145
|
+
repl.print(filename);
|
146
|
+
head.appendChild(script);
|
147
|
+
return;
|
148
|
+
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
98
153
|
}
|
99
154
|
};
|
100
155
|
})(content, window);
|
156
|
+
// reload.js('assets/application/application.js');
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mozrepl_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Jorge Falc\xC3\xA3o"
|