snippets_converter 0.1.1 → 0.1.2
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/LICENSE +3 -3
- data/README.rdoc +16 -15
- data/Rakefile +4 -2
- data/VERSION +1 -1
- data/bin/snippets_converter +2 -1
- data/lib/snippets_converter/editors/gedit.rb +13 -13
- data/lib/snippets_converter/editors/netbeans.rb +12 -11
- data/lib/snippets_converter/editors/ruble.rb +12 -12
- data/lib/snippets_converter.rb +128 -102
- data/snippets_converter.gemspec +9 -3
- data/test/examples/assert_bad_value.tmSnippet +16 -0
- data/test/test_parse_tm_snippet.rb +24 -0
- data/test/test_snippets_converter.rb +2 -1
- metadata +21 -5
data/LICENSE
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
Copyright (c) 2009 Nicolas Alpi
|
2
2
|
Copyright (c) 2010 Nowhere Man
|
3
3
|
|
4
|
-
|
4
|
+
SnippetsConverter is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
|
5
5
|
as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
|
6
6
|
|
7
|
-
|
7
|
+
SnippetsConverter is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
8
8
|
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
9
9
|
|
10
|
-
You should have received a copy of the GNU General Public License along with
|
10
|
+
You should have received a copy of the GNU General Public License along with SnippetsConverter; if not, write to the
|
11
11
|
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
12
12
|
|
13
13
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
data/README.rdoc
CHANGED
@@ -1,34 +1,34 @@
|
|
1
1
|
= Snippets Converter
|
2
2
|
|
3
|
-
Convert TextMate Snippets into
|
3
|
+
Convert TextMate Snippets into Gedit, NetBeans and Ruble (Aptana RadRails 3) snippets.
|
4
4
|
|
5
|
-
==
|
5
|
+
== Install the gem
|
6
|
+
sudo gem snippets_converter
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
== How to use (for Ubuntu)
|
9
|
+
* Open a terminal and go in your TextMate Bundle directory. Then run :
|
10
|
+
snippets_converter netbeans|gedit|ruble
|
11
|
+
* This will convert all your Snippets in a XML file into the "out" folder of your current directory.
|
10
12
|
|
11
|
-
|
12
|
-
Put the
|
13
|
+
=== Gedit
|
14
|
+
Put the gedit_snippets.xml file into
|
13
15
|
|
14
16
|
/home/username/.gnome2/gedit/snippets
|
15
17
|
|
16
|
-
|
17
|
-
== NetBeans
|
18
|
+
=== NetBeans
|
18
19
|
Put the org-netbeans-modules-editor-settings-CustomCodeTemplates.xml file into
|
19
20
|
|
20
21
|
/home/username/.netbeans/6.8/config/Editors/text/x-ruby/CodeTemplates
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
=== Ruble
|
24
|
+
Put the ruble_snippets.rb file into
|
24
25
|
|
25
|
-
|
26
|
+
/home/username/Documents/Aptana Rubles/my_ruble.ruble/snippets
|
26
27
|
|
27
|
-
|
28
|
-
sudo gem install active_support nokogiri
|
28
|
+
More info at https://radrails.tenderapp.com/faqs/radrails-3/ruble-programming-guide
|
29
29
|
|
30
30
|
== Note on Patches/Pull Requests
|
31
|
-
|
31
|
+
|
32
32
|
* Fork the project.
|
33
33
|
* Make your feature addition or bug fix.
|
34
34
|
* Add tests for it. This is important so I don't break it in a
|
@@ -43,3 +43,4 @@ you'll need ActiveSupport and Nokogiri gems in order to use this gem, so :
|
|
43
43
|
Copyright (c) 2009 Nicolas Alpi
|
44
44
|
|
45
45
|
Copyright (c) 2010 Nowhere Man. See LICENSE for details.
|
46
|
+
|
data/Rakefile
CHANGED
@@ -11,7 +11,8 @@ begin
|
|
11
11
|
gem.email = "nowhereman@open_office"
|
12
12
|
gem.homepage = "http://github.com/nowhereman/snippets_converter"
|
13
13
|
gem.authors = ["Nowhere Man"]
|
14
|
-
|
14
|
+
gem.add_dependency('activesupport', '< 3.0.0')
|
15
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for additional settings
|
15
16
|
end
|
16
17
|
Jeweler::GemcutterTasks.new
|
17
18
|
rescue LoadError
|
@@ -21,7 +22,7 @@ end
|
|
21
22
|
require 'rake/testtask'
|
22
23
|
Rake::TestTask.new(:test) do |test|
|
23
24
|
test.libs << 'lib' << 'test'
|
24
|
-
test.pattern = 'test
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
25
26
|
test.verbose = true
|
26
27
|
end
|
27
28
|
|
@@ -55,3 +56,4 @@ Rake::RDocTask.new do |rdoc|
|
|
55
56
|
rdoc.rdoc_files.include('README*')
|
56
57
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
58
|
end
|
59
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/bin/snippets_converter
CHANGED
@@ -1,23 +1,22 @@
|
|
1
|
-
|
1
|
+
module SnippetsConverter
|
2
2
|
module Editors
|
3
3
|
module Gedit
|
4
|
-
|
4
|
+
|
5
5
|
def editor_conversion(trigger, description, code)
|
6
6
|
# Need to remove dot in 'trigger' because Gedit doesn't seem to like it on the tag
|
7
7
|
return <<-CODE
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
<snippet id="#{trigger.gsub(/\./,'')}">
|
9
|
+
<tag>#{trigger.gsub(/\./,'')}</tag>
|
10
|
+
<description>#{description}</description>
|
11
|
+
<text><![CDATA[#{code}]]></text>
|
12
|
+
</snippet>
|
13
13
|
CODE
|
14
14
|
end
|
15
15
|
|
16
|
-
def editor_header(language='
|
17
|
-
# TODO use ARGV or get 'scope' attribute of TextMate to get the desire language
|
16
|
+
def editor_header(language = 'ruby')
|
18
17
|
return <<-CODE
|
19
|
-
|
20
|
-
|
18
|
+
<?xml version='1.0' encoding='utf-8'?>
|
19
|
+
<snippets language=\"#{language}\">
|
21
20
|
CODE
|
22
21
|
end
|
23
22
|
|
@@ -25,10 +24,11 @@ class SnippetsConverter
|
|
25
24
|
"</snippets>"
|
26
25
|
end
|
27
26
|
|
28
|
-
def editor_target_file
|
29
|
-
"
|
27
|
+
def editor_target_file(language = 'gedit_snippets')
|
28
|
+
"#{language.gsub(/.+\.(.+)/,'\1')}.xml"
|
30
29
|
end
|
31
30
|
|
32
31
|
end
|
33
32
|
end
|
34
33
|
end
|
34
|
+
|
@@ -1,25 +1,25 @@
|
|
1
|
-
|
1
|
+
module SnippetsConverter
|
2
2
|
module Editors
|
3
3
|
module Netbeans
|
4
|
-
|
4
|
+
|
5
5
|
def editor_conversion(trigger, description, code)
|
6
6
|
code.gsub!(/\$0/, '${cursor}')
|
7
7
|
code.gsub!(/\$\{([0-9]{1,5}):((?>[^{}]+)|(\1))+\}/m, '${\1 default="\2"}')
|
8
8
|
code.gsub!(/\$([0-9]{1,5})/, '${tabStop\1 default=""}')
|
9
9
|
|
10
10
|
return <<-CODE
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
<codetemplate abbreviation='#{trigger}' xml:space='preserve'>
|
12
|
+
<description><![CDATA[#{description}]]></description>
|
13
|
+
<code><![CDATA[#{code}]]></code>
|
14
|
+
</codetemplate>
|
15
15
|
CODE
|
16
16
|
end
|
17
17
|
|
18
|
-
def editor_header
|
18
|
+
def editor_header(language = nil)
|
19
19
|
return <<-CODE
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
21
|
+
<!DOCTYPE codetemplates PUBLIC "-//NetBeans//DTD Editor Code Templates settings 1.0//EN" "http://www.netbeans.org/dtds/EditorCodeTemplates-1_0.dtd">
|
22
|
+
<codetemplates>
|
23
23
|
CODE
|
24
24
|
end
|
25
25
|
|
@@ -27,10 +27,11 @@ class SnippetsConverter
|
|
27
27
|
"</codetemplates>"
|
28
28
|
end
|
29
29
|
|
30
|
-
def editor_target_file
|
30
|
+
def editor_target_file(language = nil)
|
31
31
|
"org-netbeans-modules-editor-settings-CustomCodeTemplates.xml"
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
@@ -1,24 +1,23 @@
|
|
1
|
-
|
1
|
+
module SnippetsConverter
|
2
2
|
module Editors
|
3
3
|
module Ruble
|
4
|
-
|
4
|
+
|
5
5
|
def editor_conversion(trigger, description, code)
|
6
6
|
# Need to escape double quote for description and code because Ruble doesn't seem to like it
|
7
7
|
return <<-CODE
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
snippet "#{description.gsub(/\"/,'\"')}" do |snippet|
|
9
|
+
snippet.trigger = "#{trigger}"
|
10
|
+
snippet.expansion = "#{code.gsub(/\"/,'\"')}"
|
11
|
+
end
|
12
12
|
|
13
13
|
CODE
|
14
14
|
end
|
15
15
|
|
16
|
-
def editor_header(language='
|
17
|
-
# TODO use ARGV or get 'scope' attribute of TextMate to get the desire language
|
16
|
+
def editor_header(language = 'source.ruby')
|
18
17
|
return <<-CODE
|
19
|
-
|
18
|
+
require 'ruble'
|
20
19
|
|
21
|
-
|
20
|
+
with_defaults :scope => "#{language}" do |bundle|
|
22
21
|
|
23
22
|
CODE
|
24
23
|
end
|
@@ -28,10 +27,11 @@ class SnippetsConverter
|
|
28
27
|
"end"
|
29
28
|
end
|
30
29
|
|
31
|
-
def editor_target_file
|
32
|
-
"
|
30
|
+
def editor_target_file(language = 'ruble')
|
31
|
+
"#{language.gsub(/.+\.(.+)/,'\1')}_snippets.rb"
|
33
32
|
end
|
34
33
|
|
35
34
|
end
|
36
35
|
end
|
37
36
|
end
|
37
|
+
|
data/lib/snippets_converter.rb
CHANGED
@@ -1,130 +1,156 @@
|
|
1
|
-
|
1
|
+
module SnippetsConverter
|
2
2
|
require 'rubygems'
|
3
3
|
require 'active_support'
|
4
|
-
require '
|
4
|
+
require 'fileutils'
|
5
|
+
require 'rexml/document'
|
5
6
|
|
6
|
-
Dir[File.dirname(__FILE__) + '/snippets_converter/editors/*.rb'].each do |file|
|
7
|
+
Dir[File.dirname(__FILE__) + '/snippets_converter/editors/*.rb'].each do |file|
|
7
8
|
require file
|
8
9
|
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
if
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
11
|
+
class Base
|
12
|
+
|
13
|
+
def initialize; end
|
14
|
+
|
15
|
+
def run(*args)
|
16
|
+
@in_folder = Dir.pwd # File.dirname(__FILE__) + '/../in'
|
17
|
+
raise Exception.new("You must have a '#{@in_folder}' folder") if !File.directory?(@in_folder)
|
18
|
+
|
19
|
+
@out_folder = Dir.pwd + '/out' # File.dirname(__FILE__) + '/../out'
|
20
|
+
FileUtils.mkdir_p(@out_folder) if !File.directory?(@out_folder)
|
21
|
+
raise Exception.new("You must have a '#{@out_folder}' folder writable") if !File.directory?(@out_folder) || !File.writable?(@out_folder)
|
22
|
+
|
23
|
+
@editor = args.first || 'Netbeans' # default editor is NetBeans
|
24
|
+
@editor = 'Netbeans' if @editor == 'NetBeans' # Dirty fix for NetBeans editor name
|
25
|
+
extend "SnippetsConverter::Editors::#{@editor.camelize}".constantize
|
26
|
+
|
27
|
+
output = nil
|
28
|
+
language = nil
|
29
|
+
for file in Dir.glob("#{@in_folder}/**/*.tmSnippet")
|
30
|
+
puts "Converting #{file} to #{@editor} snippet..."
|
31
|
+
output = "#{output}#{convert(file)}"
|
32
|
+
language = parse_tm_snippet(file)[:language] unless language
|
29
33
|
end
|
30
|
-
|
34
|
+
output = "#{editor_header(language)}#{output}#{editor_bottom}"
|
31
35
|
|
32
|
-
|
33
|
-
|
34
|
-
|
36
|
+
File.open("#{@out_folder}/#{editor_target_file(language)}", "w") do |f|
|
37
|
+
f.write(output)
|
38
|
+
end
|
39
|
+
|
40
|
+
puts "Result stored in '#{Pathname.new(@out_folder).realpath.to_s}/#{editor_target_file(language)}'"
|
41
|
+
puts "**** Done ****"
|
42
|
+
end
|
35
43
|
|
36
44
|
end
|
37
45
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
46
|
+
module ClassMethods
|
47
|
+
include REXML
|
48
|
+
|
49
|
+
def parse_tm_snippet(file)
|
50
|
+
|
51
|
+
doc = Document.new( file = File.read(file) )
|
52
|
+
i = 0
|
53
|
+
j = 0
|
54
|
+
|
55
|
+
arrKey = []
|
56
|
+
arrString = []
|
57
|
+
# Transform the key and string node into arrays
|
58
|
+
XPath.each( doc, '//key|//string') do |key|
|
59
|
+
if key.name == "key"
|
60
|
+
arrKey[i] = key.text
|
61
|
+
i+=1
|
62
|
+
else
|
63
|
+
arrString[j] = key.text
|
64
|
+
j+=1
|
65
|
+
end
|
55
66
|
end
|
67
|
+
|
68
|
+
tm_snippet = {}
|
69
|
+
tm_snippet[:trigger] = arrString[arrKey.index('tabTrigger')]
|
70
|
+
tm_snippet[:code] = arrString[arrKey.index('content')]
|
71
|
+
tm_snippet[:description] = arrString[arrKey.index('name')]
|
72
|
+
tm_snippet[:language] = arrString[arrKey.index('scope')]
|
73
|
+
|
74
|
+
tm_snippet
|
56
75
|
end
|
57
76
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
77
|
+
def convert(file)
|
78
|
+
tm_snippet = parse_tm_snippet(file)
|
79
|
+
|
80
|
+
transform_snippet(tm_snippet[:code])
|
81
|
+
return editor_conversion(tm_snippet[:trigger], tm_snippet[:description], tm_snippet[:code])
|
82
|
+
|
64
83
|
end
|
65
84
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
85
|
+
# Nested tab stops and place holders remover, e.g '${1: ${3:cool} $2 }' become ' ${3:cool} $2 '
|
86
|
+
def transform_snippet(code)
|
87
|
+
|
88
|
+
# Nested tab stops, e.g '${1: $2 }'
|
89
|
+
nested_tab_stop = /((\$\{[0-9]{1,5}:[^${}]*)\$([0-9]{1,5})([^${}]*\}))+/m
|
90
|
+
code.gsub!(nested_tab_stop, '\2:nested_tab_stop\3:\4')
|
91
|
+
|
92
|
+
code.gsub!(/\$([0-9]{1,5})/, ':tab_stop\1:') # Tab Stop, e.g '$0'
|
93
|
+
code.gsub!(/\$([^{][^0-9]+[^:])/, ':dollar:\1') # Dollar, e.g. '$titi'
|
94
|
+
|
95
|
+
# Place holders, e.g. '${1: cool }'
|
96
|
+
place_holders = /\$\{((?>[^${}]+)|(\1))+\}/m
|
97
|
+
place_holders_matches = code.scan(place_holders)
|
98
|
+
place_holders_matches.flatten.each do |place_holder|
|
99
|
+
if place_holder
|
100
|
+
idx = place_holder.gsub(/([0-9]{1,5}):.+/,'\1')
|
101
|
+
code.gsub!(/\$\{#{place_holder}\}/m, ":place_holders#{idx}:")
|
102
|
+
end
|
70
103
|
end
|
71
|
-
end
|
72
104
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
code.gsub!(/:tab_stop([0-9]{1,5}):/, '$\1')
|
83
|
-
code.gsub!(/:dollar:/, '$')
|
84
|
-
end
|
105
|
+
# Nested place holders, e.g. '${1: ${3:cool} }'
|
106
|
+
nested_place_holders = /(\$\{[0-9]{1,5}:(([^${}]*(\$\{[0-9]{1,5}:|\{)[^${}]+\}[^${}]*)|[^${}]+)\})/m
|
107
|
+
i = 0
|
108
|
+
loop do
|
109
|
+
i += 1
|
110
|
+
break if !code.gsub!(nested_place_holders, '\2') || i > 20
|
111
|
+
end
|
85
112
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
113
|
+
place_holders_matches.flatten.each do |place_holder|
|
114
|
+
if place_holder
|
115
|
+
idx = place_holder.gsub(/([0-9]{1,5}):.+/,'\1')
|
116
|
+
code.gsub!(/:place_holders#{idx}:/m, "\$\{#{place_holder}\}")
|
117
|
+
end
|
118
|
+
end
|
90
119
|
|
91
|
-
|
92
|
-
|
93
|
-
|
120
|
+
# Nested tab stops
|
121
|
+
code.gsub!(/:nested_tab_stop([0-9]{1,5}):/, '$\1')
|
122
|
+
nested_tab_stop = /(\$\{[0-9]{1,5}:([^${}]*\$[0-9]{1,5}[^${}]*)\})+/m
|
123
|
+
i = 0
|
124
|
+
loop do
|
125
|
+
i += 1
|
126
|
+
break if !code.gsub!(nested_tab_stop, '\2') || i > 20
|
127
|
+
end
|
94
128
|
|
95
|
-
|
96
|
-
|
129
|
+
code.gsub!(/:tab_stop([0-9]{1,5}):/, '$\1')
|
130
|
+
code.gsub!(/:dollar:/, '$')
|
97
131
|
end
|
98
132
|
|
99
|
-
|
100
|
-
|
101
|
-
|
133
|
+
# Dummy methods, the current Editor module must override them
|
134
|
+
def editor_conversion(trigger, description, code)
|
135
|
+
raise Exception.new("The current Editor module must implement this method")
|
136
|
+
end
|
102
137
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
raise Exception.new("You must have a '#{@in_folder}' folder writable") if !File.directory?(@in_folder) || !File.writable?(@in_folder)
|
112
|
-
raise Exception.new("You must have a '#{@out_folder}' folder writable") if !File.directory?(@out_folder) || !File.writable?(@out_folder)
|
113
|
-
|
114
|
-
output = editor_header
|
115
|
-
for file in Dir.glob("#{@in_folder}/**/*.tmSnippet")
|
116
|
-
puts "Converting #{file} to #{@editor} snippet..."
|
117
|
-
output = "#{output}#{convert(file)}"
|
118
|
-
end
|
119
|
-
output = "#{output}#{editor_bottom}"
|
120
|
-
|
121
|
-
File.open("#{@out_folder}/#{editor_target_file}", "w") do |f|
|
122
|
-
f.write(output)
|
123
|
-
end
|
138
|
+
def editor_header(language = nil)
|
139
|
+
raise Exception.new("The current Editor module must implement this method")
|
140
|
+
end
|
141
|
+
|
142
|
+
def editor_bottom
|
143
|
+
raise Exception.new("The current Editor module must implement this method")
|
144
|
+
end
|
124
145
|
|
125
|
-
|
126
|
-
|
146
|
+
def editor_target_file(language = nil)
|
147
|
+
raise Exception.new("The current Editor module must implement this method")
|
148
|
+
end
|
127
149
|
end
|
128
|
-
|
150
|
+
|
151
|
+
Base.class_eval do
|
152
|
+
include ClassMethods
|
153
|
+
end
|
154
|
+
|
129
155
|
end
|
130
156
|
|
data/snippets_converter.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{snippets_converter}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nowhere Man"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-05-07}
|
13
13
|
s.default_executable = %q{snippets_converter}
|
14
14
|
s.description = %q{Quick and dirty code to transform TextMate Snippets into Gedit, NetBeans and Ruble (Aptana Studio) snippets}
|
15
15
|
s.email = %q{nowhereman@open_office}
|
@@ -33,7 +33,9 @@ Gem::Specification.new do |s|
|
|
33
33
|
"lib/snippets_converter/editors/ruble.rb",
|
34
34
|
"out/DummyFile",
|
35
35
|
"snippets_converter.gemspec",
|
36
|
+
"test/examples/assert_bad_value.tmSnippet",
|
36
37
|
"test/test_helper.rb",
|
38
|
+
"test/test_parse_tm_snippet.rb",
|
37
39
|
"test/test_snippets_converter.rb"
|
38
40
|
]
|
39
41
|
s.homepage = %q{http://github.com/nowhereman/snippets_converter}
|
@@ -43,7 +45,8 @@ Gem::Specification.new do |s|
|
|
43
45
|
s.summary = %q{Convert TextMate Snippets Gedit, NetBeans and Ruble (Aptana Studio) Snippets.}
|
44
46
|
s.test_files = [
|
45
47
|
"test/test_helper.rb",
|
46
|
-
"test/test_snippets_converter.rb"
|
48
|
+
"test/test_snippets_converter.rb",
|
49
|
+
"test/test_parse_tm_snippet.rb"
|
47
50
|
]
|
48
51
|
|
49
52
|
if s.respond_to? :specification_version then
|
@@ -51,9 +54,12 @@ Gem::Specification.new do |s|
|
|
51
54
|
s.specification_version = 3
|
52
55
|
|
53
56
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
57
|
+
s.add_runtime_dependency(%q<activesupport>, ["< 3.0.0"])
|
54
58
|
else
|
59
|
+
s.add_dependency(%q<activesupport>, ["< 3.0.0"])
|
55
60
|
end
|
56
61
|
else
|
62
|
+
s.add_dependency(%q<activesupport>, ["< 3.0.0"])
|
57
63
|
end
|
58
64
|
end
|
59
65
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>content</key>
|
6
|
+
<string>assert_bad_value(${1:${2:Model}}, :${3:attribute}, ${4:value}${5:, /${6:message_to_expect}/})</string>
|
7
|
+
<key>name</key>
|
8
|
+
<string>assert_bad_value</string>
|
9
|
+
<key>scope</key>
|
10
|
+
<string>source.ruby.rails.shoulda</string>
|
11
|
+
<key>tabTrigger</key>
|
12
|
+
<string>asbv</string>
|
13
|
+
<key>uuid</key>
|
14
|
+
<string>7F83B339-D392-41AD-ABE7-84008F1477BE</string>
|
15
|
+
</dict>
|
16
|
+
</plist>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
class TestParseTmSnippet < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
tm_snippet = SnippetsConverter::Base.new.parse_tm_snippet(File.dirname(__FILE__) + '/examples/assert_bad_value.tmSnippet')
|
8
|
+
|
9
|
+
@trigger = tm_snippet[:trigger]
|
10
|
+
@code = tm_snippet[:code]
|
11
|
+
@description = tm_snippet[:description]
|
12
|
+
@language = tm_snippet[:language]
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def test_snippet_parsing
|
17
|
+
assert 'asbv', @trigger
|
18
|
+
assert 'assert_bad_value(${1:${2:Model}}, :${3:attribute}, ${4:value}${5:, /${6:message_to_expect}/})', @code
|
19
|
+
assert 'assert_bad_value', @description
|
20
|
+
assert 'source.ruby.rails.shoulda', @language
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
@@ -85,10 +85,11 @@ end'
|
|
85
85
|
|
86
86
|
def test_snippets_conversion
|
87
87
|
@snippets.each do |snippet, expected_snippet|
|
88
|
-
SnippetsConverter.new.transform_snippet(snippet)
|
88
|
+
SnippetsConverter::Base.new.transform_snippet(snippet)
|
89
89
|
assert_equal expected_snippet, snippet
|
90
90
|
end
|
91
91
|
|
92
92
|
end
|
93
93
|
|
94
94
|
end
|
95
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Nowhere Man
|
@@ -14,10 +14,23 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-05-07 00:00:00 +02:00
|
18
18
|
default_executable: snippets_converter
|
19
|
-
dependencies:
|
20
|
-
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: activesupport
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - <
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 3
|
29
|
+
- 0
|
30
|
+
- 0
|
31
|
+
version: 3.0.0
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
21
34
|
description: Quick and dirty code to transform TextMate Snippets into Gedit, NetBeans and Ruble (Aptana Studio) snippets
|
22
35
|
email: nowhereman@open_office
|
23
36
|
executables:
|
@@ -42,7 +55,9 @@ files:
|
|
42
55
|
- lib/snippets_converter/editors/ruble.rb
|
43
56
|
- out/DummyFile
|
44
57
|
- snippets_converter.gemspec
|
58
|
+
- test/examples/assert_bad_value.tmSnippet
|
45
59
|
- test/test_helper.rb
|
60
|
+
- test/test_parse_tm_snippet.rb
|
46
61
|
- test/test_snippets_converter.rb
|
47
62
|
has_rdoc: true
|
48
63
|
homepage: http://github.com/nowhereman/snippets_converter
|
@@ -77,3 +92,4 @@ summary: Convert TextMate Snippets Gedit, NetBeans and Ruble (Aptana Studio) Sni
|
|
77
92
|
test_files:
|
78
93
|
- test/test_helper.rb
|
79
94
|
- test/test_snippets_converter.rb
|
95
|
+
- test/test_parse_tm_snippet.rb
|