rsense 0.5.16 → 0.5.18
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.
- checksums.yaml +4 -4
- data/README.md +1 -9
- data/bin/_rsense_commandline.rb +87 -0
- data/lib/rsense/client/runner.rb +27 -10
- data/lib/rsense/version.rb +1 -1
- data/rsense.gemspec +1 -1
- data/spec/rsense/client/daemon_spec.rb +1 -1
- data/spec/rsense/client/runner_spec.rb +33 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f698810651ef1e3870d8ca2ae09a19630162243a
|
4
|
+
data.tar.gz: e297e3d65b240e5087741e57d5a7989c344a36e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0acba04264905a7871c4182c79f7c730a21d50a49c36d62ae9090bbd42aaa682ea65eb86ad46b23ed27f9bfa4b3eca36842e502a557c9c25fdbc2d948d9b2c56
|
7
|
+
data.tar.gz: e53a30024ec22724564e19667fd913053a0a740afa5c42988e53535bf89763ef1979352b334ff0a68d8eec1b211ea426c99f7a66577452afdc71f8a14fad9d3e
|
data/README.md
CHANGED
@@ -12,15 +12,7 @@ RSense is currently under heavy development and ready for testing. Currently we
|
|
12
12
|
|
13
13
|
|
14
14
|
## Installation
|
15
|
-
RSense is installed via RubyGems.
|
16
|
-
|
17
|
-
Add this line to your application's Gemfile:
|
18
|
-
|
19
|
-
gem 'rsense'
|
20
|
-
|
21
|
-
And then execute:
|
22
|
-
|
23
|
-
$ bundle
|
15
|
+
RSense is installed via RubyGems. Be sure to install it with the proper version of Ruby (whichever ruby you are using for your project).
|
24
16
|
|
25
17
|
Or install it yourself as:
|
26
18
|
|
@@ -0,0 +1,87 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'json'
|
5
|
+
require "faraday"
|
6
|
+
require "uri"
|
7
|
+
require "timeout"
|
8
|
+
|
9
|
+
module Rsense
|
10
|
+
class Request
|
11
|
+
SOCKET_PATH = 'localhost'
|
12
|
+
DEFAULT_PORT = 47367
|
13
|
+
|
14
|
+
def self.req(jsondata)
|
15
|
+
conn = Faraday.new(uri)
|
16
|
+
|
17
|
+
conn.post do |req|
|
18
|
+
req.headers["Content-Type"] = 'application.json'
|
19
|
+
req.body = jsondata
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.uri
|
24
|
+
uri = URI::HTTP.build({host: SOCKET_PATH, port: DEFAULT_PORT})
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Main
|
29
|
+
def self.run(jsondata)
|
30
|
+
begin
|
31
|
+
Timeout::timeout(1) do
|
32
|
+
res_body = request(jsondata).body
|
33
|
+
completions_hash = JSON.parse(res_body)
|
34
|
+
self.stringify(completions_hash)
|
35
|
+
end
|
36
|
+
rescue Timeout::Error => e
|
37
|
+
[""]
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.stringify(completions_hash)
|
42
|
+
compls = completions_hash["completions"].map do |c|
|
43
|
+
"#{c["name"]} #{c["qualified_name"]} #{c["base_name"]} #{c["kind"]}"
|
44
|
+
end
|
45
|
+
compls.join("\n")
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.request(jsondata)
|
49
|
+
Rsense::Request.req(jsondata)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
options = { command: "code_completion" }
|
55
|
+
OptionParser.new do |opts|
|
56
|
+
opts.banner = "Usage: rsense start [options]"
|
57
|
+
|
58
|
+
opts.on("--project PROJECT", "project path") do |project|
|
59
|
+
options[:project] = project
|
60
|
+
end
|
61
|
+
|
62
|
+
opts.on("--filepath FILEPATH", "Filepath") do |filepath|
|
63
|
+
options[:file] = filepath
|
64
|
+
end
|
65
|
+
|
66
|
+
opts.on("--text TEXT", "Text") do |text|
|
67
|
+
options[:code] = text
|
68
|
+
end
|
69
|
+
|
70
|
+
opts.on("--location LOCATION", "Location") do |location|
|
71
|
+
loc = location.split(':')
|
72
|
+
row = loc.first
|
73
|
+
col = loc.last
|
74
|
+
options[:location] = { row: (row.to_i + 1), column: (col.to_i + 1) }
|
75
|
+
end
|
76
|
+
end.parse!
|
77
|
+
|
78
|
+
begin
|
79
|
+
|
80
|
+
jsondata = JSON.generate(options)
|
81
|
+
|
82
|
+
compls = Rsense::Main.run(jsondata)
|
83
|
+
puts compls
|
84
|
+
|
85
|
+
rescue Exception => e
|
86
|
+
puts "ERROR: #{e}"
|
87
|
+
end
|
data/lib/rsense/client/runner.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'fileutils'
|
1
2
|
require 'rubygems'
|
2
3
|
require 'spoon'
|
3
4
|
|
@@ -8,11 +9,13 @@ module Rsense
|
|
8
9
|
|
9
10
|
APPNAME = 'rsense'
|
10
11
|
WORK_PATH = Dir.pwd
|
11
|
-
|
12
|
-
|
12
|
+
# TODO: Make this configurable w/out ENV variables
|
13
|
+
PID_PATH = ENV['RSENSE_PID'] || '/tmp'
|
14
|
+
OUT_PATH = ENV['RSENSE_LOG'] || '/tmp'
|
13
15
|
EXEC = "/usr/bin/env"
|
14
16
|
|
15
17
|
def initialize(args={})
|
18
|
+
ensure_paths_exist(PID_PATH, OUT_PATH)
|
16
19
|
@args = args
|
17
20
|
end
|
18
21
|
|
@@ -22,11 +25,11 @@ module Rsense
|
|
22
25
|
|
23
26
|
def create_pid(pid)
|
24
27
|
begin
|
25
|
-
open(
|
28
|
+
open(pid_path, 'w') do |f|
|
26
29
|
f.puts pid
|
27
30
|
end
|
28
31
|
rescue => e
|
29
|
-
STDERR.puts "Error: Unable to open #{
|
32
|
+
STDERR.puts "Error: Unable to open #{pid_path} for writing:\n\t" +
|
30
33
|
"(#{e.class}) #{e.message}"
|
31
34
|
exit!
|
32
35
|
end
|
@@ -35,12 +38,12 @@ module Rsense
|
|
35
38
|
def get_pid
|
36
39
|
pid = false
|
37
40
|
begin
|
38
|
-
open(
|
41
|
+
open(pid_path, 'r') do |f|
|
39
42
|
pid = f.readline
|
40
43
|
pid = pid.to_s.gsub(/[^0-9]/,'')
|
41
44
|
end
|
42
45
|
rescue => e
|
43
|
-
STDERR.puts "Error: Unable to open #{
|
46
|
+
STDERR.puts "Error: Unable to open #{pid_path} for reading:\n\t" +
|
44
47
|
"(#{e.class}) #{e.message}"
|
45
48
|
exit
|
46
49
|
end
|
@@ -49,8 +52,8 @@ module Rsense
|
|
49
52
|
end
|
50
53
|
|
51
54
|
def remove_pidfile
|
52
|
-
|
53
|
-
|
55
|
+
begin
|
56
|
+
File.unlink(pid_path)
|
54
57
|
rescue => e
|
55
58
|
STDERR.puts "ERROR: Unable to unlink #{path}:\n\t" +
|
56
59
|
"(#{e.class}) #{e.message}"
|
@@ -108,13 +111,27 @@ module Rsense
|
|
108
111
|
Dir::chdir(WORK_PATH)
|
109
112
|
file_actions = Spoon::FileActions.new
|
110
113
|
file_actions.close(1)
|
111
|
-
file_actions.open(1,
|
114
|
+
file_actions.open(1, out_path, File::WRONLY | File::TRUNC | File::CREAT, 0600)
|
112
115
|
file_actions.close(2)
|
113
|
-
file_actions.open(2,
|
116
|
+
file_actions.open(2, out_path, File::WRONLY | File::TRUNC | File::CREAT, 0600)
|
114
117
|
spawn_attr = Spoon::SpawnAttributes.new
|
115
118
|
pid = Spoon.posix_spawn EXEC, file_actions, spawn_attr, @args
|
116
119
|
create_pid(pid)
|
117
120
|
end
|
121
|
+
|
122
|
+
def pid_path
|
123
|
+
File.join(PID_PATH, "rsense.pid")
|
124
|
+
end
|
125
|
+
|
126
|
+
def out_path
|
127
|
+
File.join(OUT_PATH, "rsense.log")
|
128
|
+
end
|
129
|
+
|
130
|
+
def ensure_paths_exist(*paths)
|
131
|
+
paths.each do |path|
|
132
|
+
FileUtils.mkdir_p(path) unless File.directory?(path)
|
133
|
+
end
|
134
|
+
end
|
118
135
|
end
|
119
136
|
end
|
120
137
|
end
|
data/lib/rsense/version.rb
CHANGED
data/rsense.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "rsense-core", "~> 0.6.6"
|
22
|
-
spec.add_dependency "rsense-server", "~> 0.5.
|
22
|
+
spec.add_dependency "rsense-server", "~> 0.5.18"
|
23
23
|
spec.add_dependency "spoon", "~> 0.0.4"
|
24
24
|
spec.add_dependency "jruby-jars", "~> 1.7.4"
|
25
25
|
spec.add_dependency "jruby-parser", "~> 0.5.4"
|
@@ -74,7 +74,7 @@ describe Rsense::Client::Daemon do
|
|
74
74
|
|
75
75
|
it "should initialize a runner" do
|
76
76
|
daemon = Rsense::Client::Daemon.new(["foo", "bar"])
|
77
|
-
daemon.runner.class::PID_PATH.must_match(
|
77
|
+
daemon.runner.class::PID_PATH.must_match(Rsense::Client::Runner::PID_PATH)
|
78
78
|
end
|
79
79
|
|
80
80
|
it "should delegate start method to runner" do
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative "../../spec_helper"
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
describe Rsense::Client::Runner do
|
5
|
+
before do
|
6
|
+
@runner = Rsense::Client::Runner.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#ensure_paths_exists" do
|
10
|
+
let(:filepath) { "/tmp/rsense-test" }
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
FileUtils.rm_r(filepath) if File.directory?(filepath)
|
14
|
+
end
|
15
|
+
|
16
|
+
after(:each) do
|
17
|
+
FileUtils.rm_r(filepath) if File.directory?(filepath)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "creates directories when they don't exists" do
|
21
|
+
File.directory?(filepath).must_equal(false)
|
22
|
+
@runner.ensure_paths_exist(filepath)
|
23
|
+
File.directory?(filepath).must_equal(true)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "doesn't do anything when directories exists" do
|
27
|
+
FileUtils.mkdir_p(filepath)
|
28
|
+
File.directory?(filepath).must_equal(true)
|
29
|
+
@runner.ensure_paths_exist(filepath)
|
30
|
+
File.directory?(filepath).must_equal(true)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsense
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric West
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-11-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rsense-core
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.5.
|
34
|
+
version: 0.5.18
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 0.5.
|
41
|
+
version: 0.5.18
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: spoon
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,6 +219,7 @@ email:
|
|
219
219
|
- esw9999@gmail.com
|
220
220
|
- tomo@cx4a.org
|
221
221
|
executables:
|
222
|
+
- _rsense_commandline.rb
|
222
223
|
- rsense
|
223
224
|
extensions: []
|
224
225
|
extra_rdoc_files: []
|
@@ -229,6 +230,7 @@ files:
|
|
229
230
|
- LICENSE.txt
|
230
231
|
- README.md
|
231
232
|
- Rakefile
|
233
|
+
- bin/_rsense_commandline.rb
|
232
234
|
- bin/rsense
|
233
235
|
- lib/rsense.rb
|
234
236
|
- lib/rsense/client.rb
|
@@ -239,6 +241,7 @@ files:
|
|
239
241
|
- spec/fixtures/find_def_sample.json
|
240
242
|
- spec/fixtures/sample.json
|
241
243
|
- spec/rsense/client/daemon_spec.rb
|
244
|
+
- spec/rsense/client/runner_spec.rb
|
242
245
|
- spec/spec_helper.rb
|
243
246
|
homepage: ''
|
244
247
|
licenses:
|
@@ -268,4 +271,5 @@ test_files:
|
|
268
271
|
- spec/fixtures/find_def_sample.json
|
269
272
|
- spec/fixtures/sample.json
|
270
273
|
- spec/rsense/client/daemon_spec.rb
|
274
|
+
- spec/rsense/client/runner_spec.rb
|
271
275
|
- spec/spec_helper.rb
|