lingutest_client 0.1.5 → 0.2.3

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: c720d6b45a1920d5e0d8b6624415807e2f5ae099f62020d949f0559d4e93cac1
4
- data.tar.gz: 1d979933919db99cfaa57c5ecd40c06b58cbda121850406d8cee7ab87e79ef5c
3
+ metadata.gz: a0c93a77d5086cadaeb4f824d5896e60309f083b0671ca7c48029fd0fe003b6f
4
+ data.tar.gz: 510c3cb33addcb4cf46294fd13c2bf21a700a2c090f6fa6b8e7d469189a979ad
5
5
  SHA512:
6
- metadata.gz: dc3ed1b9e05a0e7b7c58ae5c1cd83786f2a1e10fd1776a2265d2d1c750f2fd1449b14d72af26be6d02d15dc3b3221c1efbd4173dee3445bef30e8d73af05b46f
7
- data.tar.gz: 6e291959bb887a3be5f5bdae7a16de8a0eb45a33f0227d7dc09d248219c5bc6e41c1ea609e4978d82801031a02d1fa04ec0908f898f81204092fbe48b156f82e
6
+ metadata.gz: ca771706d78940363a386aac7acfa08f954b709c7a59f61941266b41ab82c97d4f1b687256e8d9989282fb6d6624eb4bec3eff30483af826c2e5ff9def05be5d
7
+ data.tar.gz: d51fe1a6f8e21b15c0147d41b7e2f9fcda5606e2b0ebfc3acc9f3deb4dad4d3a72a4ef60ac4f140d4781ecc8c41ce8b2060f3c2e5e6e54e298310b6fd3f7cc74
data/.rubocop.yml CHANGED
@@ -1,2 +1,9 @@
1
+ require:
2
+ - rubocop-rake
3
+ - rubocop-rspec
4
+
5
+ AllCops:
6
+ NewCops: enable
7
+
1
8
  Style/Documentation:
2
9
  Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # CHANGELOG
2
+
3
+ ## Next release
4
+ ...
5
+
6
+ ## 0.2.3 (15 August 2023)
7
+ List candidates filters
8
+
9
+ ## 0.2.2 (16 March 2023)
10
+ Result URL
11
+
12
+ ## 0.2.1 (24 February 2023)
data/Gemfile CHANGED
@@ -5,5 +5,11 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in lingutest_client.gemspec
6
6
  gemspec
7
7
 
8
+ gem 'pry'
8
9
  gem 'rake', '~> 12.0'
9
10
  gem 'rspec', '~> 3.0'
11
+ gem 'rubocop', '~> 1.43.0'
12
+ gem 'rubocop-rake'
13
+ gem 'rubocop-rspec'
14
+ gem 'shoulda-matchers', '~> 5.0'
15
+ gem 'vcr', '~> 6.0'
data/Gemfile.lock CHANGED
@@ -1,115 +1,157 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lingutest_client (0.1.5)
5
- dry-configurable (~> 0.9.0)
6
- dry-schema (~> 1.4.3)
7
- dry-struct (~> 1.2.0)
8
- dry-types (~> 1.2.2)
9
- faraday (~> 1.8.0)
4
+ lingutest_client (0.2.3)
5
+ dry-configurable (~> 0.13.0)
6
+ dry-schema (~> 1.10.0)
7
+ dry-struct (~> 1.5.0)
8
+ dry-types (~> 1.6.0)
9
+ faraday (~> 1.10.0)
10
10
  faraday_middleware (~> 1.2.0)
11
+ zeitwerk (~> 2.6.7, >= 2.6.7)
11
12
 
12
13
  GEM
13
14
  remote: https://rubygems.org/
14
15
  specs:
16
+ activesupport (7.0.4.2)
17
+ concurrent-ruby (~> 1.0, >= 1.0.2)
18
+ i18n (>= 1.6, < 2)
19
+ minitest (>= 5.1)
20
+ tzinfo (~> 2.0)
15
21
  ast (2.4.2)
16
- concurrent-ruby (1.1.9)
22
+ coderay (1.1.3)
23
+ concurrent-ruby (1.2.0)
17
24
  diff-lcs (1.5.0)
18
- dry-configurable (0.9.0)
25
+ dry-configurable (0.13.0)
19
26
  concurrent-ruby (~> 1.0)
20
- dry-core (~> 0.4, >= 0.4.7)
21
- dry-container (0.8.0)
27
+ dry-core (~> 0.6)
28
+ dry-container (0.11.0)
22
29
  concurrent-ruby (~> 1.0)
23
- dry-configurable (~> 0.1, >= 0.1.3)
24
- dry-core (0.7.1)
30
+ dry-core (0.9.1)
25
31
  concurrent-ruby (~> 1.0)
26
- dry-equalizer (0.3.0)
27
- dry-inflector (0.2.1)
28
- dry-initializer (3.0.4)
29
- dry-logic (1.2.0)
32
+ zeitwerk (~> 2.6)
33
+ dry-inflector (0.3.0)
34
+ dry-initializer (3.1.1)
35
+ dry-logic (1.3.0)
30
36
  concurrent-ruby (~> 1.0)
31
- dry-core (~> 0.5, >= 0.5)
32
- dry-schema (1.4.3)
37
+ dry-core (~> 0.9, >= 0.9)
38
+ zeitwerk (~> 2.6)
39
+ dry-schema (1.10.6)
33
40
  concurrent-ruby (~> 1.0)
34
- dry-configurable (~> 0.8, >= 0.8.3)
35
- dry-core (~> 0.4)
36
- dry-equalizer (~> 0.2)
41
+ dry-configurable (~> 0.13, >= 0.13.0)
42
+ dry-core (~> 0.5, >= 0.5)
37
43
  dry-initializer (~> 3.0)
38
- dry-logic (~> 1.0)
39
- dry-types (~> 1.2)
40
- dry-struct (1.2.0)
41
- dry-core (~> 0.4, >= 0.4.3)
42
- dry-equalizer (~> 0.3)
43
- dry-types (~> 1.0)
44
+ dry-logic (~> 1.2)
45
+ dry-types (~> 1.5)
46
+ dry-struct (1.5.2)
47
+ dry-core (~> 0.9, >= 0.9)
48
+ dry-types (~> 1.6)
44
49
  ice_nine (~> 0.11)
45
- dry-types (1.2.2)
50
+ zeitwerk (~> 2.6)
51
+ dry-types (1.6.1)
46
52
  concurrent-ruby (~> 1.0)
47
53
  dry-container (~> 0.3)
48
- dry-core (~> 0.4, >= 0.4.4)
49
- dry-equalizer (~> 0.3)
54
+ dry-core (~> 0.9, >= 0.9)
50
55
  dry-inflector (~> 0.1, >= 0.1.2)
51
- dry-logic (~> 1.0, >= 1.0.2)
52
- faraday (1.8.0)
56
+ dry-logic (~> 1.3, >= 1.3)
57
+ zeitwerk (~> 2.6)
58
+ faraday (1.10.3)
53
59
  faraday-em_http (~> 1.0)
54
60
  faraday-em_synchrony (~> 1.0)
55
61
  faraday-excon (~> 1.1)
56
- faraday-httpclient (~> 1.0.1)
62
+ faraday-httpclient (~> 1.0)
63
+ faraday-multipart (~> 1.0)
57
64
  faraday-net_http (~> 1.0)
58
- faraday-net_http_persistent (~> 1.1)
65
+ faraday-net_http_persistent (~> 1.0)
59
66
  faraday-patron (~> 1.0)
60
67
  faraday-rack (~> 1.0)
61
- multipart-post (>= 1.2, < 3)
68
+ faraday-retry (~> 1.0)
62
69
  ruby2_keywords (>= 0.0.4)
63
70
  faraday-em_http (1.0.0)
64
71
  faraday-em_synchrony (1.0.0)
65
72
  faraday-excon (1.1.0)
66
73
  faraday-httpclient (1.0.1)
74
+ faraday-multipart (1.0.4)
75
+ multipart-post (~> 2)
67
76
  faraday-net_http (1.0.1)
68
77
  faraday-net_http_persistent (1.2.0)
69
78
  faraday-patron (1.0.0)
70
79
  faraday-rack (1.0.0)
80
+ faraday-retry (1.0.3)
71
81
  faraday_middleware (1.2.0)
72
82
  faraday (~> 1.0)
83
+ i18n (1.12.0)
84
+ concurrent-ruby (~> 1.0)
73
85
  ice_nine (0.11.2)
74
- jaro_winkler (1.5.4)
75
- multipart-post (2.1.1)
76
- parallel (1.21.0)
77
- parser (3.1.0.0)
86
+ json (2.6.3)
87
+ method_source (1.0.0)
88
+ minitest (5.17.0)
89
+ multipart-post (2.3.0)
90
+ parallel (1.22.1)
91
+ parser (3.2.1.0)
78
92
  ast (~> 2.4.1)
79
- rainbow (3.0.0)
93
+ pry (0.14.2)
94
+ coderay (~> 1.1)
95
+ method_source (~> 1.0)
96
+ rainbow (3.1.1)
80
97
  rake (12.3.3)
81
- rspec (3.10.0)
82
- rspec-core (~> 3.10.0)
83
- rspec-expectations (~> 3.10.0)
84
- rspec-mocks (~> 3.10.0)
85
- rspec-core (3.10.1)
86
- rspec-support (~> 3.10.0)
87
- rspec-expectations (3.10.1)
98
+ regexp_parser (2.7.0)
99
+ rexml (3.2.5)
100
+ rspec (3.12.0)
101
+ rspec-core (~> 3.12.0)
102
+ rspec-expectations (~> 3.12.0)
103
+ rspec-mocks (~> 3.12.0)
104
+ rspec-core (3.12.1)
105
+ rspec-support (~> 3.12.0)
106
+ rspec-expectations (3.12.2)
88
107
  diff-lcs (>= 1.2.0, < 2.0)
89
- rspec-support (~> 3.10.0)
90
- rspec-mocks (3.10.2)
108
+ rspec-support (~> 3.12.0)
109
+ rspec-mocks (3.12.3)
91
110
  diff-lcs (>= 1.2.0, < 2.0)
92
- rspec-support (~> 3.10.0)
93
- rspec-support (3.10.3)
94
- rubocop (0.79.0)
95
- jaro_winkler (~> 1.5.1)
111
+ rspec-support (~> 3.12.0)
112
+ rspec-support (3.12.0)
113
+ rubocop (1.43.0)
114
+ json (~> 2.3)
96
115
  parallel (~> 1.10)
97
- parser (>= 2.7.0.1)
116
+ parser (>= 3.2.0.0)
98
117
  rainbow (>= 2.2.2, < 4.0)
118
+ regexp_parser (>= 1.8, < 3.0)
119
+ rexml (>= 3.2.5, < 4.0)
120
+ rubocop-ast (>= 1.24.1, < 2.0)
99
121
  ruby-progressbar (~> 1.7)
100
- unicode-display_width (>= 1.4.0, < 1.7)
122
+ unicode-display_width (>= 2.4.0, < 3.0)
123
+ rubocop-ast (1.26.0)
124
+ parser (>= 3.2.1.0)
125
+ rubocop-capybara (2.17.1)
126
+ rubocop (~> 1.41)
127
+ rubocop-rake (0.6.0)
128
+ rubocop (~> 1.0)
129
+ rubocop-rspec (2.18.1)
130
+ rubocop (~> 1.33)
131
+ rubocop-capybara (~> 2.17)
101
132
  ruby-progressbar (1.11.0)
102
133
  ruby2_keywords (0.0.5)
103
- unicode-display_width (1.6.1)
134
+ shoulda-matchers (5.3.0)
135
+ activesupport (>= 5.2.0)
136
+ tzinfo (2.0.6)
137
+ concurrent-ruby (~> 1.0)
138
+ unicode-display_width (2.4.2)
139
+ vcr (6.1.0)
140
+ zeitwerk (2.6.7)
104
141
 
105
142
  PLATFORMS
106
143
  ruby
107
144
 
108
145
  DEPENDENCIES
109
146
  lingutest_client!
147
+ pry
110
148
  rake (~> 12.0)
111
149
  rspec (~> 3.0)
112
- rubocop (~> 0.79.0)
150
+ rubocop (~> 1.43.0)
151
+ rubocop-rake
152
+ rubocop-rspec
153
+ shoulda-matchers (~> 5.0)
154
+ vcr (~> 6.0)
113
155
 
114
156
  BUNDLED WITH
115
- 2.2.27
157
+ 2.4.18
data/README.md CHANGED
@@ -15,6 +15,17 @@ And then execute:
15
15
 
16
16
  $ bundle install
17
17
 
18
+ ## Configuration
19
+
20
+ ```ruby
21
+ # config/initializers/lingutest_client.rb
22
+
23
+ LingutestClient.configure do |config|
24
+ config.api_base = 'https://test.lingu.com/api/v1/'
25
+ config.api_key = 'yourLinguTestApiKey'
26
+ end
27
+ ```
28
+
18
29
  ## Usage
19
30
 
20
31
  ```ruby
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LingutestClient
4
- module API
4
+ module Api
5
5
  module Operations
6
6
  module Create
7
7
  module ClassMethods
8
- def create(**params) # rubocop:disable Metrics/AbcSize
8
+ def create(**params)
9
9
  schema = const_get(:CreateSchema).call(params)
10
10
  unless schema.success?
11
11
  raise ValidationError,
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LingutestClient
4
- module API
4
+ module Api
5
5
  module Operations
6
6
  module Delete
7
7
  module ClassMethods
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LingutestClient
4
- module API
4
+ module Api
5
5
  module Operations
6
6
  module Find
7
7
  module ClassMethods
@@ -1,16 +1,37 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LingutestClient
4
- module API
4
+ module Api
5
5
  module Operations
6
6
  module List
7
+ DELEGATED_METHODS = %i[
8
+ each
9
+ empty?
10
+ find
11
+ first
12
+ last
13
+ map
14
+ reject
15
+ select
16
+ size
17
+ ].freeze
18
+
7
19
  class << self
8
- def module(list_type)
20
+ def module(list_type, params_schema = nil) # rubocop:disable Metrics/MethodLength
9
21
  Module.new do
10
22
  class_methods_module = Module.new
11
- class_methods_module.define_method :list do
12
- list_type.new(Client.get(resource_url).body)
23
+
24
+ class_methods_module.define_method :list do |**options|
25
+ params = options.dup
26
+ if params_schema
27
+ result = params_schema.call(options)
28
+ raise ArgumentError, result.errors if result.failure?
29
+
30
+ params = result.to_h
31
+ end
32
+ list_type.new(Client.get(resource_url, **params).body)
13
33
  end
34
+
14
35
  define_singleton_method :included do |base|
15
36
  base.extend class_methods_module
16
37
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LingutestClient
4
- module API
4
+ module Api
5
5
  module Operations
6
6
  module Update
7
7
  module ClassMethods
8
- def update(id, **params) # rubocop:disable Metrics/AbcSize
8
+ def update(id, **params)
9
9
  schema = const_get(:UpdateSchema).call(params)
10
10
  unless schema.success?
11
11
  raise ValidationError,
@@ -3,7 +3,7 @@
3
3
  require 'ostruct'
4
4
 
5
5
  module LingutestClient
6
- module API
6
+ module Api
7
7
  module Resource
8
8
  module ClassMethods
9
9
  def resource_url
@@ -1,9 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'forwardable'
4
- require 'dry-struct'
5
- require 'dry-schema'
6
-
7
3
  module LingutestClient
8
4
  class Base < Dry::Struct
9
5
  extend Forwardable
@@ -1,36 +1,42 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'uri/mailto'
4
-
5
3
  module LingutestClient
6
4
  class Candidate < Base
7
5
  CreateSchema = Dry::Schema.Params do
8
6
  required(:fname).filled(:string)
9
7
  required(:lname).filled(:string)
10
- required(:email).filled(:string, format?: URI::MailTo::EMAIL_REGEXP)
8
+ required(:email).filled(Types::Email)
11
9
  optional(:locale).filled(:string)
12
10
  optional(:mobile).filled(:string)
13
11
  optional(:gender).filled(Types::Gender)
14
- optional(:ssn).filled(:string, format?: /\A([\d]{10,11}|[\d]{5,6}|^$)\z/i)
12
+ optional(:ssn).filled(Types::Ssn)
15
13
  end
16
14
  UpdateSchema = Dry::Schema.Params do
17
15
  optional(:fname).filled(:string)
18
16
  optional(:lname).filled(:string)
19
- optional(:email).filled(:string, format?: URI::MailTo::EMAIL_REGEXP)
17
+ optional(:email).filled(Types::Email)
20
18
  optional(:locale).filled(:string)
21
19
  optional(:mobile).filled(:string)
22
20
  optional(:gender).filled(Types::Gender)
23
- optional(:ssn).filled(:string, format?: /\A([\d]{10,11}|[\d]{5,6}|^$)\z/i)
21
+ optional(:ssn).filled(Types::Ssn)
22
+ end
23
+
24
+ FilterSchema = Dry::Schema.Params do
25
+ optional(:page)
26
+ optional(:per_page)
27
+ optional(:email_eq).filled(Types::Email)
28
+ optional(:fname_eq).filled(:string)
29
+ optional(:lname_eq).filled(:string)
24
30
  end
25
31
 
26
32
  OBJECT_NAME = :candidate
27
33
 
28
- include API::Resource
29
- include API::Operations::List.module(CandidateList)
30
- include API::Operations::Create
31
- include API::Operations::Find
32
- include API::Operations::Delete
33
- include API::Operations::Update
34
+ include Api::Resource
35
+ include Api::Operations::List.module(CandidateList, FilterSchema)
36
+ include Api::Operations::Create
37
+ include Api::Operations::Find
38
+ include Api::Operations::Delete
39
+ include Api::Operations::Update
34
40
 
35
41
  attribute :id, Types::Coercible::Integer.default(0)
36
42
  attribute :email, Types::Coercible::String.default('')
@@ -39,7 +45,6 @@ module LingutestClient
39
45
  attribute :mobile, Types::Coercible::String.default('')
40
46
  attribute :locale, Types::Coercible::String.default('')
41
47
  attribute :ssn, Types::Coercible::String.default('')
42
- attribute :gender,
43
- Types::String.optional.enum('unknown', 'male', 'female')
48
+ attribute :gender, Types::Gender
44
49
  end
45
50
  end
@@ -3,7 +3,7 @@
3
3
  module LingutestClient
4
4
  class CandidateList < Base
5
5
  include Enumerable
6
- delegate %i[each size last] => :candidates
6
+ delegate ::LingutestClient::Api::Operations::List::DELEGATED_METHODS => :candidates
7
7
 
8
8
  attribute :candidates, Types::Array.of(Candidate)
9
9
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LingutestClient
4
+ class Client
5
+ include Connection
6
+ end
7
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'forwardable'
3
+ require 'faraday'
4
4
 
5
5
  module LingutestClient
6
6
  module Connection
@@ -4,12 +4,13 @@ module LingutestClient
4
4
  class Exam < Base
5
5
  OBJECT_NAME = :exam
6
6
 
7
- include API::Resource
8
- include API::Operations::List.module(ExamList)
7
+ include Api::Resource
8
+ include Api::Operations::List.module(ExamList)
9
9
 
10
10
  attribute :id, Types::Coercible::Integer.optional.default(0)
11
11
  attribute :name, Types::Coercible::String.optional.default('')
12
12
  attribute :description, Types::Coercible::String.optional.default('')
13
+ attribute :price, Types::Coercible::Decimal.optional.default(0)
13
14
  attribute :updated_at, Types::DateTime.optional.default(nil)
14
15
  end
15
16
  end
@@ -3,7 +3,7 @@
3
3
  module LingutestClient
4
4
  class ExamList < Base
5
5
  include Enumerable
6
- delegate %i[each size last] => :exams
6
+ delegate ::LingutestClient::Api::Operations::List::DELEGATED_METHODS => :exams
7
7
 
8
8
  attribute :exams, Types::Array.of(Exam)
9
9
  end
@@ -2,35 +2,58 @@
2
2
 
3
3
  module LingutestClient
4
4
  class Examination < Base
5
+ OBJECT_NAME = :examination
6
+
7
+ STATUSES = %w[
8
+ pending
9
+ in_progress
10
+ completed
11
+ pending_review
12
+ reviewed
13
+ ].freeze
14
+
5
15
  CreateSchema = Dry::Schema.Params do
6
16
  required(:exam_id).filled(Types::Coercible::Integer)
7
17
  required(:candidate_id).filled(Types::Coercible::Integer)
8
18
  required(:expires_at).filled(Types::DateTime)
9
- optional(:redirect_url).filled(:string, format?: %r{\Ahttps?://.+\z}i)
19
+ optional(:redirect_url).filled(Types::Url)
20
+
21
+ optional(:team_id).filled(Types::Coercible::String)
22
+ optional(:team_group_id).filled(Types::Coercible::String)
23
+ optional(:student_id).filled(Types::Coercible::String)
10
24
  end
11
25
 
12
- OBJECT_NAME = :examination
26
+ FilterSchema = Dry::Schema.Params do
27
+ config.validate_keys = true
28
+ optional(:page).filled(Types::Coercible::Integer)
29
+ optional(:per_page).filled(Types::Coercible::Integer)
30
+
31
+ optional(:team_id_eq).filled(Types::Coercible::String)
32
+ optional(:team_group_id_eq).filled(Types::Coercible::String)
33
+ optional(:student_id_eq).filled(Types::Coercible::String)
34
+ end
13
35
 
14
- include API::Resource
15
- include API::Operations::List.module(ExaminationList)
16
- include API::Operations::Create
17
- include API::Operations::Find
36
+ include Api::Resource
37
+ include Api::Operations::List.module(ExaminationList, FilterSchema)
38
+ include Api::Operations::Create
39
+ include Api::Operations::Find
18
40
 
19
41
  attribute :id, Types::Integer.optional
20
42
  attribute :exam, Exam.optional.default(nil)
21
43
  attribute :candidate, Candidate.optional.default(nil)
22
44
  attribute :total_score, Types::Integer.optional.default(0)
45
+ attribute :max_score, Types::Integer.optional.default(0)
46
+ attribute :tasks_limit, Types::Integer.optional.default(0)
23
47
  attribute :total_time_spent, Types::Integer.optional.default(0)
24
48
  attribute :code, Types::String.optional.default('')
25
49
  attribute :redirect_url, Types::String.optional
50
+ attribute :price, Types::Coercible::Decimal.optional.default(0)
51
+
52
+ attribute :team_id, Types::String.optional.default(nil)
53
+ attribute :team_group_id, Types::String.optional.default(nil)
54
+ attribute :student_id, Types::String.optional.default(nil)
26
55
 
27
- attribute :status, Types::Integer.optional.default(0).enum(
28
- 0 => 'pending',
29
- 1 => 'in_progress',
30
- 2 => 'completed',
31
- 3 => 'pending_review',
32
- 4 => 'reviewed'
33
- )
56
+ attribute :status, Types::String.optional.enum(*STATUSES)
34
57
 
35
58
  attribute :expires_at, Types::Time.optional.default(nil)
36
59
  attribute :created_at, Types::Time.optional.default(nil)
@@ -39,5 +62,15 @@ module LingutestClient
39
62
  def url
40
63
  URI.join(LingutestClient.config.api_base.to_s, "/#{code}").to_s
41
64
  end
65
+
66
+ def result_url
67
+ URI.join(LingutestClient.config.api_base.to_s, "/examinations/#{code}").to_s
68
+ end
69
+
70
+ STATUSES.each do |status|
71
+ define_method "#{status}?" do
72
+ self.status == status
73
+ end
74
+ end
42
75
  end
43
76
  end
@@ -3,8 +3,15 @@
3
3
  module LingutestClient
4
4
  class ExaminationList < Base
5
5
  include Enumerable
6
- delegate %i[each size last] => :examinations
6
+ delegate ::LingutestClient::Api::Operations::List::DELEGATED_METHODS => :examinations
7
7
 
8
8
  attribute :examinations, Types::Array.of(Examination)
9
+
10
+ attribute :limit_value, Types::Coercible::Integer
11
+ attribute :current_page, Types::Coercible::Integer
12
+ attribute :total_pages, Types::Coercible::Integer
13
+ attribute :total_count, Types::Coercible::Integer
14
+ attribute :per_page, Types::Coercible::Integer
15
+ attribute :page, Types::Coercible::Integer
9
16
  end
10
17
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'dry-types'
4
+ require 'uri/mailto'
4
5
 
5
6
  module LingutestClient
6
7
  module Types
@@ -9,5 +10,8 @@ module LingutestClient
9
10
  DateTime = Strict::Date | JSON::Date | Strict::Time
10
11
  Time = Strict::Time | Types::JSON::Time
11
12
  Gender = Types::String.enum('unknown', 'male', 'female')
13
+ Email = Types::String.constrained(format: URI::MailTo::EMAIL_REGEXP)
14
+ Ssn = Types::String.constrained(format: /\A(\d{10,11}|\d{5,6}|^$)\z/i)
15
+ Url = Types::String.constrained(format: %r{\Ahttps?://.+\z}i)
12
16
  end
13
17
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LingutestClient
4
+ class ValidationError < StandardError
5
+ end
6
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LingutestClient
2
- VERSION = '0.1.5'
4
+ VERSION = '0.2.3'
3
5
  end
@@ -1,26 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  $LOAD_PATH.unshift File.dirname(__FILE__)
4
+ require 'dry-configurable'
5
+ require 'dry-schema'
6
+ require 'dry-struct'
7
+ require 'dry-types'
8
+ require 'forwardable'
9
+ require 'zeitwerk'
4
10
 
5
- module LingutestClient
6
- autoload :API, 'lingutest_client/api'
7
- autoload :Base, 'lingutest_client/base'
8
- autoload :Candidate, 'lingutest_client/candidate'
9
- autoload :Configuration, 'lingutest_client/configuration'
10
- autoload :Connection, 'lingutest_client/connection'
11
- autoload :CandidateList, 'lingutest_client/candidate_list'
12
- autoload :Exam, 'lingutest_client/exam'
13
- autoload :ExamList, 'lingutest_client/exam_list'
14
- autoload :Examination, 'lingutest_client/examination'
15
- autoload :ExaminationList, 'lingutest_client/examination_list'
16
- autoload :Types, 'lingutest_client/types'
17
- autoload :VERSION, 'lingutest_client/version'
11
+ Zeitwerk::Loader.for_gem.setup
18
12
 
19
- include Configuration
13
+ module LingutestClient
14
+ extend Dry::Configurable
20
15
 
21
- class ValidationError < StandardError; end
16
+ setting :api_base,
17
+ default: 'https://test.lingu.com/api/v1/',
18
+ constructor: proc { |value| URI.parse(value) },
19
+ reader: true
22
20
 
23
- class Client
24
- include LingutestClient::Connection
25
- end
21
+ setting :api_key,
22
+ constructor: proc { |value| value.to_s },
23
+ reader: true
26
24
  end
@@ -8,16 +8,17 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['Anatolii Didukh']
9
9
  spec.email = ['railsme7@gmail.com']
10
10
 
11
- spec.summary = 'Write a short summary, because RubyGems requires one.'
12
- spec.description = 'Write a longer description or delete this line.'
13
- # spec.homepage = "Put your gem's website or public repo URL here."
14
- spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
11
+ spec.summary = 'lingutest client'
12
+ spec.description = 'test.lingu.com API ruby client'
13
+ spec.homepage = 'https://github.com/AdeptLMS/lingutest_client'
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7.6')
15
15
 
16
+ spec.metadata['rubygems_mfa_required'] = 'true'
16
17
  # spec.metadata['allowed_push_host'] = "Set to 'http://mygemserver.com'"
17
18
 
18
- # spec.metadata["homepage_uri"] = spec.homepage
19
- # spec.metadata["source_code_uri"] = "Put your gem's public repo URL here."
20
- # spec.metadata["changelog_uri"] = "Put your gem's CHANGELOG.md URL here."
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = 'https://github.com/AdeptLMS/lingutest_client'
21
+ spec.metadata['changelog_uri'] = 'https://github.com/AdeptLMS/lingutest_client/blob/master/CHANGELOG.md'
21
22
 
22
23
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
24
  `git ls-files -z`
@@ -27,12 +28,12 @@ Gem::Specification.new do |spec|
27
28
  spec.bindir = 'exe'
28
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
30
  spec.require_paths = ['lib']
30
- spec.add_dependency 'dry-configurable', '~> 0.9.0'
31
- spec.add_dependency 'dry-schema', '~> 1.4.3'
32
- spec.add_dependency 'dry-struct', '~> 1.2.0'
33
- spec.add_dependency 'dry-types', '~> 1.2.2'
34
31
 
35
- spec.add_dependency 'faraday', '~> 1.8.0'
32
+ spec.add_dependency 'dry-configurable', '~> 0.13.0'
33
+ spec.add_dependency 'dry-schema', '~> 1.10.0'
34
+ spec.add_dependency 'dry-struct', '~> 1.5.0'
35
+ spec.add_dependency 'dry-types', '~> 1.6.0'
36
+ spec.add_dependency 'faraday', '~> 1.10.0'
36
37
  spec.add_dependency 'faraday_middleware', '~> 1.2.0'
37
- spec.add_development_dependency 'rubocop', '~> 0.79.0'
38
+ spec.add_dependency 'zeitwerk', '~> 2.6.7', '>= 2.6.7'
38
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lingutest_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatolii Didukh
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-04 00:00:00.000000000 Z
11
+ date: 2023-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
@@ -16,70 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.9.0
19
+ version: 0.13.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.9.0
26
+ version: 0.13.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: dry-schema
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.4.3
33
+ version: 1.10.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.4.3
40
+ version: 1.10.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: dry-struct
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.2.0
47
+ version: 1.5.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.2.0
54
+ version: 1.5.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: dry-types
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 1.2.2
61
+ version: 1.6.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 1.2.2
68
+ version: 1.6.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: faraday
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.8.0
75
+ version: 1.10.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.8.0
82
+ version: 1.10.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: faraday_middleware
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -95,20 +95,26 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.2.0
97
97
  - !ruby/object:Gem::Dependency
98
- name: rubocop
98
+ name: zeitwerk
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.79.0
104
- type: :development
103
+ version: 2.6.7
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: 2.6.7
107
+ type: :runtime
105
108
  prerelease: false
106
109
  version_requirements: !ruby/object:Gem::Requirement
107
110
  requirements:
108
111
  - - "~>"
109
112
  - !ruby/object:Gem::Version
110
- version: 0.79.0
111
- description: Write a longer description or delete this line.
113
+ version: 2.6.7
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 2.6.7
117
+ description: test.lingu.com API ruby client
112
118
  email:
113
119
  - railsme7@gmail.com
114
120
  executables: []
@@ -119,6 +125,7 @@ files:
119
125
  - ".rspec"
120
126
  - ".rubocop.yml"
121
127
  - ".travis.yml"
128
+ - CHANGELOG.md
122
129
  - CODE_OF_CONDUCT.md
123
130
  - Gemfile
124
131
  - Gemfile.lock
@@ -127,8 +134,6 @@ files:
127
134
  - bin/console
128
135
  - bin/setup
129
136
  - lib/lingutest_client.rb
130
- - lib/lingutest_client/api.rb
131
- - lib/lingutest_client/api/operations.rb
132
137
  - lib/lingutest_client/api/operations/create.rb
133
138
  - lib/lingutest_client/api/operations/delete.rb
134
139
  - lib/lingutest_client/api/operations/find.rb
@@ -138,18 +143,23 @@ files:
138
143
  - lib/lingutest_client/base.rb
139
144
  - lib/lingutest_client/candidate.rb
140
145
  - lib/lingutest_client/candidate_list.rb
141
- - lib/lingutest_client/configuration.rb
146
+ - lib/lingutest_client/client.rb
142
147
  - lib/lingutest_client/connection.rb
143
148
  - lib/lingutest_client/exam.rb
144
149
  - lib/lingutest_client/exam_list.rb
145
150
  - lib/lingutest_client/examination.rb
146
151
  - lib/lingutest_client/examination_list.rb
147
152
  - lib/lingutest_client/types.rb
153
+ - lib/lingutest_client/validation_error.rb
148
154
  - lib/lingutest_client/version.rb
149
155
  - lingutest_client.gemspec
150
- homepage:
156
+ homepage: https://github.com/AdeptLMS/lingutest_client
151
157
  licenses: []
152
- metadata: {}
158
+ metadata:
159
+ rubygems_mfa_required: 'true'
160
+ homepage_uri: https://github.com/AdeptLMS/lingutest_client
161
+ source_code_uri: https://github.com/AdeptLMS/lingutest_client
162
+ changelog_uri: https://github.com/AdeptLMS/lingutest_client/blob/master/CHANGELOG.md
153
163
  post_install_message:
154
164
  rdoc_options: []
155
165
  require_paths:
@@ -158,15 +168,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
168
  requirements:
159
169
  - - ">="
160
170
  - !ruby/object:Gem::Version
161
- version: 2.3.0
171
+ version: 2.7.6
162
172
  required_rubygems_version: !ruby/object:Gem::Requirement
163
173
  requirements:
164
174
  - - ">="
165
175
  - !ruby/object:Gem::Version
166
176
  version: '0'
167
177
  requirements: []
168
- rubygems_version: 3.2.22
178
+ rubygems_version: 3.4.18
169
179
  signing_key:
170
180
  specification_version: 4
171
- summary: Write a short summary, because RubyGems requires one.
181
+ summary: lingutest client
172
182
  test_files: []
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- module API
5
- module Operations
6
- autoload :Create, 'lingutest_client/api/operations/create'
7
- autoload :Delete, 'lingutest_client/api/operations/delete'
8
- autoload :Find, 'lingutest_client/api/operations/find'
9
- autoload :List, 'lingutest_client/api/operations/list'
10
- autoload :Update, 'lingutest_client/api/operations/update'
11
- end
12
- end
13
- end
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- module API
5
- autoload :Resource, 'lingutest_client/api/resource'
6
- autoload :Operations, 'lingutest_client/api/operations'
7
- end
8
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'dry-configurable'
4
-
5
- module LingutestClient
6
- module Configuration
7
- def self.included(base)
8
- base.extend Dry::Configurable
9
- base.class_eval do
10
- setting(:api_base,
11
- 'https://test.lingu.com/api/v1/',
12
- reader: true) do |value|
13
- URI.parse(value)
14
- end
15
- setting(:api_key, reader: true, &:to_s)
16
- end
17
- end
18
- end
19
- end