snippets_converter 0.1.3 → 0.1.4
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/README.rdoc +2 -2
- data/VERSION +1 -1
- data/bin/snippets_converter +0 -0
- data/lib/snippets_converter.rb +25 -19
- data/snippets_converter.gemspec +25 -27
- metadata +9 -10
- data/.gitignore +0 -9
data/README.rdoc
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Convert TextMate Snippets into Gedit, NetBeans and Ruble (Aptana Studio/RadRails 3) snippets.
|
4
4
|
|
5
5
|
== Install the gem
|
6
|
-
sudo gem snippets_converter
|
6
|
+
sudo gem install snippets_converter
|
7
7
|
|
8
8
|
== How to use (for Ubuntu and Ruby snippets)
|
9
9
|
* Open a terminal and go in your TextMate Bundle directory. Then run
|
@@ -54,5 +54,5 @@ More info at https://radrails.tenderapp.com/faqs/radrails-3/ruble-programming-gu
|
|
54
54
|
|
55
55
|
Copyright (c) 2009 Nicolas Alpi
|
56
56
|
|
57
|
-
Copyright (c)
|
57
|
+
Copyright (c) 2011 Nowhere Man. See LICENSE for details.
|
58
58
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/bin/snippets_converter
CHANGED
File without changes
|
data/lib/snippets_converter.rb
CHANGED
@@ -27,9 +27,13 @@ module SnippetsConverter
|
|
27
27
|
output = nil
|
28
28
|
language = nil
|
29
29
|
for file in Dir.glob("#{@in_folder}/**/*.tmSnippet")
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
if ( new_output = convert(file) )
|
31
|
+
puts "Converting '#{File.basename(file)}' to #{@editor} snippet..."
|
32
|
+
output = "#{output}#{new_output}"
|
33
|
+
language = parse_tm_snippet(file)[:language] unless language
|
34
|
+
else
|
35
|
+
puts "(WARNING): Unable to convert the snippet '#{File.basename(file)}'."
|
36
|
+
end
|
33
37
|
end
|
34
38
|
output = "#{editor_header(language)}#{output}#{editor_bottom}"
|
35
39
|
|
@@ -66,26 +70,28 @@ module SnippetsConverter
|
|
66
70
|
end
|
67
71
|
|
68
72
|
tm_snippet = {}
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
73
|
+
# The array, that contains the snippet info, must have all the keys below
|
74
|
+
if (['tabTrigger', 'content', 'name', 'scope'] - arrKey.uniq ).empty?
|
75
|
+
tm_snippet[:trigger] = arrString[arrKey.index('tabTrigger')]
|
76
|
+
tm_snippet[:code] = arrString[arrKey.index('content')]
|
77
|
+
tm_snippet[:description] = arrString[arrKey.index('name')]
|
78
|
+
tm_snippet[:language] = arrString[arrKey.index('scope')]
|
79
|
+
end
|
74
80
|
tm_snippet
|
75
81
|
end
|
76
82
|
|
77
83
|
def convert(file)
|
78
84
|
tm_snippet = parse_tm_snippet(file)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
85
|
+
if !tm_snippet.blank?
|
86
|
+
transform_snippet(tm_snippet[:code])
|
87
|
+
return editor_conversion(tm_snippet[:trigger], tm_snippet[:description], tm_snippet[:code])
|
88
|
+
end
|
83
89
|
end
|
84
90
|
|
85
91
|
# Nested tab stops and place holders remover, e.g '${1: ${3:cool} $2 }' become ' ${3:cool} $2 '
|
86
92
|
def transform_snippet(code)
|
87
93
|
# Transform TextMate snippets syntax into snippets converter internal codes, e.g. '$' become ':dollar:'
|
88
|
-
|
94
|
+
|
89
95
|
# Nested tab stops, e.g '${1: $2 }'
|
90
96
|
nested_tab_stop = /((\$\{[0-9]{1,5}:[^${}]*)\$([0-9]{1,5})([^${}]*\}))+/m
|
91
97
|
code.gsub!(nested_tab_stop, '\2:nested_tab_stop\3:\4')
|
@@ -101,7 +107,7 @@ module SnippetsConverter
|
|
101
107
|
loop do
|
102
108
|
i += 1
|
103
109
|
break if !code.gsub!(/\{([^{}]*|[^{}]*\{[^{}]*\}[^{}]*)\\\}/, ':escape_bracket:\1:escape_close_bracket:') || i > 20
|
104
|
-
end
|
110
|
+
end
|
105
111
|
|
106
112
|
code.gsub!(/\$([^{][^0-9]+[^:])/, ':dollar:\1') # Dollar, e.g. '$titi'
|
107
113
|
|
@@ -114,7 +120,7 @@ module SnippetsConverter
|
|
114
120
|
code.gsub!(/\$\{#{place_holder}\}/m, ":place_holders#{idx}:")
|
115
121
|
end
|
116
122
|
end
|
117
|
-
|
123
|
+
|
118
124
|
|
119
125
|
#TODO Check if the regular expression in variables are correctly converted/supported
|
120
126
|
# More info at http://manual.macromates.com/en/regular_expressions.html
|
@@ -128,14 +134,14 @@ module SnippetsConverter
|
|
128
134
|
end
|
129
135
|
|
130
136
|
# Transform snippets converter internal codes into characters, e.g. ':dollar:' become '$'
|
131
|
-
|
137
|
+
|
132
138
|
place_holders_matches.flatten.each do |place_holder|
|
133
139
|
if place_holder
|
134
140
|
idx = place_holder.gsub(/([0-9]{1,5}):.+/,'\1')
|
135
141
|
code.gsub!(/:place_holders#{idx}:/m, "\$\{#{place_holder}\}")
|
136
142
|
end
|
137
143
|
end
|
138
|
-
|
144
|
+
|
139
145
|
# Nested tab stops
|
140
146
|
code.gsub!(/:nested_tab_stop([0-9]{1,5}):/, '$\1')
|
141
147
|
nested_tab_stop = /(\$\{[0-9]{1,5}:([^${}]*\$[0-9]{1,5}[^${}]*)\})+/m
|
@@ -156,8 +162,8 @@ module SnippetsConverter
|
|
156
162
|
break if !code.gsub!(/:escape_bracket:(.*):escape_close_bracket:/, '{\1}') || i > 20
|
157
163
|
end
|
158
164
|
|
159
|
-
code.gsub!(/:dollar:/, '$')
|
160
|
-
|
165
|
+
code.gsub!(/:dollar:/, '$')
|
166
|
+
|
161
167
|
end
|
162
168
|
|
163
169
|
# Dummy methods, the current Editor module must override them
|
data/snippets_converter.gemspec
CHANGED
@@ -1,56 +1,53 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
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.4"
|
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{
|
12
|
+
s.date = %q{2011-02-08}
|
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}
|
16
16
|
s.executables = ["snippets_converter"]
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE",
|
19
|
-
|
19
|
+
"README.rdoc"
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".document",
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
"test/test_snippets_converter.rb"
|
23
|
+
"LICENSE",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"bin/snippets_converter",
|
28
|
+
"in/DummyFile",
|
29
|
+
"lib/snippets_converter.rb",
|
30
|
+
"lib/snippets_converter/editors/gedit.rb",
|
31
|
+
"lib/snippets_converter/editors/netbeans.rb",
|
32
|
+
"lib/snippets_converter/editors/ruble.rb",
|
33
|
+
"out/DummyFile",
|
34
|
+
"snippets_converter.gemspec",
|
35
|
+
"test/examples/assert_bad_value.tmSnippet",
|
36
|
+
"test/test_helper.rb",
|
37
|
+
"test/test_parse_tm_snippet.rb",
|
38
|
+
"test/test_snippets_converter.rb"
|
40
39
|
]
|
41
40
|
s.homepage = %q{http://github.com/nowhereman/snippets_converter}
|
42
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
43
41
|
s.require_paths = ["lib"]
|
44
|
-
s.rubygems_version = %q{1.
|
42
|
+
s.rubygems_version = %q{1.4.1}
|
45
43
|
s.summary = %q{Convert TextMate Snippets Gedit, NetBeans and Ruble (Aptana Studio) Snippets.}
|
46
44
|
s.test_files = [
|
45
|
+
"test/test_helper.rb",
|
47
46
|
"test/test_parse_tm_snippet.rb",
|
48
|
-
|
49
|
-
"test/test_helper.rb"
|
47
|
+
"test/test_snippets_converter.rb"
|
50
48
|
]
|
51
49
|
|
52
50
|
if s.respond_to? :specification_version then
|
53
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
54
51
|
s.specification_version = 3
|
55
52
|
|
56
53
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
@@ -62,3 +59,4 @@ Gem::Specification.new do |s|
|
|
62
59
|
s.add_dependency(%q<activesupport>, ["< 3.0.0"])
|
63
60
|
end
|
64
61
|
end
|
62
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snippets_converter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nowhere Man
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-02-08 00:00:00 +01:00
|
19
19
|
default_executable: snippets_converter
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -45,7 +45,6 @@ extra_rdoc_files:
|
|
45
45
|
- README.rdoc
|
46
46
|
files:
|
47
47
|
- .document
|
48
|
-
- .gitignore
|
49
48
|
- LICENSE
|
50
49
|
- README.rdoc
|
51
50
|
- Rakefile
|
@@ -67,8 +66,8 @@ homepage: http://github.com/nowhereman/snippets_converter
|
|
67
66
|
licenses: []
|
68
67
|
|
69
68
|
post_install_message:
|
70
|
-
rdoc_options:
|
71
|
-
|
69
|
+
rdoc_options: []
|
70
|
+
|
72
71
|
require_paths:
|
73
72
|
- lib
|
74
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -92,11 +91,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
91
|
requirements: []
|
93
92
|
|
94
93
|
rubyforge_project:
|
95
|
-
rubygems_version: 1.
|
94
|
+
rubygems_version: 1.4.1
|
96
95
|
signing_key:
|
97
96
|
specification_version: 3
|
98
97
|
summary: Convert TextMate Snippets Gedit, NetBeans and Ruble (Aptana Studio) Snippets.
|
99
98
|
test_files:
|
99
|
+
- test/test_helper.rb
|
100
100
|
- test/test_parse_tm_snippet.rb
|
101
101
|
- test/test_snippets_converter.rb
|
102
|
-
- test/test_helper.rb
|