-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from manorie/development
Refactorings.
- Loading branch information
Showing
13 changed files
with
114 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
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
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
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,18 @@ | ||
module Textoken | ||
# This module will be shared in options like, only_regexp and exclude_regexp | ||
module TokenizableOption | ||
attr_reader :base | ||
|
||
def tokenize(base) | ||
@base = base | ||
tokenize_condition | ||
end | ||
|
||
private | ||
|
||
def tokenize_condition | ||
Textoken.type_err('tokenize_condition method has to be implemented | ||
for Options.') | ||
end | ||
end | ||
end |
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
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,3 +1,3 @@ | ||
module Textoken | ||
VERSION = "1.1.0" | ||
VERSION = "1.1.1" | ||
end |
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
50 changes: 50 additions & 0 deletions
50
spec/lib/textoken/options/modules/tokenizable_option_spec.rb
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,50 @@ | ||
require 'spec_helper' | ||
|
||
module Textoken | ||
# A test dummy | ||
class TheDumy | ||
include TokenizableOption | ||
|
||
private | ||
|
||
def tokenize_condition | ||
end | ||
end | ||
end | ||
|
||
module Textoken | ||
# Another test dummy | ||
class TheErrorDumy | ||
include TokenizableOption | ||
end | ||
end | ||
|
||
describe Textoken::TokenizableOption do | ||
describe '#tokenize' do | ||
context 'sets the base' do | ||
it 'as expected' do | ||
t = Textoken::TheDumy.new | ||
object = Object.new | ||
t.tokenize(object) | ||
expect(t.base).to eq(object) | ||
end | ||
end | ||
|
||
context 'sends tokenize_condition' do | ||
it 'as expected' do | ||
t = Textoken::TheDumy.new | ||
expect(t).to receive(:tokenize_condition) | ||
t.tokenize(Object.new) | ||
end | ||
end | ||
|
||
context 'raises error when not implemented' do | ||
it 'as expected' do | ||
t = Textoken::TheErrorDumy.new | ||
expect do | ||
t.tokenize(Object.new) | ||
end.to raise_error(Textoken::TypeError) | ||
end | ||
end | ||
end | ||
end |
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