parity-RedCloth 4.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/.gemtest +0 -0
  3. data/.rspec +1 -0
  4. data/CHANGELOG +265 -0
  5. data/COPYING +18 -0
  6. data/Gemfile +7 -0
  7. data/README.rdoc +215 -0
  8. data/Rakefile +18 -0
  9. data/bin/redcloth +28 -0
  10. data/doc/textile_reference.html +631 -0
  11. data/ext/redcloth_scan/extconf.rb +6 -0
  12. data/ext/redcloth_scan/redcloth.h +220 -0
  13. data/ext/redcloth_scan/redcloth_attributes.c +650 -0
  14. data/ext/redcloth_scan/redcloth_inline.c +8153 -0
  15. data/ext/redcloth_scan/redcloth_scan.c +24407 -0
  16. data/lib/case_sensitive_require/RedCloth.rb +6 -0
  17. data/lib/redcloth/erb_extension.rb +27 -0
  18. data/lib/redcloth/formatters/base.rb +63 -0
  19. data/lib/redcloth/formatters/html.rb +352 -0
  20. data/lib/redcloth/formatters/latex.rb +331 -0
  21. data/lib/redcloth/formatters/latex_entities.yml +2414 -0
  22. data/lib/redcloth/textile_doc.rb +113 -0
  23. data/lib/redcloth/version.rb +34 -0
  24. data/lib/redcloth.rb +45 -0
  25. data/lib/tasks/pureruby.rake +17 -0
  26. data/redcloth.gemspec +54 -0
  27. data/spec/benchmark_spec.rb +15 -0
  28. data/spec/custom_tags_spec.rb +50 -0
  29. data/spec/erb_spec.rb +10 -0
  30. data/spec/extension_spec.rb +26 -0
  31. data/spec/fixtures/basic.yml +1028 -0
  32. data/spec/fixtures/code.yml +257 -0
  33. data/spec/fixtures/definitions.yml +82 -0
  34. data/spec/fixtures/extra_whitespace.yml +64 -0
  35. data/spec/fixtures/filter_html.yml +177 -0
  36. data/spec/fixtures/filter_pba.yml +20 -0
  37. data/spec/fixtures/html.yml +348 -0
  38. data/spec/fixtures/images.yml +279 -0
  39. data/spec/fixtures/instiki.yml +38 -0
  40. data/spec/fixtures/links.yml +291 -0
  41. data/spec/fixtures/lists.yml +462 -0
  42. data/spec/fixtures/poignant.yml +89 -0
  43. data/spec/fixtures/sanitize_html.yml +42 -0
  44. data/spec/fixtures/table.yml +434 -0
  45. data/spec/fixtures/textism.yml +509 -0
  46. data/spec/fixtures/threshold.yml +762 -0
  47. data/spec/formatters/class_filtered_html_spec.rb +7 -0
  48. data/spec/formatters/filtered_html_spec.rb +7 -0
  49. data/spec/formatters/html_no_breaks_spec.rb +9 -0
  50. data/spec/formatters/html_spec.rb +13 -0
  51. data/spec/formatters/id_filtered_html_spec.rb +7 -0
  52. data/spec/formatters/latex_spec.rb +13 -0
  53. data/spec/formatters/lite_mode_html_spec.rb +7 -0
  54. data/spec/formatters/no_span_caps_html_spec.rb +7 -0
  55. data/spec/formatters/sanitized_html_spec.rb +7 -0
  56. data/spec/formatters/style_filtered_html_spec.rb +7 -0
  57. data/spec/parser_spec.rb +102 -0
  58. data/spec/spec_helper.rb +36 -0
  59. data/tasks/compile.rake +47 -0
  60. data/tasks/gems.rake +37 -0
  61. data/tasks/ragel_extension_task.rb +127 -0
  62. data/tasks/release.rake +15 -0
  63. data/tasks/rspec.rake +13 -0
  64. data/tasks/rvm.rake +79 -0
  65. metadata +239 -0
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "class_filtered_html" do
4
+ examples_from_yaml do |doc|
5
+ RedCloth.new(doc['in'], [:filter_classes]).to_html
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "filtered_html" do
4
+ examples_from_yaml do |doc|
5
+ RedCloth.new(doc['in'], [:filter_html]).to_html
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "html_no_breaks" do
4
+ examples_from_yaml do |doc|
5
+ red = RedCloth.new(doc['in'])
6
+ red.hard_breaks = false
7
+ red.to_html
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "HTML" do
4
+ examples_from_yaml do |doc|
5
+ RedCloth.new(doc['in']).to_html
6
+ end
7
+
8
+ it "should not raise an error when orphaned parentheses in a link are followed by punctuation and words in HTML" do
9
+ lambda {
10
+ RedCloth.new(%Q{Test "(read this":http://test.host), ok}).to_html
11
+ }.should_not raise_error
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "id_filtered_html" do
4
+ examples_from_yaml do |doc|
5
+ RedCloth.new(doc['in'], [:filter_ids]).to_html
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "LaTeX" do
4
+ examples_from_yaml do |doc|
5
+ RedCloth.new(doc['in']).to_latex
6
+ end
7
+
8
+ it "should not raise an error when orphaned parentheses in a link are followed by punctuation and words in LaTeX" do
9
+ lambda {
10
+ RedCloth.new(%Q{Test "(read this":http://test.host), ok}).to_latex
11
+ }.should_not raise_error
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "lite_mode_html" do
4
+ examples_from_yaml do |doc|
5
+ RedCloth.new(doc['in'], [:lite_mode]).to_html
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "no_span_caps_html" do
4
+ examples_from_yaml do |doc|
5
+ RedCloth.new(doc['in'], [:no_span_caps]).to_html
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "sanitized_html" do
4
+ examples_from_yaml do |doc|
5
+ RedCloth.new(doc['in'], [:sanitize_html]).to_html
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "style_filtered_html" do
4
+ examples_from_yaml do |doc|
5
+ RedCloth.new(doc['in'], [:filter_styles]).to_html
6
+ end
7
+ end
@@ -0,0 +1,102 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe RedCloth do
4
+
5
+ describe "#new" do
6
+ it "should accept options" do
7
+ lambda {
8
+ RedCloth.new("test", [:hard_breaks])
9
+ }.should_not raise_error(ArgumentError)
10
+ end
11
+ end
12
+
13
+ it "should have a VERSION" do
14
+ RedCloth.const_defined?("VERSION").should be_true
15
+ RedCloth::VERSION.const_defined?("STRING").should be_true
16
+ end
17
+
18
+ it "should show the version as a string" do
19
+ RedCloth::VERSION::STRING.should == RedCloth::VERSION.to_s
20
+ RedCloth::VERSION.should == RedCloth::VERSION::STRING
21
+ end
22
+
23
+ it "should have EXTENSION_LANGUAGE" do
24
+ RedCloth.const_defined?("EXTENSION_LANGUAGE").should be_true
25
+ RedCloth::EXTENSION_LANGUAGE.should_not be_empty
26
+ RedCloth::DESCRIPTION.should include(RedCloth::EXTENSION_LANGUAGE)
27
+ end
28
+
29
+ it "should not segfault on a badly formatted table" do
30
+ RedCloth.new(%Q{| one | two |\nthree | four |}).to_html.should =~ /td/
31
+ end
32
+
33
+ it "should not segfault on a table without a block end" do
34
+ RedCloth.new("| a | b |\n| c | d |\nh3. foo").to_html.should =~ /h3/
35
+ end
36
+
37
+ it "should not segfault on a table with empty cells" do
38
+ RedCloth.new(%Q{|one || |\nthree | four |}).to_html.should =~ /td/
39
+ end
40
+
41
+ it "should not segfault on an unfinished html block with filter_html" do
42
+ lambda { RedCloth.new(%Q{<hr> Some text}, [:filter_html]).to_html }.should_not raise_error
43
+ end
44
+
45
+ it "should parse RedCloth::VERSION in input" do
46
+ RedCloth.new("RedCloth::VERSION").to_html.should == "<p>#{RedCloth::VERSION::STRING}</p>"
47
+ end
48
+
49
+ it "should not parse RedCloth::VERSION if it's not on a line by itself" do
50
+ input = "RedCloth::VERSION won't output the RedCloth::VERSION unless it's on a line all by itself.\n\nRedCloth::VERSION"
51
+ html = "<p>RedCloth::<span class=\"caps\">VERSION</span> won&#8217;t output the RedCloth::<span class=\"caps\">VERSION</span> unless it&#8217;s on a line all by itself.</p>\n<p>#{RedCloth::VERSION::STRING}</p>"
52
+ RedCloth.new(input).to_html.should == html
53
+ end
54
+
55
+ it "should output the RedCloth::VERSION if it's labeled on a line by itself" do
56
+ input = "RedCloth::VERSION: RedCloth::VERSION"
57
+ html = "<p>RedCloth::VERSION: #{RedCloth::VERSION::STRING}</p>"
58
+ RedCloth.new(input).to_html.should == html
59
+ end
60
+
61
+ it "should output the RedCloth::VERSION if it's labeled in a sentence on a line by itself" do
62
+ input = "RedCloth version RedCloth::VERSION"
63
+ html = "<p>RedCloth version #{RedCloth::VERSION::STRING}</p>"
64
+ RedCloth.new(input).to_html.should == html
65
+ end
66
+
67
+ it "should output the RedCloth::VERSION in brackets" do
68
+ input = "The current RedCloth version is [RedCloth::VERSION]"
69
+ html = "<p>The current RedCloth version is #{RedCloth::VERSION::STRING}</p>"
70
+ RedCloth.new(input).to_html.should == html
71
+ end
72
+
73
+ it "should strip carriage returns" do
74
+ input = "This is a paragraph\r\n\r\nThis is a\r\nline break.\r\n\r\n<div>\r\ntest\r\n\r\n</div>"
75
+ html = "<p>This is a paragraph</p>\n<p>This is a<br />\nline break.</p>\n<div>\n<p>test</p>\n</div>"
76
+ RedCloth.new(input).to_html.should == html
77
+ end
78
+
79
+ it "should not add spurious li tags to the end of markup" do
80
+ input = "* one\n* two\n* three \n\n"
81
+ failing_input = "* one\n* two\n* three \n\n\n"
82
+ RedCloth.new(input).to_html.should_not match(/<li>$/)
83
+ RedCloth.new(failing_input).to_html.should_not match(/<li>$/)
84
+ end
85
+
86
+ if RUBY_VERSION > "1.9.0"
87
+ it "should preserve character encoding" do
88
+ input = "This is an ISO-8859-1 string"
89
+ input.force_encoding 'iso-8859-1'
90
+ output = RedCloth.new(input).to_html
91
+
92
+ output.should == "<p>This is an <span class=\"caps\">ISO</span>-8859-1 string</p>"
93
+ output.encoding.to_s.should == "ISO-8859-1"
94
+ end
95
+
96
+ it "should not raise ArgumentError: invalid byte sequence" do
97
+ s = "\xa3"
98
+ s.force_encoding 'iso-8859-1'
99
+ lambda { RedCloth.new(s).to_html }.should_not raise_error
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,36 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
+ require 'redcloth'
3
+ require 'yaml'
4
+
5
+ def examples_from_yaml(&block)
6
+ formatter = description.downcase
7
+ define_method("format_as_#{formatter}", &block)
8
+
9
+ fixtures.each do |name, doc|
10
+ if doc[formatter]
11
+ example("should output #{formatter} for #{name}") do
12
+ output = method("format_as_#{formatter}").call(doc)
13
+ output.should == doc[formatter]
14
+ end
15
+ else
16
+ example("should not raise errors when rendering #{formatter} for #{name}") do
17
+ lambda { method("format_as_#{formatter}").call(doc) }.should_not raise_error
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ def fixtures
24
+ return @fixtures if @fixtures
25
+ @fixtures = {}
26
+ Dir[File.join(File.dirname(__FILE__), *%w[fixtures *.yml])].each do |testfile|
27
+ testgroup = File.basename(testfile, '.yml')
28
+ num = 0
29
+ YAML::load_documents(File.open(testfile)) do |doc|
30
+ name = doc['name'] || num
31
+ @fixtures["#{testgroup} #{name}"] = doc
32
+ num += 1
33
+ end
34
+ end
35
+ @fixtures
36
+ end
@@ -0,0 +1,47 @@
1
+ CLEAN.include [
2
+ 'tmp',
3
+ '**/*.{o,obj,class,pdb,lib,def,exp,log,rbc}',
4
+ 'ext/redcloth_scan/**/redcloth_*.rb',
5
+ 'ext/redcloth_scan/Makefile', 'ext/redcloth_scan/extconf.rb',
6
+ ]
7
+ CLOBBER.include [
8
+ 'pkg',
9
+ '**/*.{c,java}',
10
+ 'lib/**/*.{bundle,so,o,obj,pdb,lib,def,exp,jar}',
11
+ 'lib/redcloth_scan.rb',
12
+ ]
13
+
14
+ # Load the Gem specification for the current platform (Ruby or JRuby).
15
+ def gemspec(platform = RUBY_PLATFORM[/java/] || 'ruby')
16
+ Gem::Specification.load(File.expand_path('../../redcloth.gemspec', __FILE__))
17
+ end
18
+
19
+ require 'rake/extensiontask'
20
+ require 'rake/javaextensiontask'
21
+ require File.dirname(__FILE__) + '/ragel_extension_task'
22
+
23
+ if defined?(JRUBY_VERSION)
24
+ Rake::JavaRagelExtensionTask.new('redcloth_scan', gemspec)
25
+ else
26
+ extconf = "ext/redcloth_scan/extconf.rb"
27
+ file extconf do
28
+ FileUtils.mkdir(File.dirname(extconf)) unless File.directory?(File.dirname(extconf))
29
+ File.open(extconf, "w") do |io|
30
+ io.write(<<-EOF)
31
+ require 'mkmf'
32
+ CONFIG['warnflags'].gsub!(/-Wshorten-64-to-32/, '') if CONFIG['warnflags']
33
+ $CFLAGS << ' -O0 -Wall ' if CONFIG['CC'] =~ /gcc/
34
+ dir_config("redcloth_scan")
35
+ have_library("c", "main")
36
+ create_makefile("redcloth_scan")
37
+ EOF
38
+ end
39
+ end
40
+
41
+ Rake::RagelExtensionTask.new("redcloth_scan", gemspec) do |ext|
42
+ if ENV['RUBY_CC_VERSION']
43
+ ext.cross_compile = true
44
+ ext.cross_platform = ['i386-mingw32', 'i386-mswin32-60']
45
+ end
46
+ end
47
+ end
data/tasks/gems.rake ADDED
@@ -0,0 +1,37 @@
1
+ Rake::Task['build'].prerequisites.unshift('compile')
2
+
3
+ namespace :build do
4
+ desc "Generate Windows binary gems"
5
+ task :win do
6
+ unless File.directory?(File.expand_path('~/.rake-compiler'))
7
+ STDERR.puts <<-EOM
8
+
9
+ You must install Windows rubies to ~/.rake-compiler with:
10
+
11
+ rake-compiler cross-ruby VERSION=1.8.6-p398
12
+ # (Later 1.9.1 patch levels don't compile on mingw)
13
+ rake-compiler cross-ruby VERSION=1.9.1-p243
14
+ EOM
15
+ exit(1)
16
+ end
17
+ # rvm and mingw ruby versions have to match to avoid errors
18
+ sh "rvm ruby-1.8.6-p398@redcloth rake cross compile RUBY_CC_VERSION=1.8.6"
19
+ sh "rvm ruby-1.9.1-p243@redcloth rake cross compile RUBY_CC_VERSION=1.9.1"
20
+ # This will copy the .so files to the proper place
21
+ sh "rake cross native gem RUBY_CC_VERSION=1.8.6:1.9.1"
22
+ end
23
+
24
+ desc 'Generate JRuby binary gem'
25
+ task :jruby do
26
+ sh "rvm jruby@redcloth rake java gem"
27
+ end
28
+
29
+ desc "Build ruby, windows, and jruby gems into the pkg directory"
30
+ task :all => [
31
+ :clobber,
32
+ "rvm:spec",
33
+ :jruby,
34
+ :win,
35
+ :build
36
+ ]
37
+ end
@@ -0,0 +1,127 @@
1
+ module Rake
2
+ module RagelGenerationTasks
3
+ RAGEL_INCLUDE_PATTERN = /include \w+ "([^"]+)";/
4
+ RAGEL_VERSION_COMMAND = "ragel -v"
5
+
6
+ attr_accessor :rl_dir
7
+ attr_accessor :machines
8
+
9
+ def init(name = nil, gem_spec = nil)
10
+ super
11
+
12
+ @rl_dir = "ragel"
13
+ @machines = %w(scan inline attributes)
14
+ end
15
+
16
+ def lang
17
+ raise NotImplementedError
18
+ end
19
+
20
+ def source_files
21
+ @source_files ||= machines.map {|m| target(m) }
22
+ end
23
+
24
+ def define
25
+ super
26
+ define_ragel_tasks
27
+ end
28
+
29
+ def define_ragel_tasks
30
+ machines.each do |machine|
31
+ file target(machine) => [*ragel_sources(machine)] do
32
+ mkdir_p(File.dirname(target(machine))) unless File.directory?(File.dirname(target(machine)))
33
+ ensure_ragel_version
34
+ sh "ragel #{flags} #{lang_ragel(machine)} -o #{target(machine)}"
35
+ end
36
+
37
+ file extconf => [target(machine)] if lang == 'c'
38
+ end
39
+ end
40
+
41
+ def target(machine)
42
+ {
43
+ 'scan' => {
44
+ 'c' => "#{@ext_dir}/redcloth_scan.c",
45
+ 'java' => "#{@ext_dir}/RedclothScanService.java",
46
+ 'rb' => "#{@ext_dir}/redcloth_scan.rb"
47
+ },
48
+ 'inline' => {
49
+ 'c' => "#{@ext_dir}/redcloth_inline.c",
50
+ 'java' => "#{@ext_dir}/RedclothInline.java",
51
+ 'rb' => "#{@ext_dir}/redcloth_inline.rb"
52
+ },
53
+ 'attributes' => {
54
+ 'c' => "#{@ext_dir}/redcloth_attributes.c",
55
+ 'java' => "#{@ext_dir}/RedclothAttributes.java",
56
+ 'rb' => "#{@ext_dir}/redcloth_attributes.rb"
57
+ }
58
+ }[machine][lang]
59
+ end
60
+
61
+ def lang_ragel(machine)
62
+ "#{@rl_dir}/redcloth_#{machine}.#{lang}.rl"
63
+ end
64
+
65
+ def ragel_sources(machine)
66
+ deps = [lang_ragel(machine), ragel_file_dependencies(lang_ragel(machine))].flatten.dup
67
+ deps += ["#{@ext_dir}/redcloth.h"] if lang == 'c'
68
+ deps
69
+ # FIXME: merge that header file into other places so it can be eliminated?
70
+ end
71
+
72
+ def ragel_file_dependencies(ragel_file)
73
+ found = find_ragel_includes(ragel_file)
74
+ found + found.collect {|file| ragel_file_dependencies(file)}
75
+ end
76
+
77
+ def find_ragel_includes(file)
78
+ File.open(file).grep(RAGEL_INCLUDE_PATTERN) { $1 }.map do |file|
79
+ "#{@rl_dir}/#{file}"
80
+ end
81
+ end
82
+
83
+ def flags
84
+ code_style_flag = preferred_code_style ? " -" + preferred_code_style : ""
85
+ "-#{host_language_flag}#{code_style_flag}"
86
+ end
87
+
88
+ def host_language_flag
89
+ {
90
+ 'c' => 'C',
91
+ 'java' => 'J',
92
+ 'rb' => 'R'
93
+ }[lang]
94
+ end
95
+
96
+ def preferred_code_style
97
+ {
98
+ 'c' => 'T0',
99
+ 'java' => nil,
100
+ 'rb' => 'F1'
101
+ }[lang]
102
+ end
103
+
104
+ def ensure_ragel_version
105
+ @ragel_v ||= `ragel -v`[/(version )(\S*)/,2].split('.').map{|s| s.to_i}
106
+ raise unless @ragel_v[0] > 6 || (@ragel_v[0] == 6 && @ragel_v[1] >= 3)
107
+ rescue
108
+ STDERR.puts "Ragel 6.3 or greater is required."
109
+ exit(1)
110
+ end
111
+
112
+ end
113
+ class RagelExtensionTask < ExtensionTask
114
+ include RagelGenerationTasks
115
+
116
+ def lang
117
+ "c"
118
+ end
119
+ end
120
+ class JavaRagelExtensionTask < JavaExtensionTask
121
+ include RagelGenerationTasks
122
+
123
+ def lang
124
+ "java"
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,15 @@
1
+ namespace :release do
2
+ desc 'Upload all packages and tag git'
3
+ task :all => ['build:all', :release, :push_native_gems]
4
+
5
+ desc 'Push all gems to rubygems.org (gemcutter)'
6
+ task :push_native_gems do
7
+ Dir.chdir('pkg') do
8
+ Dir['*.gem'].select {|g| g =~ /\w+-[^-]+-\w+.gem/ }.each do |gem_file|
9
+ sh("gem push #{gem_file}")
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ Rake::Task['release'].prerequisites.unshift('build')
data/tasks/rspec.rake ADDED
@@ -0,0 +1,13 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec)
4
+
5
+ RSpec::Core::RakeTask.new(:rcov) do |t|
6
+ t.rcov = true
7
+ t.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/}
8
+ end
9
+
10
+ task :default => :spec
11
+ task :spec => :compile
12
+
13
+ RSpec::Core::RakeTask.new(:test) # for rubygems-test
data/tasks/rvm.rake ADDED
@@ -0,0 +1,79 @@
1
+ namespace :rvm do
2
+
3
+ RVM_RUBIES = ['jruby-1.5.6' , 'ruby-1.8.6-p398', 'ruby-1.9.1-p243', 'ruby-1.9.2-p136', 'ree-1.8.7-2010.02']
4
+ RVM_GEMSET_NAME = 'redcloth'
5
+
6
+ task :setup do
7
+ unless @rvm_setup
8
+ rvm_lib_path = "#{`echo $rvm_path`.strip}/lib"
9
+ $LOAD_PATH.unshift(rvm_lib_path) unless $LOAD_PATH.include?(rvm_lib_path)
10
+ require 'rvm'
11
+ require 'tmpdir'
12
+ @rvm_setup = true
13
+ end
14
+ end
15
+
16
+ desc "Runs specs under each rvm ruby"
17
+ task :spec => :setup do
18
+ puts rvm_rubies.join(',')
19
+ rvm_each_rubie do
20
+ # Make sure all dependencies are installed but ignore Gemfile.lock. It
21
+ # gets confused when locked to java and running ruby and vice-versa.
22
+ STDERR << RVM.run('bundle update').stderr
23
+
24
+ result = RVM.perform_set_operation(:rake)
25
+ STDOUT << result.stdout
26
+ STDERR << result.stderr
27
+ end
28
+ end
29
+
30
+ desc "Show rubies"
31
+ task :rubies => :setup do
32
+ puts rvm_rubies.join(",")
33
+ end
34
+
35
+ namespace :install do
36
+ task :rubies => :setup do
37
+ installed_rubies = RVM.list_strings
38
+ RVM_RUBIES.each do |rubie|
39
+ if installed_rubies.include?(rubie)
40
+ puts "info: Rubie #{rubie} already installed."
41
+ else
42
+ good_msg = "info: Rubie #{rubie} installed."
43
+ bad_msg = "Failed #{rubie} install! Check RVM logs here: #{RVM.path}/log/#{rubie}"
44
+ puts "info: Rubie #{rubie} installation inprogress. This could take awhile..."
45
+ if RVM.install(rubie,{})
46
+ puts(good_msg)
47
+ RVM.use(rubie)
48
+ RVM.perform_set_operation(:gem, 'install', 'bundler')
49
+ RVM.reset_current!
50
+ else
51
+ abort(bad_msg)
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ task :remove => :setup do
59
+ rvm_rubies.each { |rubie| RVM.remove(rubie) }
60
+ end
61
+ end
62
+
63
+
64
+ # RVM Helper Methods
65
+
66
+ def rvm_each_rubie
67
+ rvm_rubies.each do |rubie|
68
+ RVM.use(rubie)
69
+ puts "Using #{rubie}"
70
+ yield
71
+ end
72
+ ensure
73
+ RVM.reset_current!
74
+ end
75
+
76
+ def rvm_rubies(options={})
77
+ RVM_RUBIES.map{ |rubie| "#{rubie}@#{RVM_GEMSET_NAME}" }
78
+ end
79
+