mozrepl-client 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +5 -0
- data/Rakefile +12 -0
- data/lib/mozrepl_client.rb +34 -0
- data/mozrepl-client.gemspec +30 -0
- data/mozrepl-client.notes +37 -0
- metadata +70 -0
data/Manifest
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('mozrepl-client', '0.0.1') do |p|
|
6
|
+
p.description = "A wrapper around mozrepl - pass javascript to your browser to run!"
|
7
|
+
p.url = "http://github.com/trogdoro/mozrepl_client"
|
8
|
+
p.author = "Craig Muth and Neal Lindsay"
|
9
|
+
# p.email = "nottelling @nospam@ gmail.com"
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
+
p.development_dependencies = []
|
12
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'socket'
|
2
|
+
|
3
|
+
class MozreplClient
|
4
|
+
def self.read s
|
5
|
+
r = ''
|
6
|
+
loop do
|
7
|
+
r << s.readchar.chr
|
8
|
+
|
9
|
+
break if r =~ /^repl\d*> $/
|
10
|
+
end
|
11
|
+
r.sub /^repl\d*> /, ''
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.run js, options={}
|
15
|
+
s = TCPSocket::new("localhost", "4242")
|
16
|
+
|
17
|
+
initial_crap = self.read s
|
18
|
+
repl = initial_crap[/repl\d+/] || 'repl'
|
19
|
+
if options[:tab] # Run js in page on nth tab
|
20
|
+
s.puts("#{repl}.enter(window.gBrowser.getBrowserAtIndex(#{options[:tab]}).contentDocument)\n;")
|
21
|
+
self.read s
|
22
|
+
elsif options[:browser] # Run js at browser outer level
|
23
|
+
else # Run js in page
|
24
|
+
s.puts("#{repl}.enter(content.wrappedJSObject)\n;")
|
25
|
+
self.read s
|
26
|
+
end
|
27
|
+
|
28
|
+
s.puts js
|
29
|
+
txt = self.read s
|
30
|
+
s.close
|
31
|
+
txt.strip
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{mozrepl-client}
|
5
|
+
s.version = "0.0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Craig Muth and Neal Lindsay"]
|
9
|
+
s.date = %q{2011-05-18}
|
10
|
+
s.description = %q{A wrapper around mozrepl - pass javascript to your browser to run!}
|
11
|
+
s.email = %q{}
|
12
|
+
s.extra_rdoc_files = ["lib/mozrepl_client.rb"]
|
13
|
+
s.files = ["Rakefile", "lib/mozrepl_client.rb", "mozrepl-client.notes", "Manifest", "mozrepl-client.gemspec"]
|
14
|
+
s.homepage = %q{http://github.com/trogdoro/mozrepl_client}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Mozrepl-client"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{mozrepl-client}
|
18
|
+
s.rubygems_version = %q{1.3.6}
|
19
|
+
s.summary = %q{A wrapper around mozrepl - pass javascript to your browser to run!}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
| Test code
|
2
|
+
p MozreplClient.run "document.title"
|
3
|
+
p MozreplClient.run "alert(11)"
|
4
|
+
|
5
|
+
| Code
|
6
|
+
- ./
|
7
|
+
- mozrepl_client.rb
|
8
|
+
|
9
|
+
||
|
10
|
+
class MozreplClient
|
11
|
+
def self.read s
|
12
|
+
r = ''
|
13
|
+
loop do
|
14
|
+
r << s.readchar.chr
|
15
|
+
# break if r =~ /repl\d*> /
|
16
|
+
break if r =~ /^repl\d*> $/
|
17
|
+
end
|
18
|
+
r.sub /^repl\d*> /, ''
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.run js, options={}
|
22
|
+
s = TCPSocket::new("localhost", "4242")
|
23
|
+
|
24
|
+
initial_crap = read s
|
25
|
+
repl = initial_crap[/repl\d+/] || 'repl'
|
26
|
+
unless options[:browser]
|
27
|
+
s.puts("#{repl}.enter(content.wrappedJSObject)\n;")
|
28
|
+
read s
|
29
|
+
end
|
30
|
+
|
31
|
+
s.puts js
|
32
|
+
txt = read s
|
33
|
+
s.close
|
34
|
+
txt.strip
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mozrepl-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Craig Muth and Neal Lindsay
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-05-18 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: A wrapper around mozrepl - pass javascript to your browser to run!
|
22
|
+
email: ""
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- lib/mozrepl_client.rb
|
29
|
+
files:
|
30
|
+
- Rakefile
|
31
|
+
- lib/mozrepl_client.rb
|
32
|
+
- mozrepl-client.notes
|
33
|
+
- Manifest
|
34
|
+
- mozrepl-client.gemspec
|
35
|
+
has_rdoc: true
|
36
|
+
homepage: http://github.com/trogdoro/mozrepl_client
|
37
|
+
licenses: []
|
38
|
+
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options:
|
41
|
+
- --line-numbers
|
42
|
+
- --inline-source
|
43
|
+
- --title
|
44
|
+
- Mozrepl-client
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
segments:
|
59
|
+
- 1
|
60
|
+
- 2
|
61
|
+
version: "1.2"
|
62
|
+
requirements: []
|
63
|
+
|
64
|
+
rubyforge_project: mozrepl-client
|
65
|
+
rubygems_version: 1.3.6
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: A wrapper around mozrepl - pass javascript to your browser to run!
|
69
|
+
test_files: []
|
70
|
+
|