epuber 0.10.1 → 0.10.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d17540fe810ca7f516d68b3ce1e2e7cc177751f5642280a62e849c06538b548
4
- data.tar.gz: d95c25089769b8c400fbde4da71ff87af30ee5d9c4c24a95043dac44fc794763
3
+ metadata.gz: 2c22c5e5a5820ba5dd1090ddc015276e877b4aa535d3b0cdd83c526a6604aa5b
4
+ data.tar.gz: c8ac2c195d24bfb1971656d64777b1849b1371d59506559942c00ac826b58963
5
5
  SHA512:
6
- metadata.gz: 1d29fc3294f95370590d6cc325cece7375418ca80da33c023492fcae9cb565bd09af520d6fc13b1050cb351e32aab7995549d0a84ef74947a775f8d496ddb97c
7
- data.tar.gz: 17c3e0eb6de4ce7cc736a19cb752b368592738c40121e592fe6e25e3c2bfed230b7d8740758137cae244ccfa94e023cdd93cfae6f4b54c5451dc2327075c5b49
6
+ metadata.gz: e5bbc9209f434dd869bbc6ca75ebaf0eca0945597665e6d1fb984cdf3e11193e3b59ee284c89c5eb46abc3fc3932b7168282dc73340e72afc2419422d8da9918
7
+ data.tar.gz: bb1fe4b5fbad4f79d69b1f357ca58c58aaa7abd504b8c9fec96dd7b6105060a3ef53a93db579b0ef6ddb1565433c1d8f30dc8afbd484817dd92839aafb88109f
data/Gemfile CHANGED
@@ -15,5 +15,5 @@ gem 'rubocop', '~> 1.14'
15
15
  gem 'ruby-lsp', require: false
16
16
 
17
17
  group :dev, optional: true do
18
- gem 'rubocop-rspec', require: false
18
+ gem 'rubocop-rspec', '~> 2.0', require: false
19
19
  end
@@ -22,7 +22,7 @@ module Epuber
22
22
  'src' => :font,
23
23
  }.freeze
24
24
 
25
- URL_REGEXP = /url\((.+)\)/.freeze
25
+ URL_REGEXP = /url\((.+?)\)/.freeze
26
26
 
27
27
  # @param [Compiler::CompilationContext] compilation_context
28
28
  #
@@ -55,30 +55,29 @@ module Epuber
55
55
  # @type [CssParser::RuleSet::Declarations]
56
56
  declarations = rule_set.instance_eval { @declarations }
57
57
  declarations.each do |property, decl_value|
58
- # @type [String]
59
- value = decl_value.to_s
60
- next unless value =~ URL_REGEXP
58
+ decl_value.to_s.scan(URL_REGEXP) do
59
+ url_function = Regexp.last_match(0)
60
+ path = Regexp.last_match(1)
61
+ if path.start_with?('"') && path.end_with?('"')
62
+ path = path[1..-2]
63
+ quote = '"'
64
+ end
65
+ if path.start_with?("'") && path.end_with?("'")
66
+ path = path[1..-2]
67
+ quote = "'"
68
+ end
61
69
 
62
- path = Regexp.last_match(1)
63
- if path.start_with?('"') && path.end_with?('"')
64
- path = path[1..-2]
65
- quote = '"'
66
- end
67
- if path.start_with?("'") && path.end_with?("'")
68
- path = path[1..-2]
69
- quote = "'"
70
- end
70
+ next if path.start_with?('data:') || path.start_with?('http://') || path.start_with?('https://')
71
71
 
72
- next if path.start_with?('data:') || path.start_with?('http://') || path.start_with?('https://')
72
+ resource_group = DECLARATION_TO_FILE_GROUP_MAP[property]
73
+ new_url = SourceFile.resolve_relative_file(destination_path,
74
+ path,
75
+ compilation_context.file_resolver,
76
+ group: resource_group,
77
+ location: self)
73
78
 
74
- resource_group = DECLARATION_TO_FILE_GROUP_MAP[property]
75
- new_url = SourceFile.resolve_relative_file(destination_path,
76
- path,
77
- compilation_context.file_resolver,
78
- group: resource_group,
79
- location: self)
80
-
81
- content = content.gsub(value, "url(#{quote}#{new_url}#{quote})") if new_url
79
+ content = content.gsub(url_function, "url(#{quote}#{new_url}#{quote})") if new_url
80
+ end
82
81
  end
83
82
  end
84
83
  end
@@ -36,25 +36,6 @@ module Epuber
36
36
  def error?
37
37
  level == :error || level == :fatal
38
38
  end
39
-
40
- def self.from_json(json)
41
- json_location = json['locations'].first
42
-
43
- location = if json_location
44
- Epuber::Location.new(
45
- path: json_location['path'],
46
- lineno: json_location['line'],
47
- column: json_location['column'],
48
- )
49
- end
50
-
51
- new(
52
- level: json['severity'].downcase.to_sym,
53
- code: json['ID'],
54
- message: json['message'],
55
- location: location,
56
- )
57
- end
58
39
  end
59
40
 
60
41
  class << self
@@ -76,14 +57,41 @@ module Epuber
76
57
  report
77
58
  end
78
59
 
60
+ # Parse json from epubcheck
61
+ #
79
62
  # @param [String] string json string
80
63
  # @return [Report]
81
64
  #
82
65
  def _parse_json(string)
83
66
  json = JSON.parse(string)
84
67
  messages = json['messages']
68
+ problems = messages
69
+ .map { |msg| _parse_locations(msg) }
70
+ .flatten
71
+
72
+ Report.new(problems: problems)
73
+ end
85
74
 
86
- Report.new(problems: messages.map { |msg| Problem.from_json(msg) })
75
+ # Parse all problems from single message
76
+ #
77
+ # @param [Hash] json
78
+ # @return [Array<Problem>]
79
+ #
80
+ def _parse_locations(json)
81
+ json['locations'].map do |json_location|
82
+ location = Epuber::Location.new(
83
+ path: json_location['path'],
84
+ lineno: json_location['line'],
85
+ column: json_location['column'],
86
+ )
87
+
88
+ Problem.new(
89
+ level: json['severity'].downcase.to_sym,
90
+ code: json['ID'],
91
+ message: json['message'],
92
+ location: location,
93
+ )
94
+ end
87
95
  end
88
96
  end
89
97
  end
data/lib/epuber/server.rb CHANGED
@@ -135,7 +135,7 @@ module Epuber
135
135
  if verbose
136
136
  Thin::Logging.logger = @default_thin_logger
137
137
  else
138
- Thin::Logging.logger = Logger.new(nil)
138
+ Thin::Logging.logger = ::Logger.new(nil)
139
139
  Thin::Logging.logger.level = :fatal
140
140
  end
141
141
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Epuber
4
- VERSION = '0.10.1'
4
+ VERSION = '0.10.3'
5
5
 
6
6
  HOME_URL = 'https://github.com/epuber-io/epuber'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epuber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.10.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Kříž
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-06 00:00:00.000000000 Z
11
+ date: 2024-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -597,7 +597,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
597
597
  - !ruby/object:Gem::Version
598
598
  version: '0'
599
599
  requirements: []
600
- rubygems_version: 3.5.11
600
+ rubygems_version: 3.5.18
601
601
  signing_key:
602
602
  specification_version: 4
603
603
  summary: Epuber is simple tool to compile and pack source files into EPUB format.