relish 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -38,6 +38,11 @@ Feature: Help
38
38
  # example: relish collab:add rspec/rspec-core:justin
39
39
  collab:remove <project>:<collaborator handle or email> # remove a collaborator from a project
40
40
  # example: relish collab:remove rspec/rspec-core:justin
41
+ versions # list the versions for a project
42
+ versions:add <project>:<version name> # add a version to a project
43
+ # example: relish versions:add rspec/rspec-core:2.0
44
+ versions:remove <project>:<version name> # remove a version from a project
45
+ # example: relish versions:remove rspec/rspec-core:2.0
41
46
 
42
47
  """
43
48
 
@@ -1,12 +1,14 @@
1
1
  require 'relish'
2
2
  require 'relish/helpers'
3
3
  require 'relish/error_messages'
4
+ require 'relish/resource_methods'
4
5
  require 'relish/commands/base'
5
6
  require 'relish/commands/collab'
6
7
  require 'relish/commands/config'
7
8
  require 'relish/commands/help'
8
9
  require 'relish/commands/projects'
9
10
  require 'relish/commands/push'
11
+ require 'relish/commands/versions'
10
12
 
11
13
  module Relish
12
14
  module Command
@@ -23,7 +25,7 @@ module Relish
23
25
  command_class, method = command.split(':')
24
26
  return get_command(command_class.capitalize), get_method(method)
25
27
  rescue NameError
26
- error ErrorMessages.unknown_command
28
+ error :unknown_command
27
29
  end
28
30
 
29
31
  private
@@ -1,6 +1,8 @@
1
1
  module Relish
2
2
  module Command
3
3
  class Collab < Base
4
+ include ResourceMethods
5
+ resource_path :memberships
4
6
 
5
7
  desc 'list the collaborators for a project'
6
8
  command :default do
@@ -23,18 +25,6 @@ module Relish
23
25
 
24
26
  private
25
27
 
26
- def resource_path_for_no_option
27
- resource_path(@param || project)
28
- end
29
-
30
- def resource_path_for_option
31
- resource_path(@param.extract_project_handle || project)
32
- end
33
-
34
- def resource_path(project)
35
- "projects/#{escape(project)}/memberships"
36
- end
37
-
38
28
  def handle_or_email
39
29
  @param.extract_option
40
30
  end
@@ -63,7 +63,7 @@ module Relish
63
63
  end
64
64
 
65
65
  def rename_handle
66
- @param.has_option? ? @param.extract_option : error(:handle_is_blank)
66
+ @param.has_option? ? @param.extract_option : error(:handle_blank)
67
67
  end
68
68
 
69
69
  def private?
@@ -0,0 +1,42 @@
1
+ module Relish
2
+ module Command
3
+ class Versions < Base
4
+ include ResourceMethods
5
+ resource_path :versions
6
+
7
+ desc 'list the versions for a project'
8
+ command :default do
9
+ puts format(resource[resource_path_for_no_option].get(:accept => :json))
10
+ end
11
+
12
+ usage 'versions:add <project>:<version name>'
13
+ desc ['add a version to a project',
14
+ 'example: relish versions:add rspec/rspec-core:2.0']
15
+ command :add do
16
+ puts resource[resource_path_for_option].post(
17
+ :version => { :name => version_name }
18
+ )
19
+ end
20
+
21
+ usage 'versions:remove <project>:<version name>'
22
+ desc ['remove a version from a project',
23
+ 'example: relish versions:remove rspec/rspec-core:2.0']
24
+ command :remove do
25
+ puts resource["#{resource_path_for_option}/#{version_name}"].delete
26
+ end
27
+
28
+ private
29
+
30
+ def version_name
31
+ @param && @param.extract_option || error(:version_blank)
32
+ end
33
+
34
+ def format(response)
35
+ json_parse(response) do |hash|
36
+ "#{hash['version']['name']}"
37
+ end
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -6,9 +6,13 @@ module Relish
6
6
  'Please specify a project.' + help
7
7
  end
8
8
 
9
- def handle_is_blank
9
+ def handle_blank
10
10
  'Please specify a new handle.' + help
11
11
  end
12
+
13
+ def version_blank
14
+ 'Please specify a version name.' + help
15
+ end
12
16
 
13
17
  def unknown_command
14
18
  'Unknown command.' + help
@@ -0,0 +1,23 @@
1
+ module Relish
2
+ module ResourceMethods
3
+ def self.included(command_class)
4
+ command_class.extend ClassMethods
5
+ end
6
+
7
+ module ClassMethods
8
+ def resource_path(path)
9
+ define_method :resource_path do |project|
10
+ "projects/#{escape(project)}/#{path}"
11
+ end
12
+ end
13
+ end
14
+
15
+ def resource_path_for_no_option
16
+ resource_path(@param || project)
17
+ end
18
+
19
+ def resource_path_for_option
20
+ resource_path(@param.extract_project_handle || project)
21
+ end
22
+ end
23
+ end
data/relish.gemspec CHANGED
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "relish"
3
- s.version = "0.1.3"
3
+ s.version = "0.1.4"
4
4
 
5
5
  s.required_rubygems_version = '>= 1.3.5'
6
6
  s.authors = ["Matt Wynne", "Justin Ko"]
7
- s.date = "2010-11-17"
7
+ s.date = "2010-11-18"
8
8
  s.description = %q{Client gem for http://relishapp.com}
9
9
  s.email = "jko170@gmail.com"
10
10
 
@@ -11,13 +11,21 @@ module Relish
11
11
  end
12
12
  end
13
13
 
14
- describe '#handle_is_blank' do
14
+ describe '#handle_blank' do
15
15
  specify do
16
- described_class.handle_is_blank.should eq(
16
+ described_class.handle_blank.should eq(
17
17
  "Please specify a new handle. Run 'relish help' for usage information."
18
18
  )
19
19
  end
20
20
  end
21
+
22
+ describe '#version_blank' do
23
+ specify do
24
+ described_class.version_blank.should eq(
25
+ "Please specify a version name. Run 'relish help' for usage information."
26
+ )
27
+ end
28
+ end
21
29
 
22
30
  describe '#unknown_command' do
23
31
  specify do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relish
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Wynne
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-17 00:00:00 -07:00
19
+ date: 2010-11-18 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -198,10 +198,12 @@ files:
198
198
  - lib/relish/commands/help.rb
199
199
  - lib/relish/commands/projects.rb
200
200
  - lib/relish/commands/push.rb
201
+ - lib/relish/commands/versions.rb
201
202
  - lib/relish/error_messages.rb
202
203
  - lib/relish/helpers.rb
203
204
  - lib/relish/options_file.rb
204
205
  - lib/relish/param_methods.rb
206
+ - lib/relish/resource_methods.rb
205
207
  - lib/relish/ui.rb
206
208
  - relish.gemspec
207
209
  - spec/relish/command_spec.rb