relish 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ .bundle
2
+ .DS_Store
3
+ .rvmrc
4
+ *.gem
5
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
@@ -0,0 +1,53 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ relish (0.0.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ archive-tar-minitar (0.5.2)
10
+ aruba (0.2.2)
11
+ builder (2.1.2)
12
+ cucumber (0.9.1)
13
+ builder (~> 2.1.2)
14
+ diff-lcs (~> 1.1.2)
15
+ gherkin (~> 2.2.5)
16
+ json (~> 1.4.6)
17
+ term-ansicolor (~> 1.0.5)
18
+ diff-lcs (1.1.2)
19
+ gherkin (2.2.7)
20
+ json (~> 1.4.6)
21
+ term-ansicolor (~> 1.0.5)
22
+ trollop (~> 1.16.2)
23
+ json (1.4.6)
24
+ mime-types (1.16)
25
+ rake (0.8.7)
26
+ rest-client (1.6.1)
27
+ mime-types (>= 1.16)
28
+ rspec (2.0.0.beta.22)
29
+ rspec-core (= 2.0.0.beta.22)
30
+ rspec-expectations (= 2.0.0.beta.22)
31
+ rspec-mocks (= 2.0.0.beta.22)
32
+ rspec-core (2.0.0.beta.22)
33
+ rspec-expectations (2.0.0.beta.22)
34
+ diff-lcs (>= 1.1.2)
35
+ rspec-mocks (2.0.0.beta.22)
36
+ rspec-core (= 2.0.0.beta.22)
37
+ rspec-expectations (= 2.0.0.beta.22)
38
+ term-ansicolor (1.0.5)
39
+ trollop (1.16.2)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ archive-tar-minitar (~> 0.5.2)
46
+ aruba (~> 0.2.2)
47
+ bundler (~> 1.0.0)
48
+ cucumber (~> 0.9.1)
49
+ rake (~> 0.8.7)
50
+ relish!
51
+ rest-client (~> 1.6.1)
52
+ rspec (~> 2.0.0.beta.22)
53
+ trollop (~> 1.16.2)
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2008,2009 Matt Patterson, Matt Wynne, Justin Ko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ Hello
@@ -0,0 +1,8 @@
1
+ require 'bundler'
2
+ require 'bundler/setup'
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ require 'rake'
6
+ require 'rspec/core/rake_task'
7
+
8
+ RSpec::Core::RakeTask.new
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
3
+
4
+ args = ARGV.dup
5
+ ARGV.clear
6
+ command = args.shift.strip rescue 'help'
7
+
8
+ Relish::Cli::Runner.run(command, $stderr, $stdout)
@@ -0,0 +1,8 @@
1
+ Feature: Push
2
+ As a Relish user
3
+ In order to push my features to the Relish server
4
+ I want to run the relish push command
5
+
6
+ Scenario: Push one feature file to a project
7
+ Given pending
8
+
@@ -0,0 +1 @@
1
+ require 'aruba'
@@ -0,0 +1,2 @@
1
+ require 'relish/helpers'
2
+ require 'relish/command'
@@ -0,0 +1,51 @@
1
+ require 'trollop'
2
+ require 'relish/commands/push'
3
+
4
+ module Relish
5
+ module Cli
6
+ class OptionsParser < Trollop::Parser
7
+
8
+ COMMANDS = { 'push' => Commands::Push }
9
+
10
+ def initialize(error_stream, out_stream)
11
+ super
12
+
13
+ banner "This is the relish gem. Valid commands are: #{valid_commands.join(",")}"
14
+
15
+ opt :help, "Show help information"
16
+ opt :host, "Host to connect to", :short => '-h', :type => String
17
+ opt :account, "Account to connect to", :short => '-a', :type => String
18
+ opt :project, "Project to connect to", :short => '-p', :type => String
19
+ opt :version, "Version to connect to", :short => '-v', :type => String
20
+
21
+ stop_on valid_commands
22
+ end
23
+
24
+ def command(args)
25
+ Trollop.with_standard_exception_handling(self) do
26
+ global_options = parse(args)
27
+ grab_command(global_options)
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def grab_command(global_options)
34
+ command_name = leftovers.shift
35
+ raise Trollop::HelpNeeded unless command_name
36
+ unless valid_commands.include?(command_name)
37
+ die("'#{command_name}' is not a relish command", nil)
38
+ end
39
+ command_class(command_name).new(global_options)
40
+ end
41
+
42
+ def valid_commands
43
+ COMMANDS.keys
44
+ end
45
+
46
+ def command_class(command_name)
47
+ COMMANDS[command_name] or raise(NotImplementedError)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,12 @@
1
+ require 'relish/cli/options'
2
+
3
+ module Relish
4
+ module Cli
5
+ class Runner
6
+ def self.run(args, error_stream, out_stream)
7
+ parser = OptionsParser.new(error_stream, out_stream)
8
+ parser.command(args).run
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ require 'relish/commands/base'
2
+ require 'relish/commands/push'
@@ -0,0 +1,43 @@
1
+ require 'trollop'
2
+
3
+ module Relish
4
+ module Command
5
+ class Base
6
+ include Relish::Helpers
7
+
8
+ DEFAULT_HOST = 'relishapp.com'
9
+ LOCAL_OPTIONS_FILE = '.relish'
10
+
11
+ def initialize(global_options = {})
12
+ @options = global_options
13
+ end
14
+
15
+ [:account, :project].each do |meth|
16
+ define_method meth do
17
+ @options[meth] || parse_options_file[meth]
18
+ end
19
+ end
20
+
21
+ def host
22
+ @options[:host] || DEFAULT_HOST
23
+ end
24
+
25
+ def parse_options_file
26
+ @parsed_options_file ||= begin
27
+ if File.exist?(LOCAL_OPTIONS_FILE)
28
+ parser = Trollop::Parser.new
29
+ parser.opt :account, "", :short => '-a', :type => String
30
+ parser.opt :project, "", :short => '-p', :type => String
31
+ parser.opt :version, "", :short => '-v', :type => String
32
+ parser.parse(File.read(LOCAL_OPTIONS_FILE).split)
33
+ else {} end
34
+ end
35
+ end
36
+
37
+ def api_token
38
+ File.read("#{home_directory}/.relish/api_token")
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,60 @@
1
+ require 'zlib'
2
+ require 'archive/tar/minitar'
3
+ require 'stringio'
4
+ require 'rest_client'
5
+
6
+ module Relish
7
+ module Command
8
+ class Push < Base
9
+
10
+ def run
11
+ post files_as_tar_gz
12
+ end
13
+
14
+ def post(tar_gz_data)
15
+ resource = RestClient::Resource.new(url)
16
+ resource.post(tar_gz_data, :content_type => 'application/x-gzip')
17
+ puts "sent:\n#{files.join("\n")}"
18
+ rescue RestClient::ResourceNotFound,
19
+ RestClient::Unauthorized,
20
+ RestClient::BadRequest => exception
21
+
22
+ warn exception.response
23
+ exit 1
24
+ end
25
+
26
+ def url
27
+ "".tap do |str|
28
+ str << "http://#{host}/pushes?"
29
+ str << "account_id=#{account}&"
30
+ str << "project_id=#{project}&"
31
+ str << "version_id=#{version}&" if version
32
+ str << "api_token=#{api_token}"
33
+ end
34
+ end
35
+
36
+ def version
37
+ @options[:version]
38
+ end
39
+
40
+ def files_as_tar_gz
41
+ stream = StringIO.new
42
+ begin
43
+ tgz = Zlib::GzipWriter.new(stream)
44
+ tar = Archive::Tar::Minitar::Output.new(tgz)
45
+ files.each do |entry|
46
+ Archive::Tar::Minitar.pack_file(entry, tar)
47
+ end
48
+ ensure
49
+ tar.close if tar # Closes both tar and tgz.
50
+ end
51
+ stream.string
52
+ end
53
+
54
+ def files
55
+ Dir['features/**/*.{feature,md}']
56
+ end
57
+
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,15 @@
1
+ module Relish
2
+ module Helpers
3
+ def home_directory
4
+ running_on_windows? ? ENV['USERPROFILE'] : ENV['HOME']
5
+ end
6
+
7
+ def running_on_windows?
8
+ RUBY_PLATFORM =~ /mswin32|mingw32/
9
+ end
10
+
11
+ def running_on_a_mac?
12
+ RUBY_PLATFORM =~ /-darwin\d/
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,32 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "relish"
3
+ s.version = "0.0.1"
4
+
5
+ s.required_rubygems_version = '>= 1.3.5'
6
+ s.authors = ["Matt Patterson", "Matt Wynne", "Justin Ko"]
7
+ s.date = "2010-09-23"
8
+ s.description = %q{Client gem for http://relishapp.com}
9
+ s.email = "jko170@gmail.com"
10
+
11
+ s.homepage = "http://relishapp.com"
12
+ s.rdoc_options = ["--charset=UTF-8"]
13
+ s.rubygems_version = "1.3.6"
14
+ s.summary = %q{Client gem for http://relishapp.com}
15
+
16
+ s.require_path = "lib"
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
19
+
20
+ {
21
+ 'bundler' => '~> 1.0.0',
22
+ 'rake' => '~> 0.8.7',
23
+ 'archive-tar-minitar' => '~> 0.5.2',
24
+ 'rest-client' => '~> 1.6.1',
25
+ 'trollop' => '~> 1.16.2',
26
+ 'rspec' => '~> 2.0.0.beta.22',
27
+ 'cucumber' => '~> 0.9.1',
28
+ 'aruba' => '~> 0.2.2'
29
+ }.each do |lib, version|
30
+ s.add_development_dependency lib, version
31
+ end
32
+ end
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+
3
+ module Relish
4
+ module Command
5
+ describe Base do
6
+
7
+ {:account => 'rspec', :project => 'rspec-core'}.each do |meth, name|
8
+ describe "##{meth}" do
9
+ context 'passed in command line' do
10
+ let(:base) { described_class.new({meth => name}) }
11
+
12
+ it 'returns the value' do
13
+ base.send(meth).should eq(name)
14
+ end
15
+ end
16
+
17
+ context 'not passed in command line' do
18
+ let(:base) { described_class.new }
19
+
20
+ context 'and options file does not exist' do
21
+ it 'returns nil' do
22
+ base.send(meth).should be_nil
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+
29
+ describe '#host' do
30
+ context 'passed in command line' do
31
+ let(:base) { described_class.new({:host => 'test.com'}) }
32
+
33
+ it 'returns test.com' do
34
+ base.host.should eq('test.com')
35
+ end
36
+ end
37
+
38
+ context 'not passed in command line' do
39
+ let(:base) { described_class.new }
40
+
41
+ it 'returns the default host' do
42
+ base.host.should eq(Base::DEFAULT_HOST)
43
+ end
44
+ end
45
+ end
46
+
47
+ describe '#parse_options_file' do
48
+ let(:base) { described_class.new }
49
+
50
+ context 'with options file that exists' do
51
+ let(:options) do
52
+ '--account rspec --project rspec-core'
53
+ end
54
+
55
+ before do
56
+ File.stub(:exist?).and_return(true)
57
+ File.stub(:read).and_return(options)
58
+ end
59
+
60
+ it 'parses the account' do
61
+ base.parse_options_file[:account].should eq('rspec')
62
+ end
63
+
64
+ it 'parses the project' do
65
+ base.parse_options_file[:project].should eq('rspec-core')
66
+ end
67
+ end
68
+
69
+ context 'with options file that does not exist' do
70
+ before do
71
+ File.stub(:exist?).and_return(false)
72
+ end
73
+
74
+ it 'returns an empty hash' do
75
+ base.parse_options_file.should eq({})
76
+ end
77
+ end
78
+ end
79
+
80
+ describe '#api_token' do
81
+ let(:base) { described_class.new }
82
+
83
+ it 'calls File.read with the correct path' do
84
+ base.should_receive(:home_directory).and_return('~')
85
+ File.should_receive(:read).with('~/.relish/api_token')
86
+ base.api_token
87
+ end
88
+ end
89
+
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ module Relish
4
+ module Command
5
+ describe Push do
6
+
7
+ describe '#url' do
8
+ before do
9
+ push.should_receive(:account).and_return('rspec')
10
+ push.should_receive(:project).and_return('rspec')
11
+ push.should_receive(:api_token).and_return('abc')
12
+ end
13
+
14
+ context 'without version' do
15
+ let(:push) { described_class.new }
16
+
17
+ specify do
18
+ push.url.should eq(
19
+ "http://relishapp.com/pushes?account_id=rspec&project_id=rspec&api_token=abc"
20
+ )
21
+ end
22
+ end
23
+
24
+ context 'with version' do
25
+ let(:push) { described_class.new(:version => 'one') }
26
+
27
+ specify do
28
+ push.url.should eq(
29
+ "http://relishapp.com/pushes?" \
30
+ "account_id=rspec&project_id=rspec&version_id=one&api_token=abc"
31
+ )
32
+ end
33
+ end
34
+ end
35
+
36
+ describe '#version' do
37
+ context 'with :version in @options' do
38
+ let(:push) { described_class.new(:version => 'one') }
39
+ specify { push.version.should eq('one') }
40
+ end
41
+
42
+ context 'with :version not in @options' do
43
+ let(:push) { described_class.new }
44
+ specify { push.version.should be_nil }
45
+ end
46
+ end
47
+
48
+ describe '#files_as_tar_gz' do
49
+ let(:push) { described_class.new }
50
+ specify { expect { push.files_as_tar_gz }.to_not raise_exception }
51
+ specify { push.files_as_tar_gz.should be_a(String) }
52
+ end
53
+
54
+ describe '#files' do
55
+ let(:push) { described_class.new }
56
+ specify { expect { push.files }.to_not raise_exception }
57
+ specify { push.files.should be_a(Array) }
58
+ end
59
+
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+
5
+ require 'relish'
6
+
7
+ RSpec.configure do |config|
8
+ config.color_enabled = true
9
+ end
metadata ADDED
@@ -0,0 +1,223 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: relish
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Matt Patterson
14
+ - Matt Wynne
15
+ - Justin Ko
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2010-09-23 00:00:00 -04:00
21
+ default_executable:
22
+ dependencies:
23
+ - !ruby/object:Gem::Dependency
24
+ name: rake
25
+ prerelease: false
26
+ requirement: &id001 !ruby/object:Gem::Requirement
27
+ none: false
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ hash: 49
32
+ segments:
33
+ - 0
34
+ - 8
35
+ - 7
36
+ version: 0.8.7
37
+ type: :development
38
+ version_requirements: *id001
39
+ - !ruby/object:Gem::Dependency
40
+ name: rspec
41
+ prerelease: false
42
+ requirement: &id002 !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ hash: 62196431
48
+ segments:
49
+ - 2
50
+ - 0
51
+ - 0
52
+ - beta
53
+ - 22
54
+ version: 2.0.0.beta.22
55
+ type: :development
56
+ version_requirements: *id002
57
+ - !ruby/object:Gem::Dependency
58
+ name: aruba
59
+ prerelease: false
60
+ requirement: &id003 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ hash: 19
66
+ segments:
67
+ - 0
68
+ - 2
69
+ - 2
70
+ version: 0.2.2
71
+ type: :development
72
+ version_requirements: *id003
73
+ - !ruby/object:Gem::Dependency
74
+ name: rest-client
75
+ prerelease: false
76
+ requirement: &id004 !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ~>
80
+ - !ruby/object:Gem::Version
81
+ hash: 13
82
+ segments:
83
+ - 1
84
+ - 6
85
+ - 1
86
+ version: 1.6.1
87
+ type: :development
88
+ version_requirements: *id004
89
+ - !ruby/object:Gem::Dependency
90
+ name: trollop
91
+ prerelease: false
92
+ requirement: &id005 !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ hash: 83
98
+ segments:
99
+ - 1
100
+ - 16
101
+ - 2
102
+ version: 1.16.2
103
+ type: :development
104
+ version_requirements: *id005
105
+ - !ruby/object:Gem::Dependency
106
+ name: archive-tar-minitar
107
+ prerelease: false
108
+ requirement: &id006 !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ~>
112
+ - !ruby/object:Gem::Version
113
+ hash: 15
114
+ segments:
115
+ - 0
116
+ - 5
117
+ - 2
118
+ version: 0.5.2
119
+ type: :development
120
+ version_requirements: *id006
121
+ - !ruby/object:Gem::Dependency
122
+ name: bundler
123
+ prerelease: false
124
+ requirement: &id007 !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ~>
128
+ - !ruby/object:Gem::Version
129
+ hash: 23
130
+ segments:
131
+ - 1
132
+ - 0
133
+ - 0
134
+ version: 1.0.0
135
+ type: :development
136
+ version_requirements: *id007
137
+ - !ruby/object:Gem::Dependency
138
+ name: cucumber
139
+ prerelease: false
140
+ requirement: &id008 !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - ~>
144
+ - !ruby/object:Gem::Version
145
+ hash: 57
146
+ segments:
147
+ - 0
148
+ - 9
149
+ - 1
150
+ version: 0.9.1
151
+ type: :development
152
+ version_requirements: *id008
153
+ description: Client gem for http://relishapp.com
154
+ email: jko170@gmail.com
155
+ executables: []
156
+
157
+ extensions: []
158
+
159
+ extra_rdoc_files: []
160
+
161
+ files:
162
+ - .gitignore
163
+ - Gemfile
164
+ - Gemfile.lock
165
+ - LICENSE
166
+ - README.md
167
+ - Rakefile
168
+ - bin/relish
169
+ - features/push.feature
170
+ - features/support/env.rb
171
+ - lib/relish.rb
172
+ - lib/relish/cli/options.rb
173
+ - lib/relish/cli/runner.rb
174
+ - lib/relish/command.rb
175
+ - lib/relish/commands/base.rb
176
+ - lib/relish/commands/push.rb
177
+ - lib/relish/helpers.rb
178
+ - relish.gemspec
179
+ - spec/relish/commands/base_spec.rb
180
+ - spec/relish/commands/push_spec.rb
181
+ - spec/spec_helper.rb
182
+ has_rdoc: true
183
+ homepage: http://relishapp.com
184
+ licenses: []
185
+
186
+ post_install_message:
187
+ rdoc_options:
188
+ - --charset=UTF-8
189
+ require_paths:
190
+ - lib
191
+ required_ruby_version: !ruby/object:Gem::Requirement
192
+ none: false
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ hash: 3
197
+ segments:
198
+ - 0
199
+ version: "0"
200
+ required_rubygems_version: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ">="
204
+ - !ruby/object:Gem::Version
205
+ hash: 17
206
+ segments:
207
+ - 1
208
+ - 3
209
+ - 5
210
+ version: 1.3.5
211
+ requirements: []
212
+
213
+ rubyforge_project:
214
+ rubygems_version: 1.3.7
215
+ signing_key:
216
+ specification_version: 3
217
+ summary: Client gem for http://relishapp.com
218
+ test_files:
219
+ - features/push.feature
220
+ - features/support/env.rb
221
+ - spec/relish/commands/base_spec.rb
222
+ - spec/relish/commands/push_spec.rb
223
+ - spec/spec_helper.rb