epuber 0.10.1 → 0.10.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d17540fe810ca7f516d68b3ce1e2e7cc177751f5642280a62e849c06538b548
4
- data.tar.gz: d95c25089769b8c400fbde4da71ff87af30ee5d9c4c24a95043dac44fc794763
3
+ metadata.gz: 7d80c921e39a42f4b28674f6dda66ef56bab9b312ab3fc75bb4dbf5edfbdbcaa
4
+ data.tar.gz: 9f795d610ad9bdd2da76622cc1f0092976d026535d4b024c4eb93e376e1f20fa
5
5
  SHA512:
6
- metadata.gz: 1d29fc3294f95370590d6cc325cece7375418ca80da33c023492fcae9cb565bd09af520d6fc13b1050cb351e32aab7995549d0a84ef74947a775f8d496ddb97c
7
- data.tar.gz: 17c3e0eb6de4ce7cc736a19cb752b368592738c40121e592fe6e25e3c2bfed230b7d8740758137cae244ccfa94e023cdd93cfae6f4b54c5451dc2327075c5b49
6
+ metadata.gz: cab13905cd84cdb40179854ff843517980443a1d0d160d9f4bdb122d7fc7f7216db7c13d1f79fcaf51103d9c8e633417d50566ad524b0e502ea4cc6915687755
7
+ data.tar.gz: 5a13612e2a5e96e5ce38c5f4cbace79fa7cd052525a162650edde1400fe6bff3cdf8772ee916b36f8545f59b434b8ebc30e424deea78b0632b61f881099e1dcc
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
@@ -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.2'
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.2
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-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport