Skip to content
Browse files

Merge pull request #75 from Punchkick-Interactive/master

Added support for a "npm" installer for use with nodejs servers
  • Loading branch information...
2 parents 8447594 + bf1c53b commit f29bd70d43c56b252cd7c27394c920eb017ef828 @crafterm committed Dec 19, 2012
View
19 lib/sprinkle/installers/npm.rb
@@ -0,0 +1,19 @@
+module Sprinkle
+ module Installers
+
+ class Npm < Installer
+ attr_accessor :package_name
+
+ def initialize(parent, package_name, &block)
+ super parent, &block
+ @package_name = package_name
+ end
+
+ protected
+ def install_commands #override
+ "npm install --global #{@package_name}"
+ end
+
+ end #of class
+ end #module
+end #module
View
4 lib/sprinkle/package.rb
@@ -232,6 +232,10 @@ def pear(thePackage, &block)
logger.debug("the pear installer is " + installer.to_s)
@installers << installer;
end
+
+ def npm(thePackage, &block)
+ @installers << Sprinkle::Installers::Npm.new(self, thePackage, &block);
+ end
def process(deployment, roles)
return if meta_package?
View
21 lib/sprinkle/verifiers/npm.rb
@@ -0,0 +1,21 @@
+module Sprinkle
+ module Verifiers
+ # = Npm package Verifier
+ #
+ # Contains a verifier to check the existence of a npm module.
+ #
+ # == Example Usage
+ #
+ # verify { has_npm 'grunt' }
+ #
+ module Npm
+ Sprinkle::Verify.register(Sprinkle::Verifiers::Npm)
+
+ # Checks to make sure the npm <tt>module</tt> exists on the remote server.
+ def has_npm(package)
+ @commands << "npm --global list | grep \"#{package}@\""
+ end
+
+ end
+ end
+end
View
16 spec/sprinkle/installers/npm_spec.rb
@@ -0,0 +1,16 @@
+require File.expand_path("../../spec_helper", File.dirname(__FILE__))
+
+describe Sprinkle::Installers::Npm do
+
+ before do
+ @package = mock(Sprinkle::Package, :name => 'spec')
+ @installer = Sprinkle::Installers::Npm.new(@package, 'spec')
+ end
+
+ describe 'during installation' do
+ it 'should invoke the npm executer for all specified tasks' do
+ @install_commands = @installer.send :install_commands
+ @install_commands.should == "npm install --global spec"
+ end
+ end
+end
View
3 sprinkle.gemspec
@@ -62,6 +62,7 @@ Gem::Specification.new do |s|
"lib/sprinkle/installers/install_package.rb",
"lib/sprinkle/installers/installer.rb",
"lib/sprinkle/installers/mac_port.rb",
+ "lib/sprinkle/installers/npm.rb",
"lib/sprinkle/installers/openbsd_pkg.rb",
"lib/sprinkle/installers/opensolaris_pkg.rb",
"lib/sprinkle/installers/pacman.rb",
@@ -86,6 +87,7 @@ Gem::Specification.new do |s|
"lib/sprinkle/verifiers/directory.rb",
"lib/sprinkle/verifiers/executable.rb",
"lib/sprinkle/verifiers/file.rb",
+ "lib/sprinkle/verifiers/npm.rb",
"lib/sprinkle/verifiers/package.rb",
"lib/sprinkle/verifiers/pear.rb",
"lib/sprinkle/verifiers/process.rb",
@@ -114,6 +116,7 @@ Gem::Specification.new do |s|
"spec/sprinkle/installers/gem_spec.rb",
"spec/sprinkle/installers/installer_spec.rb",
"spec/sprinkle/installers/mac_port_spec.rb",
+ "spec/sprinkle/installers/npm_spec.rb",
"spec/sprinkle/installers/openbsd_pkg_spec.rb",
"spec/sprinkle/installers/opensolaris_pkg_spec.rb",
"spec/sprinkle/installers/pear_spec.rb",

0 comments on commit f29bd70

Please sign in to comment.
Something went wrong with that request. Please try again.