haml-sass-converters-rubymine-plugin 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use jruby@haml-sass-converters --create
data/CHANGES ADDED
@@ -0,0 +1,6 @@
1
+
2
+ = Haml/SASS Converters for RubyMine IDE Changelog
3
+
4
+ == Version 0.1.0
5
+
6
+ * Initial release.
data/README ADDED
@@ -0,0 +1,44 @@
1
+ = Haml/SASS Converters for RubyMine IDE (JRuby script-plugin)
2
+
3
+ = Installing
4
+
5
+ 1. Install jruby:
6
+
7
+ > rvm install jruby-1.5.6
8
+ > rvm use jruby
9
+
10
+ We are not going to use this version of JRuby - RubyMine already has bundled version of it. We need to install it in
11
+ order to collect all required for this plugin gems.
12
+
13
+ 2. Install this plugin as a gem into your project:
14
+
15
+ > cd <your-project-root>
16
+ > gem i haml-sass-converters-rubymine-plugin --install-dir ./scripts
17
+
18
+ #1. Copy "Gemfile", ".rvmrc" and "converters.rb" files from the root of this project into
19
+ #newly created "scripts" folder inside your RubyMine project.
20
+
21
+ 3. Go to "File|Setting|Extensions" and add "scripts" folder as new "Script Folder".
22
+
23
+ #This plugin will
24
+ #be installed in "#{ENV['HOME']}/.rvm/gems/jruby-1.5.6@haml-sass-converters/gems/haml-sass-converters-rubymine-plugin-0.1.0"
25
+
26
+ 4. From command line navigate to "scripts" folder:
27
+
28
+ > cd <your-project-root>/scripts
29
+
30
+ Accept ".rvmrc" as trusted configuration inside this folder. As a result, it will create "haml-sass-converters"
31
+ gemset and switched rvm to use it. Now install bundler and all required gems:
32
+
33
+ > gem install bundler
34
+ > bundle install
35
+
36
+ 5. Restart RubyMine. After restarting IDE will have new "Css" group under "Tools|Extensions" and new actions:
37
+ - convert Html to Haml;
38
+ - convert CSS to SASS;
39
+
40
+ You can reach them from "Tools|Extensions" in main menu or from context popup menu inside the editor.
41
+
42
+ == Usage
43
+
44
+ Select some content inside erb or css file. Right click inside the editor and select appropriate action.
@@ -0,0 +1,58 @@
1
+ # Rakefile for haml-sass-converters-rubymine-plugin
2
+
3
+ require 'rubygems' unless RUBY_VERSION =~ /1.9.*/
4
+
5
+ project_name = "haml-sass-converters-rubymine-plugin"
6
+
7
+ task :default => :gemspec
8
+
9
+ begin
10
+ require 'bundler'
11
+
12
+ begin
13
+ require 'jeweler'
14
+
15
+ Jeweler::Tasks.new do |gemspec|
16
+ gemspec.name = project_name
17
+ gemspec.summary = "Provides convenient converters for HAML/SASS as plugin for RubyMine IDE (Summary)."
18
+ gemspec.description = "Provides convenient converters for HAML/SASS as plugin for RubyMine IDE."
19
+ gemspec.email = "alexander.shvets@gmail.com"
20
+ gemspec.homepage = "http://github.com/shvets/#{project_name}"
21
+ gemspec.authors = ["Alexander Shvets"]
22
+ gemspec.files = FileList["CHANGES", "#{project_name}.gemspec", "converters.rb", ".rvmrc",
23
+ "Rakefile", "README", "VERSION"]
24
+ gemspec.requirements = ["none"]
25
+
26
+ gemspec.add_bundler_dependencies
27
+ end
28
+ rescue LoadError
29
+ puts "Jeweler not available. Install it s with: [sudo] gem install jeweler"
30
+ end
31
+ rescue LoadError
32
+ puts "Bundler not available. Install it s with: [sudo] gem install bundler"
33
+ end
34
+
35
+ desc "Release the gem"
36
+ task :"release:gem" do
37
+ require 'jruby/openssl/gem_only'
38
+
39
+ %x(
40
+ rake gemspec
41
+ rake build
42
+ git add .
43
+ )
44
+ puts "Commit message:"
45
+ message = STDIN.gets
46
+
47
+ version = "#{File.open(File::dirname(__FILE__) + "/VERSION").readlines().first}"
48
+
49
+ %x(
50
+ git commit -m "#{message}"
51
+
52
+ git push origin master
53
+
54
+ gem push pkg/#{project_name}-#{version}.gem
55
+ )
56
+ end
57
+
58
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,98 @@
1
+ include Java
2
+
3
+ require "haml"
4
+ require "haml/html"
5
+ require "sass/css"
6
+
7
+ require 'default_scripts_groups'
8
+ require 'editor_action_helper'
9
+ require 'action_group_helper'
10
+
11
+ load_required_gems
12
+
13
+ def load_required_gems
14
+ jruby_home = "#{ENV['HOME']}/.rvm/gems/jruby-1.5.6@haml-sass-converters"
15
+
16
+ $: << "#{jruby_home}/gems"
17
+
18
+ $: << "#{jruby_home}/gems/haml-3.0.24/lib"
19
+ $: << "#{jruby_home}/gems/hpricot-0.8.3-java/lib"
20
+ $: << "#{jruby_home}/gems/abstract-1.0.0/lib"
21
+ $: << "#{jruby_home}/gems/erubis-2.6.6/lib"
22
+ $: << "#{jruby_home}/gems/sexp_processor-3.0.5/lib"
23
+ $: << "#{jruby_home}/gems/ruby_parser-2.0.5/lib"
24
+ end
25
+
26
+ class Converter
27
+ def self.convert_selection editor
28
+ if editor.has_selection?
29
+ text = editor.selection
30
+ s_start = editor.selection_start
31
+
32
+ changed_text = yield(text)
33
+ editor.replace_selection_text(changed_text)
34
+
35
+ # restore selection
36
+ editor.select(s_start, s_start + changed_text.length)
37
+
38
+ # # TODO: probably restore caret position
39
+ # editor.move_caret -3
40
+ end
41
+ end
42
+
43
+ def self.convert_to_haml(html)
44
+ Haml::HTML.new(html, :erb => true, :xhtml => true).render
45
+ end
46
+
47
+ def self.convert_to_sass(css)
48
+ Sass::CSS.new(css).render(:sass)
49
+ end
50
+
51
+ def self.convert_to_scss(css)
52
+ Sass::CSS.new(css).render(:scss)
53
+ end
54
+ end
55
+
56
+ register_editor_action "html_to_haml",
57
+ :text => "Convert Html to Haml",
58
+ :description => "Converts Html content to Haml content.",
59
+ :group => "EditorPopupMenu",
60
+ :enable_in_modal_context => true do |editor, _|
61
+ Converter.convert_selection editor do |text|
62
+ Converter.convert_to_haml(text)
63
+ end
64
+ end
65
+
66
+ register_editor_action "html_to_haml_erb",
67
+ :text => "Convert Html to Haml",
68
+ :description => "Converts Html content to Haml content.",
69
+ #:shortcut => "control shift PERIOD",
70
+ :group => "ScriptsErb",
71
+ :file_type => "RHTML" do |editor, _|
72
+ Converter.convert_selection editor do |text|
73
+ Converter.convert_to_haml(text)
74
+ end
75
+ end
76
+
77
+ register_action_group "ScriptsCss", :text => "Css"
78
+
79
+ register_editor_action "css_to_sass",
80
+ :text => "Convert CSS to SASS",
81
+ :description => "Converts CSS content to SASS content.",
82
+ :group => "EditorPopupMenu",
83
+ :enable_in_modal_context => true do |editor, _|
84
+ Converter.convert_selection editor do |text|
85
+ Converter.convert_to_sass(text)
86
+ end
87
+ end
88
+
89
+ register_editor_action "css_to_sass_css",
90
+ :text => "Convert CSS to SASS",
91
+ :description => "Converts CSS content to SASS content.",
92
+ #:shortcut => "control shift PERIOD",
93
+ :group => "ScriptsCss",
94
+ :file_type => "CSS" do |editor, _|
95
+ Converter.convert_selection editor do |text|
96
+ Converter.convert_to_sass(text)
97
+ end
98
+ end
@@ -0,0 +1,97 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{haml-sass-converters-rubymine-plugin}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Alexander Shvets"]
12
+ s.date = %q{2011-01-23}
13
+ s.description = %q{Provides convenient converters for HAML/SASS as plugin for RubyMine IDE.}
14
+ s.email = %q{alexander.shvets@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README"
17
+ ]
18
+ s.files = [
19
+ ".rvmrc",
20
+ "CHANGES",
21
+ "README",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "converters.rb",
25
+ "haml-sass-converters-rubymine-plugin.gemspec"
26
+ ]
27
+ s.homepage = %q{http://github.com/shvets/haml-sass-converters-rubymine-plugin}
28
+ s.require_paths = ["lib"]
29
+ s.requirements = ["none"]
30
+ s.rubygems_version = %q{1.3.6}
31
+ s.summary = %q{Provides convenient converters for HAML/SASS as plugin for RubyMine IDE (Summary).}
32
+
33
+ if s.respond_to? :specification_version then
34
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
35
+ s.specification_version = 3
36
+
37
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
38
+ s.add_runtime_dependency(%q<haml>, ["= 3.0.24"])
39
+ s.add_runtime_dependency(%q<hpricot>, ["= 0.8.3"])
40
+ s.add_runtime_dependency(%q<abstract>, ["= 1.0.0"])
41
+ s.add_runtime_dependency(%q<erubis>, ["= 2.6.6"])
42
+ s.add_runtime_dependency(%q<sexp_processor>, ["= 3.0.5"])
43
+ s.add_runtime_dependency(%q<ruby_parser>, ["= 2.0.5"])
44
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
45
+ s.add_development_dependency(%q<gemcutter>, [">= 0"])
46
+ s.add_development_dependency(%q<jruby-openssl>, [">= 0"])
47
+ s.add_runtime_dependency(%q<haml>, ["= 3.0.24"])
48
+ s.add_runtime_dependency(%q<hpricot>, ["= 0.8.3"])
49
+ s.add_runtime_dependency(%q<abstract>, ["= 1.0.0"])
50
+ s.add_runtime_dependency(%q<erubis>, ["= 2.6.6"])
51
+ s.add_runtime_dependency(%q<sexp_processor>, ["= 3.0.5"])
52
+ s.add_runtime_dependency(%q<ruby_parser>, ["= 2.0.5"])
53
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
54
+ s.add_development_dependency(%q<gemcutter>, [">= 0"])
55
+ s.add_development_dependency(%q<jruby-openssl>, [">= 0"])
56
+ else
57
+ s.add_dependency(%q<haml>, ["= 3.0.24"])
58
+ s.add_dependency(%q<hpricot>, ["= 0.8.3"])
59
+ s.add_dependency(%q<abstract>, ["= 1.0.0"])
60
+ s.add_dependency(%q<erubis>, ["= 2.6.6"])
61
+ s.add_dependency(%q<sexp_processor>, ["= 3.0.5"])
62
+ s.add_dependency(%q<ruby_parser>, ["= 2.0.5"])
63
+ s.add_dependency(%q<jeweler>, [">= 0"])
64
+ s.add_dependency(%q<gemcutter>, [">= 0"])
65
+ s.add_dependency(%q<jruby-openssl>, [">= 0"])
66
+ s.add_dependency(%q<haml>, ["= 3.0.24"])
67
+ s.add_dependency(%q<hpricot>, ["= 0.8.3"])
68
+ s.add_dependency(%q<abstract>, ["= 1.0.0"])
69
+ s.add_dependency(%q<erubis>, ["= 2.6.6"])
70
+ s.add_dependency(%q<sexp_processor>, ["= 3.0.5"])
71
+ s.add_dependency(%q<ruby_parser>, ["= 2.0.5"])
72
+ s.add_dependency(%q<jeweler>, [">= 0"])
73
+ s.add_dependency(%q<gemcutter>, [">= 0"])
74
+ s.add_dependency(%q<jruby-openssl>, [">= 0"])
75
+ end
76
+ else
77
+ s.add_dependency(%q<haml>, ["= 3.0.24"])
78
+ s.add_dependency(%q<hpricot>, ["= 0.8.3"])
79
+ s.add_dependency(%q<abstract>, ["= 1.0.0"])
80
+ s.add_dependency(%q<erubis>, ["= 2.6.6"])
81
+ s.add_dependency(%q<sexp_processor>, ["= 3.0.5"])
82
+ s.add_dependency(%q<ruby_parser>, ["= 2.0.5"])
83
+ s.add_dependency(%q<jeweler>, [">= 0"])
84
+ s.add_dependency(%q<gemcutter>, [">= 0"])
85
+ s.add_dependency(%q<jruby-openssl>, [">= 0"])
86
+ s.add_dependency(%q<haml>, ["= 3.0.24"])
87
+ s.add_dependency(%q<hpricot>, ["= 0.8.3"])
88
+ s.add_dependency(%q<abstract>, ["= 1.0.0"])
89
+ s.add_dependency(%q<erubis>, ["= 2.6.6"])
90
+ s.add_dependency(%q<sexp_processor>, ["= 3.0.5"])
91
+ s.add_dependency(%q<ruby_parser>, ["= 2.0.5"])
92
+ s.add_dependency(%q<jeweler>, [">= 0"])
93
+ s.add_dependency(%q<gemcutter>, [">= 0"])
94
+ s.add_dependency(%q<jruby-openssl>, [">= 0"])
95
+ end
96
+ end
97
+
metadata ADDED
@@ -0,0 +1,307 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: haml-sass-converters-rubymine-plugin
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Alexander Shvets
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-01-23 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "="
24
+ - !ruby/object:Gem::Version
25
+ segments:
26
+ - 3
27
+ - 0
28
+ - 24
29
+ version: 3.0.24
30
+ name: haml
31
+ prerelease: false
32
+ requirement: *id001
33
+ type: :runtime
34
+ - !ruby/object:Gem::Dependency
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
41
+ - 8
42
+ - 3
43
+ version: 0.8.3
44
+ name: hpricot
45
+ prerelease: false
46
+ requirement: *id002
47
+ type: :runtime
48
+ - !ruby/object:Gem::Dependency
49
+ version_requirements: &id003 !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 1
55
+ - 0
56
+ - 0
57
+ version: 1.0.0
58
+ name: abstract
59
+ prerelease: false
60
+ requirement: *id003
61
+ type: :runtime
62
+ - !ruby/object:Gem::Dependency
63
+ version_requirements: &id004 !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "="
66
+ - !ruby/object:Gem::Version
67
+ segments:
68
+ - 2
69
+ - 6
70
+ - 6
71
+ version: 2.6.6
72
+ name: erubis
73
+ prerelease: false
74
+ requirement: *id004
75
+ type: :runtime
76
+ - !ruby/object:Gem::Dependency
77
+ version_requirements: &id005 !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "="
80
+ - !ruby/object:Gem::Version
81
+ segments:
82
+ - 3
83
+ - 0
84
+ - 5
85
+ version: 3.0.5
86
+ name: sexp_processor
87
+ prerelease: false
88
+ requirement: *id005
89
+ type: :runtime
90
+ - !ruby/object:Gem::Dependency
91
+ version_requirements: &id006 !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "="
94
+ - !ruby/object:Gem::Version
95
+ segments:
96
+ - 2
97
+ - 0
98
+ - 5
99
+ version: 2.0.5
100
+ name: ruby_parser
101
+ prerelease: false
102
+ requirement: *id006
103
+ type: :runtime
104
+ - !ruby/object:Gem::Dependency
105
+ version_requirements: &id007 !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ name: jeweler
113
+ prerelease: false
114
+ requirement: *id007
115
+ type: :development
116
+ - !ruby/object:Gem::Dependency
117
+ version_requirements: &id008 !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ segments:
122
+ - 0
123
+ version: "0"
124
+ name: gemcutter
125
+ prerelease: false
126
+ requirement: *id008
127
+ type: :development
128
+ - !ruby/object:Gem::Dependency
129
+ version_requirements: &id009 !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ segments:
134
+ - 0
135
+ version: "0"
136
+ name: jruby-openssl
137
+ prerelease: false
138
+ requirement: *id009
139
+ type: :development
140
+ - !ruby/object:Gem::Dependency
141
+ version_requirements: &id010 !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "="
144
+ - !ruby/object:Gem::Version
145
+ segments:
146
+ - 3
147
+ - 0
148
+ - 24
149
+ version: 3.0.24
150
+ name: haml
151
+ prerelease: false
152
+ requirement: *id010
153
+ type: :runtime
154
+ - !ruby/object:Gem::Dependency
155
+ version_requirements: &id011 !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "="
158
+ - !ruby/object:Gem::Version
159
+ segments:
160
+ - 0
161
+ - 8
162
+ - 3
163
+ version: 0.8.3
164
+ name: hpricot
165
+ prerelease: false
166
+ requirement: *id011
167
+ type: :runtime
168
+ - !ruby/object:Gem::Dependency
169
+ version_requirements: &id012 !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "="
172
+ - !ruby/object:Gem::Version
173
+ segments:
174
+ - 1
175
+ - 0
176
+ - 0
177
+ version: 1.0.0
178
+ name: abstract
179
+ prerelease: false
180
+ requirement: *id012
181
+ type: :runtime
182
+ - !ruby/object:Gem::Dependency
183
+ version_requirements: &id013 !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "="
186
+ - !ruby/object:Gem::Version
187
+ segments:
188
+ - 2
189
+ - 6
190
+ - 6
191
+ version: 2.6.6
192
+ name: erubis
193
+ prerelease: false
194
+ requirement: *id013
195
+ type: :runtime
196
+ - !ruby/object:Gem::Dependency
197
+ version_requirements: &id014 !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "="
200
+ - !ruby/object:Gem::Version
201
+ segments:
202
+ - 3
203
+ - 0
204
+ - 5
205
+ version: 3.0.5
206
+ name: sexp_processor
207
+ prerelease: false
208
+ requirement: *id014
209
+ type: :runtime
210
+ - !ruby/object:Gem::Dependency
211
+ version_requirements: &id015 !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "="
214
+ - !ruby/object:Gem::Version
215
+ segments:
216
+ - 2
217
+ - 0
218
+ - 5
219
+ version: 2.0.5
220
+ name: ruby_parser
221
+ prerelease: false
222
+ requirement: *id015
223
+ type: :runtime
224
+ - !ruby/object:Gem::Dependency
225
+ version_requirements: &id016 !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ segments:
230
+ - 0
231
+ version: "0"
232
+ name: jeweler
233
+ prerelease: false
234
+ requirement: *id016
235
+ type: :development
236
+ - !ruby/object:Gem::Dependency
237
+ version_requirements: &id017 !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - ">="
240
+ - !ruby/object:Gem::Version
241
+ segments:
242
+ - 0
243
+ version: "0"
244
+ name: gemcutter
245
+ prerelease: false
246
+ requirement: *id017
247
+ type: :development
248
+ - !ruby/object:Gem::Dependency
249
+ version_requirements: &id018 !ruby/object:Gem::Requirement
250
+ requirements:
251
+ - - ">="
252
+ - !ruby/object:Gem::Version
253
+ segments:
254
+ - 0
255
+ version: "0"
256
+ name: jruby-openssl
257
+ prerelease: false
258
+ requirement: *id018
259
+ type: :development
260
+ description: Provides convenient converters for HAML/SASS as plugin for RubyMine IDE.
261
+ email: alexander.shvets@gmail.com
262
+ executables: []
263
+
264
+ extensions: []
265
+
266
+ extra_rdoc_files:
267
+ - README
268
+ files:
269
+ - .rvmrc
270
+ - CHANGES
271
+ - README
272
+ - Rakefile
273
+ - VERSION
274
+ - converters.rb
275
+ - haml-sass-converters-rubymine-plugin.gemspec
276
+ has_rdoc: true
277
+ homepage: http://github.com/shvets/haml-sass-converters-rubymine-plugin
278
+ licenses: []
279
+
280
+ post_install_message:
281
+ rdoc_options: []
282
+
283
+ require_paths:
284
+ - lib
285
+ required_ruby_version: !ruby/object:Gem::Requirement
286
+ requirements:
287
+ - - ">="
288
+ - !ruby/object:Gem::Version
289
+ segments:
290
+ - 0
291
+ version: "0"
292
+ required_rubygems_version: !ruby/object:Gem::Requirement
293
+ requirements:
294
+ - - ">="
295
+ - !ruby/object:Gem::Version
296
+ segments:
297
+ - 0
298
+ version: "0"
299
+ requirements:
300
+ - none
301
+ rubyforge_project:
302
+ rubygems_version: 1.3.6
303
+ signing_key:
304
+ specification_version: 3
305
+ summary: Provides convenient converters for HAML/SASS as plugin for RubyMine IDE (Summary).
306
+ test_files: []
307
+