Skip to content

Commit

Permalink
Polishing bug fixes + README
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric West committed Jul 6, 2014
1 parent 066f197 commit 0084849
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 32 deletions.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[![rsense](https://cloud.githubusercontent.com/assets/1395968/2978144/51565ee2-dbb5-11e3-9b94-e97a37739d03.png)](http://rsense.github.io/)

# rsense package

### [Rsense Can See All](http://rsense.github.io/)

[![Gitter chat](https://badges.gitter.im/rsense/rsense.png)](https://gitter.im/rsense/rsense)

RSense is a tool for doing static analysis of Ruby source code. Rsense is used in conjunction with an editor plugin. This is the plugin for the Atom editor.

RSense is currently in beta and ready for testing. Currently we have exposed code-completion. In the near future we'll also be ready to expose some of Rsense's other basic features like `find-definition`. After that, there's plenty to do in the long term. See the waffle link below to find out where you can pitch in. It would be awesome if you helped get things done.

[![Stories in Ready](https://badge.waffle.io/rsense/rsense.png?label=ready&title=Ready)](https://waffle.io/rsense/rsense)

![A screenshot of your spankin' package](https://cloud.githubusercontent.com/assets/1395968/3344028/5b3c2f0a-f8a6-11e3-8952-c0f7155cb19e.gif)

## Installation

Add this line to your application's Gemfile:

gem 'rsense'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rsense

Then install this package via [Sublime Text's package manager](https://sublime.wbond.net/), within preferences. Just search for `rsense`.

## Usage

You'll need to run `rsense start` from the command line, though we do eventually plan to add an command for starting and stopping the server.
Completions are triggered on `.` and `::`.

More information about rsense can be found at http://rsense.github.io/ .
13 changes: 8 additions & 5 deletions rsense_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


# RUBY_METHOD_SEP_PATTERN = re.compile('[^.:]*$')
RUBY_METHOD_SEP_PATTERN = re.compile('((?<=\.).*$)|((?<=::).*$)')
RUBY_METHOD_SEP_PATTERN = re.compile('((?<=\.).*)|((?<=::).*)')

class RsenseCompletions(sublime_plugin.EventListener):

Expand Down Expand Up @@ -75,18 +75,21 @@ def clean_and_arrange(self, output):
parsed = self._parse_output(self._sanitize_output(output).strip())

for line in parsed:
if len(line) >= 4:
show_string = line[0] + "\t" + line[2] + "\t" + line[3]
show_string = ""
candidate = []
if len(line) > 1:
for strng in line:
candidate.append(strng)
candidate.append(" ")
compl = line[0]
completions.append((show_string, compl))
completions.append((show_string.join(candidate), compl))

return completions

# TODO: Filter completions for metadata returned by rsense.
def get_completions(self, view, text, location, path):
command_string = self.make_command(view, text, location, path)
raw_output = self.run_command(command_string)
# print(raw_output.decode('utf-8'))
return self.clean_and_arrange(raw_output)


Expand Down
53 changes: 26 additions & 27 deletions rsense_completions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,6 @@
require 'json'
require 'net/http'

options = { command: "code_completion" }
OptionParser.new do |opts|
opts.banner = "Usage: rsense start [options]"

opts.on("--project PROJECT", "project path") do |project|
options[:project] = project
end

opts.on("--filepath FILEPATH", "Filepath") do |filepath|
options[:file] = filepath
end

opts.on("--text TEXT", "Text") do |text|
options[:code] = text
end

opts.on("--location LOCATION", "Location") do |location|
loc = location.split(':')
row = loc.first
col = loc.last
options[:location] = { row: (row.to_i + 1), column: (col.to_i + 1) }
end
end.parse!

jsondata = JSON.generate(options)

module Rsense
class Request
SOCKET_PATH = 'http://localhost'
Expand Down Expand Up @@ -71,6 +45,31 @@ def self.request(jsondata)
end
end

compls = Rsense::Main.run(jsondata)
options = { command: "code_completion" }
OptionParser.new do |opts|
opts.banner = "Usage: rsense start [options]"

opts.on("--project PROJECT", "project path") do |project|
options[:project] = project
end

opts.on("--filepath FILEPATH", "Filepath") do |filepath|
options[:file] = filepath
end

opts.on("--text TEXT", "Text") do |text|
options[:code] = text
end

opts.on("--location LOCATION", "Location") do |location|
loc = location.split(':')
row = loc.first
col = loc.last
options[:location] = { row: (row.to_i + 1), column: (col.to_i + 1) }
end
end.parse!

jsondata = JSON.generate(options)

compls = Rsense::Main.run(jsondata)
puts compls
Binary file added subl_rsense.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0084849

Please sign in to comment.