Skip to content

Commit

Permalink
Merge pull request #39 from AngelList/fix_ruby_2_4_deprecations
Browse files Browse the repository at this point in the history
support ruby 2.4.3
  • Loading branch information
xinranxiao authored Feb 15, 2018
2 parents f0bb6e4 + e7b048c commit 36a2fb9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ language: ruby
cache: bundler
rvm:
- 2.2.2
- 2.4.3
gemfile:
- Gemfile
- gemfiles/Gemfile.rails-3.2
- gemfiles/Gemfile.rails-4
- gemfiles/Gemfile.rails-5
4 changes: 2 additions & 2 deletions lib/protip/decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,15 @@ def to_protobuf_value(field, value)
transformer.to_message(value, field)
end
elsif field.type == :enum
value.is_a?(Fixnum) ? value : value.to_sym
value.is_a?(1.class) ? value : value.to_sym
else
value
end
end

def matches?(field, value)
enum = Protip::Decorator.enum_for_field(field)
if value.is_a?(Fixnum)
if value.is_a?(1.class)
sym = enum.lookup_value(value)
else
sym = value.to_sym
Expand Down
2 changes: 1 addition & 1 deletion lib/protip/transformers/enum_transformer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def enum_for_field(field)
# // ScalarTransformer.to_int(:BAZ) # => 1
# // ScalarTransformer.to_int(4) # => 4
def to_int(symbol_or_int, field)
if symbol_or_int.is_a?(Fixnum)
if symbol_or_int.is_a?(1.class)
symbol_or_int
else
# Convert +.to_sym+ explicitly to allow strings (or other
Expand Down
4 changes: 2 additions & 2 deletions protip.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: utf-8
Gem::Specification.new do |spec|
spec.name = 'protip'
spec.version = '0.31.2'
spec.version = '0.32.0'
spec.summary = 'Relatively painless protocol buffers in Ruby.'
spec.licenses = ['MIT']
spec.homepage = 'https://github.com/AngelList/protip'
Expand All @@ -28,5 +28,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'simplecov', '~> 0.10'
spec.add_development_dependency 'pry', '~> 0.10'
spec.add_development_dependency 'webmock', '~> 1.20'
spec.add_development_dependency 'webmock', '~> 3.3.0'
end
6 changes: 3 additions & 3 deletions test/unit/protip/decorator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ class << self
end
end

describe 'when given a Fixnum' do
describe 'when given a Fixnum/Integer' do
before do
decorator.number = :ONE
end
Expand All @@ -609,7 +609,7 @@ class << self
end
end

describe 'when given a non-Fixnum' do
describe 'when given a non-Fixnum/Integer' do
before do
decorator.number = :TWO
end
Expand Down Expand Up @@ -656,7 +656,7 @@ class << self
refute decorator.number_message?(m)
end

it 'returns true when a Fixnum argument matches the value' do
it 'returns true when a Fixnum/Integer argument matches the value' do
assert decorator.number_message?(1)
end

Expand Down

0 comments on commit 36a2fb9

Please sign in to comment.