shotgun_api_ruby 0.0.5 → 0.0.8
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/test_and_publish.yml +73 -0
- data/.github/workflows/test_only.yml +53 -0
- data/.github/workflows/verify_version_change.yml +21 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +3 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +23 -0
- data/Gemfile.lock +43 -39
- data/README.md +48 -3
- data/lib/shotgun_api_ruby/client.rb +1 -1
- data/lib/shotgun_api_ruby/entities.rb +85 -1
- data/lib/shotgun_api_ruby/entities/schema.rb +49 -0
- data/lib/shotgun_api_ruby/entity.rb +1 -1
- data/lib/shotgun_api_ruby/version.rb +1 -1
- data/shotgun_api_ruby.gemspec +1 -1
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ae703829a60a9216ec532dd7d90c627bc15cab08a766ba245a90f67f7bff696
|
4
|
+
data.tar.gz: b7dfe8b5ecfe096ea87986eb5c4e292919503133e8baea2d115405ae52d349bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b9463f3e579cd14c74036e25691ccb73a296268a2729b188dd52453f459287c5c212ed357a48c06b6e41376a018fe7a79c5f88e9ff8b577abaa1bcc1b9b852b
|
7
|
+
data.tar.gz: 972f60041a6f0025c3691d4ed44ae08991b1b544030a59cbba61bbcbadf55ff6061032826a483572d37e3e23a12deddf6005d78870de9b84429fbdcceb5fc550
|
@@ -0,0 +1,73 @@
|
|
1
|
+
name: Test and Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
test-2_5:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Set up Ruby
|
15
|
+
uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: 2.5
|
18
|
+
- name: Install dependencies
|
19
|
+
run: bundle install
|
20
|
+
- name: Run linter
|
21
|
+
run: bundle exec rubocop
|
22
|
+
- name: Run tests
|
23
|
+
run: bundle exec rspec
|
24
|
+
test-2_6:
|
25
|
+
runs-on: ubuntu-latest
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v2
|
29
|
+
- name: Set up Ruby
|
30
|
+
uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: 2.6
|
33
|
+
- name: Install dependencies
|
34
|
+
run: bundle install
|
35
|
+
- name: Run linter
|
36
|
+
run: bundle exec rubocop
|
37
|
+
- name: Run tests
|
38
|
+
run: bundle exec rspec
|
39
|
+
test-2_7:
|
40
|
+
runs-on: ubuntu-latest
|
41
|
+
|
42
|
+
steps:
|
43
|
+
- uses: actions/checkout@v2
|
44
|
+
- name: Set up Ruby
|
45
|
+
uses: ruby/setup-ruby@v1
|
46
|
+
with:
|
47
|
+
ruby-version: 2.7
|
48
|
+
- name: Install dependencies
|
49
|
+
run: bundle install
|
50
|
+
- name: Run linter
|
51
|
+
run: bundle exec rubocop
|
52
|
+
- name: Run tests
|
53
|
+
run: bundle exec rspec
|
54
|
+
release:
|
55
|
+
needs: [test-2_5, test-2_6, test-2_7]
|
56
|
+
runs-on: ubuntu-latest
|
57
|
+
|
58
|
+
steps:
|
59
|
+
- uses: actions/checkout@v2
|
60
|
+
- name: Set up Ruby
|
61
|
+
uses: ruby/setup-ruby@v1
|
62
|
+
with:
|
63
|
+
ruby-version: 2.7
|
64
|
+
- name: Install dependencies
|
65
|
+
run: bundle install
|
66
|
+
- name: Prepare credentials
|
67
|
+
env:
|
68
|
+
RUBYGEM_KEY: ${{ secrets.RUBYGEM_KEY }}
|
69
|
+
run: "echo -e \"---\\r\\n:rubygems_api_key: $RUBYGEM_KEY\" > ~/.gem/credentials && chmod 0600 ~/.gem/credentials"
|
70
|
+
- name: Setup username/email
|
71
|
+
run: "git config --global user.email zaratan@hey.com && git config --global user.name \"Denis <Zaratan> Pasin\""
|
72
|
+
- name: Publish
|
73
|
+
run: rake release
|
@@ -0,0 +1,53 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches-ignore:
|
6
|
+
- main
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
test-2_5:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Set up Ruby
|
15
|
+
uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: 2.5
|
18
|
+
- name: Install dependencies
|
19
|
+
run: bundle install
|
20
|
+
- name: Run linter
|
21
|
+
run: bundle exec rubocop
|
22
|
+
- name: Run tests
|
23
|
+
run: bundle exec rspec
|
24
|
+
test-2_6:
|
25
|
+
runs-on: ubuntu-latest
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v2
|
29
|
+
- name: Set up Ruby
|
30
|
+
uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: 2.6
|
33
|
+
- name: Install dependencies
|
34
|
+
run: bundle install
|
35
|
+
- name: Run linter
|
36
|
+
run: bundle exec rubocop
|
37
|
+
- name: Run tests
|
38
|
+
run: bundle exec rspec
|
39
|
+
test-2_7:
|
40
|
+
runs-on: ubuntu-latest
|
41
|
+
|
42
|
+
steps:
|
43
|
+
- uses: actions/checkout@v2
|
44
|
+
- name: Set up Ruby
|
45
|
+
uses: ruby/setup-ruby@v1
|
46
|
+
with:
|
47
|
+
ruby-version: 2.7
|
48
|
+
- name: Install dependencies
|
49
|
+
run: bundle install
|
50
|
+
- name: Run linter
|
51
|
+
run: bundle exec rubocop
|
52
|
+
- name: Run tests
|
53
|
+
run: bundle exec rspec
|
@@ -0,0 +1,21 @@
|
|
1
|
+
name: Verify version change
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
version_change:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Fetch main branch
|
15
|
+
run: git fetch origin main:main
|
16
|
+
- name: Verify if there's a change in version
|
17
|
+
run: "git diff main lib/shotgun_api_ruby/version.rb | grep VERSION"
|
18
|
+
- name: Print new version
|
19
|
+
run: 'git diff main lib/shotgun_api_ruby/version.rb | grep -E "^\+.*VERSION" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?"'
|
20
|
+
- name: Verify if higher version
|
21
|
+
run: '[[ $(git diff main lib/shotgun_api_ruby/version.rb | grep -E "^\+.*VERSION" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?") > $(git diff main lib/shotgun_api_ruby/version.rb | grep -E "^-.*VERSION" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?") ]]'
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.7.2
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.0.8] - 2020-12-16
|
10
|
+
### Added
|
11
|
+
- Schema: read
|
12
|
+
- Schema: read fields
|
13
|
+
|
14
|
+
## [0.0.7] - 2020-12-16
|
15
|
+
### Added
|
16
|
+
- Entities: update
|
17
|
+
- Entities: create
|
18
|
+
- Entities: delete
|
19
|
+
- Entities: revive
|
20
|
+
|
21
|
+
[Unreleased]: https://github.com/shotgunsoftware/shotgun_api_ruby/compare/v0.0.8...HEAD
|
22
|
+
[0.0.8]: https://github.com/shotgunsoftware/shotgun_api_ruby/releases/tag/v0.0.8
|
23
|
+
[0.0.7]: https://github.com/shotgunsoftware/shotgun_api_ruby/releases/tag/v0.0.7
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
shotgun_api_ruby (0.0.
|
4
|
+
shotgun_api_ruby (0.0.8)
|
5
5
|
activesupport
|
6
6
|
faraday (~> 1)
|
7
7
|
zeitwerk (~> 2.2)
|
@@ -9,12 +9,12 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (6.0
|
12
|
+
activesupport (6.1.0)
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
-
i18n (>=
|
15
|
-
minitest (
|
16
|
-
tzinfo (~>
|
17
|
-
zeitwerk (~> 2.
|
14
|
+
i18n (>= 1.6, < 2)
|
15
|
+
minitest (>= 5.1)
|
16
|
+
tzinfo (~> 2.0)
|
17
|
+
zeitwerk (~> 2.3)
|
18
18
|
ast (2.4.1)
|
19
19
|
backport (1.1.2)
|
20
20
|
benchmark (0.1.0)
|
@@ -27,84 +27,88 @@ GEM
|
|
27
27
|
diff-lcs (1.4.4)
|
28
28
|
dotenv (2.7.6)
|
29
29
|
e2mmap (0.1.0)
|
30
|
-
faraday (1.0
|
30
|
+
faraday (1.1.0)
|
31
31
|
multipart-post (>= 1.2, < 3)
|
32
|
+
ruby2_keywords
|
32
33
|
i18n (1.8.5)
|
33
34
|
concurrent-ruby (~> 1.0)
|
34
35
|
iniparse (1.5.0)
|
35
36
|
jaro_winkler (1.5.4)
|
36
|
-
|
37
|
+
kramdown (2.3.0)
|
38
|
+
rexml
|
39
|
+
kramdown-parser-gfm (1.1.0)
|
40
|
+
kramdown (~> 2.0)
|
37
41
|
method_source (1.0.0)
|
38
42
|
mini_portile2 (2.4.0)
|
39
43
|
minitest (5.14.2)
|
40
44
|
multipart-post (2.1.1)
|
41
45
|
nokogiri (1.10.10)
|
42
46
|
mini_portile2 (~> 2.4.0)
|
43
|
-
overcommit (0.
|
47
|
+
overcommit (0.57.0)
|
44
48
|
childprocess (>= 0.6.3, < 5)
|
45
49
|
iniparse (~> 1.4)
|
46
|
-
parallel (1.
|
47
|
-
parser (2.7.
|
50
|
+
parallel (1.20.1)
|
51
|
+
parser (2.7.2.0)
|
48
52
|
ast (~> 2.4.1)
|
49
53
|
pry (0.13.1)
|
50
54
|
coderay (~> 1.1)
|
51
55
|
method_source (~> 1.0)
|
52
56
|
rainbow (3.0.0)
|
53
57
|
rake (13.0.1)
|
54
|
-
regexp_parser (
|
58
|
+
regexp_parser (2.0.0)
|
55
59
|
reverse_markdown (2.0.0)
|
56
60
|
nokogiri
|
57
61
|
rexml (3.2.4)
|
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.
|
62
|
+
rspec (3.10.0)
|
63
|
+
rspec-core (~> 3.10.0)
|
64
|
+
rspec-expectations (~> 3.10.0)
|
65
|
+
rspec-mocks (~> 3.10.0)
|
66
|
+
rspec-core (3.10.0)
|
67
|
+
rspec-support (~> 3.10.0)
|
68
|
+
rspec-expectations (3.10.0)
|
65
69
|
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
-
rspec-support (~> 3.
|
67
|
-
rspec-mocks (3.
|
70
|
+
rspec-support (~> 3.10.0)
|
71
|
+
rspec-mocks (3.10.0)
|
68
72
|
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
-
rspec-support (~> 3.
|
70
|
-
rspec-support (3.
|
71
|
-
rubocop (
|
73
|
+
rspec-support (~> 3.10.0)
|
74
|
+
rspec-support (3.10.0)
|
75
|
+
rubocop (1.6.1)
|
72
76
|
parallel (~> 1.10)
|
73
|
-
parser (>= 2.7.1.
|
77
|
+
parser (>= 2.7.1.5)
|
74
78
|
rainbow (>= 2.2.2, < 4.0)
|
75
|
-
regexp_parser (>= 1.
|
79
|
+
regexp_parser (>= 1.8, < 3.0)
|
76
80
|
rexml
|
77
|
-
rubocop-ast (>=
|
81
|
+
rubocop-ast (>= 1.2.0, < 2.0)
|
78
82
|
ruby-progressbar (~> 1.7)
|
79
83
|
unicode-display_width (>= 1.4.0, < 2.0)
|
80
|
-
rubocop-ast (
|
81
|
-
parser (>= 2.7.1.
|
82
|
-
rubocop-performance (1.
|
83
|
-
rubocop (>= 0.
|
84
|
+
rubocop-ast (1.3.0)
|
85
|
+
parser (>= 2.7.1.5)
|
86
|
+
rubocop-performance (1.9.1)
|
87
|
+
rubocop (>= 0.90.0, < 2.0)
|
84
88
|
rubocop-ast (>= 0.4.0)
|
85
89
|
ruby-progressbar (1.10.1)
|
86
|
-
|
90
|
+
ruby2_keywords (0.0.2)
|
91
|
+
solargraph (0.40.0)
|
87
92
|
backport (~> 1.1)
|
88
93
|
benchmark
|
89
94
|
bundler (>= 1.17.2)
|
90
95
|
e2mmap
|
91
96
|
jaro_winkler (~> 1.5)
|
92
|
-
|
93
|
-
|
97
|
+
kramdown (~> 2.3)
|
98
|
+
kramdown-parser-gfm (~> 1.1)
|
94
99
|
parser (~> 2.3)
|
95
100
|
reverse_markdown (>= 1.0.5, < 3)
|
96
|
-
rubocop (
|
101
|
+
rubocop (>= 0.52)
|
97
102
|
thor (~> 1.0)
|
98
103
|
tilt (~> 2.0)
|
99
104
|
yard (~> 0.9, >= 0.9.24)
|
100
105
|
thor (1.0.1)
|
101
|
-
thread_safe (0.3.6)
|
102
106
|
tilt (2.0.10)
|
103
|
-
tzinfo (
|
104
|
-
|
107
|
+
tzinfo (2.0.3)
|
108
|
+
concurrent-ruby (~> 1.0)
|
105
109
|
unicode-display_width (1.7.0)
|
106
110
|
yard (0.9.25)
|
107
|
-
zeitwerk (2.4.
|
111
|
+
zeitwerk (2.4.2)
|
108
112
|
|
109
113
|
PLATFORMS
|
110
114
|
ruby
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# ShotgunApiRuby
|
2
2
|
|
3
|
+
[](https://badge.fury.io/rb/shotgun_api_ruby)
|
4
|
+

|
5
|
+
|
3
6
|
A gem to integrate with shotgun REST API easily.
|
4
7
|
|
5
8
|
## Installation
|
@@ -305,15 +308,57 @@ client.assets.find(724, fields: [:code, 'description'], retired: false)
|
|
305
308
|
|
306
309
|
#### Create
|
307
310
|
|
308
|
-
|
311
|
+
Will create the entity referenced by the id with the following fields.
|
312
|
+
If successful, it will return the newly created entity.
|
313
|
+
|
314
|
+
```ruby
|
315
|
+
client.assets.create(code: 'New Asset', project: {type: 'Project', id: 63})
|
316
|
+
```
|
309
317
|
|
310
318
|
#### Update
|
311
319
|
|
312
|
-
|
320
|
+
Will update the entity referenced by the id with the following fields.
|
321
|
+
If successful, it will return the modified entity.
|
322
|
+
|
323
|
+
```ruby
|
324
|
+
client.assets.update(1226, code: 'Updated Asset', sg_status_list: 'fin')
|
325
|
+
```
|
313
326
|
|
314
327
|
#### Delete
|
315
328
|
|
316
|
-
|
329
|
+
Will destroys the entity referenced by the id. Will return true if successful.
|
330
|
+
|
331
|
+
```ruby
|
332
|
+
client.assets.delete(1226)
|
333
|
+
```
|
334
|
+
|
335
|
+
#### Revive
|
336
|
+
|
337
|
+
Will try to revive the entity referenced by the id. Will return true if successful.
|
338
|
+
|
339
|
+
```ruby
|
340
|
+
client.assets.revive(1226)
|
341
|
+
```
|
342
|
+
|
343
|
+
### Schema
|
344
|
+
|
345
|
+
Those calls allow to inspect the schema for a shotgun site.
|
346
|
+
|
347
|
+
#### Entity
|
348
|
+
|
349
|
+
```ruby
|
350
|
+
client.assets.schema
|
351
|
+
```
|
352
|
+
|
353
|
+
#### Entity fields
|
354
|
+
|
355
|
+
Fetch the different fields available on an entity type and their definition.
|
356
|
+
|
357
|
+
```ruby
|
358
|
+
fields = client.assets.fields
|
359
|
+
fields.code.name # => "Asset Name"
|
360
|
+
fields.code.properties.summary_default # => "none"
|
361
|
+
```
|
317
362
|
|
318
363
|
### Non implemented calls
|
319
364
|
|
@@ -5,6 +5,7 @@ module ShotgunApiRuby
|
|
5
5
|
def initialize(connection, type)
|
6
6
|
@connection = connection.dup
|
7
7
|
@type = type
|
8
|
+
@base_url_prefix = @connection.url_prefix
|
8
9
|
@connection.url_prefix = "#{@connection.url_prefix}/entity/#{type}"
|
9
10
|
end
|
10
11
|
|
@@ -52,6 +53,78 @@ module ShotgunApiRuby
|
|
52
53
|
)
|
53
54
|
end
|
54
55
|
|
56
|
+
def create(**attributes)
|
57
|
+
resp =
|
58
|
+
@connection.post('', attributes.to_json) do |req|
|
59
|
+
req.headers['Content-Type'] = 'application/json'
|
60
|
+
end
|
61
|
+
|
62
|
+
resp_body = JSON.parse(resp.body)
|
63
|
+
|
64
|
+
if resp.status >= 300
|
65
|
+
raise "Error while creating #{type}# with #{attributes}: #{resp_body['errors']}"
|
66
|
+
end
|
67
|
+
|
68
|
+
entity = resp_body["data"]
|
69
|
+
Entity.new(
|
70
|
+
entity['type'],
|
71
|
+
OpenStruct.new(entity['attributes']),
|
72
|
+
entity['relationships'],
|
73
|
+
entity['id'],
|
74
|
+
entity['links']
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
def update(id, **changes)
|
79
|
+
return find(id) if changes.empty?
|
80
|
+
|
81
|
+
resp =
|
82
|
+
@connection.put(id.to_s, changes.to_json) do |req|
|
83
|
+
req.headers['Content-Type'] = 'application/json'
|
84
|
+
end
|
85
|
+
|
86
|
+
resp_body = JSON.parse(resp.body)
|
87
|
+
|
88
|
+
if resp.status >= 300
|
89
|
+
raise "Error while updating #{type}##{id} with #{changes}: #{resp_body['errors']}"
|
90
|
+
end
|
91
|
+
|
92
|
+
entity = resp_body["data"]
|
93
|
+
Entity.new(
|
94
|
+
entity['type'],
|
95
|
+
OpenStruct.new(entity['attributes']),
|
96
|
+
entity['relationships'],
|
97
|
+
entity['id'],
|
98
|
+
entity['links']
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
def delete(id)
|
103
|
+
resp =
|
104
|
+
@connection.delete(id.to_s) do |req|
|
105
|
+
req.headers['Content-Type'] = 'application/json'
|
106
|
+
end
|
107
|
+
|
108
|
+
if resp.status >= 300
|
109
|
+
resp_body = JSON.parse(resp.body)
|
110
|
+
raise "Error while deleting #{type}##{id}: #{resp_body['errors']}"
|
111
|
+
end
|
112
|
+
|
113
|
+
true
|
114
|
+
end
|
115
|
+
|
116
|
+
def revive(id)
|
117
|
+
resp =
|
118
|
+
@connection.post("#{id}?revive=true")
|
119
|
+
|
120
|
+
if resp.status >= 300
|
121
|
+
resp_body = JSON.parse(resp.body)
|
122
|
+
raise "Error while reviving #{type}##{id}: #{resp_body['errors']}"
|
123
|
+
end
|
124
|
+
|
125
|
+
true
|
126
|
+
end
|
127
|
+
|
55
128
|
def all(
|
56
129
|
fields: nil,
|
57
130
|
logical_operator: 'and',
|
@@ -148,7 +221,6 @@ module ShotgunApiRuby
|
|
148
221
|
req.headers['Content-Type'] = 'application/vnd+shotgun.api3_hash+json'
|
149
222
|
end
|
150
223
|
req.body = params.to_h.merge(filters: filter).to_json
|
151
|
-
pp JSON.parse(req.body)
|
152
224
|
end
|
153
225
|
resp_body = JSON.parse(resp.body)
|
154
226
|
|
@@ -167,6 +239,18 @@ module ShotgunApiRuby
|
|
167
239
|
end
|
168
240
|
end
|
169
241
|
|
242
|
+
def schema_client
|
243
|
+
@schema_client ||= Schema.new(connection, type, @base_url_prefix)
|
244
|
+
end
|
245
|
+
|
246
|
+
def schema
|
247
|
+
schema_client.read
|
248
|
+
end
|
249
|
+
|
250
|
+
def fields
|
251
|
+
schema_client.fields
|
252
|
+
end
|
253
|
+
|
170
254
|
private
|
171
255
|
|
172
256
|
def filters_are_simple?(filters)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ShotgunApiRuby
|
4
|
+
class Entities
|
5
|
+
class Schema
|
6
|
+
def initialize(connection, type, base_url_prefix)
|
7
|
+
@connection = connection.dup
|
8
|
+
@type = type
|
9
|
+
@connection.url_prefix = "#{base_url_prefix}/schema/#{type}"
|
10
|
+
end
|
11
|
+
attr_reader :type, :connection
|
12
|
+
|
13
|
+
def read
|
14
|
+
resp = @connection.get('')
|
15
|
+
|
16
|
+
if resp.status >= 300
|
17
|
+
raise "Error while read schema for #{type}: #{resp.body}"
|
18
|
+
end
|
19
|
+
|
20
|
+
resp_body = JSON.parse(resp.body)
|
21
|
+
|
22
|
+
OpenStruct.new(
|
23
|
+
resp_body["data"].transform_values{ |v| v["value"] }
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
def fields
|
28
|
+
resp = @connection.get('fields')
|
29
|
+
resp_body = JSON.parse(resp.body)
|
30
|
+
|
31
|
+
if resp.status >= 300
|
32
|
+
raise "Error while read schema fields for #{type}: #{resp.body}"
|
33
|
+
end
|
34
|
+
|
35
|
+
OpenStruct.new(
|
36
|
+
resp_body["data"].transform_values do |value|
|
37
|
+
OpenStruct.new(
|
38
|
+
value.transform_values do |attribute|
|
39
|
+
attribute["value"]
|
40
|
+
end.merge(
|
41
|
+
properties: OpenStruct.new(value["properties"].transform_values{ |prop| prop["value"] })
|
42
|
+
)
|
43
|
+
)
|
44
|
+
end
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -14,7 +14,7 @@ module ShotgunApiRuby
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def respond_to_missing?(name, _private_methods = false)
|
17
|
+
def respond_to_missing?(name, _private_methods = false)
|
18
18
|
attributes.respond_to?(name) || super
|
19
19
|
end
|
20
20
|
end
|
data/shotgun_api_ruby.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
|
19
19
|
spec.metadata["homepage_uri"] = spec.homepage
|
20
20
|
spec.metadata["source_code_uri"] = "https://github.com/shotgunsoftware/shotgun_api_ruby"
|
21
|
-
|
21
|
+
spec.metadata['changelog_uri'] = "https://github.com/shotgunsoftware/shotgun_api_ruby/blob/main/CHANGELOG.md"
|
22
22
|
|
23
23
|
# Specify which files should be added to the gem when it is released.
|
24
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shotgun_api_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis <Zaratan> Pasin
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -199,6 +199,9 @@ executables: []
|
|
199
199
|
extensions: []
|
200
200
|
extra_rdoc_files: []
|
201
201
|
files:
|
202
|
+
- ".github/workflows/test_and_publish.yml"
|
203
|
+
- ".github/workflows/test_only.yml"
|
204
|
+
- ".github/workflows/verify_version_change.yml"
|
202
205
|
- ".gitignore"
|
203
206
|
- ".overcommit.yml"
|
204
207
|
- ".rspec"
|
@@ -207,6 +210,7 @@ files:
|
|
207
210
|
- ".ruby-gemset"
|
208
211
|
- ".ruby-version"
|
209
212
|
- ".travis.yml"
|
213
|
+
- CHANGELOG.md
|
210
214
|
- Gemfile
|
211
215
|
- Gemfile.lock
|
212
216
|
- LICENSE.txt
|
@@ -219,6 +223,7 @@ files:
|
|
219
223
|
- lib/shotgun_api_ruby/client.rb
|
220
224
|
- lib/shotgun_api_ruby/entities.rb
|
221
225
|
- lib/shotgun_api_ruby/entities/params.rb
|
226
|
+
- lib/shotgun_api_ruby/entities/schema.rb
|
222
227
|
- lib/shotgun_api_ruby/entity.rb
|
223
228
|
- lib/shotgun_api_ruby/preferences.rb
|
224
229
|
- lib/shotgun_api_ruby/server_info.rb
|
@@ -230,7 +235,8 @@ licenses:
|
|
230
235
|
metadata:
|
231
236
|
homepage_uri: https://github.com/shotgunsoftware/shotgun_api_ruby
|
232
237
|
source_code_uri: https://github.com/shotgunsoftware/shotgun_api_ruby
|
233
|
-
|
238
|
+
changelog_uri: https://github.com/shotgunsoftware/shotgun_api_ruby/blob/main/CHANGELOG.md
|
239
|
+
post_install_message:
|
234
240
|
rdoc_options: []
|
235
241
|
require_paths:
|
236
242
|
- lib
|
@@ -245,8 +251,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
245
251
|
- !ruby/object:Gem::Version
|
246
252
|
version: '0'
|
247
253
|
requirements: []
|
248
|
-
rubygems_version: 3.
|
249
|
-
signing_key:
|
254
|
+
rubygems_version: 3.1.4
|
255
|
+
signing_key:
|
250
256
|
specification_version: 4
|
251
257
|
summary: Gem to interact easily with Shotgun REST api.
|
252
258
|
test_files: []
|