unit-ruby 0.9.0 → 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/.github/workflows/ruby.yml +2 -0
- data/Gemfile.lock +4 -1
- data/README.md +1 -1
- data/lib/unit-ruby/util/connection.rb +10 -2
- 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 +1 -0
- metadata +18 -3
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/.github/workflows/ruby.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
unit-ruby (0.
|
4
|
+
unit-ruby (0.10.0)
|
5
5
|
activesupport
|
6
6
|
faraday (>= 2.0.1, < 3)
|
7
7
|
faraday-retry
|
@@ -56,6 +56,8 @@ GEM
|
|
56
56
|
rspec-expectations (3.13.3)
|
57
57
|
diff-lcs (>= 1.2.0, < 2.0)
|
58
58
|
rspec-support (~> 3.13.0)
|
59
|
+
rspec-file_fixtures (0.1.9)
|
60
|
+
rspec (~> 3.12)
|
59
61
|
rspec-mocks (3.13.2)
|
60
62
|
diff-lcs (>= 1.2.0, < 2.0)
|
61
63
|
rspec-support (~> 3.13.0)
|
@@ -85,6 +87,7 @@ DEPENDENCIES
|
|
85
87
|
pry
|
86
88
|
rake (~> 13.0)
|
87
89
|
rspec (~> 3.0)
|
90
|
+
rspec-file_fixtures (~> 0.1.9)
|
88
91
|
rubocop (~> 1.24.1)
|
89
92
|
unit-ruby!
|
90
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
|
|
@@ -14,6 +14,7 @@ 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
20
|
f.response :json # decode response bodies as JSON
|
@@ -37,7 +38,6 @@ module Unit
|
|
37
38
|
def post(path, data = nil)
|
38
39
|
response = connection.post do |req|
|
39
40
|
req.url path
|
40
|
-
req.headers['Content-Type'] = 'application/vnd.api+json'
|
41
41
|
req.body = data.deep_transform_keys! { |key| key.to_s.camelize(:lower) } if data
|
42
42
|
end
|
43
43
|
|
@@ -50,7 +50,6 @@ module Unit
|
|
50
50
|
def patch(path, data = nil)
|
51
51
|
response = connection.patch do |req|
|
52
52
|
req.url path
|
53
|
-
req.headers['Content-Type'] = 'application/vnd.api+json'
|
54
53
|
req.body = data.deep_transform_keys! { |key| key.to_s.camelize(:lower) } if data
|
55
54
|
end
|
56
55
|
|
@@ -59,6 +58,15 @@ module Unit
|
|
59
58
|
from_json_api(response.body)
|
60
59
|
end
|
61
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
|
+
|
62
70
|
def from_json_api(response_body)
|
63
71
|
response_body.deep_transform_keys do |key|
|
64
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
@@ -42,6 +42,7 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.add_development_dependency 'pry'
|
43
43
|
spec.add_development_dependency 'rake', '~> 13.0'
|
44
44
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
45
|
+
spec.add_development_dependency 'rspec-file_fixtures', '~> 0.1.9'
|
45
46
|
spec.add_development_dependency 'rubocop', '~> 1.24.1'
|
46
47
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
47
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
|
@@ -115,6 +115,20 @@ dependencies:
|
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
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
|
118
132
|
- !ruby/object:Gem::Dependency
|
119
133
|
name: rubocop
|
120
134
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,6 +210,7 @@ files:
|
|
196
210
|
- lib/unit-ruby/util/resource_operations.rb
|
197
211
|
- lib/unit-ruby/util/schema.rb
|
198
212
|
- lib/unit-ruby/version.rb
|
213
|
+
- lib/unit-ruby/white_label_language.rb
|
199
214
|
- lib/unit-ruby/white_label_theme.rb
|
200
215
|
- unit-ruby.gemspec
|
201
216
|
homepage: https://github.com/retirable/unit-ruby
|
@@ -222,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
237
|
- !ruby/object:Gem::Version
|
223
238
|
version: '0'
|
224
239
|
requirements: []
|
225
|
-
rubygems_version: 3.
|
240
|
+
rubygems_version: 3.2.3
|
226
241
|
signing_key:
|
227
242
|
specification_version: 4
|
228
243
|
summary: A Ruby gem for communicating with the Unit API.
|