relish 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -1
- data/features/help.feature +8 -4
- data/lib/relish/command.rb +2 -1
- data/lib/relish/commands/base.rb +9 -4
- data/lib/relish/commands/collab.rb +3 -3
- data/lib/relish/commands/projects.rb +38 -6
- data/lib/relish/error_messages.rb +21 -0
- data/lib/relish/helpers.rb +2 -0
- data/lib/relish/{commands/param_methods.rb → param_methods.rb} +0 -0
- data/relish.gemspec +2 -2
- data/spec/relish/error_messages_spec.rb +31 -0
- data/spec/relish/{commands/param_methods_spec.rb → param_methods_spec.rb} +0 -0
- metadata +10 -7
data/README.md
CHANGED
data/features/help.feature
CHANGED
@@ -24,15 +24,19 @@ Feature: Help
|
|
24
24
|
# example: relish config:add project:rspec-core
|
25
25
|
# valid configuration options: project
|
26
26
|
projects # list your projects
|
27
|
-
projects:add <
|
27
|
+
projects:add <org or user handle>/<project handle> # add a project
|
28
28
|
# append :private to make the project private
|
29
29
|
# example: relish projects:add rspec/rspec-core:private
|
30
|
-
projects:remove <
|
30
|
+
projects:remove <project> # remove a project
|
31
|
+
projects:visibility <project>:<public or private> # set the status of a project
|
32
|
+
# example: relish projects:visibility rspec/rspec-core:private
|
33
|
+
projects:rename <project>:<new handle> # rename a project's handle
|
34
|
+
# example: relish projects:rename rspec/rspec-core:rspec-corez
|
31
35
|
push <project> # push features to relishapp.com
|
32
36
|
collab # list the collaborators for a project
|
33
|
-
collab:add <project>:<
|
37
|
+
collab:add <project>:<collaborator handle or email> # add a collaborator to a project
|
34
38
|
# example: relish collab:add rspec/rspec-core:justin
|
35
|
-
collab:remove <project>:<
|
39
|
+
collab:remove <project>:<collaborator handle or email> # remove a collaborator from a project
|
36
40
|
# example: relish collab:remove rspec/rspec-core:justin
|
37
41
|
|
38
42
|
"""
|
data/lib/relish/command.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'relish'
|
2
2
|
require 'relish/helpers'
|
3
|
+
require 'relish/error_messages'
|
3
4
|
require 'relish/commands/base'
|
4
5
|
require 'relish/commands/collab'
|
5
6
|
require 'relish/commands/config'
|
@@ -22,7 +23,7 @@ module Relish
|
|
22
23
|
command_class, method = command.split(':')
|
23
24
|
return get_command(command_class.capitalize), get_method(method)
|
24
25
|
rescue NameError
|
25
|
-
error
|
26
|
+
error ErrorMessages.unknown_command
|
26
27
|
end
|
27
28
|
|
28
29
|
private
|
data/lib/relish/commands/base.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'json'
|
3
|
-
require 'relish/
|
3
|
+
require 'relish/error_messages'
|
4
4
|
require 'relish/helpers'
|
5
5
|
require 'relish/options_file'
|
6
|
+
require 'relish/param_methods'
|
7
|
+
require 'relish/ui'
|
6
8
|
require 'relish/commands/dsl'
|
7
|
-
require 'relish/commands/param_methods'
|
8
9
|
|
9
10
|
module Relish
|
10
11
|
module Command
|
@@ -13,7 +14,7 @@ module Relish
|
|
13
14
|
extend Dsl
|
14
15
|
|
15
16
|
option :api_token, :default => lambda { get_and_store_api_token }
|
16
|
-
option :host, :default => lambda { Relish.default_host }
|
17
|
+
option :host, :default => lambda { Relish.default_host }
|
17
18
|
|
18
19
|
attr_writer :args
|
19
20
|
attr_reader :cli_options
|
@@ -37,7 +38,7 @@ module Relish
|
|
37
38
|
private
|
38
39
|
|
39
40
|
def project
|
40
|
-
merged_options['project'] || error(
|
41
|
+
merged_options['project'] || error(:project_blank)
|
41
42
|
end
|
42
43
|
|
43
44
|
def get_and_store_api_token
|
@@ -99,6 +100,10 @@ module Relish
|
|
99
100
|
response
|
100
101
|
end
|
101
102
|
|
103
|
+
def escape(str)
|
104
|
+
CGI.escape(str)
|
105
|
+
end
|
106
|
+
|
102
107
|
end
|
103
108
|
end
|
104
109
|
end
|
@@ -7,14 +7,14 @@ module Relish
|
|
7
7
|
puts format(resource[resource_path_for_no_option].get(:accept => :json))
|
8
8
|
end
|
9
9
|
|
10
|
-
usage 'collab:add <project>:<
|
10
|
+
usage 'collab:add <project>:<collaborator handle or email>'
|
11
11
|
desc ['add a collaborator to a project',
|
12
12
|
'example: relish collab:add rspec/rspec-core:justin']
|
13
13
|
command :add do
|
14
14
|
puts resource[resource_path_for_option].post(:handle_or_email => handle_or_email)
|
15
15
|
end
|
16
16
|
|
17
|
-
usage 'collab:remove <project>:<
|
17
|
+
usage 'collab:remove <project>:<collaborator handle or email>'
|
18
18
|
desc ['remove a collaborator from a project',
|
19
19
|
'example: relish collab:remove rspec/rspec-core:justin']
|
20
20
|
command :remove do
|
@@ -32,7 +32,7 @@ module Relish
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def resource_path(project)
|
35
|
-
"projects/#{project}/memberships"
|
35
|
+
"projects/#{escape(project)}/memberships"
|
36
36
|
end
|
37
37
|
|
38
38
|
def handle_or_email
|
@@ -1,27 +1,46 @@
|
|
1
1
|
module Relish
|
2
2
|
module Command
|
3
3
|
class Projects < Base
|
4
|
-
|
4
|
+
|
5
5
|
desc 'list your projects'
|
6
6
|
command :default do
|
7
7
|
puts format(resource['projects'].get(:accept => :json))
|
8
8
|
end
|
9
9
|
|
10
|
-
usage 'projects:add <
|
10
|
+
usage 'projects:add <org or user handle>/<project handle>'
|
11
11
|
desc ['add a project',
|
12
12
|
'append :private to make the project private',
|
13
13
|
'example: relish projects:add rspec/rspec-core:private']
|
14
14
|
command :add do
|
15
|
-
puts resource['projects'].post(:handle =>
|
15
|
+
puts resource['projects'].post(:handle => handle_to_add, :private => private?)
|
16
16
|
end
|
17
17
|
|
18
|
-
usage 'projects:remove <
|
18
|
+
usage 'projects:remove <project>'
|
19
19
|
desc 'remove a project'
|
20
20
|
command :remove do
|
21
|
-
puts resource["projects/#{
|
21
|
+
puts resource["projects/#{escape(handle_to_remove)}"].delete
|
22
|
+
end
|
23
|
+
|
24
|
+
usage 'projects:visibility <project>:<public or private>'
|
25
|
+
desc ['set the status of a project',
|
26
|
+
'example: relish projects:visibility rspec/rspec-core:private']
|
27
|
+
command :visibility do
|
28
|
+
puts resource["projects/#{escape(handle_to_update)}"].put(
|
29
|
+
:project => { :private => private? }
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
usage 'projects:rename <project>:<new handle>'
|
34
|
+
desc ["rename a project's handle",
|
35
|
+
'example: relish projects:rename rspec/rspec-core:rspec-corez']
|
36
|
+
command :rename do
|
37
|
+
puts resource["projects/#{escape(handle_to_update)}"].put(
|
38
|
+
:project => { :handle => rename_handle }
|
39
|
+
)
|
22
40
|
end
|
23
41
|
|
24
42
|
private
|
43
|
+
|
25
44
|
def format(response)
|
26
45
|
json_parse(response) do |hash|
|
27
46
|
result = hash['project']['full_handle']
|
@@ -30,8 +49,21 @@ module Relish
|
|
30
49
|
end
|
31
50
|
end
|
32
51
|
|
52
|
+
def handle_to_add
|
53
|
+
handle || error(:project_blank)
|
54
|
+
end
|
55
|
+
alias_method :handle_to_update, :handle_to_add
|
56
|
+
|
57
|
+
def handle_to_remove
|
58
|
+
handle || project
|
59
|
+
end
|
60
|
+
|
33
61
|
def handle
|
34
|
-
@param.without_option
|
62
|
+
@param.without_option if @param
|
63
|
+
end
|
64
|
+
|
65
|
+
def rename_handle
|
66
|
+
@param.has_option? ? @param.extract_option : error(:handle_is_blank)
|
35
67
|
end
|
36
68
|
|
37
69
|
def private?
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Relish
|
2
|
+
module ErrorMessages
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def project_blank
|
6
|
+
'Please specify a project.' + help
|
7
|
+
end
|
8
|
+
|
9
|
+
def handle_is_blank
|
10
|
+
'Please specify a new handle.' + help
|
11
|
+
end
|
12
|
+
|
13
|
+
def unknown_command
|
14
|
+
'Unknown command.' + help
|
15
|
+
end
|
16
|
+
|
17
|
+
def help(pad = true)
|
18
|
+
(pad ? ' ' : '') + "Run 'relish help' for usage information."
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/relish/helpers.rb
CHANGED
File without changes
|
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
|
+
s.version = "0.1.3"
|
4
4
|
|
5
5
|
s.required_rubygems_version = '>= 1.3.5'
|
6
6
|
s.authors = ["Matt Wynne", "Justin Ko"]
|
7
|
-
s.date = "2010-11-
|
7
|
+
s.date = "2010-11-17"
|
8
8
|
s.description = %q{Client gem for http://relishapp.com}
|
9
9
|
s.email = "jko170@gmail.com"
|
10
10
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Relish
|
4
|
+
describe ErrorMessages do
|
5
|
+
|
6
|
+
describe '#project_blank' do
|
7
|
+
specify do
|
8
|
+
described_class.project_blank.should eq(
|
9
|
+
"Please specify a project. Run 'relish help' for usage information."
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#handle_is_blank' do
|
15
|
+
specify do
|
16
|
+
described_class.handle_is_blank.should eq(
|
17
|
+
"Please specify a new handle. Run 'relish help' for usage information."
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#unknown_command' do
|
23
|
+
specify do
|
24
|
+
described_class.unknown_command.should eq(
|
25
|
+
"Unknown command. Run 'relish help' for usage information."
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
File without changes
|
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:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
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-
|
19
|
+
date: 2010-11-17 00:00:00 -07:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -196,11 +196,12 @@ files:
|
|
196
196
|
- lib/relish/commands/dsl/help_text.rb
|
197
197
|
- lib/relish/commands/dsl/option.rb
|
198
198
|
- lib/relish/commands/help.rb
|
199
|
-
- lib/relish/commands/param_methods.rb
|
200
199
|
- lib/relish/commands/projects.rb
|
201
200
|
- lib/relish/commands/push.rb
|
201
|
+
- lib/relish/error_messages.rb
|
202
202
|
- lib/relish/helpers.rb
|
203
203
|
- lib/relish/options_file.rb
|
204
|
+
- lib/relish/param_methods.rb
|
204
205
|
- lib/relish/ui.rb
|
205
206
|
- relish.gemspec
|
206
207
|
- spec/relish/command_spec.rb
|
@@ -209,10 +210,11 @@ files:
|
|
209
210
|
- spec/relish/commands/dsl/command_spec.rb
|
210
211
|
- spec/relish/commands/dsl/help_text_spec.rb
|
211
212
|
- spec/relish/commands/dsl/option_spec.rb
|
212
|
-
- spec/relish/commands/param_methods_spec.rb
|
213
213
|
- spec/relish/commands/projects_spec.rb
|
214
214
|
- spec/relish/commands/push_spec.rb
|
215
|
+
- spec/relish/error_messages_spec.rb
|
215
216
|
- spec/relish/options_file_spec.rb
|
217
|
+
- spec/relish/param_methods_spec.rb
|
216
218
|
- spec/relish_spec.rb
|
217
219
|
- spec/spec_helper.rb
|
218
220
|
- spec/support/context_class_examples.rb
|
@@ -265,10 +267,11 @@ test_files:
|
|
265
267
|
- spec/relish/commands/dsl/command_spec.rb
|
266
268
|
- spec/relish/commands/dsl/help_text_spec.rb
|
267
269
|
- spec/relish/commands/dsl/option_spec.rb
|
268
|
-
- spec/relish/commands/param_methods_spec.rb
|
269
270
|
- spec/relish/commands/projects_spec.rb
|
270
271
|
- spec/relish/commands/push_spec.rb
|
272
|
+
- spec/relish/error_messages_spec.rb
|
271
273
|
- spec/relish/options_file_spec.rb
|
274
|
+
- spec/relish/param_methods_spec.rb
|
272
275
|
- spec/relish_spec.rb
|
273
276
|
- spec/spec_helper.rb
|
274
277
|
- spec/support/context_class_examples.rb
|