Skip to content

Commit

Permalink
Merge pull request #17 from citizen428/master
Browse files Browse the repository at this point in the history
Make gem work with Ruby < 2.4 and >= 2.4
  • Loading branch information
M. Cetin authored May 28, 2019
2 parents e66b0c3 + 49add50 commit 15dbe53
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.3
2.6.3
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ language: ruby
cache: bundler
sudo: false
rvm:
- 2.0.0
- 2.1
- 2.2.5
- 2.3.1
- ruby-head
- 2.0.0
- 2.1
- 2.2.5
- 2.3.1
- 2.4.6
- 2.5.5
- 2.6.3
- ruby-head
# uncomment this line if your project needs to run something other than `rake`:
# script: bundle exec rspec spec
1 change: 1 addition & 0 deletions lib/textoken.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'yaml'

require 'textoken/version'
require 'textoken/compat'
require 'textoken/base'
require 'textoken/errors'
require 'textoken/searcher'
Expand Down
1 change: 1 addition & 0 deletions lib/textoken/compat.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
IntClass = defined?(RUBY_VERSION) && RUBY_VERSION > "2.4" ? Integer : Fixnum
7 changes: 2 additions & 5 deletions lib/textoken/errors.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
module Textoken
class ExpressionError < Exception
end

class TypeError < Exception
end
ExpressionError = Class.new(StandardError)
TypeError = Class.new(StandardError)
end
4 changes: 2 additions & 2 deletions lib/textoken/findings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def push(index, word)

# collection will return a sorted and unique array of tokens
def collection
@collection.uniq { |w| w[0].to_s + w[1] }.sort_by(&:first)
@collection.uniq { |w| "#{w[0]}#{w[1]}" }.sort_by(&:first)
end

# result will return a one dimensional array of words
Expand All @@ -27,7 +27,7 @@ def result
private

def type_check(i, word)
return if word.is_a?(String) && (i.is_a?(Fixnum) || i.is_a?(Float))
return if word.is_a?(String) && (i.is_a?(IntClass) || i.is_a?(Float))
Textoken.type_err("#{word} and #{i} has to be a String and Integer")
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/textoken/options/modules/numeric_option.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def tokenize_if(&code)
end

def validate(&code)
return if number.class == Fixnum && code.call(number)
return if number.class == IntClass && code.call(number)
Textoken.expression_err "value #{number} is not permitted for
#{self.class.name} option."
end
Expand Down
2 changes: 1 addition & 1 deletion lib/textoken/scanner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def result

def partition(scan, word)
scan.each do |p|
word = word.gsub(p, ' ' + p + ' ')
word = word.gsub(p, " #{p} ")
end
word.split(' ')
end
Expand Down

0 comments on commit 15dbe53

Please sign in to comment.