Skip to content
Snippets Groups Projects
Commit 81550ec8 authored by Andre Starosta's avatar Andre Starosta
Browse files

criacao de comm

parent be0aa3e3
No related branches found
No related tags found
No related merge requests found
...@@ -9,4 +9,5 @@ f.each_line { |line| ...@@ -9,4 +9,5 @@ f.each_line { |line|
f.close f.close
data.each{|line| data.each{|line|
puts line.scan(/"(.*)"/) puts line.scan(/"(.*)"/)
puts line.class
} }
...@@ -11,7 +11,6 @@ param2 = ARGV[2] ...@@ -11,7 +11,6 @@ param2 = ARGV[2]
param3 = ARGV[3] param3 = ARGV[3]
param4 = ARGV[4] param4 = ARGV[4]
#==========================# #==========================#
p "dasd"
#==AUTHENTICATION==# #==AUTHENTICATION==#
client = Dspace::Client.new(dspace_api: 'https://seppirdev.c3sl.ufpr.br:8443/rest') client = Dspace::Client.new(dspace_api: 'https://seppirdev.c3sl.ufpr.br:8443/rest')
if !client.is_running? if !client.is_running?
...@@ -99,6 +98,7 @@ end ...@@ -99,6 +98,7 @@ end
#==DELETE ALL FOR TESTING==# #==DELETE ALL FOR TESTING==#
if task == "delete" if task == "delete"
puts "Deletando todas as comunidades"
client.communities.all.each do |community| client.communities.all.each do |community|
client.communities.delete(id: community.id) client.communities.delete(id: community.id)
end end
......
class String
def extractMeta
self[/#{"\""}(.*?)#{"\""}/m, 1]
end
end
###################################################################################################
$LOAD_PATH.unshift('/home/starosta/c3sl/seppir/scriptsRuby/rest-client-gem/lib') $LOAD_PATH.unshift('/home/starosta/c3sl/seppir/scriptsRuby/rest-client-gem/lib')
#################################### A U T E N T I C A C A O ###################################### #################################### A U T E N T I C A C A O ######################################
...@@ -13,6 +19,8 @@ client.login 'admin@seppirdev.com', 'adminadmin' ...@@ -13,6 +19,8 @@ client.login 'admin@seppirdev.com', 'adminadmin'
root = "/home/starosta/c3sl/seppir/scriptsRuby/files/SEPPIR_SoNucleos/" root = "/home/starosta/c3sl/seppir/scriptsRuby/files/SEPPIR_SoNucleos/"
d = Dir[root + "*"].sort d = Dir[root + "*"].sort
data = Array.new(2) data = Array.new(2)
name = String.new
description = String.new
d.each{ |file| d.each{ |file|
i = 0 i = 0
meta = file + "/" + file.split('/')[-1] + ".metadata" meta = file + "/" + file.split('/')[-1] + ".metadata"
...@@ -21,13 +29,22 @@ d.each{ |file| ...@@ -21,13 +29,22 @@ d.each{ |file|
data[i] = line data[i] = line
i += 1 i += 1
} }
name = data[0].scan(/"(.*)"/) j = 0
description = data[1] data.each{|line|
if(j == 0)
name = line.extractMeta
end
if(j == 1)
description = line.extractMeta
end
j += 1
}
community = client.communities.create( community = client.communities.create(
Dspace::Community.new( Dspace::Community.new(
{ {
'name' => name 'name'=> name ,
} 'introductoryText' => description
}
) )
) )
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment