From 4628558e368e77e9f3e4f5d191e5cbb760559cc3 Mon Sep 17 00:00:00 2001 From: Jakukyo Friel Date: Mon, 30 Mar 2015 12:13:03 +0800 Subject: [PATCH 1/2] Add luarocks installer. --- lib/sprinkle/installers/luarocks.rb | 39 +++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 lib/sprinkle/installers/luarocks.rb diff --git a/lib/sprinkle/installers/luarocks.rb b/lib/sprinkle/installers/luarocks.rb new file mode 100644 index 0000000..3c674a6 --- /dev/null +++ b/lib/sprinkle/installers/luarocks.rb @@ -0,0 +1,39 @@ +module Sprinkle + module Installers + # The luarocks package installer installs Lua modules. + # + # + # == Example Usage + # + # A simple installation: + # + # package :magic_beans do + # description "Beans beans they're good for your heart..." + # luarocks 'magic_beans' + # end + class LuaRocks < Installer + + api do + def luarocks(name, options = {}, &block) + install LuaRocks.new(self, name, options, &block) + end + end + + attr_accessor :luarocks #:nodoc: + + def initialize(parent, luarocks, options = {}, &block) #:nodoc: + super parent, options, &block + @luarocks = luarocks + end + + + protected + + + def install_commands #:nodoc: + cmd = "#{sudo_cmd}luarocks install #{luarocks}" + end + + end + end +end From 25a5864a45677b50e8ec859bdc533973dd6761b6 Mon Sep 17 00:00:00 2001 From: Jakukyo Friel Date: Mon, 11 Jul 2016 19:50:22 +0800 Subject: [PATCH 2/2] luarocks: refactor to use `auto_api`. --- lib/sprinkle/installers/luarocks.rb | 30 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/sprinkle/installers/luarocks.rb b/lib/sprinkle/installers/luarocks.rb index 3c674a6..6e012ea 100644 --- a/lib/sprinkle/installers/luarocks.rb +++ b/lib/sprinkle/installers/luarocks.rb @@ -11,27 +11,27 @@ module Installers # description "Beans beans they're good for your heart..." # luarocks 'magic_beans' # end + # + # You may also specify multiple packages as an array: + # + # package :magic_beans do + # luarocks %w(magic_beans magic_sauce) + # end + # class LuaRocks < Installer - api do - def luarocks(name, options = {}, &block) - install LuaRocks.new(self, name, options, &block) - end - end - - attr_accessor :luarocks #:nodoc: - - def initialize(parent, luarocks, options = {}, &block) #:nodoc: - super parent, options, &block - @luarocks = luarocks - end - + ## + # installs the luarocks passed + # :method: luarocks + # :call-seq: luarocks(*packages) + auto_api protected - def install_commands #:nodoc: - cmd = "#{sudo_cmd}luarocks install #{luarocks}" + # `luarocks` does not accept multiple packages. + cmds = @packages.map { |p| "#{sudo_cmd}luarocks install #{p}" } + cmd = cmds.join('; ') end end