3. 1. Aptana Ruble?
Ruble = RUby BundLE
• IDE와 에디터 영역의 사용 환경을 Ruby를 사
용해 확장하는 런타임 환경을 의미
• TextMate bundles와 호환
4. 2. 생성하기
Creating a new Ruble :
https://wiki.appcelerator.org/display/tis/Creating+a+new+Ruble
a. Wizard :
New > Ruby Project >
b. Modifying existing ruble
Commands > [Ruble Name] > Edit this bundle
5. 2. 생성하기 : bundle.rb
bundle.rb
require 'ruble'
bundle do |bundle|
bundle.display_name = 'Test Plugin'
bundle.author = 'My Name'
bundle.copyright = <<END
(c) Copyright 2011 sample.org. Distributed under MIT license.
END
bundle.description = <<END
Sample description
END
# uncomment with the url to the git repo if one exists
# bundle.repository = 'git@github.com:username/repo-name.git'
# Use Commands > Bundle Development > Insert Bundle Section > Menu
# to easily add new sections
bundle.menu 'Test Plugin' do |menu|
menu.command 'Swap Case'
menu.command 'Sample Snippet'
menu.separator
menu.menu 'Sub Menu' do |sub_menu|
sub_menu.command 'Sample Snippet'
end
end
end
7. 2. 생성하기 : How command is invoked
/commands/commands.rb
/bundle.rb
require 'ruble'
bundle.menu 'Test Plugin' do |menu|
menu.command 'Swap Case' command 'Swap Case' do |cmd|
menu.command 'Sample Snippet' cmd.key_binding = 'SHIFT+CTRL+A'
menu.separator cmd.scope = 'source'
menu.menu 'Sub Menu' do |sub_menu| cmd.output = :replace_selection
sub_menu.command 'Sample cmd.input = :selection, :word
Snippet' cmd.invoke do |context|
end word = $stdin.gets
end context.exit_discard if word.nil?
end print word.swapcase
end
end
8. 3. Commands : scope
• 명령이 수행되는 스코프를 지정. 스코프가 지정되지 않으면, 모든 스코프를 대상으로 실행
Specification : https://wiki.appcelerator.org/display/tis/Ruble+Specification#RubleSpecification-Scopes
• Name Selector / Dotted Name Selector
ex. text
text, text.html, text.html.ruby 등의 파일명과 매칭. texts.physics는 매칭되지 않음. 프리픽스는 점(dot)
표현 식으로 종료되는 표현 식만 매칭됨.
• Descendant Selector
ex. text.html source.ruby
“text.html” 내에 존재하는 Ruby 코드 내에 에디터의 커서가 위치하는 경우
The editor's cursor is within Ruby code which is within HTML
• Union Selector
콤마는 OR과 같이 수행됨. 파이프 연산자는 콤마 연산자 보다 연산자의 우선 순위에서 뒤쳐짐
ex. text.html.ruby, text.html source.ruby
text.html.ruby | text.html source.ruby
9. 3. Commands : scope (cont’d)
• Intersection Selector
2개의 조건이 부합되는 경우에만
ex. text & source
• Grouping
그룹핑
ex. source & (js | ruby)
• Negative Lookahead
ex. text.html – source.ruby
"source.ruby " 와 매칭되지 않는 모든 "text.html" 스코프
Operator Name(s)
() Parentheses, Group
& Ampersand, Intersection
• 연산자 우선 순위
<space> Descendant
- Negative Lookahead, Asymmetric Difference
, Comma, Or, Union
| Pipe, Or, Union
10. 3. Commands : input
• 명령이 실행되는 대상의 입력 정의 (INPUT_SPECIFIER에 따름)
Specification : https://wiki.appcelerator.org/display/tis/Ruble+Specification#RubleSpecification-INPUTSPECIFIER
Specifier Description
:selection selected text in the editor
:left_character the character to the immediate left of the caret
:right_character the character to the immediate right of the caret
:word word surrounding the current caret
:line the line containing the caret
:document the entire current document
:clipboard the contents of the clipboard
:scope (NOT YET IMPLEMENTED) As in TextMate: search backwards and forwards for the first cha
racter which is not matched by the scope selector of the command and use those as bou
ndaries for the input.
:input_from_console take input from a shell window? How do we specify which console?
:none no input is needed by this command. When encountered in the multiple symbol specifie
r case, this symbol always terminates fallback evaluation
:selected_lines I'm not sure what this does or how it differs from :selection!!!
11. 3. Commands : output
• 명령의 수행결과 출력대상 정의 (OUTPUT_SPECIFIER에 따름)
Specification : https://wiki.appcelerator.org/display/tis/Ruble+Specification#RubleSpecification-OUTPUTSPECIFIER
Specifier Description
:insert_as_text insert text at the caret position. If there is a selection, the text is inserted immediately foll
owing the selection and the selection is lost.
:insert_as_snippet as with :insert_as_text, but the output is interpreted as snippet expansion text
:replace_selection replace the currently selected text with the output. If no text is selected, this is equivalent
to the :insert_as_text specifier
:replace_document replace the entire document with the output
:copy_to_clipboard replace the contents of the clipboard with the output
:show_as_html open an html browser window and intepret the output as html
:show_as_tooltip show a tooltip containing the output
:create_new_document create a new editor document containing the output
:output_to_console display the output in a console. HOW DO WE SPECIFY WHICH CONSOLE
:discard throw any output away
:replace_selected_lines what does this do? probably unnecessary
:replace_line replace the line around the caret. probably unnecessary
:replace_word replace the word around the caret. probably unnecessary
12. 3. Commands : key_binding
• 명령 수행 단축키. 플랫폼에 따라 다르게 지정할 수
도 있음
Key ... ...
Specification :
https://wiki.appcelerator.org/display/tis/Ruble+Specification#RubleSp ARROW_DOWN F1 NUMPAD_0
ecification-KeyBindings ARROW_LEFT F2 NUMPAD_1
ARROW_RIGHT F3 NUMPAD_2
ARROW_UP F4 NUMPAD_3
BREAK F5 NUMPAD_4
Shortcut Platform Key BS F6 NUMPAD_5
M1 OS X COMMAND CAPS_LOCK F7 NUMPAD_6
M1 Other Platforms CONTROL (CTRL) CR F8 NUMPAD_7
M2 All Platforms SHIFT DEL F9 NUMPAD_8
M3 OS X OPTION END F10 NUMPAD_9
M3 Other Platforms ALT ESC F11 NUMPAD_ADD
M4 OS X CONTROL (CTRL) HOME F12 NUMPAD_DECIMAL
INSERT F13 NUMPAD_DIVIDE
LF F14 NUMPAD_ENTER
FF F15 NUMPAD_EQUAL
NUL PRINT_SCREEN NUMPAD_MULTIPLY
PAGE_UP PAUSE NUMPAD_SUBTRACT
PAGE_DOWN SCROLL_LOCK NUM_LOCK
SPACE TAB VT
13. 3. Commands : invoke
• 실제 명령의 수행을 담당하는 코드
• Output에 따라 Ruby, HTML 또는 shell script 등을 사용할 수 있다.
Specification : https://wiki.appcelerator.org/display/tis/Ruble+Specification#RubleSpecification-KeyBindings
command 'Jindo API' do |cmd|
cmd.key_binding = "ALT+SHIFT+HOME"
cmd.output = :show_as_html
cmd.input = :none
cmd.invoke do |context|
url = "file://#{File.dirname(ENV['TM_BUNDLE_SUPPORT'])}/views/ko/symbols/$A.html"
<<-END
<html><head><title>Jindo
API</title><style>html,body{width:100%;height:100%}body{margin:0;padding:0}</style></h
ead>
<body>
<iframe src='#{url}' marginwidth=0 marginheight=0 frameborder=0
style='width:100%;height:100%'></iframe>
</body>
</html>
END
end
end
18. 6. Packaging & installation
• zip으로 디렉토리를 모두 압축
설치는 압축된 파일을 플랫폼에 따라 아래 위치에 압축해제
a. Windows : C:Users사용자Aptana Rubles
b. MacOS : /User/사용자/Documents/Aptana Rubles/
• 몇 가지 기억할 점
- cache.*.yml은 패키징에 포함시키면 안된다.
- command의 코드에 따라 운영체제에 따른 분기처리가 필요할 수도 있다.