Skip to content

Commit ff90b4d

Browse files
committed
Change most use of %w to %i and arrays of strings mapped to symbols to use %i.
1 parent 9367d1b commit ff90b4d

8 files changed

Lines changed: 20 additions & 20 deletions

File tree

lib/rdf/model/dataset.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def isolation_level
104104
# @private
105105
# @see RDF::Enumerable#supports?
106106
def supports?(feature)
107-
return true if [:graph_name, :rdfstar].include?(feature)
107+
return true if %i(graph_name rdfstar).include?(feature)
108108
super
109109
end
110110

lib/rdf/model/uri.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,12 @@ def initialize(*args, validate: false, canonicalize: false, **options)
226226
@value.dup.force_encoding(Encoding::UTF_8) if @value.encoding != Encoding::UTF_8
227227
@value.freeze
228228
else
229-
%w(
229+
%i(
230230
scheme
231231
user password userinfo
232232
host port authority
233233
path query fragment
234-
).map(&:to_sym).each do |meth|
234+
).each do |meth|
235235
if options.key?(meth)
236236
self.send("#{meth}=".to_sym, options[meth])
237237
else
@@ -416,7 +416,7 @@ def canonicalize!
416416
# @see http://tools.ietf.org/html/rfc3986#section-5.2.2
417417
# @see http://tools.ietf.org/html/rfc3986#section-5.2.3
418418
def join(*uris)
419-
joined_parts = object.dup.delete_if {|k, v| [:user, :password, :host, :port].include?(k)}
419+
joined_parts = object.dup.delete_if {|k, v| %i(user password host port).include?(k)}
420420

421421
uris.each do |uri|
422422
uri = RDF::URI.new(uri) unless uri.is_a?(RDF::URI)
@@ -580,7 +580,7 @@ def root
580580
else
581581
RDF::URI.new(
582582
**object.merge(path: '/').
583-
keep_if {|k, v| [:scheme, :authority, :path].include?(k)})
583+
keep_if {|k, v| %i(scheme authority path).include?(k)})
584584
end
585585
end
586586

@@ -1123,7 +1123,7 @@ def authority
11231123
# @param [String, #to_s] value
11241124
# @return [RDF::URI] self
11251125
def authority=(value)
1126-
object.delete_if {|k, v| [:user, :password, :host, :port, :userinfo].include?(k)}
1126+
object.delete_if {|k, v| %i(user password host port userinfo).include?(k)}
11271127
object[:authority] = (value.to_s.dup.force_encoding(Encoding::UTF_8) if value)
11281128
user; password; userinfo; host; port
11291129
@value = nil
@@ -1153,7 +1153,7 @@ def userinfo
11531153
# @param [String, #to_s] value
11541154
# @return [RDF::URI] self
11551155
def userinfo=(value)
1156-
object.delete_if {|k, v| [:user, :password, :authority].include?(k)}
1156+
object.delete_if {|k, v| %i(user password authority).include?(k)}
11571157
object[:userinfo] = (value.to_s.dup.force_encoding(Encoding::UTF_8) if value)
11581158
user; password; authority
11591159
@value = nil

lib/rdf/query/pattern.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def variable_terms(name = nil)
248248
# @param [RDF::Statement] statement
249249
# @return [Array<RDF::Term>]
250250
def var_values(var, statement)
251-
[:subject, :predicate, :object, :graph_name].map do |position|
251+
%i(subject predicate object graph_name).map do |position|
252252
po = self.send(position)
253253
so = statement.send(position)
254254
po.var_values(var, so) if po.respond_to?(:var_values)

lib/rdf/util/logger.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def method_missing(method, *args)
285285

286286
def respond_to_missing?(name, include_private = false)
287287
return true if
288-
[:fatal, :error, :warn, :info, :debug, :level, :sev_threshold]
288+
%i(fatal error warn info debug level sev_threshold)
289289
.include?(name.to_sym)
290290
super
291291
end

spec/dataset_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434
end
3535

3636
describe '#supports?' do
37-
[:validity, :literal_equality, :graph_name].each do |key|
37+
%i(validity literal_equality graph_name).each do |key|
3838
it "supports #{key}" do
3939
expect(subject.supports?(key)).to be true
4040
end
4141
end
4242

43-
[:inference, :skolemize].each do |key|
43+
%i(inference skolemize).each do |key|
4444
it "does not support #{key}" do
4545
expect(subject.supports?(key)).to be false
4646
end

spec/format_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def self.to_sym; :foo_bar; end
103103

104104
describe ".reader_symbols" do
105105
it "returns symbols of available readers" do
106-
[:ntriples, :nquads, :foo_bar].each do |sym|
106+
%i(ntriples nquads foo_bar).each do |sym|
107107
expect(RDF::Format.reader_symbols).to include(sym)
108108
end
109109
end
@@ -131,10 +131,10 @@ def self.to_sym; :foo_bar; end
131131

132132
describe ".writer_symbols" do
133133
it "returns symbols of available writers" do
134-
[:ntriples, :nquads].each do |sym|
134+
%i(ntriples nquads).each do |sym|
135135
expect(RDF::Format.writer_symbols).to include(sym)
136136
end
137-
[:fooformat, :barformat].each do |sym|
137+
%i(fooformat barformat).each do |sym|
138138
expect(RDF::Format.writer_symbols).not_to include(sym)
139139
end
140140
end

spec/mixin_queryable_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
it "calls #query_pattern" do
1515
is_expected.to receive(:query_pattern)
1616
is_expected.not_to receive(:query_execute)
17-
subject.query([:s, :p, :o]) {}
17+
subject.query(%i(s p o)) {}
1818
end
1919
it "with array" do
2020
expect(subject.query([nil, RDF::Vocab::DOAP.developer, nil]).to_a).not_to be_empty
@@ -29,7 +29,7 @@
2929
end
3030

3131
context "Querying for solutions from a BGP" do
32-
let(:query) { query = RDF::Query.new {pattern [:s, :p, :o]} }
32+
let(:query) { query = RDF::Query.new {pattern %i(s p o)} }
3333
it "calls #query_execute" do
3434
is_expected.to receive(:query_execute)
3535
is_expected.not_to receive(:query_pattern)

spec/model_literal_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ def self.literal(selector)
3434
def self.literals(*selector)
3535
selector.inject([]) do |ary, sel|
3636
ary += case sel
37-
when :all_simple then [:empty, :plain, :string].map {|s| literal(s)}
38-
when :all_plain_lang then [:empty_lang, :plain_lang].map {|s| literal(s)}
39-
when :all_native then [:false, :true, :int, :long, :decimal, :double, :time, :date, :datetime].map {|s| literal(s)}
40-
when :all_invalid_lang then [:wrong_lang, :unset_lang].map {|s| literal(s)}
37+
when :all_simple then %i(empty plain string).map {|s| literal(s)}
38+
when :all_plain_lang then %i(empty_lang plain_lang).map {|s| literal(s)}
39+
when :all_native then %i(false true int long decimal double time date datetime).map {|s| literal(s)}
40+
when :all_invalid_lang then %i(wrong_lang unset_lang).map {|s| literal(s)}
4141
when :all_plain then literals(:all_simple, :all_plain_lang)
4242
else literals(:all_plain, :all_native)
4343
end

0 commit comments

Comments
 (0)