wcc-jtj-client 0.1.7 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -29
- data/Gemfile +10 -7
- data/Rakefile +3 -1
- data/lib/wcc/jtj/client/response.rb +2 -3
- data/lib/wcc/jtj/client/responses/curriculum_show_response.rb +5 -5
- data/lib/wcc/jtj/client/responses/curriculums_list_response.rb +7 -7
- data/lib/wcc/jtj/client/responses/entries_list_response.rb +7 -7
- data/lib/wcc/jtj/client/responses/entry_show_response.rb +5 -4
- data/lib/wcc/jtj/client/responses/memory_verse_show_response.rb +4 -4
- data/lib/wcc/jtj/client/responses/memory_verses_list_response.rb +7 -7
- data/lib/wcc/jtj/client/responses/root_response.rb +4 -8
- data/lib/wcc/jtj/client/schemas/base.rb +3 -1
- data/lib/wcc/jtj/client/schemas/curriculum_summary.rb +3 -3
- data/lib/wcc/jtj/client/schemas/entry.rb +5 -13
- data/lib/wcc/jtj/client/schemas/entry_summary.rb +15 -3
- data/lib/wcc/jtj/client/utils.rb +2 -2
- data/lib/wcc/jtj/client/version.rb +1 -1
- data/lib/wcc/jtj/client.rb +42 -32
- data/lib/wcc-jtj-client.rb +1 -1
- data/wcc-jtj-client.gemspec +3 -2
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 696017c2ad72ec343127921f1aa64ca966f4e44c4773f14bdf9d9df4c94083c5
|
4
|
+
data.tar.gz: 4a201251e16f3e83a69f3ab70495cd9ecdc73704280b07c81aa77bca96f24d7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b50435f553f0e71be454a065447cdf62a77e07750efd01604c70d4ab0fb5c10f1868925463a0bb25b4b4ff8f4f42e7b59bbd09f833e6194f3da43c952699c405
|
7
|
+
data.tar.gz: a835f58c86395bb08e0c7c148399a337f003b7bfb95b1163c5e5b4cde385e66461061a82a92709aabb2e01279e1697235b0d7487543f66f441eb5fc17653ca23
|
data/.rubocop.yml
CHANGED
@@ -1,35 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Exclude:
|
4
|
-
- '**/templates/**/*'
|
5
|
-
- '**/vendor/**/*'
|
6
|
-
Include:
|
7
|
-
- 'lib/**/*'
|
8
|
-
- 'Gemfile'
|
9
|
-
- 'wcc-jtj-client.gemspec'
|
1
|
+
inherit_from:
|
2
|
+
- http://watermarkchurch.github.io/watermarkchurch/rubocop_base.yml
|
10
3
|
|
11
|
-
|
12
|
-
|
4
|
+
require:
|
5
|
+
- rubocop-performance
|
13
6
|
|
14
7
|
Naming/FileName:
|
15
8
|
Exclude:
|
16
|
-
- 'lib/wcc-jtj-client.rb' #
|
17
|
-
|
18
|
-
Style/ClassAndModuleChildren:
|
19
|
-
Enabled: false
|
20
|
-
|
21
|
-
Style/Documentation:
|
22
|
-
Enabled: false
|
9
|
+
- 'lib/wcc-jtj-client.rb' # allow `require 'wcc-jtj-client'`
|
23
10
|
|
24
|
-
|
11
|
+
# We have a lot of OpenStructs in the client intentionally to model flexible JSON
|
12
|
+
Style/OpenStructUse:
|
25
13
|
Enabled: false
|
26
|
-
|
27
|
-
Style/IfUnlessModifier:
|
28
|
-
Enabled: false
|
29
|
-
|
30
|
-
Style/MultilineIfModifier:
|
31
|
-
Enabled: false
|
32
|
-
|
33
|
-
# This one won't let me EnforcedStyle: slashes, do we need to upgrade rubocop?
|
34
|
-
Style/RegexpLiteral:
|
35
|
-
Enabled: false
|
data/Gemfile
CHANGED
@@ -5,17 +5,20 @@ source 'https://rubygems.org'
|
|
5
5
|
# Specify your gem's dependencies in wcc-events-client.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
+
# Lock rubocop to the same version the parent app uses
|
9
|
+
lockfile = Bundler::LockfileParser.new(Bundler.read_file('../../Gemfile.lock'))
|
10
|
+
parent_version = ->(spec) { lockfile.specs.find { |s| s.name == spec }.version.to_s }
|
11
|
+
|
8
12
|
group :development, :test do
|
9
13
|
gem 'capybara', '>= 2.15'
|
10
|
-
gem 'guard', '~> 2.15'
|
11
|
-
gem 'guard-rspec', '~> 4.7'
|
12
|
-
gem 'guard-rubocop', '~> 1.3'
|
13
14
|
gem 'rake', '~> 12.3'
|
14
15
|
gem 'rspec', '~> 3.0'
|
15
16
|
gem 'rspec_junit_formatter', '~> 0.4.1'
|
16
|
-
gem 'rubocop',
|
17
|
-
gem 'rubocop-performance', require: false
|
18
|
-
gem '
|
19
|
-
gem '
|
17
|
+
gem 'rubocop', parent_version.call('rubocop'), require: false
|
18
|
+
gem 'rubocop-performance', parent_version.call('rubocop-performance'), require: false
|
19
|
+
gem 'rubocop-rails', parent_version.call('rubocop-rails'), require: false
|
20
|
+
gem 'rubocop-rspec', parent_version.call('rubocop-rspec'), require: false
|
21
|
+
gem 'simplecov', parent_version.call('simplecov'), require: false
|
22
|
+
gem 'simplecov-cobertura', parent_version.call('simplecov-cobertura')
|
20
23
|
gem 'webmock', '~> 3.1'
|
21
24
|
end
|
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require 'forwardable'
|
|
4
4
|
|
5
5
|
module WCC::JTJ
|
6
6
|
class Client
|
7
|
-
Response = Struct.new(:client, :request, :raw_response) do
|
7
|
+
Response = Struct.new(:client, :request, :raw_response) do
|
8
8
|
extend Forwardable
|
9
9
|
|
10
10
|
def_delegators :raw_response, :status, :headers
|
@@ -49,7 +49,7 @@ module WCC::JTJ
|
|
49
49
|
def each_page(&block)
|
50
50
|
ret = PaginatingEnumerable.new(self)
|
51
51
|
|
52
|
-
if
|
52
|
+
if block
|
53
53
|
ret.map(&block)
|
54
54
|
else
|
55
55
|
ret.lazy
|
@@ -72,7 +72,6 @@ module WCC::JTJ
|
|
72
72
|
|
73
73
|
def each
|
74
74
|
page = @initial_page
|
75
|
-
puts 'yield page'
|
76
75
|
yield page
|
77
76
|
|
78
77
|
while page.next_page?
|
@@ -19,7 +19,7 @@ module WCC::JTJ::Client::Responses
|
|
19
19
|
)
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
alias_method :currentWeek, :current_week
|
23
23
|
|
24
24
|
define_camelcase_alias(
|
25
25
|
'links'
|
@@ -28,10 +28,10 @@ module WCC::JTJ::Client::Responses
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def validate!
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
return if curriculum&.id
|
32
|
+
|
33
|
+
raise WCC::JTJ::Client::Schemas::SchemaValidationError,
|
34
|
+
"Not a CurriculumShowResponse! #{raw.url}"
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -5,12 +5,12 @@ module WCC::JTJ::Client::Responses
|
|
5
5
|
def total
|
6
6
|
raw['total']
|
7
7
|
end
|
8
|
-
|
8
|
+
alias_method :count, :total
|
9
9
|
|
10
10
|
def curriculums
|
11
11
|
raw.each_page
|
12
|
-
|
13
|
-
|
12
|
+
.flat_map { |page| page['curriculums'] }
|
13
|
+
.map do |raw_curriculum|
|
14
14
|
WCC::JTJ::Client::Schemas::CurriculumSummary.new(
|
15
15
|
raw_curriculum, client: @client
|
16
16
|
)
|
@@ -25,10 +25,10 @@ module WCC::JTJ::Client::Responses
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def validate!
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
return if total && raw['curriculums'].is_a?(Array)
|
29
|
+
|
30
|
+
raise WCC::JTJ::Client::Schemas::SchemaValidationError,
|
31
|
+
"Not a CurriculumsListResponse! #{raw.url}"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -5,12 +5,12 @@ module WCC::JTJ::Client::Responses
|
|
5
5
|
def total
|
6
6
|
raw['total']
|
7
7
|
end
|
8
|
-
|
8
|
+
alias_method :count, :total
|
9
9
|
|
10
10
|
def entries
|
11
11
|
raw.each_page
|
12
|
-
|
13
|
-
|
12
|
+
.flat_map { |page| page['entries'] }
|
13
|
+
.map do |raw_entry|
|
14
14
|
WCC::JTJ::Client::Schemas::EntrySummary.new(
|
15
15
|
raw_entry, client: @client
|
16
16
|
)
|
@@ -25,10 +25,10 @@ module WCC::JTJ::Client::Responses
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def validate!
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
return if total && raw['entries'].is_a?(Array)
|
29
|
+
|
30
|
+
raise WCC::JTJ::Client::Schemas::SchemaValidationError,
|
31
|
+
"Not an EntriesListResponse! #{raw.url}"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -21,16 +21,17 @@ module WCC::JTJ::Client::Responses
|
|
21
21
|
end
|
22
22
|
|
23
23
|
define_camelcase_alias(
|
24
|
+
'settings',
|
24
25
|
'links'
|
25
26
|
) do |camelcase|
|
26
27
|
OpenStruct.new(raw[camelcase]) if raw[camelcase]
|
27
28
|
end
|
28
29
|
|
29
30
|
def validate!
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
return if entry&.id
|
32
|
+
|
33
|
+
raise WCC::JTJ::Client::Schemas::SchemaValidationError,
|
34
|
+
"Not an EntryShowResponse! #{raw.url}"
|
34
35
|
end
|
35
36
|
end
|
36
37
|
end
|
@@ -18,10 +18,10 @@ module WCC::JTJ::Client::Responses
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def validate!
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
return if memory_verse&.id
|
22
|
+
|
23
|
+
raise WCC::JTJ::Client::Schemas::SchemaValidationError,
|
24
|
+
"Not a MemoryVerseShowResponse! #{raw.url}"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -5,12 +5,12 @@ module WCC::JTJ::Client::Responses
|
|
5
5
|
def total
|
6
6
|
raw['total']
|
7
7
|
end
|
8
|
-
|
8
|
+
alias_method :count, :total
|
9
9
|
|
10
10
|
def memory_verses
|
11
11
|
raw.each_page
|
12
|
-
|
13
|
-
|
12
|
+
.flat_map { |page| page['memory_verses'] }
|
13
|
+
.map do |raw_verse|
|
14
14
|
WCC::JTJ::Client::Schemas::MemoryVerseSummary.new(
|
15
15
|
raw_verse, client: @client
|
16
16
|
)
|
@@ -25,10 +25,10 @@ module WCC::JTJ::Client::Responses
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def validate!
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
return if total && raw['memory_verses'].is_a?(Array)
|
29
|
+
|
30
|
+
raise WCC::JTJ::Client::Schemas::SchemaValidationError,
|
31
|
+
"Not a MemoryVersesListResponse! #{raw.url}"
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -4,18 +4,14 @@ module WCC::JTJ::Client::Responses
|
|
4
4
|
class RootResponse < Base
|
5
5
|
def curriculum
|
6
6
|
@curriculum ||=
|
7
|
-
if raw['curriculum']
|
8
|
-
WCC::JTJ::Client::Schemas::CurriculumSummary.new(raw['curriculum'], client: @client)
|
9
|
-
end
|
7
|
+
(WCC::JTJ::Client::Schemas::CurriculumSummary.new(raw['curriculum'], client: @client) if raw['curriculum'])
|
10
8
|
end
|
11
9
|
|
12
10
|
def latest_entry
|
13
11
|
@latest_entry ||=
|
14
|
-
if raw['latest_entry']
|
15
|
-
WCC::JTJ::Client::Schemas::Entry.new(raw['latest_entry'], client: @client)
|
16
|
-
end
|
12
|
+
(WCC::JTJ::Client::Schemas::Entry.new(raw['latest_entry'], client: @client) if raw['latest_entry'])
|
17
13
|
end
|
18
|
-
|
14
|
+
alias_method :latestEntry, :latest_entry
|
19
15
|
|
20
16
|
def current_week
|
21
17
|
@current_week ||=
|
@@ -25,7 +21,7 @@ module WCC::JTJ::Client::Responses
|
|
25
21
|
)
|
26
22
|
end
|
27
23
|
end
|
28
|
-
|
24
|
+
alias_method :currentWeek, :current_week
|
29
25
|
|
30
26
|
define_camelcase_alias(
|
31
27
|
'settings',
|
@@ -9,6 +9,7 @@ module WCC::JTJ::Client::Schemas
|
|
9
9
|
extend WCC::JTJ::Client::Utils
|
10
10
|
|
11
11
|
attr_reader :raw
|
12
|
+
|
12
13
|
def_delegators :raw, :[], :dig, :to_h, :to_json
|
13
14
|
|
14
15
|
def initialize(raw, client: WCC::JTJ::Client.client)
|
@@ -16,6 +17,7 @@ module WCC::JTJ::Client::Schemas
|
|
16
17
|
@client = client
|
17
18
|
end
|
18
19
|
|
19
|
-
def validate
|
20
|
+
def validate!
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
@@ -21,9 +21,9 @@ module WCC::JTJ::Client::Schemas
|
|
21
21
|
raw[snake_case]
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
alias_method :startDate, :start_date
|
25
|
+
alias_method :endDate, :end_date
|
26
|
+
alias_method :daysOfWeek, :days_of_week
|
27
27
|
|
28
28
|
def links
|
29
29
|
OpenStruct.new(raw['links']) if raw['links']
|
@@ -27,31 +27,23 @@ module WCC::JTJ::Client::Schemas
|
|
27
27
|
|
28
28
|
def key_verse
|
29
29
|
@key_verse ||=
|
30
|
-
if raw['key_verse']
|
31
|
-
WCC::JTJ::Client::Schemas::Scripture.new(raw['key_verse'], client: @client)
|
32
|
-
end
|
30
|
+
(WCC::JTJ::Client::Schemas::Scripture.new(raw['key_verse'], client: @client) if raw['key_verse'])
|
33
31
|
end
|
34
|
-
|
32
|
+
alias_method :keyVerse, :key_verse
|
35
33
|
|
36
34
|
def writer
|
37
35
|
@writer ||=
|
38
|
-
if raw['writer']
|
39
|
-
WCC::JTJ::Client::Schemas::Writer.new(raw['writer'], client: @client)
|
40
|
-
end
|
36
|
+
(WCC::JTJ::Client::Schemas::Writer.new(raw['writer'], client: @client) if raw['writer'])
|
41
37
|
end
|
42
38
|
|
43
39
|
def podcast
|
44
40
|
@podcast ||=
|
45
|
-
if raw['podcast']
|
46
|
-
WCC::JTJ::Client::Schemas::Podcast.new(raw['podcast'], client: @client)
|
47
|
-
end
|
41
|
+
(WCC::JTJ::Client::Schemas::Podcast.new(raw['podcast'], client: @client) if raw['podcast'])
|
48
42
|
end
|
49
43
|
|
50
44
|
def memory_verse
|
51
45
|
@memory_verse ||=
|
52
|
-
if raw['memory_verse']
|
53
|
-
WCC::JTJ::Client::Schemas::MemoryVerse.new(raw['memory_verse'], client: @client)
|
54
|
-
end
|
46
|
+
(WCC::JTJ::Client::Schemas::MemoryVerse.new(raw['memory_verse'], client: @client) if raw['memory_verse'])
|
55
47
|
end
|
56
48
|
|
57
49
|
def links
|
@@ -16,13 +16,25 @@ module WCC::JTJ::Client::Schemas
|
|
16
16
|
|
17
17
|
def podcast
|
18
18
|
@podcast ||=
|
19
|
-
if raw['podcast']
|
20
|
-
WCC::JTJ::Client::Schemas::Podcast.new(raw['podcast'], client: @client)
|
21
|
-
end
|
19
|
+
(WCC::JTJ::Client::Schemas::Podcast.new(raw['podcast'], client: @client) if raw['podcast'])
|
22
20
|
end
|
23
21
|
|
24
22
|
def links
|
25
23
|
OpenStruct.new(raw['links']) if raw['links']
|
26
24
|
end
|
25
|
+
|
26
|
+
def scriptures
|
27
|
+
(raw['scriptures'] || []).map do |s|
|
28
|
+
EntrySummary::Scripture.new(s, client: @client)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Scripture < Base
|
33
|
+
define_camelcase_alias(
|
34
|
+
'reference'
|
35
|
+
) do |camelcase|
|
36
|
+
raw[camelcase]
|
37
|
+
end
|
38
|
+
end
|
27
39
|
end
|
28
40
|
end
|
data/lib/wcc/jtj/client/utils.rb
CHANGED
@@ -6,8 +6,8 @@ module WCC::JTJ::Client::Utils
|
|
6
6
|
def camelcase(term)
|
7
7
|
term
|
8
8
|
.to_s
|
9
|
-
.gsub(
|
10
|
-
.gsub(
|
9
|
+
.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{Regexp.last_match(1)}#{Regexp.last_match(2).capitalize}" }
|
10
|
+
.gsub('/', '::')
|
11
11
|
end
|
12
12
|
|
13
13
|
def define_camelcase_alias(*underscore_method_names, &block)
|
data/lib/wcc/jtj/client.rb
CHANGED
@@ -2,32 +2,32 @@
|
|
2
2
|
|
3
3
|
require 'faraday'
|
4
4
|
|
5
|
-
require_relative '
|
6
|
-
require_relative '
|
7
|
-
require_relative '
|
8
|
-
|
9
|
-
require_relative '
|
10
|
-
require_relative '
|
11
|
-
require_relative '
|
12
|
-
require_relative '
|
13
|
-
require_relative '
|
14
|
-
require_relative '
|
15
|
-
require_relative '
|
16
|
-
require_relative '
|
17
|
-
require_relative '
|
18
|
-
require_relative '
|
19
|
-
|
20
|
-
require_relative '
|
21
|
-
require_relative '
|
22
|
-
require_relative '
|
23
|
-
require_relative '
|
24
|
-
require_relative '
|
25
|
-
require_relative '
|
26
|
-
require_relative '
|
27
|
-
require_relative '
|
5
|
+
require_relative 'client/version'
|
6
|
+
require_relative 'client/utils'
|
7
|
+
require_relative 'client/response'
|
8
|
+
|
9
|
+
require_relative 'client/schemas/base'
|
10
|
+
require_relative 'client/schemas/schema_validation_error'
|
11
|
+
require_relative 'client/schemas/curriculum_summary'
|
12
|
+
require_relative 'client/schemas/entry_summary'
|
13
|
+
require_relative 'client/schemas/entry'
|
14
|
+
require_relative 'client/schemas/scripture'
|
15
|
+
require_relative 'client/schemas/podcast'
|
16
|
+
require_relative 'client/schemas/writer'
|
17
|
+
require_relative 'client/schemas/memory_verse_summary'
|
18
|
+
require_relative 'client/schemas/memory_verse'
|
19
|
+
|
20
|
+
require_relative 'client/responses/base'
|
21
|
+
require_relative 'client/responses/root_response'
|
22
|
+
require_relative 'client/responses/curriculums_list_response'
|
23
|
+
require_relative 'client/responses/curriculum_show_response'
|
24
|
+
require_relative 'client/responses/entries_list_response'
|
25
|
+
require_relative 'client/responses/entry_show_response'
|
26
|
+
require_relative 'client/responses/memory_verses_list_response'
|
27
|
+
require_relative 'client/responses/memory_verse_show_response'
|
28
28
|
|
29
29
|
module WCC::JTJ
|
30
|
-
class Client
|
30
|
+
class Client
|
31
31
|
class << self
|
32
32
|
attr_writer :client
|
33
33
|
|
@@ -62,8 +62,8 @@ module WCC::JTJ
|
|
62
62
|
url = URI.join(@base_url, path)
|
63
63
|
|
64
64
|
Response.new(self,
|
65
|
-
|
66
|
-
|
65
|
+
{ url: url, query: query },
|
66
|
+
get_http(url, query))
|
67
67
|
end
|
68
68
|
|
69
69
|
# rubocop:disable Naming/AccessorMethodName
|
@@ -86,8 +86,10 @@ module WCC::JTJ
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def get_curriculum(id_or_link)
|
89
|
+
raise ArgumentError, 'please provide curriculum ID' unless id_or_link
|
90
|
+
|
89
91
|
path =
|
90
|
-
if /^https
|
92
|
+
if /^https?:\/\//.match?(id_or_link.to_s)
|
91
93
|
id_or_link
|
92
94
|
else
|
93
95
|
File.join(base_path, 'curriculums', id_or_link.to_s)
|
@@ -109,15 +111,17 @@ module WCC::JTJ
|
|
109
111
|
Responses::EntriesListResponse.new(resp, client: self).tap(&:validate!)
|
110
112
|
end
|
111
113
|
|
112
|
-
def get_entry(id_or_link, preview_code: nil)
|
114
|
+
def get_entry(id_or_link, preview_code: nil, **query)
|
115
|
+
raise ArgumentError, 'please provide entry ID' unless id_or_link
|
116
|
+
|
113
117
|
path =
|
114
|
-
if /^https
|
118
|
+
if /^https?:\/\//.match?(id_or_link.to_s)
|
115
119
|
id_or_link
|
116
120
|
else
|
117
121
|
File.join(base_path, 'entries', id_or_link.to_s)
|
118
122
|
end
|
119
123
|
|
120
|
-
query = preview_code
|
124
|
+
query = query.merge(preview_code: preview_code) if preview_code
|
121
125
|
|
122
126
|
resp = get(path, query).assert_ok!
|
123
127
|
|
@@ -125,6 +129,8 @@ module WCC::JTJ
|
|
125
129
|
end
|
126
130
|
|
127
131
|
def get_legacy(id)
|
132
|
+
raise ArgumentError, 'please provide legacy ID' unless id
|
133
|
+
|
128
134
|
path = File.join(base_path, 'entries', 'legacy', id.to_s)
|
129
135
|
resp = get(path).assert_ok!
|
130
136
|
|
@@ -144,8 +150,10 @@ module WCC::JTJ
|
|
144
150
|
end
|
145
151
|
|
146
152
|
def get_memory_verse(id_or_link)
|
153
|
+
raise ArgumentError, 'please provide memory verse ID' unless id_or_link
|
154
|
+
|
147
155
|
path =
|
148
|
-
if /^https
|
156
|
+
if /^https?:\/\//.match?(id_or_link.to_s)
|
149
157
|
id_or_link
|
150
158
|
else
|
151
159
|
File.join(base_path, 'memory_verses', id_or_link.to_s)
|
@@ -158,13 +166,15 @@ module WCC::JTJ
|
|
158
166
|
|
159
167
|
private
|
160
168
|
|
169
|
+
REDIRECT_STATUS_CODES = [301, 302, 307].freeze
|
170
|
+
|
161
171
|
def get_http(url, query, headers = {})
|
162
172
|
q = @query_defaults.merge(query || {})
|
163
173
|
|
164
174
|
loop do
|
165
175
|
resp = @connection.get(url, q, headers)
|
166
176
|
|
167
|
-
if
|
177
|
+
if REDIRECT_STATUS_CODES.include?(resp.status)
|
168
178
|
url = URI.join(@base_url, resp.headers['Location'])
|
169
179
|
next
|
170
180
|
end
|
data/lib/wcc-jtj-client.rb
CHANGED
data/wcc-jtj-client.gemspec
CHANGED
@@ -14,14 +14,15 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.description = ''
|
15
15
|
spec.license = 'Not licensed for external use'
|
16
16
|
|
17
|
-
spec.required_ruby_version = '>= 2.
|
17
|
+
spec.required_ruby_version = '>= 2.7'
|
18
18
|
|
19
19
|
spec.files =
|
20
20
|
`git ls-files -z`.split("\x0").reject do |f|
|
21
|
-
f.match(
|
21
|
+
f.match(/^(test|spec|features)\//)
|
22
22
|
end
|
23
23
|
|
24
24
|
spec.require_paths = ['lib']
|
25
25
|
|
26
26
|
spec.add_runtime_dependency 'faraday'
|
27
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
27
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wcc-jtj-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Watermark Dev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -59,11 +59,12 @@ files:
|
|
59
59
|
- lib/wcc/jtj/client/utils.rb
|
60
60
|
- lib/wcc/jtj/client/version.rb
|
61
61
|
- wcc-jtj-client.gemspec
|
62
|
-
homepage:
|
62
|
+
homepage:
|
63
63
|
licenses:
|
64
64
|
- Not licensed for external use
|
65
|
-
metadata:
|
66
|
-
|
65
|
+
metadata:
|
66
|
+
rubygems_mfa_required: 'true'
|
67
|
+
post_install_message:
|
67
68
|
rdoc_options: []
|
68
69
|
require_paths:
|
69
70
|
- lib
|
@@ -71,7 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
72
|
requirements:
|
72
73
|
- - ">="
|
73
74
|
- !ruby/object:Gem::Version
|
74
|
-
version: '2.
|
75
|
+
version: '2.7'
|
75
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
77
|
requirements:
|
77
78
|
- - ">="
|
@@ -79,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
80
|
version: '0'
|
80
81
|
requirements: []
|
81
82
|
rubygems_version: 3.1.6
|
82
|
-
signing_key:
|
83
|
+
signing_key:
|
83
84
|
specification_version: 4
|
84
85
|
summary: Internal Watermark.org gem, not licensed for external use.
|
85
86
|
test_files: []
|