From 3e884356e255feca0da88eac481b041795507cdd Mon Sep 17 00:00:00 2001 From: Will Farrington Date: Wed, 6 Mar 2013 09:36:36 -0800 Subject: [PATCH 1/2] First spike at jruby --- .gitignore | 1 + README.md | 2 ++ manifests/1_8_7.pp | 6 +----- manifests/1_9_2.pp | 6 +----- manifests/1_9_3.pp | 6 +----- manifests/2_0_0.pp | 7 +------ manifests/alias.pp | 15 +++++++++++++++ manifests/jruby.pp | 6 ++++++ manifests/jruby_1_7_3.pp | 10 ++++++++++ spec/classes/jruby_1_7_3_spec.rb | 19 +++++++++++++++++++ spec/classes/jruby_spec.rb | 18 ++++++++++++++++++ spec/defines/ruby_alias_spec.rb | 26 ++++++++++++++++++++++++++ spec/fixtures/Puppetfile | 14 +++++++++++--- 13 files changed, 112 insertions(+), 24 deletions(-) create mode 100644 manifests/alias.pp create mode 100644 manifests/jruby.pp create mode 100644 manifests/jruby_1_7_3.pp create mode 100644 spec/classes/jruby_1_7_3_spec.rb create mode 100644 spec/classes/jruby_spec.rb create mode 100644 spec/defines/ruby_alias_spec.rb diff --git a/.gitignore b/.gitignore index e1e36c7..087c802 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ /spec/fixtures/vendor/ /spec/fixtures/modules/boxen/ /spec/fixtures/modules/homebrew/ +/spec/fixtures/modules/java/ /spec/fixtures/modules/stdlib/ diff --git a/README.md b/README.md index f961b88..469d7f3 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ Requires the following boxen modules: * `boxen` +* `java` (only if using JRuby) +* `stdlib` ## Usage diff --git a/manifests/1_8_7.pp b/manifests/1_8_7.pp index 4fccdf5..773917a 100644 --- a/manifests/1_8_7.pp +++ b/manifests/1_8_7.pp @@ -7,9 +7,5 @@ require ruby require ruby::1_8_7_p358 - file { "${ruby::root}/versions/1.8.7": - ensure => symlink, - force => true, - target => "${ruby::root}/versions/1.8.7-p358" - } + ruby::alias { '1.8.7': target => '1.8.7-p358' } } diff --git a/manifests/1_9_2.pp b/manifests/1_9_2.pp index 6fce4b1..761b886 100644 --- a/manifests/1_9_2.pp +++ b/manifests/1_9_2.pp @@ -7,9 +7,5 @@ require ruby require ruby::1_9_2_p320 - file { "${ruby::root}/versions/1.9.2": - ensure => symlink, - force => true, - target => "${ruby::root}/versions/1.9.2-p320" - } + ruby::alias { '1.9.2': target => '1.9.2-p320' } } diff --git a/manifests/1_9_3.pp b/manifests/1_9_3.pp index 172345e..19c1180 100644 --- a/manifests/1_9_3.pp +++ b/manifests/1_9_3.pp @@ -7,9 +7,5 @@ require ruby require ruby::1_9_3_p392 - file { "${ruby::root}/versions/1.9.3": - ensure => symlink, - force => true, - target => "${ruby::root}/versions/1.9.3-p392" - } + ruby::alias { '1.9.3': target => '1.9.3-p392' } } diff --git a/manifests/2_0_0.pp b/manifests/2_0_0.pp index fed6192..7304acb 100644 --- a/manifests/2_0_0.pp +++ b/manifests/2_0_0.pp @@ -7,10 +7,5 @@ require ruby require ruby::2_0_0_p0 - file { "${ruby::root}/versions/2.0.0": - ensure => symlink, - force => true, - target => "${ruby::root}/versions/2.0.0-p0" - } + ruby::alias { '2.0.0': target => '2.0.0-p0' } } - diff --git a/manifests/alias.pp b/manifests/alias.pp new file mode 100644 index 0000000..758065d --- /dev/null +++ b/manifests/alias.pp @@ -0,0 +1,15 @@ +# Public: Sets up an alias for $name to the rbenv version for $target. +# +# Usage: +# +# ruby::alias { '1.9.3': target => '1.9.3-p392' } + +define ruby::alias($target) { + require ruby + + file { "${ruby::root}/versions/${name}": + ensure => symlink, + force => true, + target => "${ruby::root}/versions/${target}" + } +} diff --git a/manifests/jruby.pp b/manifests/jruby.pp new file mode 100644 index 0000000..1e3f5fe --- /dev/null +++ b/manifests/jruby.pp @@ -0,0 +1,6 @@ +class ruby::jruby { + require ruby + require ruby::jruby_1_7_3 + + ruby::alias { 'jruby': target => 'jruby-1.7.3' } +} diff --git a/manifests/jruby_1_7_3.pp b/manifests/jruby_1_7_3.pp new file mode 100644 index 0000000..9e45740 --- /dev/null +++ b/manifests/jruby_1_7_3.pp @@ -0,0 +1,10 @@ +class ruby::jruby_1_7_3 { + include ruby + include java + + ruby::version { 'jruby-1.7.3': } + + Ruby::Version <| title == 'jruby-1.7.3' |> { + require +> Class['java'] + } +} diff --git a/spec/classes/jruby_1_7_3_spec.rb b/spec/classes/jruby_1_7_3_spec.rb new file mode 100644 index 0000000..c61e337 --- /dev/null +++ b/spec/classes/jruby_1_7_3_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe 'ruby::jruby_1_7_3' do + let(:facts) do + { + :boxen_home => '/test/boxen', + :boxen_user => 'testuser', + :macosx_productversion_major => '10.8' + } + end + + it do + should include_class('java') + should include_class('ruby') + + should contain_ruby__version('jruby-1.7.3')#. + #with_require('[Class[java], Class[ruby]]') + end +end diff --git a/spec/classes/jruby_spec.rb b/spec/classes/jruby_spec.rb new file mode 100644 index 0000000..159517a --- /dev/null +++ b/spec/classes/jruby_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +describe 'ruby::jruby' do + let(:facts) do + { + :boxen_home => '/test/boxen', + :boxen_user => 'testuser', + :macosx_productversion_major => '10.8' + } + end + + it do + should include_class('ruby') + should include_class('ruby::jruby_1_7_3') + + should contain_ruby__alias('jruby').with_target('jruby-1.7.3') + end +end diff --git a/spec/defines/ruby_alias_spec.rb b/spec/defines/ruby_alias_spec.rb new file mode 100644 index 0000000..269d38f --- /dev/null +++ b/spec/defines/ruby_alias_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe 'ruby::alias' do + let(:facts) do + { + :boxen_home => '/test/boxen', + :boxen_user => 'testuser', + :macosx_productversion_major => '10.8' + } + end + + let(:title) { "2.1.0" } + let(:params) do + { + :target => '2.1.0-dev' + } + end + + it do + should contain_file('/test/boxen/rbenv/versions/2.1.0').with({ + :ensure => 'symlink', + :force => true, + :target => '/test/boxen/rbenv/versions/2.1.0-dev' + }) + end +end diff --git a/spec/fixtures/Puppetfile b/spec/fixtures/Puppetfile index 98d838c..f7e9bdf 100644 --- a/spec/fixtures/Puppetfile +++ b/spec/fixtures/Puppetfile @@ -1,3 +1,11 @@ -mod "boxen", "0.1.8", :github_tarball => "boxen/puppet-boxen" -mod "homebrew", "0.0.17", :github_tarball => "boxen/puppet-homebrew" -mod "stdlib", "3.0.0", :github_tarball => "puppetlabs/puppetlabs-stdlib" +def github(name, version, options = nil) + options ||= {} + options[:repo] ||= "boxen/puppet-#{name}" + mod name, version, :github_tarball => options[:repo] +end + + +github "boxen", "1.2.0" +github "homebrew", "1.1.0" +github "java", "1.0.6" +github "stdlib", "3.0.0", :repo => "puppetlabs/puppetlabs-stdlib" From d9ca59586412e6b9cc48e8885c18e0a6f2a3872a Mon Sep 17 00:00:00 2001 From: Will Farrington Date: Thu, 7 Mar 2013 14:20:55 -0500 Subject: [PATCH 2/2] DOC IT --- manifests/jruby.pp | 7 +++++++ manifests/jruby_1_7_3.pp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/manifests/jruby.pp b/manifests/jruby.pp index 1e3f5fe..a828b9b 100644 --- a/manifests/jruby.pp +++ b/manifests/jruby.pp @@ -1,3 +1,10 @@ +# Public: Installs our blessed version of jruby and symlinks it in rbenv +# to "jruby" +# +# Usage: +# +# include ruby::jruby + class ruby::jruby { require ruby require ruby::jruby_1_7_3 diff --git a/manifests/jruby_1_7_3.pp b/manifests/jruby_1_7_3.pp index 9e45740..14e5697 100644 --- a/manifests/jruby_1_7_3.pp +++ b/manifests/jruby_1_7_3.pp @@ -1,3 +1,10 @@ +# Public: Installs JRuby 1.7.3 from rbenv +# +# Usage: +# +# include ruby::jruby_1_7_3 + + class ruby::jruby_1_7_3 { include ruby include java