archivesspace-client 0.1.0 → 0.1.1
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/lib/archivesspace/client/client.rb +2 -2
- data/lib/archivesspace/client/helpers.rb +35 -30
- data/lib/archivesspace/client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac87676e73f32df56e132fdf948cc70f9bcaaed5
|
4
|
+
data.tar.gz: 732ac0b2af6e77d00497f07d3dbd110b451bbaf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 281c55f2fc3d494817b52e95fffc64b1bbe8d50d34ecb5956608f9a781d3c1b46e7d441ccae1ae2a9988beab6ff72fb313f0cdc95c1f4034eca5794831a1f4fb
|
7
|
+
data.tar.gz: 35f0ead243047aa1afb8c7fcdfd8b734872ecc7f38a3ab32a14ed08fb4f8ab6c2fc165399c2b3170268b11296d5065ef2763e9478fc0ea45089068448e667645
|
@@ -19,8 +19,8 @@ module ArchivesSpace
|
|
19
19
|
request 'POST', path, { body: payload.to_json, query: params }
|
20
20
|
end
|
21
21
|
|
22
|
-
def put(path, payload)
|
23
|
-
request 'PUT', path, { body: payload.to_json }
|
22
|
+
def put(path, payload, params = {})
|
23
|
+
request 'PUT', path, { body: payload.to_json, query: params }
|
24
24
|
end
|
25
25
|
|
26
26
|
def delete(path)
|
@@ -18,14 +18,16 @@ module ArchivesSpace
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def all(path, options = {}, &block)
|
21
|
-
all
|
22
|
-
format
|
21
|
+
all = []
|
22
|
+
format = options.delete(:format)
|
23
|
+
parse_id = options.delete(:parse_id)
|
23
24
|
# options[:headers] -- add xml headers if format
|
24
25
|
|
25
26
|
result = get(path, options.merge({ query: { all_ids: true } } ))
|
26
|
-
ap result
|
27
27
|
raise RequestError.new result.status if result.status_code != 200
|
28
|
-
result.parsed
|
28
|
+
ids = result.parsed
|
29
|
+
ids = ids.map{ |object| object["uri"].split("/")[-1] } if parse_id
|
30
|
+
ids.each do |id|
|
29
31
|
path_with_id = format ? "#{format}/#{id}.xml" : "#{path}/#{id}"
|
30
32
|
result = get(path_with_id, options)
|
31
33
|
raise RequestError.new result.status if result.status_code != 200
|
@@ -60,35 +62,38 @@ module ArchivesSpace
|
|
60
62
|
end
|
61
63
|
|
62
64
|
def groups
|
63
|
-
|
65
|
+
records = all('groups', { parse_id: true }) do |record|
|
66
|
+
yield record if block_given?
|
67
|
+
end
|
68
|
+
records
|
64
69
|
end
|
65
70
|
|
66
71
|
def group_user_assignment(users_with_roles, params = { with_members: true })
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
72
|
+
updated = []
|
73
|
+
groups do |group|
|
74
|
+
changed = false
|
75
|
+
|
76
|
+
users_with_roles.each do |user, roles|
|
77
|
+
if roles.include? group["group_code"]
|
78
|
+
unless group["member_usernames"].include? user
|
79
|
+
group["member_usernames"] << user
|
80
|
+
changed = true
|
81
|
+
end
|
82
|
+
else
|
83
|
+
if group["member_usernames"].include? user
|
84
|
+
group["member_usernames"].delete user
|
85
|
+
changed = true
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
if changed
|
91
|
+
id = group["uri"].split("/")[-1]
|
92
|
+
response = post( "/groups/#{id}", group, params )
|
93
|
+
updated << response.parsed
|
94
|
+
end
|
95
|
+
end
|
96
|
+
updated
|
92
97
|
end
|
93
98
|
|
94
99
|
def login
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: archivesspace-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Cooper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|