Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
extend an object, not open core class
Browse files Browse the repository at this point in the history
  • Loading branch information
justinko committed Nov 15, 2010
1 parent bd743ad commit cdb825d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 40 deletions.
2 changes: 0 additions & 2 deletions lib/relish.rb
@@ -1,5 +1,3 @@
require 'relish/core_ext'

module Relish
class << self

Expand Down
3 changes: 2 additions & 1 deletion lib/relish/commands/base.rb
Expand Up @@ -4,6 +4,7 @@
require 'relish/helpers'
require 'relish/options_file'
require 'relish/commands/dsl'
require 'relish/commands/param_methods'

module Relish
module Command
Expand All @@ -19,7 +20,7 @@ class Base

def initialize(args = [])
@args = clean_args(args)
@param = get_param
@param = get_param.extend(ParamMethods)
@cli_options = Hash[*@args]

validate_cli_options
Expand Down
17 changes: 17 additions & 0 deletions lib/relish/commands/param_methods.rb
@@ -0,0 +1,17 @@
module Relish
module Command
module ParamMethods
def extract_option
include?(':') ? split(':')[1] : self
end

def without_option
split(':')[0]
end

def has_option?
include?(':')
end
end
end
end
19 changes: 0 additions & 19 deletions lib/relish/core_ext.rb

This file was deleted.

26 changes: 26 additions & 0 deletions spec/relish/commands/param_methods_spec.rb
@@ -0,0 +1,26 @@
require 'spec_helper'

module Relish
module Command
describe ParamMethods do
let(:foo_bar) { 'foo:bar'.extend(described_class) }
let(:foo) { 'foo'.extend(described_class) }

describe '#extract_option' do
specify { foo_bar.extract_option.should eq('bar') }
specify { foo.extract_option.should eq('foo') }
end

describe '#without_option' do
specify { foo_bar.without_option.should eq('foo') }
specify { foo.without_option.should eq('foo') }
end

describe '#has_option?' do
specify { foo_bar.has_option?.should be_true }
specify { foo.has_option?.should be_false }
end

end
end
end
18 changes: 0 additions & 18 deletions spec/relish/core_ext_spec.rb

This file was deleted.

0 comments on commit cdb825d

Please sign in to comment.