Skip to content

Commit

Permalink
Use the new Ruby 1.9 hash syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Dec 6, 2016
1 parent 9dd52b4 commit 0c6c5c9
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 22 deletions.
3 changes: 0 additions & 3 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ Style/EachWithObject:
Style/Encoding:
Enabled: false

Style/HashSyntax:
EnforcedStyle: hash_rockets

Style/Lambda:
Enabled: false

Expand Down
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ source 'https://rubygems.org'
gem 'rake'
gem 'yard'

gem 'libxml-ruby', :require => nil, :platforms => :ruby
gem 'nokogiri', :require => nil
gem 'oga', '>= 2.3', :require => nil
gem 'ox', :require => nil, :platforms => :ruby
gem 'libxml-ruby', require: nil, platforms: :ruby
gem 'nokogiri', require: nil
gem 'oga', '>= 2.3', require: nil
gem 'ox', require: nil, platforms: :ruby

group :development do
gem 'kramdown'
Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)

task :test => :spec
task test: :spec

require 'rubocop/rake_task'
RuboCop::RakeTask.new
Expand All @@ -30,4 +30,4 @@ Yardstick::Rake::Verify.new do |verify|
verify.threshold = 48.8
end

task :default => [:spec, :rubocop, :verify_measurements]
task default: [:spec, :rubocop, :verify_measurements]
6 changes: 3 additions & 3 deletions lib/multi_xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def initialize(type)
DISALLOWED_XML_TYPES = %w(symbol yaml).freeze

DEFAULT_OPTIONS = {
:typecast_xml_value => true,
:disallowed_types => DISALLOWED_XML_TYPES,
:symbolize_keys => false,
typecast_xml_value: true,
disallowed_types: DISALLOWED_XML_TYPES,
symbolize_keys: false,
}.freeze

class << self
Expand Down
2 changes: 1 addition & 1 deletion lib/multi_xml/parsers/ox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def parse_error

def parse(io)
handler = Handler.new
::Ox.sax_parse(handler, io, :convert_special => true)
::Ox.sax_parse(handler, io, convert_special: true)
handler.doc
end

Expand Down
8 changes: 4 additions & 4 deletions lib/multi_xml/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def pre
# @return [Hash]
def to_h
{
:major => major,
:minor => minor,
:patch => patch,
:pre => pre,
major: major,
minor: minor,
patch: patch,
pre: pre,
}
end

Expand Down
10 changes: 5 additions & 5 deletions spec/parser_shared_example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@

context 'with :typecast_xml_value => false' do
before do
@setting = MultiXml.parse(@xml, :typecast_xml_value => false)['global_settings']['group']['setting']
@setting = MultiXml.parse(@xml, typecast_xml_value: false)['global_settings']['group']['setting']
end

it { expect(@setting).to eq('type' => 'string', 'description' => {'__content__' => 'Test'}) }
Expand All @@ -151,7 +151,7 @@
end

it 'symbolizes keys' do
expect(MultiXml.parse(@xml, :symbolize_keys => true)).to eq(:users => {:user => [{:name => 'Erik Michaels-Ober'}, {:name => 'Wynn Netherland'}]})
expect(MultiXml.parse(@xml, symbolize_keys: true)).to eq(users: {user: [{name: 'Erik Michaels-Ober'}, {name: 'Wynn Netherland'}]})
end
end

Expand Down Expand Up @@ -332,7 +332,7 @@
end

it 'returns the correctly parsed YAML when the type is allowed' do
expect(MultiXml.parse(@xml, :disallowed_types => [])['tag']).to eq(:message => 'Have a nice day', 1 => 'returns an integer', 'array' => [{'has-dashes' => true, 'has_underscores' => true}])
expect(MultiXml.parse(@xml, disallowed_types: [])['tag']).to eq(:message => 'Have a nice day', 1 => 'returns an integer', 'array' => [{'has-dashes' => true, 'has_underscores' => true}])
end
end

Expand All @@ -346,7 +346,7 @@
end

it 'returns the correctly parsed Symbol when the type is allowed' do
expect(MultiXml.parse(@xml, :disallowed_types => [])['tag']).to eq(:my_symbol)
expect(MultiXml.parse(@xml, disallowed_types: [])['tag']).to eq(:my_symbol)
end
end

Expand Down Expand Up @@ -459,7 +459,7 @@
end

it 'returns nil when the type is allowed' do
expect(MultiXml.parse(@xml, :disallowed_types => [])['tag']).to be nil
expect(MultiXml.parse(@xml, disallowed_types: [])['tag']).to be nil
end
end
end
Expand Down

0 comments on commit 0c6c5c9

Please sign in to comment.