Skip to content
This repository
Browse code

Use explicit publisher ID

this avoids passing slashes in a URL segment, which has been causing problems when running Relish on apache.
  • Loading branch information...
commit e2019865a536761fd143be5e2780ddb308b2a8a4 1 parent ffafb37
Matt Wynne mattwynne authored
2  Gemfile
... ... @@ -1,4 +1,4 @@
1   -source :rubygems
  1 +source 'https://rubygems.org'
2 2 gemspec
3 3
4 4 platforms :jruby do
15 lib/relish/commands/handle.rb
... ... @@ -0,0 +1,15 @@
  1 +module Relish
  2 + module Commands
  3 + class Handle
  4 + def initialize(string)
  5 + @project_id, @publisher_id = *string.split('/').reverse
  6 + end
  7 +
  8 + def resource_url
  9 + result = "projects/#{@project_id}"
  10 + result << "?publisher_id=#{@publisher_id}" if @publisher_id
  11 + result
  12 + end
  13 + end
  14 + end
  15 +end
11 lib/relish/commands/projects.rb
... ... @@ -1,3 +1,5 @@
  1 +require 'relish/commands/handle'
  2 +
1 3 module Relish
2 4 module Command
3 5 class Projects < Base
@@ -18,14 +20,14 @@ class Projects < Base
18 20 usage 'projects:remove <project>'
19 21 desc 'remove a project'
20 22 command :remove do
21   - puts resource["projects/#{escape(handle_to_remove)}"].delete
  23 + puts resource[resource_url(handle_to_remove)].delete
22 24 end
23 25
24 26 usage 'projects:visibility <project>:<public or private>'
25 27 desc 'set the status of a project',
26 28 'example: relish projects:visibility rspec/rspec-core:private'
27 29 command :visibility do
28   - puts resource["projects/#{escape(handle_to_update)}"].put(
  30 + puts resource[resource_url(handle_to_update)].put(
29 31 :project => { :private => private? }
30 32 )
31 33 end
@@ -34,7 +36,7 @@ class Projects < Base
34 36 desc "rename a project's handle",
35 37 'example: relish projects:rename rspec/rspec-core:rspec-corez'
36 38 command :rename do
37   - puts resource["projects/#{escape(handle_to_update)}"].put(
  39 + puts resource[resource_url(handle_to_update)].put(
38 40 :project => { :handle => rename_handle }
39 41 )
40 42 end
@@ -70,6 +72,9 @@ def private?
70 72 @param.extract_option == 'private'
71 73 end
72 74
  75 + def resource_url(handle)
  76 + Commands::Handle.new(handle).resource_url
  77 + end
73 78 end
74 79 end
75 80 end
2  lib/relish/version.rb
... ... @@ -1,6 +1,6 @@
1 1 module Relish
2 2 module Version
3   - STRING = '0.6'
  3 + STRING = '0.7'
4 4 end
5 5 end
6 6
3  relish.gemspec
@@ -7,7 +7,6 @@ Gem::Specification.new do |s|
7 7
8 8 s.required_rubygems_version = '>= 1.3.5'
9 9 s.authors = ["Matt Wynne", "Justin Ko"]
10   - s.date = Date.today
11 10 s.description = %q{Client gem for http://relishapp.com}
12 11 s.email = "matt@mattwynne.net"
13 12
@@ -30,7 +29,7 @@ Gem::Specification.new do |s|
30 29 end
31 30
32 31 {
33   - 'bundler' => '~> 1.2.0.pre.1',
  32 + 'bundler' => '~> 1.3',
34 33 'rake' => '~> 0.8.7',
35 34 'rspec' => '~> 2.8.0',
36 35 'cucumber' => '~> 1.0.2',
23 spec/relish/commands/handle_spec.rb
... ... @@ -0,0 +1,23 @@
  1 +require 'relish/commands/handle'
  2 +
  3 +module Relish
  4 + module Commands
  5 + describe Handle do
  6 + context "converting to resource URL" do
  7 + context "with publisher and project id" do
  8 + handle = Handle.new('foo/bar')
  9 + it "converts to a URL with a querystring parameter" do
  10 + handle.resource_url.should == "projects/bar?publisher_id=foo"
  11 + end
  12 + end
  13 +
  14 + context "with project id only" do
  15 + handle = Handle.new('bar')
  16 + it "converts to one querystring parameter" do
  17 + handle.resource_url.should == "projects/bar"
  18 + end
  19 + end
  20 + end
  21 + end
  22 + end
  23 +end

0 comments on commit e201986

Please sign in to comment.
Something went wrong with that request. Please try again.