ripl-johnson 0.1.0
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/.gemspec +21 -0
- data/CHANGELOG.rdoc +2 -0
- data/LICENSE.txt +22 -0
- data/README.rdoc +40 -0
- data/Rakefile +35 -0
- data/bin/ripl-johnson +6 -0
- data/deps.rip +2 -0
- data/lib/ripl/johnson.rb +31 -0
- data/lib/ripl/johnson/completion.rb +34 -0
- data/lib/ripl/johnson/multi_line.rb +45 -0
- data/lib/ripl/johnson/version.rb +5 -0
- metadata +112 -0
data/.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'rubygems' unless Object.const_defined?(:Gem)
|
3
|
+
require File.dirname(__FILE__) + "/lib/ripl/johnson/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "ripl-johnson"
|
7
|
+
s.version = Ripl::Johnson::VERSION
|
8
|
+
s.authors = ["Gabriel Horner"]
|
9
|
+
s.email = "gabriel.horner@gmail.com"
|
10
|
+
s.homepage = "http://github.com/cldwalker/ripl-johnson"
|
11
|
+
s.summary = "A javascript shell using johnson (mozilla's tracemonkey)"
|
12
|
+
s.description = "A full-featured javscript shell based on johnson a.k.a mozilla's tracemonkey. Since this uses ripl, it comes with most irb functionality: a global config(~/.johnsonrc), autocompletion (very basic currently), history (~/.johnson_history) and multi-line support."
|
13
|
+
s.required_rubygems_version = ">= 1.3.6"
|
14
|
+
s.rubyforge_project = 'tagaholic'
|
15
|
+
s.executables = ['ripl-johnson']
|
16
|
+
s.add_dependency 'ripl', '>= 0.2.8'
|
17
|
+
s.add_dependency 'johnson', '>= 2.0.0.pre3'
|
18
|
+
s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
|
19
|
+
s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
|
20
|
+
s.license = 'MIT'
|
21
|
+
end
|
data/CHANGELOG.rdoc
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT LICENSE
|
2
|
+
|
3
|
+
Copyright (c) 2010 Gabriel Horner
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
== Description
|
2
|
+
A full-featured javscript shell based on {johnson}[https://github.com/jbarnette/johnson] a.k.a
|
3
|
+
mozilla's tracemonkey. Since this uses {ripl}[http://github.com/cldwalker/ripl], it comes with most
|
4
|
+
irb functionality: a global config(~/.johnsonrc), autocompletion (very basic currently), history
|
5
|
+
(~/.johnson_history) and multi-line support.
|
6
|
+
|
7
|
+
== Install
|
8
|
+
Install the gem with:
|
9
|
+
|
10
|
+
sudo gem install ripl-johnson
|
11
|
+
|
12
|
+
== Usage
|
13
|
+
|
14
|
+
$ ripl johnson
|
15
|
+
|
16
|
+
# tab completion
|
17
|
+
js>> f[TAB]
|
18
|
+
false finally for function
|
19
|
+
js>> fu[TAB]
|
20
|
+
js>> function
|
21
|
+
|
22
|
+
# multi-line support (Ctrl-C to break out of incorrect multi-line)
|
23
|
+
js>> function ohai() {
|
24
|
+
> print("This ain't no browser");
|
25
|
+
> }
|
26
|
+
=> nil
|
27
|
+
|
28
|
+
>> o[TAB]
|
29
|
+
>> ohai
|
30
|
+
>> ohai()
|
31
|
+
This ain't no browser
|
32
|
+
=> nil
|
33
|
+
|
34
|
+
== Todo
|
35
|
+
* Add autocompletion for js methods!
|
36
|
+
* Remove ruby autocompletions from bond
|
37
|
+
* Add commandline option to autoload js files from rails projects
|
38
|
+
* Add commandline option for loading files (like johnson executable)
|
39
|
+
* Add rb and js functionality (like johnson executable)
|
40
|
+
* Add _ for last js result
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
def gemspec
|
5
|
+
@gemspec ||= eval(File.read('.gemspec'), binding, '.gemspec')
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "Build the gem"
|
9
|
+
task :gem=>:gemspec do
|
10
|
+
sh "gem build .gemspec"
|
11
|
+
FileUtils.mkdir_p 'pkg'
|
12
|
+
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Install the gem locally"
|
16
|
+
task :install => :gem do
|
17
|
+
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Generate the gemspec"
|
21
|
+
task :generate do
|
22
|
+
puts gemspec.to_ruby
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Validate the gemspec"
|
26
|
+
task :gemspec do
|
27
|
+
gemspec.validate
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'Run tests'
|
31
|
+
task :test do |t|
|
32
|
+
sh 'bacon -q -Ilib -I. test/*_test.rb'
|
33
|
+
end
|
34
|
+
|
35
|
+
task :default => :test
|
data/bin/ripl-johnson
ADDED
data/deps.rip
ADDED
data/lib/ripl/johnson.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'johnson/cli'
|
2
|
+
require 'ripl'
|
3
|
+
require 'ripl/johnson/version'
|
4
|
+
require 'ripl/johnson/completion'
|
5
|
+
|
6
|
+
module Ripl::Johnson
|
7
|
+
def before_loop
|
8
|
+
super
|
9
|
+
Ripl::Johnson.runtime.evaluate(Johnson::CLI::JS)
|
10
|
+
end
|
11
|
+
|
12
|
+
def loop_eval(expression)
|
13
|
+
Ripl::Johnson.runtime.evaluate(expression)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.runtime
|
17
|
+
@runtime ||= ::Johnson::Runtime.new
|
18
|
+
end
|
19
|
+
|
20
|
+
module Runner
|
21
|
+
def load(file)
|
22
|
+
Ripl::Johnson.runtime.load(File.expand_path(file))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Ripl::Shell.send :include, Ripl::Johnson
|
28
|
+
Ripl::Runner.extend Ripl::Johnson::Runner
|
29
|
+
|
30
|
+
# Needs to wrap Ripl::Johnson#loop_eval
|
31
|
+
require 'ripl/johnson/multi_line'
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'bond'
|
2
|
+
module Ripl::Johnson::Completion
|
3
|
+
def before_loop
|
4
|
+
super
|
5
|
+
Ripl::Johnson::Completion.start
|
6
|
+
end
|
7
|
+
|
8
|
+
# From https://developer.mozilla.org/en/JavaScript/Reference
|
9
|
+
|
10
|
+
RESERVED_WORDS = %w{break case catch continue default delete do else
|
11
|
+
finally for function if in instanceof new return switch this throw
|
12
|
+
try typeof var void while with debugger true false null}
|
13
|
+
|
14
|
+
OBJECTS = %w{Boolean Number String Array Object Function RegExp Date
|
15
|
+
Error EvalError RangeError ReferenceError SyntaxError TypeError URIError
|
16
|
+
decodeURI decodeURIComponent encodeURI encodeURIComponent eval isFinite
|
17
|
+
isNaN parseFloat parseInt Infinity Math NaN undefined}
|
18
|
+
|
19
|
+
def self.start
|
20
|
+
Bond.start(:default_mission=>lambda {|e| Ripl::Johnson::Completion.default_action })
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.default_action
|
24
|
+
RESERVED_WORDS + OBJECTS + locals
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.locals
|
28
|
+
Ripl::Johnson.runtime.evaluate(
|
29
|
+
"(function() { var arr = []; for(var e in this) { arr.push(e) }; return arr })();"
|
30
|
+
).to_a
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Ripl::Shell.send :include, Ripl::Johnson::Completion
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Ripl::Johnson::MultiLine
|
2
|
+
def before_loop
|
3
|
+
super
|
4
|
+
@buffer = @unterminated_string = nil
|
5
|
+
end
|
6
|
+
|
7
|
+
def prompt
|
8
|
+
@buffer ? config[:johnson_multi_line_prompt] : super
|
9
|
+
end
|
10
|
+
|
11
|
+
def loop_once
|
12
|
+
catch(:multiline) do
|
13
|
+
super
|
14
|
+
@buffer = nil
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def print_eval_error(e)
|
19
|
+
if e.is_a?(::Johnson::Error) && e.original_exception.to_s[/^SyntaxError/]
|
20
|
+
@unterminated_string = e.to_s[/unterminated string literal/]
|
21
|
+
@buffer ||= []
|
22
|
+
@buffer << @input
|
23
|
+
throw :multiline
|
24
|
+
else
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def loop_eval(input)
|
30
|
+
if @buffer
|
31
|
+
join = @unterminated_string ? "" : "\n"
|
32
|
+
super @buffer* join + join + input
|
33
|
+
else
|
34
|
+
super input
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def handle_interrupt
|
39
|
+
@buffer = @unterminated_string = nil
|
40
|
+
super
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
Ripl::Shell.send :include, Ripl::Johnson::MultiLine
|
45
|
+
Ripl.config[:johnson_multi_line_prompt] ||= ' > '
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ripl-johnson
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Gabriel Horner
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-13 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: ripl
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 7
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 2
|
33
|
+
- 8
|
34
|
+
version: 0.2.8
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: johnson
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 270495454
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 0
|
49
|
+
- 0
|
50
|
+
- pre3
|
51
|
+
version: 2.0.0.pre3
|
52
|
+
type: :runtime
|
53
|
+
version_requirements: *id002
|
54
|
+
description: "A full-featured javscript shell based on johnson a.k.a mozilla's tracemonkey. Since this uses ripl, it comes with most irb functionality: a global config(~/.johnsonrc), autocompletion (very basic currently), history (~/.johnson_history) and multi-line support."
|
55
|
+
email: gabriel.horner@gmail.com
|
56
|
+
executables:
|
57
|
+
- ripl-johnson
|
58
|
+
extensions: []
|
59
|
+
|
60
|
+
extra_rdoc_files:
|
61
|
+
- README.rdoc
|
62
|
+
- LICENSE.txt
|
63
|
+
files:
|
64
|
+
- lib/ripl/johnson/completion.rb
|
65
|
+
- lib/ripl/johnson/multi_line.rb
|
66
|
+
- lib/ripl/johnson/version.rb
|
67
|
+
- lib/ripl/johnson.rb
|
68
|
+
- bin/ripl-johnson
|
69
|
+
- LICENSE.txt
|
70
|
+
- CHANGELOG.rdoc
|
71
|
+
- README.rdoc
|
72
|
+
- deps.rip
|
73
|
+
- Rakefile
|
74
|
+
- .gemspec
|
75
|
+
has_rdoc: true
|
76
|
+
homepage: http://github.com/cldwalker/ripl-johnson
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 3
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
hash: 23
|
99
|
+
segments:
|
100
|
+
- 1
|
101
|
+
- 3
|
102
|
+
- 6
|
103
|
+
version: 1.3.6
|
104
|
+
requirements: []
|
105
|
+
|
106
|
+
rubyforge_project: tagaholic
|
107
|
+
rubygems_version: 1.3.7
|
108
|
+
signing_key:
|
109
|
+
specification_version: 3
|
110
|
+
summary: A javascript shell using johnson (mozilla's tracemonkey)
|
111
|
+
test_files: []
|
112
|
+
|