This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
91 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Relish | ||
module ResourceMethods | ||
def self.included(command_class) | ||
command_class.extend ClassMethods | ||
end | ||
|
||
module ClassMethods | ||
def resource_path(path) | ||
define_method :resource_path do |project| | ||
"projects/#{escape(project)}/#{path}" | ||
end | ||
end | ||
end | ||
|
||
def resource_path_for_no_option | ||
resource_path(@param || project) | ||
end | ||
|
||
def resource_path_for_option | ||
resource_path(@param.extract_project_handle || project) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters