Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Organization support.

  • Loading branch information...
commit 32f1cc0e0bcff6088f9212286280f310fb0f996a 1 parent 0d8dcbf
@justinko justinko authored
View
2  Gemfile.lock
@@ -16,6 +16,7 @@ GEM
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
diff-lcs (1.1.2)
+ fakeweb (1.3.0)
gherkin (2.2.7)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
@@ -46,6 +47,7 @@ DEPENDENCIES
aruba (~> 0.2.2)
bundler (~> 1.0.0)
cucumber (~> 0.9.1)
+ fakeweb (~> 1.3.0)
rake (~> 0.8.7)
relish!
rest-client (~> 1.6.1)
View
6 bin/relish
@@ -1,8 +1,6 @@
#!/usr/bin/env ruby
$:.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
-args = ARGV.dup
-ARGV.clear
-command = args.shift.strip rescue 'help'
+require 'relish/cli/runner'
-Relish::Cli::Runner.run(command, $stderr, $stdout)
+Relish::Cli::Runner.run(ARGV, $stderr, $stdout)
View
2  lib/relish.rb
@@ -1,2 +0,0 @@
-require 'relish/helpers'
-require 'relish/command'
View
14 lib/relish/cli/options.rb
@@ -1,22 +1,22 @@
require 'trollop'
-require 'relish/commands/push'
+require 'relish/command'
module Relish
module Cli
class OptionsParser < Trollop::Parser
- COMMANDS = { 'push' => Commands::Push }
+ COMMANDS = { 'push' => Command::Push }
def initialize(error_stream, out_stream)
super
banner "This is the relish gem. Valid commands are: #{valid_commands.join(",")}"
- opt :help, "Show help information"
- opt :host, "Host to connect to", :short => '-h', :type => String
- opt :account, "Account to connect to", :short => '-a', :type => String
- opt :project, "Project to connect to", :short => '-p', :type => String
- opt :version, "Version to connect to", :short => '-v', :type => String
+ opt :help, "Show help information"
+ opt :host, "Host to connect to", :short => '-h', :type => String
+ opt :organization, "Account to connect to", :short => '-o', :type => String
+ opt :project, "Project to connect to", :short => '-p', :type => String
+ opt :version, "Version to connect to", :short => '-v', :type => String
stop_on valid_commands
end
View
9 lib/relish/commands/base.rb
@@ -1,4 +1,5 @@
require 'trollop'
+require 'relish/helpers'
module Relish
module Command
@@ -12,7 +13,7 @@ def initialize(global_options = {})
@options = global_options
end
- [:account, :project].each do |meth|
+ [:organization, :project].each do |meth|
define_method meth do
@options[meth] || parse_options_file[meth]
end
@@ -26,9 +27,9 @@ def parse_options_file
@parsed_options_file ||= begin
if File.exist?(LOCAL_OPTIONS_FILE)
parser = Trollop::Parser.new
- parser.opt :account, "", :short => '-a', :type => String
- parser.opt :project, "", :short => '-p', :type => String
- parser.opt :version, "", :short => '-v', :type => String
+ parser.opt :organization, "", :short => '-o', :type => String
+ parser.opt :project, "", :short => '-p', :type => String
+ parser.opt :version, "", :short => '-v', :type => String
parser.parse(File.read(LOCAL_OPTIONS_FILE).split)
else {} end
end
View
2  lib/relish/commands/push.rb
@@ -26,7 +26,7 @@ def post(tar_gz_data)
def url
"".tap do |str|
str << "http://#{host}/pushes?"
- str << "account_id=#{account}&"
+ str << "creator_id=#{organization}&" if organization
str << "project_id=#{project}&"
str << "version_id=#{version}&" if version
str << "api_token=#{api_token}"
View
3  relish.gemspec
@@ -25,7 +25,8 @@ Gem::Specification.new do |s|
'trollop' => '~> 1.16.2',
'rspec' => '~> 2.0.0.beta.22',
'cucumber' => '~> 0.9.1',
- 'aruba' => '~> 0.2.2'
+ 'aruba' => '~> 0.2.2',
+ 'fakeweb' => '~> 1.3.0'
}.each do |lib, version|
s.add_development_dependency lib, version
end
View
6 spec/relish/commands/base_spec.rb
@@ -4,7 +4,7 @@ module Relish
module Command
describe Base do
- {:account => 'rspec', :project => 'rspec-core'}.each do |meth, name|
+ {:organization => 'rspec', :project => 'rspec-core'}.each do |meth, name|
describe "##{meth}" do
context 'passed in command line' do
let(:base) { described_class.new({meth => name}) }
@@ -49,7 +49,7 @@ module Command
context 'with options file that exists' do
let(:options) do
- '--account rspec --project rspec-core'
+ '--organization rspec --project rspec-core'
end
before do
@@ -58,7 +58,7 @@ module Command
end
it 'parses the account' do
- base.parse_options_file[:account].should eq('rspec')
+ base.parse_options_file[:organization].should eq('rspec')
end
it 'parses the project' do
View
6 spec/relish/commands/push_spec.rb
@@ -6,7 +6,6 @@ module Command
describe '#url' do
before do
- push.should_receive(:account).and_return('rspec')
push.should_receive(:project).and_return('rspec')
push.should_receive(:api_token).and_return('abc')
end
@@ -16,7 +15,7 @@ module Command
specify do
push.url.should eq(
- "http://relishapp.com/pushes?account_id=rspec&project_id=rspec&api_token=abc"
+ "http://relishapp.com/pushes?project_id=rspec&api_token=abc"
)
end
end
@@ -26,8 +25,7 @@ module Command
specify do
push.url.should eq(
- "http://relishapp.com/pushes?" \
- "account_id=rspec&project_id=rspec&version_id=one&api_token=abc"
+ "http://relishapp.com/pushes?project_id=rspec&version_id=one&api_token=abc"
)
end
end
View
2  spec/spec_helper.rb
@@ -2,7 +2,7 @@
require 'bundler'
Bundler.setup
-require 'relish'
+require 'relish/command'
RSpec.configure do |config|
config.color_enabled = true
Please sign in to comment.
Something went wrong with that request. Please try again.