schlueter-rushmate 0.0.7 → 0.0.8
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/History.txt +3 -0
- data/MIT-LICENSE +20 -0
- data/README +3 -1
- data/Rakefile +20 -1
- data/lib/rushmate/command.rb +21 -0
- data/lib/rushmate/exit.rb +18 -0
- data/lib/rushmate/textmate_helper.rb +20 -0
- data/lib/rushmate/user_input.rb +10 -0
- data/rushmate.gemspec +3 -2
- metadata +3 -1
data/History.txt
CHANGED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Nicholas Schlueter (http://simpltry.com)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
= Rushmate
|
2
2
|
|
3
|
-
Rushmate attempts to make Textmate (http://macromates.com) custom command writing in ruby
|
3
|
+
Rushmate attempts to make Textmate (http://macromates.com) custom command writing in ruby
|
4
|
+
cleaner and smaller. It does this by leveraging rush (http://rush.heroku.com/).
|
4
5
|
|
5
6
|
== Dependencies
|
6
7
|
|
@@ -9,6 +10,7 @@ Rushmate attempts to make Textmate (http://macromates.com) custom command writin
|
|
9
10
|
== Install
|
10
11
|
|
11
12
|
gem sources -a http://gems.github.com
|
13
|
+
|
12
14
|
sudo gem install schlueter-rushmate
|
13
15
|
|
14
16
|
== Sample
|
data/Rakefile
CHANGED
@@ -1,5 +1,24 @@
|
|
1
|
-
task :coverage do
|
1
|
+
task :coverage => :cleanup do
|
2
2
|
system("rm -fr coverage")
|
3
3
|
system("export TM_SUPPORT_PATH=/Applications/TextMate.app/Contents/SharedSupport/Support && rcov --sort=coverage --threshold=100 --exclude=gems/*,TextMate.app --sort=coverage test/*_test.rb")
|
4
4
|
system("open coverage/index.html")
|
5
|
+
end
|
6
|
+
|
7
|
+
task :install => :cleanup do
|
8
|
+
puts %x{gem build rushmate.gemspec}
|
9
|
+
puts %x{sudo gem install --local -f rushmate}
|
10
|
+
end
|
11
|
+
|
12
|
+
task :uninstall do
|
13
|
+
puts %x{sudo gem uninstall rushmate}
|
14
|
+
end
|
15
|
+
|
16
|
+
task :cleanup do
|
17
|
+
%x{rm -rf coverage}
|
18
|
+
%x{rm -f rushmate-*}
|
19
|
+
%x{rm -rf doc}
|
20
|
+
end
|
21
|
+
|
22
|
+
task :rdoc => :cleanup do
|
23
|
+
%x{rdoc -o doc -m README lib/rushmate/**.rb README MIT-LICENSE}
|
5
24
|
end
|
data/lib/rushmate/command.rb
CHANGED
@@ -3,24 +3,45 @@ module Rushmate
|
|
3
3
|
class Command
|
4
4
|
include TextmateHelper
|
5
5
|
attr_accessor :shell
|
6
|
+
# Class construction is designed to take a block that gets executed
|
7
|
+
# as part of the class
|
8
|
+
#
|
9
|
+
# Example:
|
10
|
+
#
|
11
|
+
# Rushmate::Command.new {
|
12
|
+
# exit.show_tool_tip project_directory['**/*.rb'].line_count
|
13
|
+
# }
|
6
14
|
def initialize(&block)
|
7
15
|
setup_shell
|
8
16
|
self.instance_eval(&block) if block
|
9
17
|
end
|
10
18
|
|
19
|
+
# execute the parameter against a Rush::Shell instance
|
11
20
|
def execute(thing)
|
12
21
|
shell.execute(thing)
|
13
22
|
$last_res
|
14
23
|
end
|
15
24
|
|
25
|
+
# anything not defined in Rushmate::Command should be defered to
|
26
|
+
# Rushmate::Command#execute
|
16
27
|
def method_missing(sym, *args, &block)
|
17
28
|
execute sym.to_s
|
18
29
|
end
|
19
30
|
|
31
|
+
# return a reference to Rushmate::Exit
|
32
|
+
# This is useful for shortening up your code
|
33
|
+
# Example:
|
34
|
+
#
|
35
|
+
# exit.show_tool_tip("nothing found")
|
20
36
|
def exit
|
21
37
|
Rushmate::Exit
|
22
38
|
end
|
23
39
|
|
40
|
+
# return a reference to Rushmate::UserInput
|
41
|
+
# This is useful for shortening up your code
|
42
|
+
# Example:
|
43
|
+
#
|
44
|
+
# user_input.quick_menu_from_array(['opt 1', 'opt 2'])
|
24
45
|
def user_input
|
25
46
|
Rushmate::UserInput
|
26
47
|
end
|
data/lib/rushmate/exit.rb
CHANGED
@@ -1,40 +1,58 @@
|
|
1
1
|
module Rushmate
|
2
|
+
# Rushmate::Exit provides a list of methods for exiting
|
3
|
+
# a command and changing the output type in Textmate
|
4
|
+
#
|
5
|
+
# For instance if you specified the command to be
|
6
|
+
# output: Discard
|
7
|
+
# it may be benificial to show a tooltip if the command
|
8
|
+
# could not do what it was tasked to do
|
9
|
+
#
|
10
|
+
# Example:
|
11
|
+
#
|
12
|
+
# Rushmate::Exit.show_tool_tip("could not find file")
|
2
13
|
module Exit
|
3
14
|
class << self
|
4
15
|
def discard
|
5
16
|
exit 200
|
6
17
|
end
|
7
18
|
|
19
|
+
# changes output to replace selected text
|
8
20
|
def replace_text(out = nil)
|
9
21
|
print out if out
|
10
22
|
exit 201
|
11
23
|
end
|
12
24
|
|
25
|
+
# changes output to replace selected document
|
13
26
|
def replace_document(out = nil)
|
14
27
|
print out if out
|
15
28
|
exit 202
|
16
29
|
end
|
17
30
|
|
31
|
+
# changes output to insert text at editor position
|
18
32
|
def insert_text(out = nil)
|
19
33
|
print out if out
|
20
34
|
exit 203
|
21
35
|
end
|
22
36
|
|
37
|
+
# changes output to insert a snippet at editor position
|
23
38
|
def insert_snippet(out = nil)
|
24
39
|
print out if out
|
25
40
|
exit 204
|
26
41
|
end
|
27
42
|
|
43
|
+
# changes output to show html
|
28
44
|
def show_html(out = nil)
|
29
45
|
print out if out
|
30
46
|
exit 205
|
31
47
|
end
|
32
48
|
|
49
|
+
# changes output to show a tool tip
|
33
50
|
def show_tool_tip(out = nil)
|
34
51
|
print out if out
|
35
52
|
exit 206
|
36
53
|
end
|
37
54
|
|
55
|
+
# changes output to create a new document
|
38
56
|
def create_new_document(out = nil)
|
39
57
|
print out if out
|
40
58
|
exit 207
|
@@ -1,33 +1,53 @@
|
|
1
1
|
module Rushmate
|
2
|
+
# Rushmate::TextmateHelper provides convenience methods to Environment
|
3
|
+
# variables that Textmate exposes to your command
|
2
4
|
module TextmateHelper
|
5
|
+
# returns the current line in the editor window
|
3
6
|
def current_line
|
4
7
|
ENV["TM_CURRENT_LINE"]
|
5
8
|
end
|
6
9
|
|
10
|
+
# returns the current word in the editor window
|
7
11
|
def current_word
|
8
12
|
ENV['TM_CURRENT_WORD']
|
9
13
|
end
|
10
14
|
|
15
|
+
# returns the directory of the active file in the
|
16
|
+
# editor window
|
17
|
+
#
|
18
|
+
# return type Rush::Dir
|
11
19
|
def tm_directory
|
12
20
|
root[ENV['TM_DIRECTORY'] + "/"]
|
13
21
|
end
|
14
22
|
|
23
|
+
# returns the file of the active file in
|
24
|
+
# the editor window
|
25
|
+
#
|
26
|
+
# return type Rush::File
|
15
27
|
def tm_file
|
16
28
|
root[ENV['TM_FILEPATH']]
|
17
29
|
end
|
18
30
|
|
31
|
+
# returns the file name of the active file in the
|
32
|
+
# editor window
|
19
33
|
def tm_filename
|
20
34
|
ENV["TM_FILENAME"]
|
21
35
|
end
|
22
36
|
|
37
|
+
# indicates if the command was activeted from a file
|
38
|
+
# within a textmate project
|
23
39
|
def project_directory?
|
24
40
|
ENV['TM_PROJECT_DIRECTORY']
|
25
41
|
end
|
26
42
|
|
43
|
+
# returns the directory of the textmate project
|
44
|
+
#
|
45
|
+
# return type Rush::Dir
|
27
46
|
def project_directory
|
28
47
|
root[ENV['TM_PROJECT_DIRECTORY'] + "/"]
|
29
48
|
end
|
30
49
|
|
50
|
+
# returns the text selected within Textmate
|
31
51
|
def selected_text
|
32
52
|
ENV["TM_SELECTED_TEXT"]
|
33
53
|
end
|
data/lib/rushmate/user_input.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
module Rushmate
|
2
|
+
# The Rushmate::UserInput class is a convenience class
|
3
|
+
# it provides higher level apis to methods defined in TextMate::UI
|
2
4
|
module UserInput
|
3
5
|
class << self
|
6
|
+
# quick_menu_from_array takes an array of strings and presents them
|
7
|
+
# as menu options similar to the context menu
|
8
|
+
#
|
9
|
+
# Return type is the string the user selected
|
10
|
+
#
|
11
|
+
# This method blocks until the user chooses an option, if the user
|
12
|
+
# presses esc the command is terminated without notifing the
|
13
|
+
# command script
|
4
14
|
def quick_menu_from_array(strings)
|
5
15
|
strings[TextMate::UI.menu(strings)]
|
6
16
|
end
|
data/rushmate.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "rushmate"
|
3
|
-
s.version = "0.0.
|
3
|
+
s.version = "0.0.8"
|
4
4
|
s.email = "schlueter@gmail.com"
|
5
5
|
s.homepage = "http://github.com/schlueter/rushmate"
|
6
6
|
s.description = "Makes writing TextMate commands easier by providing convient methods for getting environment variables and getting user input."
|
@@ -12,6 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.authors = ["Nicholas Schlueter"]
|
13
13
|
s.files = [
|
14
14
|
"History.txt",
|
15
|
+
"MIT-LICENSE",
|
15
16
|
"Manifest.txt",
|
16
17
|
"README",
|
17
18
|
"Rakefile",
|
@@ -29,7 +30,7 @@ Gem::Specification.new do |s|
|
|
29
30
|
|
30
31
|
s.has_rdoc = true
|
31
32
|
s.rdoc_options = ["--main", "README"]
|
32
|
-
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README"]
|
33
|
+
s.extra_rdoc_files = ["History.txt", "MIT-LICENSE", "Manifest.txt", "README"]
|
33
34
|
s.add_dependency(%q<rush>, [">= 0.4"])
|
34
35
|
|
35
36
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schlueter-rushmate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Schlueter
|
@@ -29,10 +29,12 @@ extensions: []
|
|
29
29
|
|
30
30
|
extra_rdoc_files:
|
31
31
|
- History.txt
|
32
|
+
- MIT-LICENSE
|
32
33
|
- Manifest.txt
|
33
34
|
- README
|
34
35
|
files:
|
35
36
|
- History.txt
|
37
|
+
- MIT-LICENSE
|
36
38
|
- Manifest.txt
|
37
39
|
- README
|
38
40
|
- Rakefile
|