atlas_rb 0.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +17 -0
- data/.version +1 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +46 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/atlas_rb/collection.rb +31 -0
- data/lib/atlas_rb/community.rb +30 -0
- data/lib/atlas_rb/faraday_helper.rb +20 -0
- data/lib/atlas_rb/file.rb +30 -0
- data/lib/atlas_rb/file_set.rb +27 -0
- data/lib/atlas_rb/resource.rb +7 -0
- data/lib/atlas_rb/version.rb +5 -0
- data/lib/atlas_rb/work.rb +27 -0
- data/lib/atlas_rb.rb +15 -0
- data/sig/atlas_rb.rbs +4 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 177c9eb9e57db673457bc6c37f8a0b7fd5eda574aa9eb5f2d88e5cf25a930f8d
|
4
|
+
data.tar.gz: 4dba91136ace456d990d298f30e49209df5c460c2821e313b905ecae6e1970ac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b36261fb81bcde9d1dac862d2da28e79e46f261883c645d3fa6aac09ac821ad3b2ac2ebd0342089b034cb21af24cfd43c81a0b7a8086c12fc507eedf27e66e22
|
7
|
+
data.tar.gz: f5babb72d54e08ce9d7f6d280ae378d2c9b66b7b92864a676f2a0d14278f77f4a382e05c2adc196cb549f1aa220848130074d479b4d56939221a37440add1a5d
|
data/.editorconfig
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
; EditorConfig is awesome: http://EditorConfig.org
|
2
|
+
|
3
|
+
; top-most EditorConfig file
|
4
|
+
root = true
|
5
|
+
|
6
|
+
; Unix-style newlines with a newline ending every file
|
7
|
+
[*]
|
8
|
+
end_of_line = lf
|
9
|
+
indent_style = space
|
10
|
+
indent_size = 2
|
11
|
+
trim_trailing_whitespace: true
|
12
|
+
charset = utf-8
|
13
|
+
insert_final_newline = true
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
TargetRubyVersion: 2.6
|
4
|
+
|
5
|
+
Style/StringLiterals:
|
6
|
+
Enabled: true
|
7
|
+
EnforcedStyle: double_quotes
|
8
|
+
|
9
|
+
Style/StringLiteralsInInterpolation:
|
10
|
+
Enabled: true
|
11
|
+
EnforcedStyle: double_quotes
|
12
|
+
|
13
|
+
Layout/LineLength:
|
14
|
+
Max: 120
|
15
|
+
|
16
|
+
Style/Documentation:
|
17
|
+
Enabled: false
|
data/.version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.21
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
atlas_rb (0.1.0)
|
5
|
+
faraday (~> 2.7)
|
6
|
+
faraday-multipart (~> 1)
|
7
|
+
require_all (~> 3)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
diff-lcs (1.5.0)
|
13
|
+
faraday (2.7.10)
|
14
|
+
faraday-net_http (>= 2.0, < 3.1)
|
15
|
+
ruby2_keywords (>= 0.0.4)
|
16
|
+
faraday-multipart (1.0.4)
|
17
|
+
multipart-post (~> 2)
|
18
|
+
faraday-net_http (3.0.2)
|
19
|
+
multipart-post (2.3.0)
|
20
|
+
rake (13.0.6)
|
21
|
+
require_all (3.0.0)
|
22
|
+
rspec (3.12.0)
|
23
|
+
rspec-core (~> 3.12.0)
|
24
|
+
rspec-expectations (~> 3.12.0)
|
25
|
+
rspec-mocks (~> 3.12.0)
|
26
|
+
rspec-core (3.12.2)
|
27
|
+
rspec-support (~> 3.12.0)
|
28
|
+
rspec-expectations (3.12.3)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.12.0)
|
31
|
+
rspec-mocks (3.12.6)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.12.0)
|
34
|
+
rspec-support (3.12.1)
|
35
|
+
ruby2_keywords (0.0.5)
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
x86_64-linux
|
39
|
+
|
40
|
+
DEPENDENCIES
|
41
|
+
atlas_rb!
|
42
|
+
rake (~> 13.0)
|
43
|
+
rspec (~> 3.0)
|
44
|
+
|
45
|
+
BUNDLED WITH
|
46
|
+
2.2.33
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 David Cliff
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# AtlasRb
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/atlas_rb`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'atlas_rb'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install atlas_rb
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/atlas_rb.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "atlas_rb"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AtlasRb
|
4
|
+
class Collection < Resource
|
5
|
+
ROUTE = "/collections/"
|
6
|
+
|
7
|
+
def self.find(id)
|
8
|
+
JSON.parse(connection({}).get(ROUTE + id)&.body)["collection"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.create(id)
|
12
|
+
# params[:parent_id]
|
13
|
+
JSON.parse(connection({ parent_id: id }).post(ROUTE)&.body)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.destroy(id)
|
17
|
+
connection({}).delete(ROUTE + id)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.children(id)
|
21
|
+
JSON.parse(connection({}).get(ROUTE + id + '/children')&.body)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.update(id, xml_path)
|
25
|
+
payload = { binary: Faraday::Multipart::FilePart.new(File.open(xml_path),
|
26
|
+
"application/xml",
|
27
|
+
File.basename(xml_path)) }
|
28
|
+
JSON.parse(multipart({}).patch(ROUTE + id, payload)&.body)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AtlasRb
|
4
|
+
class Community < Resource
|
5
|
+
ROUTE = "/communities/"
|
6
|
+
|
7
|
+
def self.find(id)
|
8
|
+
JSON.parse(connection({}).get(ROUTE + id)&.body)["community"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.create(id = nil)
|
12
|
+
JSON.parse(connection({ parent_id: id }).post(ROUTE)&.body)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.destroy(id)
|
16
|
+
connection({}).delete(ROUTE + id)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.children(id)
|
20
|
+
JSON.parse(connection({}).get(ROUTE + id + '/children')&.body)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.update(id, xml_path)
|
24
|
+
payload = { binary: Faraday::Multipart::FilePart.new(File.open(xml_path),
|
25
|
+
"application/xml",
|
26
|
+
File.basename(xml_path)) }
|
27
|
+
JSON.parse(multipart({}).patch(ROUTE + id, payload)&.body)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AtlasRb
|
4
|
+
module FaradayHelper
|
5
|
+
def connection(params)
|
6
|
+
Faraday.new(
|
7
|
+
url: ENV.fetch("ATLAS_URL", nil),
|
8
|
+
params: params,
|
9
|
+
headers: { "Content-Type" => "application/json" }
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
def multipart(_params)
|
14
|
+
Faraday.new(url: ENV.fetch("ATLAS_URL", nil)) do |f|
|
15
|
+
f.request :multipart
|
16
|
+
f.request :url_encoded
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AtlasRb
|
4
|
+
class File < Resource
|
5
|
+
ROUTE = "/files/"
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.find(id)
|
9
|
+
connection({}).get(ROUTE + id)&.body
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.create(id, blob_path)
|
13
|
+
payload = { binary: Faraday::Multipart::FilePart.new(File.open(blob_path),
|
14
|
+
"application/octet-stream",
|
15
|
+
File.basename(blob_path)) }
|
16
|
+
|
17
|
+
multipart({ work_id: id }).post(ROUTE, payload)&.body
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.destroy(id)
|
21
|
+
connection({}).delete(ROUTE + id)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.update(id, blob_path)
|
25
|
+
payload = { binary: Faraday::Multipart::FilePart.new(File.open(blob_path),
|
26
|
+
"application/octet-stream",
|
27
|
+
File.basename(blob_path)) }
|
28
|
+
multipart({}).patch(ROUTE + id, payload)&.body
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AtlasRb
|
4
|
+
class FileSet < Resource
|
5
|
+
ROUTE = "/file_sets/"
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.find(id)
|
9
|
+
connection({}).get(ROUTE + id)&.body
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.create(id, classification)
|
13
|
+
connection({ work_id: id, classification: classification }).post(ROUTE)&.body
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.destroy(id)
|
17
|
+
connection({}).delete(ROUTE + id)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.update(id, blob_path)
|
21
|
+
# Need to figure out blob vs XML
|
22
|
+
payload = { binary: Faraday::Multipart::FilePart.new(File.open(blob_path),
|
23
|
+
"application/octet-stream",
|
24
|
+
File.basename(blob_path)) }
|
25
|
+
multipart({}).patch(ROUTE + id, payload)&.body
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module AtlasRb
|
4
|
+
class Work < Resource
|
5
|
+
ROUTE = "/works/"
|
6
|
+
|
7
|
+
def self.find(id)
|
8
|
+
connection({}).get(ROUTE + id)&.body
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.create(id)
|
12
|
+
# params[:collection_id]
|
13
|
+
connection({ collection_id: id }).post(ROUTE)&.body
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.destroy(id)
|
17
|
+
connection({}).delete(ROUTE + id)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.update(id, xml_path)
|
21
|
+
payload = { binary: Faraday::Multipart::FilePart.new(File.open(xml_path),
|
22
|
+
"application/xml",
|
23
|
+
File.basename(xml_path)) }
|
24
|
+
multipart({}).patch(ROUTE + id, payload)&.body
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/atlas_rb.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "faraday"
|
4
|
+
require "faraday/multipart"
|
5
|
+
require_relative "atlas_rb/version"
|
6
|
+
require_relative "atlas_rb/faraday_helper"
|
7
|
+
require_relative "atlas_rb/resource"
|
8
|
+
require_relative "atlas_rb/community"
|
9
|
+
require_relative "atlas_rb/collection"
|
10
|
+
require_relative "atlas_rb/work"
|
11
|
+
|
12
|
+
module AtlasRb
|
13
|
+
class Error < StandardError; end
|
14
|
+
# Your code goes here...
|
15
|
+
end
|
data/sig/atlas_rb.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: atlas_rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.21
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- David Cliff
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-11-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday-multipart
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.12'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- david.g.cliff@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".editorconfig"
|
63
|
+
- ".rspec"
|
64
|
+
- ".rubocop.yml"
|
65
|
+
- ".version"
|
66
|
+
- Gemfile
|
67
|
+
- Gemfile.lock
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- bin/console
|
72
|
+
- bin/setup
|
73
|
+
- lib/atlas_rb.rb
|
74
|
+
- lib/atlas_rb/collection.rb
|
75
|
+
- lib/atlas_rb/community.rb
|
76
|
+
- lib/atlas_rb/faraday_helper.rb
|
77
|
+
- lib/atlas_rb/file.rb
|
78
|
+
- lib/atlas_rb/file_set.rb
|
79
|
+
- lib/atlas_rb/resource.rb
|
80
|
+
- lib/atlas_rb/version.rb
|
81
|
+
- lib/atlas_rb/work.rb
|
82
|
+
- sig/atlas_rb.rbs
|
83
|
+
homepage:
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata:
|
87
|
+
rubygems_mfa_required: 'true'
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.6.0
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubygems_version: 3.2.33
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Ruby gem for Atlas API.
|
107
|
+
test_files: []
|