Skip to content

Commit

Permalink
Fix for Ruby2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Feb 10, 2016
1 parent 749a5f7 commit b03637c
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ rvm:
- 2.0
- 2.1
- 2.2
- 2.3.0
- ruby-head

matrix:
allow_failures:
- rvm: 2.1
- rvm: ruby-head
fast_finish: true

Expand Down
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
source 'https://rubygems.org'

gemspec development_group: :test

gem 'phut', github: 'trema/phut', branch: 'develop'
6 changes: 3 additions & 3 deletions features/step_definitions/show_stats_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
when /-> (\S+) = (\d+) packet/
result[Regexp.last_match(1)] = Regexp.last_match(2).to_i
else
fail "Failed to parse line '#{each}'"
raise "Failed to parse line '#{each}'"
end
end
end
Expand Down Expand Up @@ -45,7 +45,7 @@
next unless received
result[Regexp.last_match(1)] = Regexp.last_match(3).to_i
else
fail "Failed to parse line '#{each}'"
raise "Failed to parse line '#{each}'"
end
end
end
Expand Down Expand Up @@ -74,7 +74,7 @@
next unless received
result += Regexp.last_match(3).to_i
else
fail "Failed to parse line '#{each}'"
raise "Failed to parse line '#{each}'"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion features/support/hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
end

Before('@sudo') do
fail 'sudo authentication failed' unless system 'sudo -v'
raise 'sudo authentication failed' unless system 'sudo -v'
@aruba_timeout_seconds = 15
end

Expand Down
2 changes: 1 addition & 1 deletion features/trema_run/conf_option.feature
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Feature: -c (--conf) option
"""
When I run `trema run null_controller.rb -c invalid_trema.conf`
Then the exit status should not be 0
Then the output should contain "uninitialized constant Phut::Syntax::Baz (NameError)"
Then the output should match /uninitialized constant .*::Baz \(NameError\)/

@sudo
Scenario: SyntaxError
Expand Down
6 changes: 3 additions & 3 deletions lib/trema/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class InvalidLoggingLevel < StandardError; end
# rubocop:disable ClassLength
class Command
def self.unix_domain_socket(name, check = false)
path = File.expand_path(File.join Phut.socket_dir, "#{name}.ctl")
path = File.expand_path(File.join(Phut.socket_dir, "#{name}.ctl"))
if check && !FileTest.socket?(path)
fail "Socket file #{path} does not exist."
raise "Socket file #{path} does not exist."
end
'drbunix:' + path
end
Expand Down Expand Up @@ -165,7 +165,7 @@ def trap_signals
# rubocop:enable MethodLength

def create_pid_file
fail "#{name} is already running." if running?
raise "#{name} is already running." if running?
update_pid_file
end

Expand Down
10 changes: 5 additions & 5 deletions lib/trema/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class << self

include Pio

SWITCH = {}
SWITCH = {} # rubocop:disable MutableConstant
DEFAULT_TCP_PORT = 6653

# @return [Logger]
Expand All @@ -136,7 +136,7 @@ def self.inherited(subclass)
# @private
def self.create(port_number = DEFAULT_TCP_PORT)
unless @controller_klass
fail NoControllerDefined, 'No controller class is defined.'
raise NoControllerDefined, 'No controller class is defined.'
end
@controller_klass.new(port_number)
end
Expand Down Expand Up @@ -178,7 +178,7 @@ def send_flow_mod_add(datapath_id, options)
when 'OpenFlow13'
FlowMod.new(FlowModAdd13Option.new(options).to_hash)
else
fail "Unsupported OpenFlow version: #{Pio::OpenFlow.version}"
raise "Unsupported OpenFlow version: #{Pio::OpenFlow.version}"
end
send_message datapath_id, flow_mod
end
Expand Down Expand Up @@ -314,14 +314,14 @@ def handle_openflow_message(datapath_id)
when :modify
maybe_send_handler :port_modify, datapath_id, message
else
fail "Invalid Port Status message: #{message.inspect}"
raise "Invalid Port Status message: #{message.inspect}"
end
when Barrier::Reply
maybe_send_handler :barrier_reply, datapath_id, message
when DescriptionStats::Reply
maybe_send_handler :description_stats_reply, datapath_id, message
else
fail "Unknown OpenFlow message: #{message.inspect}"
raise "Unknown OpenFlow message: #{message.inspect}"
end
end
# rubocop:enable MethodLength
Expand Down
8 changes: 4 additions & 4 deletions lib/trema/drb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ def self.trema_process(controller_name, socket_dir)
Phut.socket_dir = socket_dir
socket_path = File.join(Phut.socket_dir, "#{controller_name}.ctl")
unless FileTest.socket?(socket_path)
fail %(Controller process "#{controller_name}" does not exist.)
raise %(Controller process "#{controller_name}" does not exist.)
end
DRbObject.new_with_uri('drbunix:' + socket_path)
end

def self.trema_processes(socket_dir = Phut.socket_dir)
Phut.socket_dir = socket_dir
all = Dir.glob(File.join Phut.socket_dir, '*.ctl')
vhosts = Dir.glob(File.join Phut.socket_dir, 'vhost.*.ctl')
all = Dir.glob(File.join(Phut.socket_dir, '*.ctl'))
vhosts = Dir.glob(File.join(Phut.socket_dir, 'vhost.*.ctl'))
(all - vhosts).map { |each| DRbObject.new_with_uri("drbunix:#{each}") }
end

Expand All @@ -27,6 +27,6 @@ def self.fetch(name, socket_dir)
next
end
end
fail %("#{name}" does not exist.)
raise %("#{name}" does not exist.)
end
end
8 changes: 4 additions & 4 deletions lib/trema/switch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ def init
end

def datapath_id
fail 'Switch is not initialized.' unless @features_reply
raise 'Switch is not initialized.' unless @features_reply
@features_reply.datapath_id
end
alias_method :dpid, :datapath_id
alias dpid datapath_id

def write(message)
@socket.write message.to_binary
Expand Down Expand Up @@ -68,7 +68,7 @@ def expect_receiving(expected_message_klass)
@error_message = message
fail InitError, message.description
else
fail "Failed to receive #{expected_message_klass} message"
raise "Failed to receive #{expected_message_klass} message"
end
end
end
Expand All @@ -78,7 +78,7 @@ def read_openflow_binary
header_binary = drain(OPENFLOW_HEADER_LENGTH)
header = OpenFlowHeaderParser.read(header_binary)
body_binary = drain(header.message_length - OPENFLOW_HEADER_LENGTH)
fail if (header_binary + body_binary).length != header.message_length
raise if (header_binary + body_binary).length != header.message_length
header_binary + body_binary
end

Expand Down
12 changes: 6 additions & 6 deletions trema.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ Gem::Specification.new do |gem|

gem.add_dependency 'bundler', '~> 1.11.2'
gem.add_dependency 'gli', '~> 2.13.4'
# gem.add_dependency 'phut', '~> 0.7.5'
gem.add_dependency 'phut', '~> 0.7.6'
gem.add_dependency 'pio', '~> 0.30.0'

# Docs
gem.add_development_dependency 'relish', '~> 0.7.1'
gem.add_development_dependency 'yard', '~> 0.8.7.6'

# Test
gem.add_development_dependency 'aruba', '~> 0.11.2'
gem.add_development_dependency 'aruba', '~> 0.13.0'
gem.add_development_dependency 'codeclimate-test-reporter', '~> 0.4.8'
gem.add_development_dependency 'coveralls', '~> 0.8.10'
gem.add_development_dependency 'cucumber', '~> 2.1.0'
gem.add_development_dependency 'cucumber', '~> 2.3.2'
gem.add_development_dependency 'rake'
gem.add_development_dependency 'reek', '~> 3.7.1'
gem.add_development_dependency 'reek', '~> 3.10.0'
gem.add_development_dependency 'rspec', '~> 3.4.0'
gem.add_development_dependency 'rspec-given', '~> 3.7.1'
gem.add_development_dependency 'rubocop', '~> 0.35.1'
gem.add_development_dependency 'rspec-given', '~> 3.8.0'
gem.add_development_dependency 'rubocop', '~> 0.37.0'
end

0 comments on commit b03637c

Please sign in to comment.