diff --git a/.gitignore b/.gitignore index 86339a0..7c574a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ +.bundle +.DS_Store +.rvmrc *.gem \ No newline at end of file diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..df87cd4 --- /dev/null +++ b/Gemfile @@ -0,0 +1,2 @@ +source :rubygems +gemspec \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..4fe1e89 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,51 @@ +PATH + remote: . + specs: + relish (0.0.1) + +GEM + remote: http://rubygems.org/ + specs: + archive-tar-minitar (0.5.2) + aruba (0.2.2) + builder (2.1.2) + cucumber (0.8.5) + builder (~> 2.1.2) + diff-lcs (~> 1.1.2) + gherkin (~> 2.1.4) + json_pure (~> 1.4.3) + term-ansicolor (~> 1.0.4) + diff-lcs (1.1.2) + gherkin (2.1.5) + trollop (~> 1.16.2) + json_pure (1.4.6) + mime-types (1.16) + rake (0.8.7) + rest-client (1.6.1) + mime-types (>= 1.16) + rspec (2.0.0.beta.22) + rspec-core (= 2.0.0.beta.22) + rspec-expectations (= 2.0.0.beta.22) + rspec-mocks (= 2.0.0.beta.22) + rspec-core (2.0.0.beta.22) + rspec-expectations (2.0.0.beta.22) + diff-lcs (>= 1.1.2) + rspec-mocks (2.0.0.beta.22) + rspec-core (= 2.0.0.beta.22) + rspec-expectations (= 2.0.0.beta.22) + term-ansicolor (1.0.5) + trollop (1.16.2) + +PLATFORMS + ruby + +DEPENDENCIES + archive-tar-minitar (~> 0.5.2) + aruba (~> 0.2.1) + bundler (~> 1.0.0) + cucumber (~> 0.8.5) + rake (~> 0.8.7) + relish! + rest-client (~> 1.6.1) + rspec (~> 2.0.0.beta.22) + trollop (~> 1.16.2) diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..f295e9f --- /dev/null +++ b/Rakefile @@ -0,0 +1,8 @@ +require 'bundler' +require 'bundler/setup' +Bundler::GemHelper.install_tasks + +require 'rake' +require 'rspec/core/rake_task' + +RSpec::Core::RakeTask.new(:spec) \ No newline at end of file diff --git a/lib/relish.rb b/lib/relish.rb new file mode 100644 index 0000000..946933e --- /dev/null +++ b/lib/relish.rb @@ -0,0 +1,2 @@ +require 'relish/helpers' +require 'relish/command' \ No newline at end of file diff --git a/lib/relish/cli/options.rb b/lib/relish/cli/options.rb index fc2c101..84b0466 100644 --- a/lib/relish/cli/options.rb +++ b/lib/relish/cli/options.rb @@ -1,11 +1,10 @@ -require 'rubygems' require 'trollop' -require 'relish/commands/push_command' +require 'relish/commands/push' module Relish module Cli class OptionsParser < Trollop::Parser - COMMANDS = { 'push' => Commands::PushCommand } + COMMANDS = { 'push' => Commands::Push } def initialize(error_stream, out_stream) super diff --git a/lib/relish/command.rb b/lib/relish/command.rb new file mode 100644 index 0000000..3cb13b9 --- /dev/null +++ b/lib/relish/command.rb @@ -0,0 +1,2 @@ +require 'relish/commands/base' +require 'relish/commands/push' \ No newline at end of file diff --git a/lib/relish/commands/base.rb b/lib/relish/commands/base.rb new file mode 100644 index 0000000..ca3d94d --- /dev/null +++ b/lib/relish/commands/base.rb @@ -0,0 +1,12 @@ +module Relish + module Command + class Base + include Relish::Helpers + + def api_token + File.read("#{home_directory}/.relish/api_token") + end + + end + end +end \ No newline at end of file diff --git a/lib/relish/commands/push_command.rb b/lib/relish/commands/push.rb similarity index 79% rename from lib/relish/commands/push_command.rb rename to lib/relish/commands/push.rb index 4b97f09..398be88 100644 --- a/lib/relish/commands/push_command.rb +++ b/lib/relish/commands/push.rb @@ -4,8 +4,9 @@ require 'rest_client' module Relish - module Commands - class PushCommand + module Command + class Push < Base + def initialize(global_options) @options = global_options end @@ -39,10 +40,6 @@ def url end end - def api_token - File.read("#{home_directory}/.relish/api_token") - end - def features_as_tar_gz stream = StringIO.new @@ -64,17 +61,6 @@ def files Dir['features/**/*.{feature,md}'] end - def home_directory - running_on_windows? ? ENV['USERPROFILE'] : ENV['HOME'] - end - - def running_on_windows? - RUBY_PLATFORM =~ /mswin32|mingw32/ - end - - def running_on_a_mac? - RUBY_PLATFORM =~ /-darwin\d/ - end end end end \ No newline at end of file diff --git a/lib/relish/helpers.rb b/lib/relish/helpers.rb new file mode 100644 index 0000000..839a9bf --- /dev/null +++ b/lib/relish/helpers.rb @@ -0,0 +1,15 @@ +module Relish + module Helpers + def home_directory + running_on_windows? ? ENV['USERPROFILE'] : ENV['HOME'] + end + + def running_on_windows? + RUBY_PLATFORM =~ /mswin32|mingw32/ + end + + def running_on_a_mac? + RUBY_PLATFORM =~ /-darwin\d/ + end + end +end \ No newline at end of file diff --git a/relish.gemspec b/relish.gemspec index fca6817..6d892b5 100644 --- a/relish.gemspec +++ b/relish.gemspec @@ -2,47 +2,31 @@ Gem::Specification.new do |s| s.name = "relish" s.version = "0.0.1" - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.required_rubygems_version = '>= 1.3.5' s.authors = ["Matt Patterson", "Matt Wynne", "Justin Ko"] s.date = "2010-09-23" s.description = %q{Client gem for http://relishapp.com} - s.email = "matt@reprocessed.org" - s.extra_rdoc_files = [ - "LICENSE", - "README.md" - ] - s.files = Dir.glob([ - "VERSION", - "README.md", - "LICENSE", - "Rakefile", - "lib/**/*.rb", - ]) + s.email = "jko170@gmail.com" + s.homepage = "http://relishapp.com" s.rdoc_options = ["--charset=UTF-8"] - s.require_paths = ["lib"] s.rubygems_version = "1.3.6" s.summary = %q{Client gem for http://relishapp.com} - s.test_files = Dir.glob([ - "spec/spec.opts", - "spec/**/*.rb", - "features/**/*.rb", - "features/**/*.feature" - ]) - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 3 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - s.add_development_dependency(%q, [">= 1.2.9"]) - s.add_development_dependency(%q, [">= 0.5"]) - else - s.add_dependency(%q, [">= 1.2.9"]) - s.add_dependency(%q, [">= 0.5"]) - end - else - s.add_dependency(%q, [">= 1.2.9"]) - s.add_dependency(%q, [">= 0.5"]) + s.require_path = "lib" + s.files = `git ls-files`.split("\n") + s.test_files = `git ls-files -- {spec,features}/*`.split("\n") + + { + 'bundler' => '~> 1.0.0', + 'rake' => '~> 0.8.7', + 'archive-tar-minitar' => '~> 0.5.2', + 'rest-client' => '~> 1.6.1', + 'trollop' => '~> 1.16.2', + 'rspec' => '~> 2.0.0.beta.22', + 'cucumber' => '~> 0.8.5', + 'aruba' => '~> 0.2.1' + }.each do |lib, version| + s.add_development_dependency lib, version end end \ No newline at end of file diff --git a/spec/relish/commands/base_spec.rb b/spec/relish/commands/base_spec.rb new file mode 100644 index 0000000..c8706b7 --- /dev/null +++ b/spec/relish/commands/base_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +module Relish + module Command + describe Base do + + describe '#api_token' do + let(:base) { described_class.new } + + it 'calls File.read with the correct path' do + base.should_receive(:home_directory).and_return('~') + File.should_receive(:read).with('~/.relish/api_token') + base.api_token + end + end + + end + end +end \ No newline at end of file diff --git a/spec/relish/commands/push_spec.rb b/spec/relish/commands/push_spec.rb new file mode 100644 index 0000000..f7ff187 --- /dev/null +++ b/spec/relish/commands/push_spec.rb @@ -0,0 +1,8 @@ +require 'spec_helper' + +module Relish + module Command + describe Push do + end + end +end \ No newline at end of file diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..3fdee79 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,9 @@ +require 'rubygems' +require 'bundler' +Bundler.setup + +require 'relish' + +RSpec.configure do |config| + config.color_enabled = true +end \ No newline at end of file