archivesspace-client 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 166c7dc29eb3bba590d2480d4b0a4d67392d7066
4
- data.tar.gz: 63c5bd51a5f5f093a1afb247da0942bba3bd68d2
3
+ metadata.gz: ac87676e73f32df56e132fdf948cc70f9bcaaed5
4
+ data.tar.gz: 732ac0b2af6e77d00497f07d3dbd110b451bbaf6
5
5
  SHA512:
6
- metadata.gz: 774fcbf7d02bbb34cdc549ee8dbda2f6fb7181eaecb188f70879a7f975a7e93ca2792d2748ade0fc46afda945a57ecaadd5c0f7cd5cd9198621d459c11813667
7
- data.tar.gz: d6996636d70071997bd14f185acf17e3e3cd7b3338be987a39514af25ce46516b2cc456aae9e64ed1d2b3b4caa9e66c81648424fe34d8e4031839674a0e469e7
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 = options.delete(: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.each do |id|
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
- # updated = []
68
- # groups.each do |group|
69
- # changed = false
70
-
71
- # users_with_roles.each do |user, roles|
72
- # if roles.include? group["group_code"]
73
- # unless group["member_usernames"].include? user
74
- # group["member_usernames"] << user
75
- # changed = true
76
- # end
77
- # else
78
- # if group["member_usernames"].include? user
79
- # group["member_usernames"].delete user
80
- # changed = true
81
- # end
82
- # end
83
- # end
84
-
85
- # if changed
86
- # updated << update( group, params )
87
- # end
88
-
89
- # sleep 1 # moderate requests
90
- # end
91
- # updated
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
@@ -1,5 +1,5 @@
1
1
  module ArchivesSpace
2
2
  class Client
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
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.0
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-15 00:00:00.000000000 Z
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler