Top Level Namespace

Defined Under Namespace

Modules: ActionDispatch, ActiveFedora, ActiveTriples, EngineRoutes, Hyrax, HyraxHelper, Sipity, Valkyrie, Vocab, Wings Classes: AdminSet, AttachFilesToWorkJob, AttachFilesToWorkWithOrderedMembersJob, BatchCreateJob, BatchUploadItem, CatalogController, ChangeDepositorEventJob, CharacterizeJob, ChecksumAuditLog, ClamAV, Collection, CollectionBrandingInfo, ContentBlock, ContentDeleteEventJob, ContentDepositEventJob, ContentEventJob, ContentNewVersionEventJob, ContentRestoredVersionEventJob, ContentUpdateEventJob, ControlledVocabularyInput, CreateDerivativesJob, CreateWorkJob, EmbargoExpiryJob, EventJob, FeaturedWork, FeaturedWorkList, FileDownloadStat, FileSet, FileSetAttachedEventJob, FileViewStat, FixityCheckJob, HyraxListener, IiifManifestCachePrewarmJob, ImportExportJob, ImportUrlJob, IngestJob, IngestLocalFileJob, InheritPermissionsJob, JobIoWrapper, JsonStrategy, LeaseExpiryJob, MockFile, MoveAllWorksToAdminSet, MultiValueSelectInput, MultifileInput, ProxyDepositRequest, ProxyDepositRights, ResolrizeJob, SingleUseLink, SolrHit, StreamNotificationsJob, Trophy, UserEditProfileEventJob, UserMailbox, UserStat, ValkyrieCharacterizationJob, ValkyrieCreateDerivativesJob, ValkyrieCreateStrategy, ValkyrieIngestJob, VisibilityCopyJob, WorkViewStat

Constant Summary collapse

BuffaloWings =

some aliases for use by diners of varying sophistication

Wings
MightyWings =
Wings
HotWings =
Wings
SpicyWings =
Wings
SwissWings =
Wings
BuffaloCauliflowerWings =
Wings

Instance Method Summary collapse

Instance Method Details

#collection_attributes_for(collection_ids) ⇒ Object



98
99
100
101
102
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 98

def collection_attributes_for(collection_ids)
  attrs = {}
  0.upto(collection_ids.size) { |i| attrs[i.to_s] = { 'id' => collection_ids[i] } }
  attrs
end

#create_authenticated_work(user, id, options) ⇒ Object



77
78
79
80
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 77

def create_authenticated_work(user, id, options)
  options[:visibility] = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED
  create_work(user, id, options)
end

#create_collection(user, type_gid, id, options) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 59

def create_collection(user, type_gid, id, options)
  col = Collection.where(id: id)
  return col.first if col.present?
  col = Collection.new(id: id)
  col.attributes = options.except(:visibility)
  col.(user.user_key)
  col.collection_type_gid = type_gid
  col.visibility = options[:visibility]
  col.save
  Hyrax::Collections::PermissionsCreateService.create_default(collection: col, creating_user: user)
  col
end

#create_collection_type(machine_id, options) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 36

def create_collection_type(machine_id, options)
  coltype = Hyrax::CollectionType.find_by_machine_id(machine_id)
  return coltype if coltype.present?
  default_options = {
    nestable: false, discoverable: false, sharable: false, allow_multiple_membership: false,
    require_membership: false, assigns_workflow: false, assigns_visibility: false,
    participants: [{ agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE, agent_id: ::Ability.admin_group_name, access: Hyrax::CollectionTypeParticipant::MANAGE_ACCESS },
                   { agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE, agent_id: ::Ability.registered_group_name, access: Hyrax::CollectionTypeParticipant::CREATE_ACCESS }]
  }
  final_options = default_options.merge(options.except(:title))
  Hyrax::CollectionTypes::CreateService.create_collection_type(machine_id: machine_id, title: options[:title], options: final_options)
end

#create_private_collection(user, type_gid, id, options) ⇒ Object



54
55
56
57
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 54

def create_private_collection(user, type_gid, id, options)
  options[:visibility] = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
  create_collection(user, type_gid, id, options)
end

#create_private_work(user, id, options) ⇒ Object



82
83
84
85
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 82

def create_private_work(user, id, options)
  options[:visibility] = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
  create_work(user, id, options)
end

#create_public_collection(user, type_gid, id, options) ⇒ Object



49
50
51
52
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 49

def create_public_collection(user, type_gid, id, options)
  options[:visibility] = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
  create_collection(user, type_gid, id, options)
end

#create_public_work(user, id, options) ⇒ Object



72
73
74
75
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 72

def create_public_work(user, id, options)
  options[:visibility] = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC
  create_work(user, id, options)
end

#create_user(email, pw) ⇒ Object


methods to create various objects




26
27
28
29
30
31
32
33
34
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 26

def create_user(email, pw)
  # user = User.find_or_create_by(email: email) do |user|
  user = User.find_or_create_by(Hydra.config.user_key_field => email) do |u|
    u.email = email
    u.password = pw
    u.password_confirmation = pw
  end
  user
end

#create_work(user, id, options) ⇒ Object



87
88
89
90
91
92
93
94
95
96
# File 'lib/generators/hyrax/templates/db/seeds.rb', line 87

def create_work(user, id, options)
  work = GenericWork.where(id: id)
  return work.first if work.present?
  actor = Hyrax::CurationConcern.actor
  attributes_for_actor = options
  work = GenericWork.new(id: id)
  actor_environment = Hyrax::Actors::Environment.new(work, Ability.new(user), attributes_for_actor)
  actor.create(actor_environment)
  work
end

#save_timestamped_page_and_screenshot(page, meta) ⇒ Object

Save CircleCI artifacts



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/hyrax/specs/capybara.rb', line 66

def save_timestamped_page_and_screenshot(page, meta)
  filename = File.basename(meta[:file_path])
  line_number = meta[:line_number]

  time_now = Time.zone.now
  timestamp = "#{time_now.strftime('%Y-%m-%d-%H-%M-%S.')}#{'%03d' % (time_now.usec / 1000).to_i}"

  artifact_dir = Capybara.save_path

  screenshot_name = "screenshot-#{filename}-#{line_number}-#{timestamp}.png"
  screenshot_path = "#{artifact_dir}/#{screenshot_name}"
  page.save_screenshot(screenshot_path)

  page_name = "html-#{filename}-#{line_number}-#{timestamp}.html"
  page_path = "#{artifact_dir}/#{page_name}"
  page.save_page(page_path)

  puts "\n  Screenshot: #{screenshot_path}"
  puts "  HTML: #{page_path}"
end