unit-ruby 0.8.1 → 0.10.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/.env.example +2 -0
- data/.github/workflows/ruby.yml +3 -1
- data/Gemfile.lock +49 -55
- data/README.md +1 -1
- data/lib/unit-ruby/util/connection.rb +11 -4
- data/lib/unit-ruby/util/resource_operations.rb +20 -0
- data/lib/unit-ruby/version.rb +1 -1
- data/lib/unit-ruby/white_label_language.rb +9 -0
- data/lib/unit-ruby/white_label_theme.rb +5 -0
- data/lib/unit-ruby.rb +1 -0
- data/unit-ruby.gemspec +4 -4
- metadata +35 -33
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e31b034179f13eb859547998eaba9d38df67c7becaea41ed14e23bfef35d4aa7
|
|
4
|
+
data.tar.gz: ff540f8d02f5fbe31096a0158dc4050c41830bb596c572986377339c406f462c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2219dc5eb8680c78c08f3efee4e10aaa237507431b3c079ca6a9ba600e77a06928e8f5132cb9f5b094bc87afec643095c5dc3e47c6d330896283079fb0170945
|
|
7
|
+
data.tar.gz: 473e5f6ebc1e409a739a788792a64fceccd8c53fcbc07666d792bd9aa3e09e19a784260a516406466b30d8d72ea3f38b3918c1f2961c26da703d21f8f67e6432
|
data/.env.example
ADDED
data/.github/workflows/ruby.yml
CHANGED
|
@@ -16,13 +16,15 @@ on:
|
|
|
16
16
|
env:
|
|
17
17
|
UNIT_API_KEY: "${{secrets.UNIT_API_KEY}}"
|
|
18
18
|
UNIT_BASE_URL: "${{secrets.UNIT_BASE_URL}}"
|
|
19
|
+
UNIT_THEME_ID: 55392
|
|
20
|
+
UNIT_LANGUAGE_ID: 14363
|
|
19
21
|
|
|
20
22
|
jobs:
|
|
21
23
|
test:
|
|
22
24
|
runs-on: ubuntu-latest
|
|
23
25
|
strategy:
|
|
24
26
|
matrix:
|
|
25
|
-
ruby-version: ["
|
|
27
|
+
ruby-version: ["3.0", "3.3"]
|
|
26
28
|
|
|
27
29
|
steps:
|
|
28
30
|
- uses: actions/checkout@v2
|
data/Gemfile.lock
CHANGED
|
@@ -1,73 +1,67 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
unit-ruby (0.
|
|
5
|
-
activesupport
|
|
6
|
-
faraday (
|
|
7
|
-
|
|
4
|
+
unit-ruby (0.10.0)
|
|
5
|
+
activesupport
|
|
6
|
+
faraday (>= 2.0.1, < 3)
|
|
7
|
+
faraday-retry
|
|
8
8
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
activesupport (7.0.
|
|
12
|
+
activesupport (7.0.8.7)
|
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
14
14
|
i18n (>= 1.6, < 2)
|
|
15
15
|
minitest (>= 5.1)
|
|
16
16
|
tzinfo (~> 2.0)
|
|
17
17
|
ast (2.4.2)
|
|
18
18
|
coderay (1.1.3)
|
|
19
|
-
concurrent-ruby (1.
|
|
20
|
-
diff-lcs (1.5.
|
|
19
|
+
concurrent-ruby (1.3.4)
|
|
20
|
+
diff-lcs (1.5.1)
|
|
21
21
|
dotenv (2.7.6)
|
|
22
|
-
faraday (
|
|
23
|
-
faraday-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
faraday
|
|
30
|
-
|
|
31
|
-
multipart-post (>= 1.2, < 3)
|
|
32
|
-
ruby2_keywords (>= 0.0.4)
|
|
33
|
-
faraday-em_http (1.0.0)
|
|
34
|
-
faraday-em_synchrony (1.0.0)
|
|
35
|
-
faraday-excon (1.1.0)
|
|
36
|
-
faraday-httpclient (1.0.1)
|
|
37
|
-
faraday-net_http (1.0.1)
|
|
38
|
-
faraday-net_http_persistent (1.2.0)
|
|
39
|
-
faraday-patron (1.0.0)
|
|
40
|
-
faraday-rack (1.0.0)
|
|
41
|
-
faraday_middleware (1.0.0)
|
|
42
|
-
faraday (~> 1.0)
|
|
43
|
-
i18n (1.12.0)
|
|
22
|
+
faraday (2.12.2)
|
|
23
|
+
faraday-net_http (>= 2.0, < 3.5)
|
|
24
|
+
json
|
|
25
|
+
logger
|
|
26
|
+
faraday-net_http (3.4.0)
|
|
27
|
+
net-http (>= 0.5.0)
|
|
28
|
+
faraday-retry (2.2.1)
|
|
29
|
+
faraday (~> 2.0)
|
|
30
|
+
i18n (1.14.6)
|
|
44
31
|
concurrent-ruby (~> 1.0)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
32
|
+
json (2.9.1)
|
|
33
|
+
logger (1.6.4)
|
|
34
|
+
method_source (1.1.0)
|
|
35
|
+
minitest (5.25.4)
|
|
36
|
+
net-http (0.6.0)
|
|
37
|
+
uri
|
|
38
|
+
parallel (1.26.3)
|
|
39
|
+
parser (3.3.6.0)
|
|
50
40
|
ast (~> 2.4.1)
|
|
51
|
-
|
|
41
|
+
racc
|
|
42
|
+
pry (0.15.2)
|
|
52
43
|
coderay (~> 1.1)
|
|
53
44
|
method_source (~> 1.0)
|
|
45
|
+
racc (1.8.1)
|
|
54
46
|
rainbow (3.1.1)
|
|
55
|
-
rake (13.
|
|
56
|
-
regexp_parser (2.
|
|
57
|
-
rexml (3.
|
|
58
|
-
rspec (3.
|
|
59
|
-
rspec-core (~> 3.
|
|
60
|
-
rspec-expectations (~> 3.
|
|
61
|
-
rspec-mocks (~> 3.
|
|
62
|
-
rspec-core (3.
|
|
63
|
-
rspec-support (~> 3.
|
|
64
|
-
rspec-expectations (3.
|
|
47
|
+
rake (13.2.1)
|
|
48
|
+
regexp_parser (2.10.0)
|
|
49
|
+
rexml (3.4.0)
|
|
50
|
+
rspec (3.13.0)
|
|
51
|
+
rspec-core (~> 3.13.0)
|
|
52
|
+
rspec-expectations (~> 3.13.0)
|
|
53
|
+
rspec-mocks (~> 3.13.0)
|
|
54
|
+
rspec-core (3.13.2)
|
|
55
|
+
rspec-support (~> 3.13.0)
|
|
56
|
+
rspec-expectations (3.13.3)
|
|
65
57
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
66
|
-
rspec-support (~> 3.
|
|
67
|
-
rspec-
|
|
58
|
+
rspec-support (~> 3.13.0)
|
|
59
|
+
rspec-file_fixtures (0.1.9)
|
|
60
|
+
rspec (~> 3.12)
|
|
61
|
+
rspec-mocks (3.13.2)
|
|
68
62
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
69
|
-
rspec-support (~> 3.
|
|
70
|
-
rspec-support (3.
|
|
63
|
+
rspec-support (~> 3.13.0)
|
|
64
|
+
rspec-support (3.13.2)
|
|
71
65
|
rubocop (1.24.1)
|
|
72
66
|
parallel (~> 1.10)
|
|
73
67
|
parser (>= 3.0.0.0)
|
|
@@ -77,23 +71,23 @@ GEM
|
|
|
77
71
|
rubocop-ast (>= 1.15.1, < 2.0)
|
|
78
72
|
ruby-progressbar (~> 1.7)
|
|
79
73
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
80
|
-
rubocop-ast (1.
|
|
81
|
-
parser (>= 3.
|
|
82
|
-
ruby-progressbar (1.
|
|
83
|
-
ruby2_keywords (0.0.5)
|
|
74
|
+
rubocop-ast (1.37.0)
|
|
75
|
+
parser (>= 3.3.1.0)
|
|
76
|
+
ruby-progressbar (1.13.0)
|
|
84
77
|
tzinfo (2.0.6)
|
|
85
78
|
concurrent-ruby (~> 1.0)
|
|
86
|
-
unicode-display_width (2.
|
|
79
|
+
unicode-display_width (2.6.0)
|
|
80
|
+
uri (1.0.2)
|
|
87
81
|
|
|
88
82
|
PLATFORMS
|
|
89
83
|
ruby
|
|
90
84
|
|
|
91
85
|
DEPENDENCIES
|
|
92
|
-
bundler (~> 2.4.0)
|
|
93
86
|
dotenv (~> 2.7.6)
|
|
94
87
|
pry
|
|
95
88
|
rake (~> 13.0)
|
|
96
89
|
rspec (~> 3.0)
|
|
90
|
+
rspec-file_fixtures (~> 0.1.9)
|
|
97
91
|
rubocop (~> 1.24.1)
|
|
98
92
|
unit-ruby!
|
|
99
93
|
|
data/README.md
CHANGED
|
@@ -35,7 +35,7 @@ end
|
|
|
35
35
|
|
|
36
36
|
## Development
|
|
37
37
|
|
|
38
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
38
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You will also need UNIT_THEME_ID and UNIT_LANGUAGE_ID set in your environment. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
39
39
|
|
|
40
40
|
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
41
41
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
require 'faraday'
|
|
2
|
-
require '
|
|
2
|
+
require 'faraday/retry'
|
|
3
3
|
require 'active_support/core_ext/hash'
|
|
4
4
|
|
|
5
5
|
module Unit
|
|
@@ -14,9 +14,9 @@ module Unit
|
|
|
14
14
|
@connection = Faraday.new(self.class.base_url) do |f|
|
|
15
15
|
f.headers['UNIT_TRUST_TOKEN'] = self.class.trust_token if self.class.trust_token
|
|
16
16
|
f.headers['Authorization'] = "Bearer #{self.class.api_key}"
|
|
17
|
+
f.headers['Content-Type'] = 'application/vnd.api+json'
|
|
17
18
|
f.request :json # encode req bodies as JSON
|
|
18
19
|
f.request :retry # retry transient failures
|
|
19
|
-
f.response :follow_redirects # follow redirects
|
|
20
20
|
f.response :json # decode response bodies as JSON
|
|
21
21
|
end
|
|
22
22
|
end
|
|
@@ -38,7 +38,6 @@ module Unit
|
|
|
38
38
|
def post(path, data = nil)
|
|
39
39
|
response = connection.post do |req|
|
|
40
40
|
req.url path
|
|
41
|
-
req.headers['Content-Type'] = 'application/vnd.api+json'
|
|
42
41
|
req.body = data.deep_transform_keys! { |key| key.to_s.camelize(:lower) } if data
|
|
43
42
|
end
|
|
44
43
|
|
|
@@ -51,7 +50,6 @@ module Unit
|
|
|
51
50
|
def patch(path, data = nil)
|
|
52
51
|
response = connection.patch do |req|
|
|
53
52
|
req.url path
|
|
54
|
-
req.headers['Content-Type'] = 'application/vnd.api+json'
|
|
55
53
|
req.body = data.deep_transform_keys! { |key| key.to_s.camelize(:lower) } if data
|
|
56
54
|
end
|
|
57
55
|
|
|
@@ -60,6 +58,15 @@ module Unit
|
|
|
60
58
|
from_json_api(response.body)
|
|
61
59
|
end
|
|
62
60
|
|
|
61
|
+
# Executes a PUT of a JSON object
|
|
62
|
+
def put(path, data = nil)
|
|
63
|
+
response = connection.put(path, data)
|
|
64
|
+
|
|
65
|
+
handle_errors(response)
|
|
66
|
+
|
|
67
|
+
from_json_api(response.body)
|
|
68
|
+
end
|
|
69
|
+
|
|
63
70
|
def from_json_api(response_body)
|
|
64
71
|
response_body.deep_transform_keys do |key|
|
|
65
72
|
key.to_s.underscore.to_sym
|
|
@@ -77,5 +77,25 @@ module Unit
|
|
|
77
77
|
update_resource_from_json_api(updated_resource)
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
|
+
|
|
81
|
+
# Replace the entire resource, instead of only patching dirty attributes
|
|
82
|
+
module Replace
|
|
83
|
+
def replace(attributes)
|
|
84
|
+
updated_resource = self.class.connection.put(
|
|
85
|
+
self.class.resource_path(id),
|
|
86
|
+
{
|
|
87
|
+
data: {
|
|
88
|
+
type: resource_type,
|
|
89
|
+
attributes: attributes
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
update_resource_from_json_api(updated_resource)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def replace_json(json_attributes)
|
|
97
|
+
replace(JSON.parse(json_attributes))
|
|
98
|
+
end
|
|
99
|
+
end
|
|
80
100
|
end
|
|
81
101
|
end
|
data/lib/unit-ruby/version.rb
CHANGED
data/lib/unit-ruby.rb
CHANGED
data/unit-ruby.gemspec
CHANGED
|
@@ -34,15 +34,15 @@ Gem::Specification.new do |spec|
|
|
|
34
34
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
35
35
|
spec.require_paths = ['lib']
|
|
36
36
|
|
|
37
|
-
spec.add_dependency 'activesupport'
|
|
38
|
-
spec.add_dependency 'faraday', '
|
|
39
|
-
spec.add_dependency '
|
|
37
|
+
spec.add_dependency 'activesupport'
|
|
38
|
+
spec.add_dependency 'faraday', '>= 2.0.1', '< 3'
|
|
39
|
+
spec.add_dependency 'faraday-retry'
|
|
40
40
|
|
|
41
|
-
spec.add_development_dependency 'bundler', '~> 2.4.0'
|
|
42
41
|
spec.add_development_dependency 'dotenv', '~> 2.7.6'
|
|
43
42
|
spec.add_development_dependency 'pry'
|
|
44
43
|
spec.add_development_dependency 'rake', '~> 13.0'
|
|
45
44
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
45
|
+
spec.add_development_dependency 'rspec-file_fixtures', '~> 0.1.9'
|
|
46
46
|
spec.add_development_dependency 'rubocop', '~> 1.24.1'
|
|
47
47
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
48
48
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: unit-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chloe Isacke
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: exe
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2025-01-30 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|
|
@@ -17,62 +17,48 @@ dependencies:
|
|
|
17
17
|
requirements:
|
|
18
18
|
- - ">="
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
|
-
version:
|
|
21
|
-
- - "<"
|
|
22
|
-
- !ruby/object:Gem::Version
|
|
23
|
-
version: 7.1.0
|
|
20
|
+
version: '0'
|
|
24
21
|
type: :runtime
|
|
25
22
|
prerelease: false
|
|
26
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
27
24
|
requirements:
|
|
28
25
|
- - ">="
|
|
29
26
|
- !ruby/object:Gem::Version
|
|
30
|
-
version:
|
|
31
|
-
- - "<"
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: 7.1.0
|
|
27
|
+
version: '0'
|
|
34
28
|
- !ruby/object:Gem::Dependency
|
|
35
29
|
name: faraday
|
|
36
30
|
requirement: !ruby/object:Gem::Requirement
|
|
37
31
|
requirements:
|
|
38
|
-
- - "
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: 1.8.0
|
|
41
|
-
type: :runtime
|
|
42
|
-
prerelease: false
|
|
43
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - "~>"
|
|
32
|
+
- - ">="
|
|
46
33
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
48
|
-
-
|
|
49
|
-
name: faraday_middleware
|
|
50
|
-
requirement: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - "~>"
|
|
34
|
+
version: 2.0.1
|
|
35
|
+
- - "<"
|
|
53
36
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
37
|
+
version: '3'
|
|
55
38
|
type: :runtime
|
|
56
39
|
prerelease: false
|
|
57
40
|
version_requirements: !ruby/object:Gem::Requirement
|
|
58
41
|
requirements:
|
|
59
|
-
- - "
|
|
42
|
+
- - ">="
|
|
60
43
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
44
|
+
version: 2.0.1
|
|
45
|
+
- - "<"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3'
|
|
62
48
|
- !ruby/object:Gem::Dependency
|
|
63
|
-
name:
|
|
49
|
+
name: faraday-retry
|
|
64
50
|
requirement: !ruby/object:Gem::Requirement
|
|
65
51
|
requirements:
|
|
66
|
-
- - "
|
|
52
|
+
- - ">="
|
|
67
53
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
69
|
-
type: :
|
|
54
|
+
version: '0'
|
|
55
|
+
type: :runtime
|
|
70
56
|
prerelease: false
|
|
71
57
|
version_requirements: !ruby/object:Gem::Requirement
|
|
72
58
|
requirements:
|
|
73
|
-
- - "
|
|
59
|
+
- - ">="
|
|
74
60
|
- !ruby/object:Gem::Version
|
|
75
|
-
version:
|
|
61
|
+
version: '0'
|
|
76
62
|
- !ruby/object:Gem::Dependency
|
|
77
63
|
name: dotenv
|
|
78
64
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -129,6 +115,20 @@ dependencies:
|
|
|
129
115
|
- - "~>"
|
|
130
116
|
- !ruby/object:Gem::Version
|
|
131
117
|
version: '3.0'
|
|
118
|
+
- !ruby/object:Gem::Dependency
|
|
119
|
+
name: rspec-file_fixtures
|
|
120
|
+
requirement: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: 0.1.9
|
|
125
|
+
type: :development
|
|
126
|
+
prerelease: false
|
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: 0.1.9
|
|
132
132
|
- !ruby/object:Gem::Dependency
|
|
133
133
|
name: rubocop
|
|
134
134
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -151,6 +151,7 @@ executables: []
|
|
|
151
151
|
extensions: []
|
|
152
152
|
extra_rdoc_files: []
|
|
153
153
|
files:
|
|
154
|
+
- ".env.example"
|
|
154
155
|
- ".github/workflows/ruby.yml"
|
|
155
156
|
- ".gitignore"
|
|
156
157
|
- ".rspec"
|
|
@@ -209,6 +210,7 @@ files:
|
|
|
209
210
|
- lib/unit-ruby/util/resource_operations.rb
|
|
210
211
|
- lib/unit-ruby/util/schema.rb
|
|
211
212
|
- lib/unit-ruby/version.rb
|
|
213
|
+
- lib/unit-ruby/white_label_language.rb
|
|
212
214
|
- lib/unit-ruby/white_label_theme.rb
|
|
213
215
|
- unit-ruby.gemspec
|
|
214
216
|
homepage: https://github.com/retirable/unit-ruby
|