mozrepl_tools 0.0.1
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.
- data/LICENSE +20 -0
- data/README.rdoc +37 -0
- data/bin/mozrepl +16 -0
- data/lib/mozrepl_tools.rb +5 -0
- data/lib/textmate/Commands/repl.tmCommand +24 -0
- data/lib/textmate/Support/lib/mozrepl_tools.rb +100 -0
- data/lib/textmate/info.plist +10 -0
- data/test/helper.rb +10 -0
- data/test/test_mozrepl_tools.rb +7 -0
- metadata +77 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Jorge Falcão
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
= mozrepl_tools
|
2
|
+
|
3
|
+
Reload css or js (and Ext.component) through your editor. Thanks to MozRepl :)
|
4
|
+
|
5
|
+
== Before install
|
6
|
+
|
7
|
+
install MozRepl
|
8
|
+
http://wiki.github.com/bard/mozrepl/
|
9
|
+
|
10
|
+
== Install
|
11
|
+
|
12
|
+
gem install mozrepl_tools
|
13
|
+
|
14
|
+
== Reload css (<link /> tag only)
|
15
|
+
|
16
|
+
#> mozrepl 'main.css'
|
17
|
+
|
18
|
+
== Adding a js file to current tab
|
19
|
+
|
20
|
+
#> mozrepl 'my/path/file.js'
|
21
|
+
|
22
|
+
It's works with Sencha(ExtJS) Components!!!
|
23
|
+
|
24
|
+
== Using with Textmate (~/Library/Application Support/TextMate/Bundles/MozRepl.tmbundle)
|
25
|
+
|
26
|
+
#> mozrepl textmate
|
27
|
+
|
28
|
+
And now, use "Command+Shif+R" (like magic)
|
29
|
+
|
30
|
+
== TODO
|
31
|
+
|
32
|
+
#TODO: use watchr to reload automatic
|
33
|
+
|
34
|
+
== Copyright
|
35
|
+
|
36
|
+
Copyright (c) 2010 Jorge Falcão. See LICENSE for details.
|
37
|
+
|
data/bin/mozrepl
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
if ARGV[0] == 'textmate'
|
3
|
+
puts "textmate plugin ok!"
|
4
|
+
textmate = File.expand_path("~/Library/Application Support/TextMate/Bundles/MozRepl.tmbundle")
|
5
|
+
|
6
|
+
basedir = File.join(File.dirname(File.dirname(__FILE__)))
|
7
|
+
|
8
|
+
bundle = File.join basedir, 'lib', 'textmate'
|
9
|
+
|
10
|
+
File.unlink(textmate)
|
11
|
+
File.symlink(bundle, textmate)
|
12
|
+
system %Q{osascript -e 'tell app "TextMate" to reload bundles'}
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
|
16
|
+
require 'mozrepl_tools'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>command</key>
|
6
|
+
<string>#!/usr/bin/env sh
|
7
|
+
|
8
|
+
${TM_RUBY:-ruby} "$TM_BUNDLE_SUPPORT/lib/mozrepl_tools.rb"
|
9
|
+
|
10
|
+
</string>
|
11
|
+
<key>fallbackInput</key>
|
12
|
+
<string>document</string>
|
13
|
+
<key>input</key>
|
14
|
+
<string>none</string>
|
15
|
+
<key>keyEquivalent</key>
|
16
|
+
<string>@R</string>
|
17
|
+
<key>name</key>
|
18
|
+
<string>Reload Using MozRepl</string>
|
19
|
+
<key>output</key>
|
20
|
+
<string>showAsTooltip</string>
|
21
|
+
<key>uuid</key>
|
22
|
+
<string>E36D6544-2445-4B6B-82FF-61B233ED7901</string>
|
23
|
+
</dict>
|
24
|
+
</plist>
|
@@ -0,0 +1,100 @@
|
|
1
|
+
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
s = TCPSocket.open('localhost', 4242)
|
5
|
+
|
6
|
+
script = DATA.read
|
7
|
+
|
8
|
+
filepath = ENV["TM_FILEPATH"] || ARGV[0]
|
9
|
+
file = File.basename filepath
|
10
|
+
ext = File.extname filepath
|
11
|
+
filename = File.expand_path filepath
|
12
|
+
# p ext
|
13
|
+
s.puts(script)
|
14
|
+
|
15
|
+
if ext == ".css"
|
16
|
+
s.puts("reload.css('#{file}')")
|
17
|
+
puts "reloaded #{file}"
|
18
|
+
elsif ext == ".js"
|
19
|
+
s.puts("reload.js('#{filename}')")
|
20
|
+
puts "reloaded #{filename}"
|
21
|
+
end
|
22
|
+
|
23
|
+
# puts script
|
24
|
+
|
25
|
+
# workaround
|
26
|
+
sleep 1
|
27
|
+
|
28
|
+
s.close
|
29
|
+
|
30
|
+
__END__
|
31
|
+
|
32
|
+
|
33
|
+
var reload = (function(content, window) {
|
34
|
+
var window = (function() {
|
35
|
+
for ( var i = 0; i < window.length; i++ ) {
|
36
|
+
if ( content.location == window[i].location ) {
|
37
|
+
return window[i];
|
38
|
+
}
|
39
|
+
}
|
40
|
+
})();
|
41
|
+
|
42
|
+
var document = doc = window.document;
|
43
|
+
var Ext = window.Ext;
|
44
|
+
|
45
|
+
// firebug
|
46
|
+
var console = window.console || {debug:function(){}};
|
47
|
+
|
48
|
+
console.debug("loading...");
|
49
|
+
|
50
|
+
// add development Ext.reg
|
51
|
+
if ( ! Ext._reg ) {
|
52
|
+
console.debug('saving original Ext.reg');
|
53
|
+
Ext._reg = Ext.reg;
|
54
|
+
}
|
55
|
+
|
56
|
+
Ext.reg = function(xtype) {
|
57
|
+
console.debug("Ext.reg:", arguments);
|
58
|
+
// calling old Ext.reg
|
59
|
+
Ext._reg.apply(Ext, arguments);
|
60
|
+
|
61
|
+
// reinstance all xtypes
|
62
|
+
var items = Ext.ComponentMgr.all.filterBy(function(e) { return e.getXType() == xtype }).each(function(item) {
|
63
|
+
repl.print(item)
|
64
|
+
var ic = item.initialConfig;
|
65
|
+
var o = item.ownerCt;
|
66
|
+
o.remove(item);
|
67
|
+
var it = o.add(ic)
|
68
|
+
if ( o.getLayout().setActiveItem ) {
|
69
|
+
o.getLayout().setActiveItem(it);
|
70
|
+
};
|
71
|
+
o.doLayout();
|
72
|
+
});
|
73
|
+
};
|
74
|
+
|
75
|
+
var head = document.getElementsByTagName("head")[0];
|
76
|
+
|
77
|
+
return {
|
78
|
+
css:function(file) {
|
79
|
+
var l = doc.getElementsByTagName('link');
|
80
|
+
for ( var i = 0; i < l.length; i++ ) {
|
81
|
+
var ss = l[i];
|
82
|
+
console.debug("reloading:", ss);
|
83
|
+
if ( ss.href && ss.href.indexOf(file) != -1 ) {
|
84
|
+
try {
|
85
|
+
ss.href = (ss.href.split("?")[0]) + "?" + Math.random();
|
86
|
+
} catch (e) {
|
87
|
+
repl.print(e);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
},
|
92
|
+
js:function(filename) {
|
93
|
+
var script = document.createElement('script');
|
94
|
+
script.type = "text/javascript";
|
95
|
+
script.src = filename;
|
96
|
+
repl.print(filename);
|
97
|
+
head.appendChild(script);
|
98
|
+
}
|
99
|
+
};
|
100
|
+
})(content, window);
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>name</key>
|
6
|
+
<string>MozRepl</string>
|
7
|
+
<key>uuid</key>
|
8
|
+
<string>16A1485C-204A-4160-9B43-541DD45E4386</string>
|
9
|
+
</dict>
|
10
|
+
</plist>
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mozrepl_tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- "Jorge Falc\xC3\xA3o"
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-08-12 00:00:00 -03:00
|
19
|
+
default_executable: mozrepl
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: ""
|
23
|
+
email: jlbfalcao@gmail.com
|
24
|
+
executables:
|
25
|
+
- mozrepl
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- LICENSE
|
30
|
+
- README.rdoc
|
31
|
+
files:
|
32
|
+
- lib/mozrepl_tools.rb
|
33
|
+
- lib/textmate/Commands/repl.tmCommand
|
34
|
+
- lib/textmate/Support/lib/mozrepl_tools.rb
|
35
|
+
- lib/textmate/info.plist
|
36
|
+
- LICENSE
|
37
|
+
- README.rdoc
|
38
|
+
- test/helper.rb
|
39
|
+
- test/test_mozrepl_tools.rb
|
40
|
+
- bin/mozrepl
|
41
|
+
has_rdoc: true
|
42
|
+
homepage: http://github.com/jlbfalcao/mozrepl_tools
|
43
|
+
licenses: []
|
44
|
+
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options:
|
47
|
+
- --charset=UTF-8
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
hash: 3
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
requirements: []
|
69
|
+
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.3.7
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Some mozrepl tools
|
75
|
+
test_files:
|
76
|
+
- test/helper.rb
|
77
|
+
- test/test_mozrepl_tools.rb
|