openstax_content 1.0.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openstax/content/abl.rb +3 -1
- data/lib/openstax/content/archive.rb +10 -3
- data/lib/openstax/content/book.rb +16 -6
- data/lib/openstax/content/page.rb +3 -2
- data/lib/openstax/content/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82eddc2890b74eeea7b59646cda86001dbb0385ddc00ad874ae5f69573441d57
|
4
|
+
data.tar.gz: a8f83e6c1a5bb7c0e5cda4e6171da21da8cfce91e1e89c74ecc954a8299015eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34fe275a54727deb10d3636fbc82cf3c9a86461d67f6695ea157209b71ae0ded2660d4c0e4f100af332c5db9bb5b8b54769ce22f060ff96d13e2b3be9a3f98cc
|
7
|
+
data.tar.gz: 05ec447981510aac02c672ba6606aaf111ffe785ffdc5b7a8d1a0223f7e8c3807da7168b61551e1acc23d48cf31134a6d080e2a65ee4864a7a2491787b85eac3
|
data/lib/openstax/content/abl.rb
CHANGED
@@ -71,7 +71,9 @@ class OpenStax::Content::Abl
|
|
71
71
|
uuid: book[:uuid],
|
72
72
|
version: version[:commit_sha][0..6],
|
73
73
|
slug: book[:slug],
|
74
|
-
style: book[:style]
|
74
|
+
style: book[:style],
|
75
|
+
min_code_version: version[:min_code_version],
|
76
|
+
committed_at: commit_metadata[:committed_at]
|
75
77
|
)
|
76
78
|
end
|
77
79
|
end
|
@@ -11,13 +11,20 @@ class OpenStax::Content::Archive
|
|
11
11
|
@s3 ||= OpenStax::Content::S3.new
|
12
12
|
end
|
13
13
|
|
14
|
+
def versions
|
15
|
+
@versions ||= s3.ls.reverse
|
16
|
+
end
|
17
|
+
|
14
18
|
def version
|
15
|
-
@version
|
19
|
+
@version || versions.first
|
20
|
+
end
|
21
|
+
|
22
|
+
def previous_version
|
23
|
+
versions[versions.index(version) + 1]
|
16
24
|
end
|
17
25
|
|
18
26
|
def base_url
|
19
|
-
@base_url ||= "https://#{OpenStax::Content.domain}/#{
|
20
|
-
OpenStax::Content.archive_path}/#{version}"
|
27
|
+
@base_url ||= "https://#{OpenStax::Content.domain}/#{OpenStax::Content.archive_path}/#{version}"
|
21
28
|
end
|
22
29
|
|
23
30
|
def url_for(object)
|
@@ -1,11 +1,15 @@
|
|
1
|
+
require 'forwardable'
|
1
2
|
require_relative 'book_part'
|
2
3
|
|
3
4
|
class OpenStax::Content::Book
|
4
5
|
extend Forwardable
|
5
6
|
|
6
|
-
attr_reader :archive, :uuid, :version, :slug, :style
|
7
|
+
attr_reader :archive, :uuid, :version, :slug, :style, :min_code_version, :committed_at
|
7
8
|
|
8
|
-
def initialize(
|
9
|
+
def initialize(
|
10
|
+
archive:, uuid:, version:,
|
11
|
+
url: nil, hash: nil, slug: nil, style: nil, min_code_version: nil, committed_at: nil
|
12
|
+
)
|
9
13
|
@archive = archive
|
10
14
|
@uuid = uuid
|
11
15
|
@version = version
|
@@ -13,20 +17,26 @@ class OpenStax::Content::Book
|
|
13
17
|
@hash = hash
|
14
18
|
@slug = slug
|
15
19
|
@style = style
|
20
|
+
@min_code_version = min_code_version
|
21
|
+
@committed_at = committed_at
|
16
22
|
end
|
17
23
|
|
18
|
-
def
|
19
|
-
|
24
|
+
def valid?
|
25
|
+
min_code_version.nil? || min_code_version <= archive.version
|
20
26
|
end
|
21
27
|
|
22
|
-
def
|
23
|
-
@
|
28
|
+
def url
|
29
|
+
@url ||= archive.url_for "#{uuid}@#{version}"
|
24
30
|
end
|
25
31
|
|
26
32
|
def url_fragment
|
27
33
|
@url_fragment ||= url.chomp('.json')
|
28
34
|
end
|
29
35
|
|
36
|
+
def hash
|
37
|
+
@hash ||= archive.json url
|
38
|
+
end
|
39
|
+
|
30
40
|
def baked
|
31
41
|
@baked ||= hash['baked']
|
32
42
|
end
|
@@ -32,7 +32,7 @@ class OpenStax::Content::Page
|
|
32
32
|
node.at_css(feature_id_css)
|
33
33
|
end
|
34
34
|
|
35
|
-
def initialize(book: nil, hash: {}, uuid: nil, url: nil, title: nil, content: nil)
|
35
|
+
def initialize(book: nil, hash: {}, uuid: nil, url: nil, title: nil, slug: nil, content: nil)
|
36
36
|
@uuid = uuid || hash['id']&.split('@', 2)&.first
|
37
37
|
raise ArgumentError, 'Either uuid or hash with id key is required' if @uuid.nil?
|
38
38
|
|
@@ -40,11 +40,12 @@ class OpenStax::Content::Page
|
|
40
40
|
@hash = hash
|
41
41
|
@url = url
|
42
42
|
@title = title || hash['title']
|
43
|
+
@slug = slug || hash['slug']
|
43
44
|
@content = content
|
44
45
|
end
|
45
46
|
|
46
47
|
attr_accessor :chapter_section
|
47
|
-
attr_reader :uuid, :hash
|
48
|
+
attr_reader :uuid, :hash, :slug
|
48
49
|
|
49
50
|
def book
|
50
51
|
raise ArgumentError, 'Book was not specified' if @book.nil?
|
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.3.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: 2022-
|
11
|
+
date: 2022-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|