This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extend an object, not open core class
- Loading branch information
Showing
6 changed files
with
45 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
require 'relish/core_ext' | ||
|
||
module Relish | ||
class << self | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file was deleted.
Oops, something went wrong.