moxml 0.1.22 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -13,7 +13,9 @@ begin
13
13
  # Opal-compatible overrides go first so they shadow the gem originals.
14
14
  if defined?(Opal)
15
15
  Opal.append_path File.expand_path("lib/compat/opal", __dir__)
16
- rexml_lib = $LOAD_PATH.find { |p| File.exist?(File.join(p, "rexml", "document.rb")) }
16
+ rexml_lib = $LOAD_PATH.find do |p|
17
+ File.exist?(File.join(p, "rexml", "document.rb"))
18
+ end
17
19
  Opal.append_path rexml_lib if rexml_lib
18
20
  end
19
21
  rescue LoadError
@@ -32,10 +34,11 @@ namespace :spec do
32
34
  server.append_path "spec"
33
35
 
34
36
  runner.default_path = "spec"
35
- runner.requires = %w[rexml_compat rexml/document rexml/xpath moxml/adapter/rexml spec_helper support/opal]
37
+ runner.requires = %w[rexml_compat rexml/document rexml/xpath
38
+ moxml/adapter/rexml spec_helper support/opal]
36
39
  runner.files = Dir.glob("spec/moxml/*opal*_spec.rb") +
37
- Dir.glob("spec/moxml/native_attachment/opal_spec.rb") +
38
- Dir.glob("spec/moxml/adapter/shared_examples/*.rb")
40
+ Dir.glob("spec/moxml/native_attachment/opal_spec.rb") +
41
+ Dir.glob("spec/moxml/adapter/shared_examples/*.rb")
39
42
  end
40
43
  end
41
44
 
@@ -158,17 +161,17 @@ namespace :opal do
158
161
  lines << " OPAL_ENTITY_DATA = {"
159
162
  chars.each do |name, char|
160
163
  codepoint = if char.start_with?("\\u")
161
- char.unicode_normalize(:nfc)[2..].to_i(16)
162
- else
163
- char.ord
164
- end
164
+ char.unicode_normalize(:nfc)[2..].to_i(16)
165
+ else
166
+ char.ord
167
+ end
165
168
  lines << " #{name.inspect} => #{codepoint},"
166
169
  end
167
170
  lines << " }.freeze"
168
171
  lines << " end"
169
172
  lines << "end"
170
173
 
171
- File.write(target, lines.join("\n") + "\n")
174
+ File.write(target, "#{lines.join("\n")}\n")
172
175
  puts "Generated #{target} (#{chars.size} entities, #{lines.size} lines)"
173
176
  end
174
177
  end
@@ -1,16 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rexml/xmltokens'
3
+ require "rexml/xmltokens"
4
4
 
5
5
  module REXML
6
6
  module Namespace
7
7
  attr_reader :name, :expanded_name
8
8
  attr_accessor :prefix
9
+
9
10
  include XMLTokens
11
+
10
12
  NAME_WITHOUT_NAMESPACE = /^#{NCNAME_STR}$/
11
13
  NAMESPLIT = /^(?:(#{NCNAME_STR}):)?(#{NCNAME_STR})/u
12
14
 
13
- def name=( name )
15
+ def name=(name)
14
16
  @expanded_name = name
15
17
  if name.match?(NAME_WITHOUT_NAMESPACE)
16
18
  @prefix = ""
@@ -35,9 +37,9 @@ module REXML
35
37
  end
36
38
  end
37
39
 
38
- def has_name?( other, ns=nil )
40
+ def has_name?(other, ns = nil)
39
41
  if ns
40
- namespace() == ns and name() == other
42
+ namespace == ns and name == other
41
43
  elsif other.include? ":"
42
44
  fully_expanded_name == other
43
45
  else
@@ -49,7 +51,8 @@ module REXML
49
51
 
50
52
  def fully_expanded_name
51
53
  ns = prefix
52
- return "#{ns}:#@name" if ns.size > 0
54
+ return "#{ns}:#@name" if ns.size.positive?
55
+
53
56
  @name
54
57
  end
55
58
  end