Sha256: 55f24b1efc1cec571d4e86eecdb0d61e23b7df031bc216cd1c9769827ede8c51

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

module Relish
  module Command
    class Versions < Base
      include ResourceMethods
      resource_path :versions
      
      desc    'list the versions for a project'
      command :default do
        puts format(resource[resource_path_for_no_option].get(:accept => :json))
      end

      usage   'versions:add <project>:<version name>'
      desc    ['add a version to a project',
               'example: relish versions:add rspec/rspec-core:2.0']
      command :add do
        puts resource[resource_path_for_option].post(
          :version => { :name => version_name }
        )
      end
      
      usage   'versions:remove <project>:<version name>'
      desc    ['remove a version from a project',
               'example: relish versions:remove rspec/rspec-core:2.0']
      command :remove do
        puts resource["#{resource_path_for_option}/#{version_name}"].delete
      end
      
    private
      
      def version_name
        @param && @param.extract_option || error(:version_blank)
      end
    
      def format(response)
        json_parse(response) do |hash|
          "#{hash['version']['name']}"
        end
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
relish-0.1.4 lib/relish/commands/versions.rb