openstax_content 1.5.0 → 1.6.0
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 +4 -4
- data/lib/openstax/content/abl.rb +32 -24
- data/lib/openstax/content/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3172a1f7fe5b47aa50f602f78991ee47d9ee4f6861e02e5becf8eb5077c83c30
|
|
4
|
+
data.tar.gz: d88d0221599583018bf2eba76e4781523c5855261d8c3f61d751c50d48620b85
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d41858c0fe490b46d3d441daa2a98294aa8262fa73c1ea703ccf136cc3fa233f50d470259de4a2186a60c50e5a3f0fe2282b97903182c5b5b4c9972d61bb7ee8
|
|
7
|
+
data.tar.gz: 12beea979dd0a43e019e88be1c0b53c940f8b6683d59ac3c74f42e0bbd9456cdb6824bdd75d60572787aeba3492acdfb918975d46aa1f9218f624b50bdcf437b
|
data/lib/openstax/content/abl.rb
CHANGED
|
@@ -6,8 +6,11 @@ class OpenStax::Content::Abl
|
|
|
6
6
|
# If there are more than this number of archive versions still building, errors will happen
|
|
7
7
|
DEFAULT_MAX_ARCHIVE_ATTEMPTS = 5
|
|
8
8
|
|
|
9
|
+
attr_reader :partial_data
|
|
10
|
+
|
|
9
11
|
def initialize(url: nil)
|
|
10
12
|
@url = url
|
|
13
|
+
@partial_data = false
|
|
11
14
|
end
|
|
12
15
|
|
|
13
16
|
def url
|
|
@@ -39,35 +42,34 @@ class OpenStax::Content::Abl
|
|
|
39
42
|
end
|
|
40
43
|
end
|
|
41
44
|
|
|
42
|
-
def each_book_with_previous_archive_version_fallback(max_attempts: DEFAULT_MAX_ARCHIVE_ATTEMPTS, &block)
|
|
45
|
+
def each_book_with_previous_archive_version_fallback(max_attempts: DEFAULT_MAX_ARCHIVE_ATTEMPTS, allow_partial_data: true, &block)
|
|
43
46
|
raise ArgumentError, 'no block given' if block.nil?
|
|
44
47
|
raise ArgumentError, 'given block must accept the book as its first argument' if block.arity == 0
|
|
45
48
|
|
|
46
49
|
books = OpenStax::Content::Abl.new.books
|
|
47
|
-
|
|
50
|
+
@partial_data = false
|
|
48
51
|
|
|
49
|
-
|
|
52
|
+
books.each do |book|
|
|
53
|
+
attempt = 1
|
|
50
54
|
previous_version = nil
|
|
51
55
|
previous_archive = nil
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
books.each do |book|
|
|
56
|
+
while attempt <= max_attempts
|
|
55
57
|
begin
|
|
56
58
|
block.call book
|
|
59
|
+
break
|
|
57
60
|
rescue StandardError => exception
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
previous_version = book.archive.previous_version
|
|
62
|
+
if previous_version.nil? || attempt >= max_attempts
|
|
63
|
+
raise exception unless allow_partial_data
|
|
64
|
+
@partial_data = true
|
|
65
|
+
OpenStax::Content::logger.warn do
|
|
66
|
+
"Failed to process book: #{book.uuid}. " \
|
|
67
|
+
"Error: #{exception.class}: #{exception.message}"
|
|
68
|
+
end
|
|
69
|
+
break
|
|
67
70
|
else
|
|
68
|
-
previous_archive
|
|
69
|
-
|
|
70
|
-
retry_book = OpenStax::Content::Book.new(
|
|
71
|
+
previous_archive = OpenStax::Content::Archive.new version: previous_version
|
|
72
|
+
book = OpenStax::Content::Book.new(
|
|
71
73
|
archive: previous_archive,
|
|
72
74
|
uuid: book.uuid,
|
|
73
75
|
version: book.version,
|
|
@@ -75,15 +77,21 @@ class OpenStax::Content::Abl
|
|
|
75
77
|
min_code_version: book.min_code_version,
|
|
76
78
|
committed_at: book.committed_at
|
|
77
79
|
)
|
|
78
|
-
|
|
79
|
-
#
|
|
80
|
-
|
|
80
|
+
# NOTE: This assumes that subsequent archive versions are invalid
|
|
81
|
+
# after finding one invalid archive versions
|
|
82
|
+
unless book.valid?
|
|
83
|
+
raise exception unless allow_partial_data
|
|
84
|
+
@partial_data = true
|
|
85
|
+
OpenStax::Content::logger.warn do
|
|
86
|
+
"Failed to process book: #{book.uuid}. " \
|
|
87
|
+
"Error: invalid book for archive version #{previous_version}"
|
|
88
|
+
end
|
|
89
|
+
break
|
|
90
|
+
end
|
|
81
91
|
end
|
|
92
|
+
attempt += 1
|
|
82
93
|
end
|
|
83
94
|
end
|
|
84
|
-
|
|
85
|
-
books = retry_books
|
|
86
|
-
attempt += 1
|
|
87
95
|
end
|
|
88
96
|
end
|
|
89
97
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openstax_content
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dante Soares
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-02-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: aws-sdk-s3
|
|
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
183
183
|
- !ruby/object:Gem::Version
|
|
184
184
|
version: '0'
|
|
185
185
|
requirements: []
|
|
186
|
-
rubygems_version: 3.
|
|
186
|
+
rubygems_version: 3.3.7
|
|
187
187
|
signing_key:
|
|
188
188
|
specification_version: 4
|
|
189
189
|
summary: Ruby bindings to read and parse the OpenStax ABL and the content archive
|