redcar-clojure 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +0 -0
- data/lib/clojure.rb +39 -0
- data/lib/clojure/repl_mirror.rb +65 -0
- data/plugin.rb +9 -0
- data/vendor/Wrapper.clj +16 -0
- data/vendor/clojure-1.2beta1.jar +0 -0
- data/vendor/clojure-contrib-1.2beta1.jar +0 -0
- data/vendor/enclojure-wrapper.jar +0 -0
- metadata +56 -0
data/README.md
ADDED
File without changes
|
data/lib/clojure.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
|
2
|
+
require 'clojure/repl_mirror'
|
3
|
+
|
4
|
+
puts "loading the clojure plugin"
|
5
|
+
|
6
|
+
module Redcar
|
7
|
+
class Clojure
|
8
|
+
|
9
|
+
def self.menus
|
10
|
+
Menu::Builder.build do
|
11
|
+
sub_menu "Plugins" do
|
12
|
+
sub_menu "REPL" do
|
13
|
+
item "Open Clojure REPL", OpenClojureREPL
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.load_dependencies
|
20
|
+
unless @loaded
|
21
|
+
require File.join(vendor_dir, "clojure-1.2beta1.jar")
|
22
|
+
require File.join(vendor_dir, "clojure-contrib-1.2beta1.jar")
|
23
|
+
require File.join(vendor_dir, "org-enclojure-repl-server.jar")
|
24
|
+
require File.join(vendor_dir, "enclojure-wrapper.jar")
|
25
|
+
@loaded = true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.vendor_dir
|
30
|
+
File.expand_path("../../vendor", __FILE__)
|
31
|
+
end
|
32
|
+
|
33
|
+
class OpenClojureREPL < Redcar::REPL::OpenREPL
|
34
|
+
def execute
|
35
|
+
open_repl(ReplMirror.new)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
|
2
|
+
module Redcar
|
3
|
+
class Clojure
|
4
|
+
class ReplMirror < Redcar::REPL::ReplMirror
|
5
|
+
|
6
|
+
def title
|
7
|
+
"Clojure REPL"
|
8
|
+
end
|
9
|
+
|
10
|
+
def grammar_name
|
11
|
+
"Clojure REPL"
|
12
|
+
end
|
13
|
+
|
14
|
+
def prompt
|
15
|
+
"user=>"
|
16
|
+
end
|
17
|
+
|
18
|
+
def evaluator
|
19
|
+
@evaluator ||= Evaluator.new(self)
|
20
|
+
end
|
21
|
+
|
22
|
+
def format_error(e)
|
23
|
+
"ERROR: #{e.message}\n\n#{e.backtrace.join("\n")}"
|
24
|
+
end
|
25
|
+
|
26
|
+
class Evaluator
|
27
|
+
attr_reader :wrapper
|
28
|
+
|
29
|
+
def self.load_dependencies
|
30
|
+
unless @loaded
|
31
|
+
Clojure.load_dependencies
|
32
|
+
import 'redcar.repl.Wrapper'
|
33
|
+
@loaded = true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def initialize(mirror)
|
38
|
+
Evaluator.load_dependencies
|
39
|
+
@mirror = mirror
|
40
|
+
@wrapper ||= begin
|
41
|
+
wrapper = Wrapper.new
|
42
|
+
|
43
|
+
@thread = Thread.new do
|
44
|
+
loop do
|
45
|
+
output = wrapper.getResult
|
46
|
+
output =~ /^(.*)\nuser=> /
|
47
|
+
@result = $1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
wrapper
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def execute(expr)
|
56
|
+
wrapper.sendToRepl(expr)
|
57
|
+
true until @result
|
58
|
+
str = @result
|
59
|
+
@result = nil
|
60
|
+
str
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/plugin.rb
ADDED
data/vendor/Wrapper.clj
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
(ns redcar.repl.Wrapper
|
2
|
+
(:require [org.enclojure.repl.main])
|
3
|
+
(:gen-class
|
4
|
+
:state state
|
5
|
+
:init init
|
6
|
+
:methods [[getResult [] String]
|
7
|
+
[sendToRepl [String] void]]))
|
8
|
+
|
9
|
+
(defn -init []
|
10
|
+
[[] (org.enclojure.repl.main/create-clojure-repl)])
|
11
|
+
|
12
|
+
(defn -getResult [this]
|
13
|
+
((:result-fn (.state this))))
|
14
|
+
|
15
|
+
(defn -sendToRepl [this expr]
|
16
|
+
((:repl-fn (.state this)) expr))
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redcar-clojure
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.2'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Daniel Lucraft
|
9
|
+
- Delisa Mason
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2011-09-10 00:00:00.000000000 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
description: ''
|
17
|
+
email:
|
18
|
+
- dan@fluentradical.com
|
19
|
+
executables: []
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- lib/clojure/repl_mirror.rb
|
24
|
+
- lib/clojure.rb
|
25
|
+
- README.md
|
26
|
+
- plugin.rb
|
27
|
+
- vendor/clojure-1.2beta1.jar
|
28
|
+
- vendor/clojure-contrib-1.2beta1.jar
|
29
|
+
- vendor/enclojure-wrapper.jar
|
30
|
+
- vendor/Wrapper.clj
|
31
|
+
has_rdoc: true
|
32
|
+
homepage: http://github.com/danlucraft/redcar-clojure
|
33
|
+
licenses: []
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.6.2
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: A Redcar plugin for Clojure development
|
56
|
+
test_files: []
|