diff --git a/lib/puppet/face/module_tool/build.rb b/lib/puppet/face/module_tool/build.rb new file mode 100644 index 000000000..e2efea716 --- /dev/null +++ b/lib/puppet/face/module_tool/build.rb @@ -0,0 +1,35 @@ +Puppet::Face.define(:module_tool, '0.0.1') do + action(:build) do + summary "Build a module release package." + description <<-EOT + Build a module release archive file by processing the Modulefile in the + module directory. The release archive file will be stored in the pkg + directory of the module directory. + EOT + + returns "Pathname object representing the path to the release archive." + + examples <<-EOT + Build a module release from within the module directory: + + $ puppet module_tool build + + Build a module release from outside the module directory: + + $ puppet module_tool build /path/to/module + EOT + + arguments "" + + when_invoked do |path, options| + root_path = Puppet::Module::Tool.find_module_root(path) + Puppet::Module::Tool::Applications::Builder.run(root_path, options) + end + + when_rendering :console do |return_value| + # Get the string representation of the Pathname object and print it to + # the console. + return_value.to_s + end + end +end diff --git a/spec/unit/face/module_tool/build_spec.rb b/spec/unit/face/module_tool/build_spec.rb new file mode 100644 index 000000000..33db6a623 --- /dev/null +++ b/spec/unit/face/module_tool/build_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' +require 'puppet/face' + +describe "puppet module_tool build" do + subject { Puppet::Face[:module_tool, :current] } + + describe "option validation" do + context "without any options" do + it "should require a path" do + pattern = /wrong number of arguments/ + expect { subject.build }.to raise_error ArgumentError, pattern + end + end + end + + describe "inline documentation" do + subject { Puppet::Face[:module_tool, :current].get_action :build } + + its(:summary) { should =~ /build.*module/im } + its(:description) { should =~ /build.*module/im } + its(:returns) { should =~ /pathname/i } + its(:examples) { should_not be_empty } + + %w{ license copyright summary description returns examples }.each do |doc| + context "of the" do + its(doc.to_sym) { should_not =~ /(FIXME|REVISIT|TODO)/ } + end + end + end +end