id
int32 0
24.9k
| repo
stringlengths 5
58
| path
stringlengths 9
168
| func_name
stringlengths 9
130
| original_string
stringlengths 66
10.5k
| language
stringclasses 1
value | code
stringlengths 66
10.5k
| code_tokens
list | docstring
stringlengths 8
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 94
266
|
|---|---|---|---|---|---|---|---|---|---|---|---|
11,700
|
gocardless/hutch
|
lib/hutch/broker.rb
|
Hutch.Broker.unbind_redundant_bindings
|
def unbind_redundant_bindings(queue, routing_keys)
return unless http_api_use_enabled?
bindings.each do |dest, keys|
next unless dest == queue.name
keys.reject { |key| routing_keys.include?(key) }.each do |key|
logger.debug "removing redundant binding #{queue.name} <--> #{key}"
queue.unbind(exchange, routing_key: key)
end
end
end
|
ruby
|
def unbind_redundant_bindings(queue, routing_keys)
return unless http_api_use_enabled?
bindings.each do |dest, keys|
next unless dest == queue.name
keys.reject { |key| routing_keys.include?(key) }.each do |key|
logger.debug "removing redundant binding #{queue.name} <--> #{key}"
queue.unbind(exchange, routing_key: key)
end
end
end
|
[
"def",
"unbind_redundant_bindings",
"(",
"queue",
",",
"routing_keys",
")",
"return",
"unless",
"http_api_use_enabled?",
"bindings",
".",
"each",
"do",
"|",
"dest",
",",
"keys",
"|",
"next",
"unless",
"dest",
"==",
"queue",
".",
"name",
"keys",
".",
"reject",
"{",
"|",
"key",
"|",
"routing_keys",
".",
"include?",
"(",
"key",
")",
"}",
".",
"each",
"do",
"|",
"key",
"|",
"logger",
".",
"debug",
"\"removing redundant binding #{queue.name} <--> #{key}\"",
"queue",
".",
"unbind",
"(",
"exchange",
",",
"routing_key",
":",
"key",
")",
"end",
"end",
"end"
] |
Find the existing bindings, and unbind any redundant bindings
|
[
"Find",
"the",
"existing",
"bindings",
"and",
"unbind",
"any",
"redundant",
"bindings"
] |
9314b3b8c84abeb78170730757f3eb8ccc4f54c5
|
https://github.com/gocardless/hutch/blob/9314b3b8c84abeb78170730757f3eb8ccc4f54c5/lib/hutch/broker.rb#L194-L204
|
11,701
|
gocardless/hutch
|
lib/hutch/broker.rb
|
Hutch.Broker.bind_queue
|
def bind_queue(queue, routing_keys)
unbind_redundant_bindings(queue, routing_keys)
# Ensure all the desired bindings are present
routing_keys.each do |routing_key|
logger.debug "creating binding #{queue.name} <--> #{routing_key}"
queue.bind(exchange, routing_key: routing_key)
end
end
|
ruby
|
def bind_queue(queue, routing_keys)
unbind_redundant_bindings(queue, routing_keys)
# Ensure all the desired bindings are present
routing_keys.each do |routing_key|
logger.debug "creating binding #{queue.name} <--> #{routing_key}"
queue.bind(exchange, routing_key: routing_key)
end
end
|
[
"def",
"bind_queue",
"(",
"queue",
",",
"routing_keys",
")",
"unbind_redundant_bindings",
"(",
"queue",
",",
"routing_keys",
")",
"# Ensure all the desired bindings are present",
"routing_keys",
".",
"each",
"do",
"|",
"routing_key",
"|",
"logger",
".",
"debug",
"\"creating binding #{queue.name} <--> #{routing_key}\"",
"queue",
".",
"bind",
"(",
"exchange",
",",
"routing_key",
":",
"routing_key",
")",
"end",
"end"
] |
Bind a queue to the broker's exchange on the routing keys provided. Any
existing bindings on the queue that aren't present in the array of
routing keys will be unbound.
|
[
"Bind",
"a",
"queue",
"to",
"the",
"broker",
"s",
"exchange",
"on",
"the",
"routing",
"keys",
"provided",
".",
"Any",
"existing",
"bindings",
"on",
"the",
"queue",
"that",
"aren",
"t",
"present",
"in",
"the",
"array",
"of",
"routing",
"keys",
"will",
"be",
"unbound",
"."
] |
9314b3b8c84abeb78170730757f3eb8ccc4f54c5
|
https://github.com/gocardless/hutch/blob/9314b3b8c84abeb78170730757f3eb8ccc4f54c5/lib/hutch/broker.rb#L209-L217
|
11,702
|
gocardless/hutch
|
lib/hutch/cli.rb
|
Hutch.CLI.run
|
def run(argv = ARGV)
Hutch::Config.initialize
parse_options(argv)
daemonise_process
write_pid if Hutch::Config.pidfile
Hutch.logger.info "hutch booted with pid #{::Process.pid}"
if load_app && start_work_loop == :success
# If we got here, the worker was shut down nicely
Hutch.logger.info 'hutch shut down gracefully'
exit 0
else
Hutch.logger.info 'hutch terminated due to an error'
exit 1
end
end
|
ruby
|
def run(argv = ARGV)
Hutch::Config.initialize
parse_options(argv)
daemonise_process
write_pid if Hutch::Config.pidfile
Hutch.logger.info "hutch booted with pid #{::Process.pid}"
if load_app && start_work_loop == :success
# If we got here, the worker was shut down nicely
Hutch.logger.info 'hutch shut down gracefully'
exit 0
else
Hutch.logger.info 'hutch terminated due to an error'
exit 1
end
end
|
[
"def",
"run",
"(",
"argv",
"=",
"ARGV",
")",
"Hutch",
"::",
"Config",
".",
"initialize",
"parse_options",
"(",
"argv",
")",
"daemonise_process",
"write_pid",
"if",
"Hutch",
"::",
"Config",
".",
"pidfile",
"Hutch",
".",
"logger",
".",
"info",
"\"hutch booted with pid #{::Process.pid}\"",
"if",
"load_app",
"&&",
"start_work_loop",
"==",
":success",
"# If we got here, the worker was shut down nicely",
"Hutch",
".",
"logger",
".",
"info",
"'hutch shut down gracefully'",
"exit",
"0",
"else",
"Hutch",
".",
"logger",
".",
"info",
"'hutch terminated due to an error'",
"exit",
"1",
"end",
"end"
] |
Run a Hutch worker with the command line interface.
|
[
"Run",
"a",
"Hutch",
"worker",
"with",
"the",
"command",
"line",
"interface",
"."
] |
9314b3b8c84abeb78170730757f3eb8ccc4f54c5
|
https://github.com/gocardless/hutch/blob/9314b3b8c84abeb78170730757f3eb8ccc4f54c5/lib/hutch/cli.rb#L13-L31
|
11,703
|
geokit/geokit
|
lib/geokit/bounds.rb
|
Geokit.Bounds.contains?
|
def contains?(point)
point = Geokit::LatLng.normalize(point)
res = point.lat > @sw.lat && point.lat < @ne.lat
if crosses_meridian?
res &= point.lng < @ne.lng || point.lng > @sw.lng
else
res &= point.lng < @ne.lng && point.lng > @sw.lng
end
res
end
|
ruby
|
def contains?(point)
point = Geokit::LatLng.normalize(point)
res = point.lat > @sw.lat && point.lat < @ne.lat
if crosses_meridian?
res &= point.lng < @ne.lng || point.lng > @sw.lng
else
res &= point.lng < @ne.lng && point.lng > @sw.lng
end
res
end
|
[
"def",
"contains?",
"(",
"point",
")",
"point",
"=",
"Geokit",
"::",
"LatLng",
".",
"normalize",
"(",
"point",
")",
"res",
"=",
"point",
".",
"lat",
">",
"@sw",
".",
"lat",
"&&",
"point",
".",
"lat",
"<",
"@ne",
".",
"lat",
"if",
"crosses_meridian?",
"res",
"&=",
"point",
".",
"lng",
"<",
"@ne",
".",
"lng",
"||",
"point",
".",
"lng",
">",
"@sw",
".",
"lng",
"else",
"res",
"&=",
"point",
".",
"lng",
"<",
"@ne",
".",
"lng",
"&&",
"point",
".",
"lng",
">",
"@sw",
".",
"lng",
"end",
"res",
"end"
] |
Returns true if the bounds contain the passed point.
allows for bounds which cross the meridian
|
[
"Returns",
"true",
"if",
"the",
"bounds",
"contain",
"the",
"passed",
"point",
".",
"allows",
"for",
"bounds",
"which",
"cross",
"the",
"meridian"
] |
b7c13376bd85bf14f9534228ea466d09ac0afbf4
|
https://github.com/geokit/geokit/blob/b7c13376bd85bf14f9534228ea466d09ac0afbf4/lib/geokit/bounds.rb#L32-L41
|
11,704
|
geokit/geokit
|
lib/geokit/geo_loc.rb
|
Geokit.GeoLoc.to_geocodeable_s
|
def to_geocodeable_s
a = [street_address, district, city, state, zip, country_code].compact
a.delete_if { |e| !e || e == '' }
a.join(', ')
end
|
ruby
|
def to_geocodeable_s
a = [street_address, district, city, state, zip, country_code].compact
a.delete_if { |e| !e || e == '' }
a.join(', ')
end
|
[
"def",
"to_geocodeable_s",
"a",
"=",
"[",
"street_address",
",",
"district",
",",
"city",
",",
"state",
",",
"zip",
",",
"country_code",
"]",
".",
"compact",
"a",
".",
"delete_if",
"{",
"|",
"e",
"|",
"!",
"e",
"||",
"e",
"==",
"''",
"}",
"a",
".",
"join",
"(",
"', '",
")",
"end"
] |
Returns a comma-delimited string consisting of the street address, city,
state, zip, and country code. Only includes those attributes that are
non-blank.
|
[
"Returns",
"a",
"comma",
"-",
"delimited",
"string",
"consisting",
"of",
"the",
"street",
"address",
"city",
"state",
"zip",
"and",
"country",
"code",
".",
"Only",
"includes",
"those",
"attributes",
"that",
"are",
"non",
"-",
"blank",
"."
] |
b7c13376bd85bf14f9534228ea466d09ac0afbf4
|
https://github.com/geokit/geokit/blob/b7c13376bd85bf14f9534228ea466d09ac0afbf4/lib/geokit/geo_loc.rb#L138-L142
|
11,705
|
ClosureTree/closure_tree
|
lib/closure_tree/hash_tree_support.rb
|
ClosureTree.HashTreeSupport.build_hash_tree
|
def build_hash_tree(tree_scope)
tree = ActiveSupport::OrderedHash.new
id_to_hash = {}
tree_scope.each do |ea|
h = id_to_hash[ea.id] = ActiveSupport::OrderedHash.new
(id_to_hash[ea._ct_parent_id] || tree)[ea] = h
end
tree
end
|
ruby
|
def build_hash_tree(tree_scope)
tree = ActiveSupport::OrderedHash.new
id_to_hash = {}
tree_scope.each do |ea|
h = id_to_hash[ea.id] = ActiveSupport::OrderedHash.new
(id_to_hash[ea._ct_parent_id] || tree)[ea] = h
end
tree
end
|
[
"def",
"build_hash_tree",
"(",
"tree_scope",
")",
"tree",
"=",
"ActiveSupport",
"::",
"OrderedHash",
".",
"new",
"id_to_hash",
"=",
"{",
"}",
"tree_scope",
".",
"each",
"do",
"|",
"ea",
"|",
"h",
"=",
"id_to_hash",
"[",
"ea",
".",
"id",
"]",
"=",
"ActiveSupport",
"::",
"OrderedHash",
".",
"new",
"(",
"id_to_hash",
"[",
"ea",
".",
"_ct_parent_id",
"]",
"||",
"tree",
")",
"[",
"ea",
"]",
"=",
"h",
"end",
"tree",
"end"
] |
Builds nested hash structure using the scope returned from the passed in scope
|
[
"Builds",
"nested",
"hash",
"structure",
"using",
"the",
"scope",
"returned",
"from",
"the",
"passed",
"in",
"scope"
] |
9babda807861a1b76745cfb986b001db01017ef9
|
https://github.com/ClosureTree/closure_tree/blob/9babda807861a1b76745cfb986b001db01017ef9/lib/closure_tree/hash_tree_support.rb#L25-L34
|
11,706
|
ClosureTree/closure_tree
|
lib/closure_tree/finders.rb
|
ClosureTree.Finders.find_or_create_by_path
|
def find_or_create_by_path(path, attributes = {})
subpath = _ct.build_ancestry_attr_path(path, attributes)
return self if subpath.empty?
found = find_by_path(subpath, attributes)
return found if found
attrs = subpath.shift
_ct.with_advisory_lock do
# shenanigans because children.create is bound to the superclass
# (in the case of polymorphism):
child = self.children.where(attrs).first || begin
# Support STI creation by using base_class:
_ct.create(self.class, attrs).tap do |ea|
# We know that there isn't a cycle, because we just created it, and
# cycle detection is expensive when the node is deep.
ea._ct_skip_cycle_detection!
self.children << ea
end
end
child.find_or_create_by_path(subpath, attributes)
end
end
|
ruby
|
def find_or_create_by_path(path, attributes = {})
subpath = _ct.build_ancestry_attr_path(path, attributes)
return self if subpath.empty?
found = find_by_path(subpath, attributes)
return found if found
attrs = subpath.shift
_ct.with_advisory_lock do
# shenanigans because children.create is bound to the superclass
# (in the case of polymorphism):
child = self.children.where(attrs).first || begin
# Support STI creation by using base_class:
_ct.create(self.class, attrs).tap do |ea|
# We know that there isn't a cycle, because we just created it, and
# cycle detection is expensive when the node is deep.
ea._ct_skip_cycle_detection!
self.children << ea
end
end
child.find_or_create_by_path(subpath, attributes)
end
end
|
[
"def",
"find_or_create_by_path",
"(",
"path",
",",
"attributes",
"=",
"{",
"}",
")",
"subpath",
"=",
"_ct",
".",
"build_ancestry_attr_path",
"(",
"path",
",",
"attributes",
")",
"return",
"self",
"if",
"subpath",
".",
"empty?",
"found",
"=",
"find_by_path",
"(",
"subpath",
",",
"attributes",
")",
"return",
"found",
"if",
"found",
"attrs",
"=",
"subpath",
".",
"shift",
"_ct",
".",
"with_advisory_lock",
"do",
"# shenanigans because children.create is bound to the superclass",
"# (in the case of polymorphism):",
"child",
"=",
"self",
".",
"children",
".",
"where",
"(",
"attrs",
")",
".",
"first",
"||",
"begin",
"# Support STI creation by using base_class:",
"_ct",
".",
"create",
"(",
"self",
".",
"class",
",",
"attrs",
")",
".",
"tap",
"do",
"|",
"ea",
"|",
"# We know that there isn't a cycle, because we just created it, and",
"# cycle detection is expensive when the node is deep.",
"ea",
".",
"_ct_skip_cycle_detection!",
"self",
".",
"children",
"<<",
"ea",
"end",
"end",
"child",
".",
"find_or_create_by_path",
"(",
"subpath",
",",
"attributes",
")",
"end",
"end"
] |
Find or create a descendant node whose +ancestry_path+ will be ```self.ancestry_path + path```
|
[
"Find",
"or",
"create",
"a",
"descendant",
"node",
"whose",
"+",
"ancestry_path",
"+",
"will",
"be",
"self",
".",
"ancestry_path",
"+",
"path"
] |
9babda807861a1b76745cfb986b001db01017ef9
|
https://github.com/ClosureTree/closure_tree/blob/9babda807861a1b76745cfb986b001db01017ef9/lib/closure_tree/finders.rb#L12-L34
|
11,707
|
samvera/hyrax
|
app/helpers/hyrax/hyrax_helper_behavior.rb
|
Hyrax.HyraxHelperBehavior.iconify_auto_link
|
def iconify_auto_link(field, show_link = true)
if field.is_a? Hash
options = field[:config].separator_options || {}
text = field[:value].to_sentence(options)
else
text = field
end
# this block is only executed when a link is inserted;
# if we pass text containing no links, it just returns text.
auto_link(html_escape(text)) do |value|
"<span class='glyphicon glyphicon-new-window'></span>#{(' ' + value) if show_link}"
end
end
|
ruby
|
def iconify_auto_link(field, show_link = true)
if field.is_a? Hash
options = field[:config].separator_options || {}
text = field[:value].to_sentence(options)
else
text = field
end
# this block is only executed when a link is inserted;
# if we pass text containing no links, it just returns text.
auto_link(html_escape(text)) do |value|
"<span class='glyphicon glyphicon-new-window'></span>#{(' ' + value) if show_link}"
end
end
|
[
"def",
"iconify_auto_link",
"(",
"field",
",",
"show_link",
"=",
"true",
")",
"if",
"field",
".",
"is_a?",
"Hash",
"options",
"=",
"field",
"[",
":config",
"]",
".",
"separator_options",
"||",
"{",
"}",
"text",
"=",
"field",
"[",
":value",
"]",
".",
"to_sentence",
"(",
"options",
")",
"else",
"text",
"=",
"field",
"end",
"# this block is only executed when a link is inserted;",
"# if we pass text containing no links, it just returns text.",
"auto_link",
"(",
"html_escape",
"(",
"text",
")",
")",
"do",
"|",
"value",
"|",
"\"<span class='glyphicon glyphicon-new-window'></span>#{(' ' + value) if show_link}\"",
"end",
"end"
] |
Uses Rails auto_link to add links to fields
@param field [String,Hash] string to format and escape, or a hash as per helper_method
@option field [SolrDocument] :document
@option field [String] :field name of the solr field
@option field [Blacklight::Configuration::IndexField, Blacklight::Configuration::ShowField] :config
@option field [Array] :value array of values for the field
@param show_link [Boolean]
@return [ActiveSupport::SafeBuffer]
@todo stop being a helper_method, start being part of the Blacklight render stack?
|
[
"Uses",
"Rails",
"auto_link",
"to",
"add",
"links",
"to",
"fields"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/helpers/hyrax/hyrax_helper_behavior.rb#L171-L183
|
11,708
|
samvera/hyrax
|
app/services/hyrax/user_stat_importer.rb
|
Hyrax.UserStatImporter.sorted_users
|
def sorted_users
users = []
::User.find_each do |user|
users.push(UserRecord.new(user.id, user.user_key, date_since_last_cache(user)))
end
users.sort_by(&:last_stats_update)
end
|
ruby
|
def sorted_users
users = []
::User.find_each do |user|
users.push(UserRecord.new(user.id, user.user_key, date_since_last_cache(user)))
end
users.sort_by(&:last_stats_update)
end
|
[
"def",
"sorted_users",
"users",
"=",
"[",
"]",
"::",
"User",
".",
"find_each",
"do",
"|",
"user",
"|",
"users",
".",
"push",
"(",
"UserRecord",
".",
"new",
"(",
"user",
".",
"id",
",",
"user",
".",
"user_key",
",",
"date_since_last_cache",
"(",
"user",
")",
")",
")",
"end",
"users",
".",
"sort_by",
"(",
":last_stats_update",
")",
"end"
] |
Returns an array of users sorted by the date of their last stats update. Users that have not been recently updated
will be at the top of the array.
|
[
"Returns",
"an",
"array",
"of",
"users",
"sorted",
"by",
"the",
"date",
"of",
"their",
"last",
"stats",
"update",
".",
"Users",
"that",
"have",
"not",
"been",
"recently",
"updated",
"will",
"be",
"at",
"the",
"top",
"of",
"the",
"array",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/services/hyrax/user_stat_importer.rb#L39-L45
|
11,709
|
samvera/hyrax
|
app/services/hyrax/user_stat_importer.rb
|
Hyrax.UserStatImporter.rescue_and_retry
|
def rescue_and_retry(fail_message)
Retriable.retriable(retry_options) do
return yield
end
rescue StandardError => exception
log_message fail_message
log_message "Last exception #{exception}"
end
|
ruby
|
def rescue_and_retry(fail_message)
Retriable.retriable(retry_options) do
return yield
end
rescue StandardError => exception
log_message fail_message
log_message "Last exception #{exception}"
end
|
[
"def",
"rescue_and_retry",
"(",
"fail_message",
")",
"Retriable",
".",
"retriable",
"(",
"retry_options",
")",
"do",
"return",
"yield",
"end",
"rescue",
"StandardError",
"=>",
"exception",
"log_message",
"fail_message",
"log_message",
"\"Last exception #{exception}\"",
"end"
] |
This method never fails. It tries multiple times and finally logs the exception
|
[
"This",
"method",
"never",
"fails",
".",
"It",
"tries",
"multiple",
"times",
"and",
"finally",
"logs",
"the",
"exception"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/services/hyrax/user_stat_importer.rb#L79-L86
|
11,710
|
samvera/hyrax
|
app/controllers/concerns/hyrax/leases_controller_behavior.rb
|
Hyrax.LeasesControllerBehavior.destroy
|
def destroy
Hyrax::Actors::LeaseActor.new(curation_concern).destroy
flash[:notice] = curation_concern.lease_history.last
if curation_concern.work? && curation_concern.file_sets.present?
redirect_to confirm_permission_path
else
redirect_to edit_lease_path
end
end
|
ruby
|
def destroy
Hyrax::Actors::LeaseActor.new(curation_concern).destroy
flash[:notice] = curation_concern.lease_history.last
if curation_concern.work? && curation_concern.file_sets.present?
redirect_to confirm_permission_path
else
redirect_to edit_lease_path
end
end
|
[
"def",
"destroy",
"Hyrax",
"::",
"Actors",
"::",
"LeaseActor",
".",
"new",
"(",
"curation_concern",
")",
".",
"destroy",
"flash",
"[",
":notice",
"]",
"=",
"curation_concern",
".",
"lease_history",
".",
"last",
"if",
"curation_concern",
".",
"work?",
"&&",
"curation_concern",
".",
"file_sets",
".",
"present?",
"redirect_to",
"confirm_permission_path",
"else",
"redirect_to",
"edit_lease_path",
"end",
"end"
] |
Removes a single lease
|
[
"Removes",
"a",
"single",
"lease"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/controllers/concerns/hyrax/leases_controller_behavior.rb#L15-L23
|
11,711
|
samvera/hyrax
|
app/models/concerns/hyrax/collection_behavior.rb
|
Hyrax.CollectionBehavior.bytes
|
def bytes
return 0 if member_object_ids.empty?
raise "Collection must be saved to query for bytes" if new_record?
# One query per member_id because Solr is not a relational database
member_object_ids.collect { |work_id| size_for_work(work_id) }.sum
end
|
ruby
|
def bytes
return 0 if member_object_ids.empty?
raise "Collection must be saved to query for bytes" if new_record?
# One query per member_id because Solr is not a relational database
member_object_ids.collect { |work_id| size_for_work(work_id) }.sum
end
|
[
"def",
"bytes",
"return",
"0",
"if",
"member_object_ids",
".",
"empty?",
"raise",
"\"Collection must be saved to query for bytes\"",
"if",
"new_record?",
"# One query per member_id because Solr is not a relational database",
"member_object_ids",
".",
"collect",
"{",
"|",
"work_id",
"|",
"size_for_work",
"(",
"work_id",
")",
"}",
".",
"sum",
"end"
] |
Compute the sum of each file in the collection using Solr to
avoid having to access Fedora
@return [Fixnum] size of collection in bytes
@raise [RuntimeError] unsaved record does not exist in solr
|
[
"Compute",
"the",
"sum",
"of",
"each",
"file",
"in",
"the",
"collection",
"using",
"Solr",
"to",
"avoid",
"having",
"to",
"access",
"Fedora"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/models/concerns/hyrax/collection_behavior.rb#L118-L125
|
11,712
|
samvera/hyrax
|
app/models/concerns/hyrax/collection_behavior.rb
|
Hyrax.CollectionBehavior.size_for_work
|
def size_for_work(work_id)
argz = { fl: "id, #{file_size_field}",
fq: "{!join from=#{member_ids_field} to=id}id:#{work_id}" }
files = ::FileSet.search_with_conditions({}, argz)
files.reduce(0) { |sum, f| sum + f[file_size_field].to_i }
end
|
ruby
|
def size_for_work(work_id)
argz = { fl: "id, #{file_size_field}",
fq: "{!join from=#{member_ids_field} to=id}id:#{work_id}" }
files = ::FileSet.search_with_conditions({}, argz)
files.reduce(0) { |sum, f| sum + f[file_size_field].to_i }
end
|
[
"def",
"size_for_work",
"(",
"work_id",
")",
"argz",
"=",
"{",
"fl",
":",
"\"id, #{file_size_field}\"",
",",
"fq",
":",
"\"{!join from=#{member_ids_field} to=id}id:#{work_id}\"",
"}",
"files",
"=",
"::",
"FileSet",
".",
"search_with_conditions",
"(",
"{",
"}",
",",
"argz",
")",
"files",
".",
"reduce",
"(",
"0",
")",
"{",
"|",
"sum",
",",
"f",
"|",
"sum",
"+",
"f",
"[",
"file_size_field",
"]",
".",
"to_i",
"}",
"end"
] |
Calculate the size of all the files in the work
@param work_id [String] identifer for a work
@return [Integer] the size in bytes
|
[
"Calculate",
"the",
"size",
"of",
"all",
"the",
"files",
"in",
"the",
"work"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/models/concerns/hyrax/collection_behavior.rb#L174-L179
|
11,713
|
samvera/hyrax
|
app/services/hyrax/admin_set_service.rb
|
Hyrax.AdminSetService.search_results_with_work_count
|
def search_results_with_work_count(access, join_field: "isPartOf_ssim")
admin_sets = search_results(access)
ids = admin_sets.map(&:id).join(',')
query = "{!terms f=#{join_field}}#{ids}"
results = ActiveFedora::SolrService.instance.conn.get(
ActiveFedora::SolrService.select_path,
params: { fq: query,
rows: 0,
'facet.field' => join_field }
)
counts = results['facet_counts']['facet_fields'][join_field].each_slice(2).to_h
file_counts = count_files(admin_sets)
admin_sets.map do |admin_set|
SearchResultForWorkCount.new(admin_set, counts[admin_set.id].to_i, file_counts[admin_set.id].to_i)
end
end
|
ruby
|
def search_results_with_work_count(access, join_field: "isPartOf_ssim")
admin_sets = search_results(access)
ids = admin_sets.map(&:id).join(',')
query = "{!terms f=#{join_field}}#{ids}"
results = ActiveFedora::SolrService.instance.conn.get(
ActiveFedora::SolrService.select_path,
params: { fq: query,
rows: 0,
'facet.field' => join_field }
)
counts = results['facet_counts']['facet_fields'][join_field].each_slice(2).to_h
file_counts = count_files(admin_sets)
admin_sets.map do |admin_set|
SearchResultForWorkCount.new(admin_set, counts[admin_set.id].to_i, file_counts[admin_set.id].to_i)
end
end
|
[
"def",
"search_results_with_work_count",
"(",
"access",
",",
"join_field",
":",
"\"isPartOf_ssim\"",
")",
"admin_sets",
"=",
"search_results",
"(",
"access",
")",
"ids",
"=",
"admin_sets",
".",
"map",
"(",
":id",
")",
".",
"join",
"(",
"','",
")",
"query",
"=",
"\"{!terms f=#{join_field}}#{ids}\"",
"results",
"=",
"ActiveFedora",
"::",
"SolrService",
".",
"instance",
".",
"conn",
".",
"get",
"(",
"ActiveFedora",
"::",
"SolrService",
".",
"select_path",
",",
"params",
":",
"{",
"fq",
":",
"query",
",",
"rows",
":",
"0",
",",
"'facet.field'",
"=>",
"join_field",
"}",
")",
"counts",
"=",
"results",
"[",
"'facet_counts'",
"]",
"[",
"'facet_fields'",
"]",
"[",
"join_field",
"]",
".",
"each_slice",
"(",
"2",
")",
".",
"to_h",
"file_counts",
"=",
"count_files",
"(",
"admin_sets",
")",
"admin_sets",
".",
"map",
"do",
"|",
"admin_set",
"|",
"SearchResultForWorkCount",
".",
"new",
"(",
"admin_set",
",",
"counts",
"[",
"admin_set",
".",
"id",
"]",
".",
"to_i",
",",
"file_counts",
"[",
"admin_set",
".",
"id",
"]",
".",
"to_i",
")",
"end",
"end"
] |
This performs a two pass query, first getting the AdminSets
and then getting the work and file counts
@param [Symbol] access :read or :edit
@param join_field [String] how are we joining the admin_set ids (by default "isPartOf_ssim")
@return [Array<Hyrax::AdminSetService::SearchResultForWorkCount>] a list with document, then work and file count
|
[
"This",
"performs",
"a",
"two",
"pass",
"query",
"first",
"getting",
"the",
"AdminSets",
"and",
"then",
"getting",
"the",
"work",
"and",
"file",
"counts"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/services/hyrax/admin_set_service.rb#L29-L44
|
11,714
|
samvera/hyrax
|
app/services/hyrax/admin_set_service.rb
|
Hyrax.AdminSetService.count_files
|
def count_files(admin_sets)
file_counts = Hash.new(0)
admin_sets.each do |admin_set|
query = "{!join from=file_set_ids_ssim to=id}isPartOf_ssim:#{admin_set.id}"
file_results = ActiveFedora::SolrService.instance.conn.get(
ActiveFedora::SolrService.select_path,
params: { fq: [query, "has_model_ssim:FileSet"],
rows: 0 }
)
file_counts[admin_set.id] = file_results['response']['numFound']
end
file_counts
end
|
ruby
|
def count_files(admin_sets)
file_counts = Hash.new(0)
admin_sets.each do |admin_set|
query = "{!join from=file_set_ids_ssim to=id}isPartOf_ssim:#{admin_set.id}"
file_results = ActiveFedora::SolrService.instance.conn.get(
ActiveFedora::SolrService.select_path,
params: { fq: [query, "has_model_ssim:FileSet"],
rows: 0 }
)
file_counts[admin_set.id] = file_results['response']['numFound']
end
file_counts
end
|
[
"def",
"count_files",
"(",
"admin_sets",
")",
"file_counts",
"=",
"Hash",
".",
"new",
"(",
"0",
")",
"admin_sets",
".",
"each",
"do",
"|",
"admin_set",
"|",
"query",
"=",
"\"{!join from=file_set_ids_ssim to=id}isPartOf_ssim:#{admin_set.id}\"",
"file_results",
"=",
"ActiveFedora",
"::",
"SolrService",
".",
"instance",
".",
"conn",
".",
"get",
"(",
"ActiveFedora",
"::",
"SolrService",
".",
"select_path",
",",
"params",
":",
"{",
"fq",
":",
"[",
"query",
",",
"\"has_model_ssim:FileSet\"",
"]",
",",
"rows",
":",
"0",
"}",
")",
"file_counts",
"[",
"admin_set",
".",
"id",
"]",
"=",
"file_results",
"[",
"'response'",
"]",
"[",
"'numFound'",
"]",
"end",
"file_counts",
"end"
] |
Count number of files from admin set works
@param [Array] AdminSets to count files in
@return [Hash] admin set id keys and file count values
|
[
"Count",
"number",
"of",
"files",
"from",
"admin",
"set",
"works"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/services/hyrax/admin_set_service.rb#L56-L68
|
11,715
|
samvera/hyrax
|
lib/hyrax/configuration.rb
|
Hyrax.Configuration.register_curation_concern
|
def register_curation_concern(*curation_concern_types)
Array.wrap(curation_concern_types).flatten.compact.each do |cc_type|
@registered_concerns << cc_type unless @registered_concerns.include?(cc_type)
end
end
|
ruby
|
def register_curation_concern(*curation_concern_types)
Array.wrap(curation_concern_types).flatten.compact.each do |cc_type|
@registered_concerns << cc_type unless @registered_concerns.include?(cc_type)
end
end
|
[
"def",
"register_curation_concern",
"(",
"*",
"curation_concern_types",
")",
"Array",
".",
"wrap",
"(",
"curation_concern_types",
")",
".",
"flatten",
".",
"compact",
".",
"each",
"do",
"|",
"cc_type",
"|",
"@registered_concerns",
"<<",
"cc_type",
"unless",
"@registered_concerns",
".",
"include?",
"(",
"cc_type",
")",
"end",
"end"
] |
Registers the given curation concern model in the configuration
@param [Array<Symbol>,Symbol] curation_concern_types
|
[
"Registers",
"the",
"given",
"curation",
"concern",
"model",
"in",
"the",
"configuration"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/lib/hyrax/configuration.rb#L207-L211
|
11,716
|
samvera/hyrax
|
app/presenters/hyrax/admin_set_options_presenter.rb
|
Hyrax.AdminSetOptionsPresenter.select_options
|
def select_options(access = :deposit)
@service.search_results(access).map do |admin_set|
[admin_set.to_s, admin_set.id, data_attributes(admin_set)]
end
end
|
ruby
|
def select_options(access = :deposit)
@service.search_results(access).map do |admin_set|
[admin_set.to_s, admin_set.id, data_attributes(admin_set)]
end
end
|
[
"def",
"select_options",
"(",
"access",
"=",
":deposit",
")",
"@service",
".",
"search_results",
"(",
"access",
")",
".",
"map",
"do",
"|",
"admin_set",
"|",
"[",
"admin_set",
".",
"to_s",
",",
"admin_set",
".",
"id",
",",
"data_attributes",
"(",
"admin_set",
")",
"]",
"end",
"end"
] |
Return AdminSet selectbox options based on access type
@param [Symbol] access :deposit, :read, or :edit
|
[
"Return",
"AdminSet",
"selectbox",
"options",
"based",
"on",
"access",
"type"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/presenters/hyrax/admin_set_options_presenter.rb#L10-L14
|
11,717
|
samvera/hyrax
|
app/presenters/hyrax/admin_set_options_presenter.rb
|
Hyrax.AdminSetOptionsPresenter.data_attributes
|
def data_attributes(admin_set)
# Get permission template associated with this AdminSet (if any)
permission_template = PermissionTemplate.find_by(source_id: admin_set.id)
# Only add data attributes if permission template exists
return {} unless permission_template
attributes_for(permission_template: permission_template)
end
|
ruby
|
def data_attributes(admin_set)
# Get permission template associated with this AdminSet (if any)
permission_template = PermissionTemplate.find_by(source_id: admin_set.id)
# Only add data attributes if permission template exists
return {} unless permission_template
attributes_for(permission_template: permission_template)
end
|
[
"def",
"data_attributes",
"(",
"admin_set",
")",
"# Get permission template associated with this AdminSet (if any)",
"permission_template",
"=",
"PermissionTemplate",
".",
"find_by",
"(",
"source_id",
":",
"admin_set",
".",
"id",
")",
"# Only add data attributes if permission template exists",
"return",
"{",
"}",
"unless",
"permission_template",
"attributes_for",
"(",
"permission_template",
":",
"permission_template",
")",
"end"
] |
Create a hash of HTML5 'data' attributes. These attributes are added to select_options and
later utilized by Javascript to limit new Work options based on AdminSet selected
|
[
"Create",
"a",
"hash",
"of",
"HTML5",
"data",
"attributes",
".",
"These",
"attributes",
"are",
"added",
"to",
"select_options",
"and",
"later",
"utilized",
"by",
"Javascript",
"to",
"limit",
"new",
"Work",
"options",
"based",
"on",
"AdminSet",
"selected"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/presenters/hyrax/admin_set_options_presenter.rb#L20-L27
|
11,718
|
samvera/hyrax
|
app/presenters/hyrax/admin_set_options_presenter.rb
|
Hyrax.AdminSetOptionsPresenter.sharing?
|
def sharing?(permission_template:)
wf = workflow(permission_template: permission_template)
return false unless wf
wf.allows_access_grant?
end
|
ruby
|
def sharing?(permission_template:)
wf = workflow(permission_template: permission_template)
return false unless wf
wf.allows_access_grant?
end
|
[
"def",
"sharing?",
"(",
"permission_template",
":",
")",
"wf",
"=",
"workflow",
"(",
"permission_template",
":",
"permission_template",
")",
"return",
"false",
"unless",
"wf",
"wf",
".",
"allows_access_grant?",
"end"
] |
Does the workflow for the currently selected permission template allow sharing?
|
[
"Does",
"the",
"workflow",
"for",
"the",
"currently",
"selected",
"permission",
"template",
"allow",
"sharing?"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/presenters/hyrax/admin_set_options_presenter.rb#L45-L49
|
11,719
|
samvera/hyrax
|
app/controllers/concerns/hyrax/local_file_downloads_controller_behavior.rb
|
Hyrax.LocalFileDownloadsControllerBehavior.send_local_content
|
def send_local_content
response.headers['Accept-Ranges'] = 'bytes'
if request.head?
local_content_head
elsif request.headers['Range']
send_range_for_local_file
else
send_local_file_contents
end
end
|
ruby
|
def send_local_content
response.headers['Accept-Ranges'] = 'bytes'
if request.head?
local_content_head
elsif request.headers['Range']
send_range_for_local_file
else
send_local_file_contents
end
end
|
[
"def",
"send_local_content",
"response",
".",
"headers",
"[",
"'Accept-Ranges'",
"]",
"=",
"'bytes'",
"if",
"request",
".",
"head?",
"local_content_head",
"elsif",
"request",
".",
"headers",
"[",
"'Range'",
"]",
"send_range_for_local_file",
"else",
"send_local_file_contents",
"end",
"end"
] |
Handle the HTTP show request
|
[
"Handle",
"the",
"HTTP",
"show",
"request"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/controllers/concerns/hyrax/local_file_downloads_controller_behavior.rb#L6-L15
|
11,720
|
samvera/hyrax
|
app/controllers/concerns/hyrax/local_file_downloads_controller_behavior.rb
|
Hyrax.LocalFileDownloadsControllerBehavior.send_range_for_local_file
|
def send_range_for_local_file
_, range = request.headers['Range'].split('bytes=')
from, to = range.split('-').map(&:to_i)
to = local_file_size - 1 unless to
length = to - from + 1
response.headers['Content-Range'] = "bytes #{from}-#{to}/#{local_file_size}"
response.headers['Content-Length'] = length.to_s
self.status = 206
prepare_local_file_headers
# For derivatives stored on the local file system
send_data IO.binread(file, length, from), local_derivative_download_options.merge(status: status)
end
|
ruby
|
def send_range_for_local_file
_, range = request.headers['Range'].split('bytes=')
from, to = range.split('-').map(&:to_i)
to = local_file_size - 1 unless to
length = to - from + 1
response.headers['Content-Range'] = "bytes #{from}-#{to}/#{local_file_size}"
response.headers['Content-Length'] = length.to_s
self.status = 206
prepare_local_file_headers
# For derivatives stored on the local file system
send_data IO.binread(file, length, from), local_derivative_download_options.merge(status: status)
end
|
[
"def",
"send_range_for_local_file",
"_",
",",
"range",
"=",
"request",
".",
"headers",
"[",
"'Range'",
"]",
".",
"split",
"(",
"'bytes='",
")",
"from",
",",
"to",
"=",
"range",
".",
"split",
"(",
"'-'",
")",
".",
"map",
"(",
":to_i",
")",
"to",
"=",
"local_file_size",
"-",
"1",
"unless",
"to",
"length",
"=",
"to",
"-",
"from",
"+",
"1",
"response",
".",
"headers",
"[",
"'Content-Range'",
"]",
"=",
"\"bytes #{from}-#{to}/#{local_file_size}\"",
"response",
".",
"headers",
"[",
"'Content-Length'",
"]",
"=",
"length",
".",
"to_s",
"self",
".",
"status",
"=",
"206",
"prepare_local_file_headers",
"# For derivatives stored on the local file system",
"send_data",
"IO",
".",
"binread",
"(",
"file",
",",
"length",
",",
"from",
")",
",",
"local_derivative_download_options",
".",
"merge",
"(",
"status",
":",
"status",
")",
"end"
] |
render an HTTP Range response
|
[
"render",
"an",
"HTTP",
"Range",
"response"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/controllers/concerns/hyrax/local_file_downloads_controller_behavior.rb#L18-L29
|
11,721
|
samvera/hyrax
|
app/services/hyrax/admin_set_create_service.rb
|
Hyrax.AdminSetCreateService.create
|
def create
admin_set.creator = [creating_user.user_key] if creating_user
admin_set.save.tap do |result|
if result
ActiveRecord::Base.transaction do
permission_template = create_permission_template
workflow = create_workflows_for(permission_template: permission_template)
create_default_access_for(permission_template: permission_template, workflow: workflow) if admin_set.default_set?
end
end
end
end
|
ruby
|
def create
admin_set.creator = [creating_user.user_key] if creating_user
admin_set.save.tap do |result|
if result
ActiveRecord::Base.transaction do
permission_template = create_permission_template
workflow = create_workflows_for(permission_template: permission_template)
create_default_access_for(permission_template: permission_template, workflow: workflow) if admin_set.default_set?
end
end
end
end
|
[
"def",
"create",
"admin_set",
".",
"creator",
"=",
"[",
"creating_user",
".",
"user_key",
"]",
"if",
"creating_user",
"admin_set",
".",
"save",
".",
"tap",
"do",
"|",
"result",
"|",
"if",
"result",
"ActiveRecord",
"::",
"Base",
".",
"transaction",
"do",
"permission_template",
"=",
"create_permission_template",
"workflow",
"=",
"create_workflows_for",
"(",
"permission_template",
":",
"permission_template",
")",
"create_default_access_for",
"(",
"permission_template",
":",
"permission_template",
",",
"workflow",
":",
"workflow",
")",
"if",
"admin_set",
".",
"default_set?",
"end",
"end",
"end",
"end"
] |
Creates an admin set, setting the creator and the default access controls.
@return [TrueClass, FalseClass] true if it was successful
|
[
"Creates",
"an",
"admin",
"set",
"setting",
"the",
"creator",
"and",
"the",
"default",
"access",
"controls",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/services/hyrax/admin_set_create_service.rb#L55-L66
|
11,722
|
samvera/hyrax
|
app/services/hyrax/admin_set_create_service.rb
|
Hyrax.AdminSetCreateService.create_default_access_for
|
def create_default_access_for(permission_template:, workflow:)
permission_template.access_grants.create(agent_type: 'group', agent_id: ::Ability.registered_group_name, access: Hyrax::PermissionTemplateAccess::DEPOSIT)
deposit = Sipity::Role[Hyrax::RoleRegistry::DEPOSITING]
workflow.update_responsibilities(role: deposit, agents: Hyrax::Group.new('registered'))
end
|
ruby
|
def create_default_access_for(permission_template:, workflow:)
permission_template.access_grants.create(agent_type: 'group', agent_id: ::Ability.registered_group_name, access: Hyrax::PermissionTemplateAccess::DEPOSIT)
deposit = Sipity::Role[Hyrax::RoleRegistry::DEPOSITING]
workflow.update_responsibilities(role: deposit, agents: Hyrax::Group.new('registered'))
end
|
[
"def",
"create_default_access_for",
"(",
"permission_template",
":",
",",
"workflow",
":",
")",
"permission_template",
".",
"access_grants",
".",
"create",
"(",
"agent_type",
":",
"'group'",
",",
"agent_id",
":",
"::",
"Ability",
".",
"registered_group_name",
",",
"access",
":",
"Hyrax",
"::",
"PermissionTemplateAccess",
"::",
"DEPOSIT",
")",
"deposit",
"=",
"Sipity",
"::",
"Role",
"[",
"Hyrax",
"::",
"RoleRegistry",
"::",
"DEPOSITING",
"]",
"workflow",
".",
"update_responsibilities",
"(",
"role",
":",
"deposit",
",",
"agents",
":",
"Hyrax",
"::",
"Group",
".",
"new",
"(",
"'registered'",
")",
")",
"end"
] |
Gives deposit access to registered users to default AdminSet
|
[
"Gives",
"deposit",
"access",
"to",
"registered",
"users",
"to",
"default",
"AdminSet"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/services/hyrax/admin_set_create_service.rb#L122-L126
|
11,723
|
samvera/hyrax
|
app/services/hyrax/microdata.rb
|
Hyrax.Microdata.flatten
|
def flatten(hash)
hash.each_with_object({}) do |(key, value), h|
if value.instance_of?(Hash)
value.map do |k, v|
# We could add recursion here if we ever had more than 2 levels
h["#{key}.#{k}"] = v
end
else
h[key] = value
end
end
end
|
ruby
|
def flatten(hash)
hash.each_with_object({}) do |(key, value), h|
if value.instance_of?(Hash)
value.map do |k, v|
# We could add recursion here if we ever had more than 2 levels
h["#{key}.#{k}"] = v
end
else
h[key] = value
end
end
end
|
[
"def",
"flatten",
"(",
"hash",
")",
"hash",
".",
"each_with_object",
"(",
"{",
"}",
")",
"do",
"|",
"(",
"key",
",",
"value",
")",
",",
"h",
"|",
"if",
"value",
".",
"instance_of?",
"(",
"Hash",
")",
"value",
".",
"map",
"do",
"|",
"k",
",",
"v",
"|",
"# We could add recursion here if we ever had more than 2 levels",
"h",
"[",
"\"#{key}.#{k}\"",
"]",
"=",
"v",
"end",
"else",
"h",
"[",
"key",
"]",
"=",
"value",
"end",
"end",
"end"
] |
Given a deeply nested hash, return a single hash
|
[
"Given",
"a",
"deeply",
"nested",
"hash",
"return",
"a",
"single",
"hash"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/services/hyrax/microdata.rb#L84-L95
|
11,724
|
samvera/hyrax
|
app/presenters/hyrax/member_presenter_factory.rb
|
Hyrax.MemberPresenterFactory.file_set_ids
|
def file_set_ids
@file_set_ids ||= begin
ActiveFedora::SolrService.query("{!field f=has_model_ssim}FileSet",
rows: 10_000,
fl: ActiveFedora.id_field,
fq: "{!join from=ordered_targets_ssim to=id}id:\"#{id}/list_source\"")
.flat_map { |x| x.fetch(ActiveFedora.id_field, []) }
end
end
|
ruby
|
def file_set_ids
@file_set_ids ||= begin
ActiveFedora::SolrService.query("{!field f=has_model_ssim}FileSet",
rows: 10_000,
fl: ActiveFedora.id_field,
fq: "{!join from=ordered_targets_ssim to=id}id:\"#{id}/list_source\"")
.flat_map { |x| x.fetch(ActiveFedora.id_field, []) }
end
end
|
[
"def",
"file_set_ids",
"@file_set_ids",
"||=",
"begin",
"ActiveFedora",
"::",
"SolrService",
".",
"query",
"(",
"\"{!field f=has_model_ssim}FileSet\"",
",",
"rows",
":",
"10_000",
",",
"fl",
":",
"ActiveFedora",
".",
"id_field",
",",
"fq",
":",
"\"{!join from=ordered_targets_ssim to=id}id:\\\"#{id}/list_source\\\"\"",
")",
".",
"flat_map",
"{",
"|",
"x",
"|",
"x",
".",
"fetch",
"(",
"ActiveFedora",
".",
"id_field",
",",
"[",
"]",
")",
"}",
"end",
"end"
] |
These are the file sets that belong to this work, but not necessarily
in order.
Arbitrarily maxed at 10 thousand; had to specify rows due to solr's default of 10
|
[
"These",
"are",
"the",
"file",
"sets",
"that",
"belong",
"to",
"this",
"work",
"but",
"not",
"necessarily",
"in",
"order",
".",
"Arbitrarily",
"maxed",
"at",
"10",
"thousand",
";",
"had",
"to",
"specify",
"rows",
"due",
"to",
"solr",
"s",
"default",
"of",
"10"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/presenters/hyrax/member_presenter_factory.rb#L54-L62
|
11,725
|
samvera/hyrax
|
lib/hyrax/rails/routes.rb
|
ActionDispatch::Routing.Mapper.namespaced_resources
|
def namespaced_resources(target, opts = {}, &block)
if target.include?('/')
the_namespace = target[0..target.index('/') - 1]
new_target = target[target.index('/') + 1..-1]
namespace the_namespace, ROUTE_OPTIONS.fetch(the_namespace, {}) do
namespaced_resources(new_target, opts, &block)
end
else
resources target, opts do
yield if block_given?
end
end
end
|
ruby
|
def namespaced_resources(target, opts = {}, &block)
if target.include?('/')
the_namespace = target[0..target.index('/') - 1]
new_target = target[target.index('/') + 1..-1]
namespace the_namespace, ROUTE_OPTIONS.fetch(the_namespace, {}) do
namespaced_resources(new_target, opts, &block)
end
else
resources target, opts do
yield if block_given?
end
end
end
|
[
"def",
"namespaced_resources",
"(",
"target",
",",
"opts",
"=",
"{",
"}",
",",
"&",
"block",
")",
"if",
"target",
".",
"include?",
"(",
"'/'",
")",
"the_namespace",
"=",
"target",
"[",
"0",
"..",
"target",
".",
"index",
"(",
"'/'",
")",
"-",
"1",
"]",
"new_target",
"=",
"target",
"[",
"target",
".",
"index",
"(",
"'/'",
")",
"+",
"1",
"..",
"-",
"1",
"]",
"namespace",
"the_namespace",
",",
"ROUTE_OPTIONS",
".",
"fetch",
"(",
"the_namespace",
",",
"{",
"}",
")",
"do",
"namespaced_resources",
"(",
"new_target",
",",
"opts",
",",
"block",
")",
"end",
"else",
"resources",
"target",
",",
"opts",
"do",
"yield",
"if",
"block_given?",
"end",
"end",
"end"
] |
Namespaces routes appropriately
@example namespaced_resources("hyrax/my_work") is equivalent to
namespace "hyrax", path: :concern do
resources "my_work", except: [:index]
end
|
[
"Namespaces",
"routes",
"appropriately"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/lib/hyrax/rails/routes.rb#L59-L71
|
11,726
|
samvera/hyrax
|
app/presenters/hyrax/work_show_presenter.rb
|
Hyrax.WorkShowPresenter.manifest_metadata
|
def manifest_metadata
metadata = []
Hyrax.config.iiif_metadata_fields.each do |field|
metadata << {
'label' => I18n.t("simple_form.labels.defaults.#{field}"),
'value' => Array.wrap(send(field).map { |f| Loofah.fragment(f.to_s).scrub!(:whitewash).to_s })
}
end
metadata
end
|
ruby
|
def manifest_metadata
metadata = []
Hyrax.config.iiif_metadata_fields.each do |field|
metadata << {
'label' => I18n.t("simple_form.labels.defaults.#{field}"),
'value' => Array.wrap(send(field).map { |f| Loofah.fragment(f.to_s).scrub!(:whitewash).to_s })
}
end
metadata
end
|
[
"def",
"manifest_metadata",
"metadata",
"=",
"[",
"]",
"Hyrax",
".",
"config",
".",
"iiif_metadata_fields",
".",
"each",
"do",
"|",
"field",
"|",
"metadata",
"<<",
"{",
"'label'",
"=>",
"I18n",
".",
"t",
"(",
"\"simple_form.labels.defaults.#{field}\"",
")",
",",
"'value'",
"=>",
"Array",
".",
"wrap",
"(",
"send",
"(",
"field",
")",
".",
"map",
"{",
"|",
"f",
"|",
"Loofah",
".",
"fragment",
"(",
"f",
".",
"to_s",
")",
".",
"scrub!",
"(",
":whitewash",
")",
".",
"to_s",
"}",
")",
"}",
"end",
"metadata",
"end"
] |
IIIF metadata for inclusion in the manifest
Called by the `iiif_manifest` gem to add metadata
@return [Array] array of metadata hashes
|
[
"IIIF",
"metadata",
"for",
"inclusion",
"in",
"the",
"manifest",
"Called",
"by",
"the",
"iiif_manifest",
"gem",
"to",
"add",
"metadata"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/presenters/hyrax/work_show_presenter.rb#L216-L225
|
11,727
|
samvera/hyrax
|
app/presenters/hyrax/work_show_presenter.rb
|
Hyrax.WorkShowPresenter.authorized_item_ids
|
def authorized_item_ids
@member_item_list_ids ||= begin
items = ordered_ids
items.delete_if { |m| !current_ability.can?(:read, m) } if Flipflop.hide_private_items?
items
end
end
|
ruby
|
def authorized_item_ids
@member_item_list_ids ||= begin
items = ordered_ids
items.delete_if { |m| !current_ability.can?(:read, m) } if Flipflop.hide_private_items?
items
end
end
|
[
"def",
"authorized_item_ids",
"@member_item_list_ids",
"||=",
"begin",
"items",
"=",
"ordered_ids",
"items",
".",
"delete_if",
"{",
"|",
"m",
"|",
"!",
"current_ability",
".",
"can?",
"(",
":read",
",",
"m",
")",
"}",
"if",
"Flipflop",
".",
"hide_private_items?",
"items",
"end",
"end"
] |
list of item ids to display is based on ordered_ids
|
[
"list",
"of",
"item",
"ids",
"to",
"display",
"is",
"based",
"on",
"ordered_ids"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/presenters/hyrax/work_show_presenter.rb#L237-L243
|
11,728
|
samvera/hyrax
|
app/presenters/hyrax/work_show_presenter.rb
|
Hyrax.WorkShowPresenter.paginated_item_list
|
def paginated_item_list(page_array:)
Kaminari.paginate_array(page_array, total_count: page_array.size).page(current_page).per(rows_from_params)
end
|
ruby
|
def paginated_item_list(page_array:)
Kaminari.paginate_array(page_array, total_count: page_array.size).page(current_page).per(rows_from_params)
end
|
[
"def",
"paginated_item_list",
"(",
"page_array",
":",
")",
"Kaminari",
".",
"paginate_array",
"(",
"page_array",
",",
"total_count",
":",
"page_array",
".",
"size",
")",
".",
"page",
"(",
"current_page",
")",
".",
"per",
"(",
"rows_from_params",
")",
"end"
] |
Uses kaminari to paginate an array to avoid need for solr documents for items here
|
[
"Uses",
"kaminari",
"to",
"paginate",
"an",
"array",
"to",
"avoid",
"need",
"for",
"solr",
"documents",
"for",
"items",
"here"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/presenters/hyrax/work_show_presenter.rb#L246-L248
|
11,729
|
samvera/hyrax
|
app/helpers/hyrax/collections_helper.rb
|
Hyrax.CollectionsHelper.single_item_action_form_fields
|
def single_item_action_form_fields(form, document, action)
render 'hyrax/dashboard/collections/single_item_action_fields', form: form, document: document, action: action
end
|
ruby
|
def single_item_action_form_fields(form, document, action)
render 'hyrax/dashboard/collections/single_item_action_fields', form: form, document: document, action: action
end
|
[
"def",
"single_item_action_form_fields",
"(",
"form",
",",
"document",
",",
"action",
")",
"render",
"'hyrax/dashboard/collections/single_item_action_fields'",
",",
"form",
":",
"form",
",",
"document",
":",
"document",
",",
"action",
":",
"action",
"end"
] |
add hidden fields to a form for performing an action on a single document on a collection
|
[
"add",
"hidden",
"fields",
"to",
"a",
"form",
"for",
"performing",
"an",
"action",
"on",
"a",
"single",
"document",
"on",
"a",
"collection"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/helpers/hyrax/collections_helper.rb#L74-L76
|
11,730
|
samvera/hyrax
|
app/controllers/concerns/hyrax/works_controller_behavior.rb
|
Hyrax.WorksControllerBehavior.show
|
def show
@user_collections = user_collections
respond_to do |wants|
wants.html { presenter && parent_presenter }
wants.json do
# load and authorize @curation_concern manually because it's skipped for html
@curation_concern = _curation_concern_type.find(params[:id]) unless curation_concern
authorize! :show, @curation_concern
render :show, status: :ok
end
additional_response_formats(wants)
wants.ttl do
render body: presenter.export_as_ttl, content_type: 'text/turtle'
end
wants.jsonld do
render body: presenter.export_as_jsonld, content_type: 'application/ld+json'
end
wants.nt do
render body: presenter.export_as_nt, content_type: 'application/n-triples'
end
end
end
|
ruby
|
def show
@user_collections = user_collections
respond_to do |wants|
wants.html { presenter && parent_presenter }
wants.json do
# load and authorize @curation_concern manually because it's skipped for html
@curation_concern = _curation_concern_type.find(params[:id]) unless curation_concern
authorize! :show, @curation_concern
render :show, status: :ok
end
additional_response_formats(wants)
wants.ttl do
render body: presenter.export_as_ttl, content_type: 'text/turtle'
end
wants.jsonld do
render body: presenter.export_as_jsonld, content_type: 'application/ld+json'
end
wants.nt do
render body: presenter.export_as_nt, content_type: 'application/n-triples'
end
end
end
|
[
"def",
"show",
"@user_collections",
"=",
"user_collections",
"respond_to",
"do",
"|",
"wants",
"|",
"wants",
".",
"html",
"{",
"presenter",
"&&",
"parent_presenter",
"}",
"wants",
".",
"json",
"do",
"# load and authorize @curation_concern manually because it's skipped for html",
"@curation_concern",
"=",
"_curation_concern_type",
".",
"find",
"(",
"params",
"[",
":id",
"]",
")",
"unless",
"curation_concern",
"authorize!",
":show",
",",
"@curation_concern",
"render",
":show",
",",
"status",
":",
":ok",
"end",
"additional_response_formats",
"(",
"wants",
")",
"wants",
".",
"ttl",
"do",
"render",
"body",
":",
"presenter",
".",
"export_as_ttl",
",",
"content_type",
":",
"'text/turtle'",
"end",
"wants",
".",
"jsonld",
"do",
"render",
"body",
":",
"presenter",
".",
"export_as_jsonld",
",",
"content_type",
":",
"'application/ld+json'",
"end",
"wants",
".",
"nt",
"do",
"render",
"body",
":",
"presenter",
".",
"export_as_nt",
",",
"content_type",
":",
"'application/n-triples'",
"end",
"end",
"end"
] |
Finds a solr document matching the id and sets @presenter
@raise CanCan::AccessDenied if the document is not found or the user doesn't have access to it.
|
[
"Finds",
"a",
"solr",
"document",
"matching",
"the",
"id",
"and",
"sets"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/controllers/concerns/hyrax/works_controller_behavior.rb#L69-L91
|
11,731
|
samvera/hyrax
|
app/controllers/concerns/hyrax/works_controller_behavior.rb
|
Hyrax.WorksControllerBehavior.search_result_document
|
def search_result_document(search_params)
_, document_list = search_results(search_params)
return document_list.first unless document_list.empty?
document_not_found!
end
|
ruby
|
def search_result_document(search_params)
_, document_list = search_results(search_params)
return document_list.first unless document_list.empty?
document_not_found!
end
|
[
"def",
"search_result_document",
"(",
"search_params",
")",
"_",
",",
"document_list",
"=",
"search_results",
"(",
"search_params",
")",
"return",
"document_list",
".",
"first",
"unless",
"document_list",
".",
"empty?",
"document_not_found!",
"end"
] |
Only returns unsuppressed documents the user has read access to
|
[
"Only",
"returns",
"unsuppressed",
"documents",
"the",
"user",
"has",
"read",
"access",
"to"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/controllers/concerns/hyrax/works_controller_behavior.rb#L207-L211
|
11,732
|
samvera/hyrax
|
app/controllers/concerns/hyrax/works_controller_behavior.rb
|
Hyrax.WorksControllerBehavior.attributes_for_actor
|
def attributes_for_actor
raw_params = params[hash_key_for_curation_concern]
attributes = if raw_params
work_form_service.form_class(curation_concern).model_attributes(raw_params)
else
{}
end
# If they selected a BrowseEverything file, but then clicked the
# remove button, it will still show up in `selected_files`, but
# it will no longer be in uploaded_files. By checking the
# intersection, we get the files they added via BrowseEverything
# that they have not removed from the upload widget.
uploaded_files = params.fetch(:uploaded_files, [])
selected_files = params.fetch(:selected_files, {}).values
browse_everything_urls = uploaded_files &
selected_files.map { |f| f[:url] }
# we need the hash of files with url and file_name
browse_everything_files = selected_files
.select { |v| uploaded_files.include?(v[:url]) }
attributes[:remote_files] = browse_everything_files
# Strip out any BrowseEverthing files from the regular uploads.
attributes[:uploaded_files] = uploaded_files -
browse_everything_urls
attributes
end
|
ruby
|
def attributes_for_actor
raw_params = params[hash_key_for_curation_concern]
attributes = if raw_params
work_form_service.form_class(curation_concern).model_attributes(raw_params)
else
{}
end
# If they selected a BrowseEverything file, but then clicked the
# remove button, it will still show up in `selected_files`, but
# it will no longer be in uploaded_files. By checking the
# intersection, we get the files they added via BrowseEverything
# that they have not removed from the upload widget.
uploaded_files = params.fetch(:uploaded_files, [])
selected_files = params.fetch(:selected_files, {}).values
browse_everything_urls = uploaded_files &
selected_files.map { |f| f[:url] }
# we need the hash of files with url and file_name
browse_everything_files = selected_files
.select { |v| uploaded_files.include?(v[:url]) }
attributes[:remote_files] = browse_everything_files
# Strip out any BrowseEverthing files from the regular uploads.
attributes[:uploaded_files] = uploaded_files -
browse_everything_urls
attributes
end
|
[
"def",
"attributes_for_actor",
"raw_params",
"=",
"params",
"[",
"hash_key_for_curation_concern",
"]",
"attributes",
"=",
"if",
"raw_params",
"work_form_service",
".",
"form_class",
"(",
"curation_concern",
")",
".",
"model_attributes",
"(",
"raw_params",
")",
"else",
"{",
"}",
"end",
"# If they selected a BrowseEverything file, but then clicked the",
"# remove button, it will still show up in `selected_files`, but",
"# it will no longer be in uploaded_files. By checking the",
"# intersection, we get the files they added via BrowseEverything",
"# that they have not removed from the upload widget.",
"uploaded_files",
"=",
"params",
".",
"fetch",
"(",
":uploaded_files",
",",
"[",
"]",
")",
"selected_files",
"=",
"params",
".",
"fetch",
"(",
":selected_files",
",",
"{",
"}",
")",
".",
"values",
"browse_everything_urls",
"=",
"uploaded_files",
"&",
"selected_files",
".",
"map",
"{",
"|",
"f",
"|",
"f",
"[",
":url",
"]",
"}",
"# we need the hash of files with url and file_name",
"browse_everything_files",
"=",
"selected_files",
".",
"select",
"{",
"|",
"v",
"|",
"uploaded_files",
".",
"include?",
"(",
"v",
"[",
":url",
"]",
")",
"}",
"attributes",
"[",
":remote_files",
"]",
"=",
"browse_everything_files",
"# Strip out any BrowseEverthing files from the regular uploads.",
"attributes",
"[",
":uploaded_files",
"]",
"=",
"uploaded_files",
"-",
"browse_everything_urls",
"attributes",
"end"
] |
Add uploaded_files to the parameters received by the actor.
|
[
"Add",
"uploaded_files",
"to",
"the",
"parameters",
"received",
"by",
"the",
"actor",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/controllers/concerns/hyrax/works_controller_behavior.rb#L258-L284
|
11,733
|
samvera/hyrax
|
app/builders/hyrax/manifest_helper.rb
|
Hyrax.ManifestHelper.build_rendering
|
def build_rendering(file_set_id)
file_set_document = query_for_rendering(file_set_id)
label = file_set_document.label.present? ? ": #{file_set_document.label}" : ''
mime = file_set_document.mime_type.present? ? file_set_document.mime_type : I18n.t("hyrax.manifest.unknown_mime_text")
{
'@id' => Hyrax::Engine.routes.url_helpers.download_url(file_set_document.id, host: @hostname),
'format' => mime,
'label' => I18n.t("hyrax.manifest.download_text") + label
}
end
|
ruby
|
def build_rendering(file_set_id)
file_set_document = query_for_rendering(file_set_id)
label = file_set_document.label.present? ? ": #{file_set_document.label}" : ''
mime = file_set_document.mime_type.present? ? file_set_document.mime_type : I18n.t("hyrax.manifest.unknown_mime_text")
{
'@id' => Hyrax::Engine.routes.url_helpers.download_url(file_set_document.id, host: @hostname),
'format' => mime,
'label' => I18n.t("hyrax.manifest.download_text") + label
}
end
|
[
"def",
"build_rendering",
"(",
"file_set_id",
")",
"file_set_document",
"=",
"query_for_rendering",
"(",
"file_set_id",
")",
"label",
"=",
"file_set_document",
".",
"label",
".",
"present?",
"?",
"\": #{file_set_document.label}\"",
":",
"''",
"mime",
"=",
"file_set_document",
".",
"mime_type",
".",
"present?",
"?",
"file_set_document",
".",
"mime_type",
":",
"I18n",
".",
"t",
"(",
"\"hyrax.manifest.unknown_mime_text\"",
")",
"{",
"'@id'",
"=>",
"Hyrax",
"::",
"Engine",
".",
"routes",
".",
"url_helpers",
".",
"download_url",
"(",
"file_set_document",
".",
"id",
",",
"host",
":",
"@hostname",
")",
",",
"'format'",
"=>",
"mime",
",",
"'label'",
"=>",
"I18n",
".",
"t",
"(",
"\"hyrax.manifest.download_text\"",
")",
"+",
"label",
"}",
"end"
] |
Build a rendering hash
@return [Hash] rendering
|
[
"Build",
"a",
"rendering",
"hash"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/builders/hyrax/manifest_helper.rb#L18-L27
|
11,734
|
samvera/hyrax
|
spec/support/selectors.rb
|
Selectors.Dashboard.select_user
|
def select_user(user, role = 'Depositor')
first('a.select2-choice').click
find('.select2-input').set(user.user_key)
sleep 1
first('div.select2-result-label').click
within('div.add-users') do
select(role)
find('input.edit-collection-add-sharing-button').click
end
end
|
ruby
|
def select_user(user, role = 'Depositor')
first('a.select2-choice').click
find('.select2-input').set(user.user_key)
sleep 1
first('div.select2-result-label').click
within('div.add-users') do
select(role)
find('input.edit-collection-add-sharing-button').click
end
end
|
[
"def",
"select_user",
"(",
"user",
",",
"role",
"=",
"'Depositor'",
")",
"first",
"(",
"'a.select2-choice'",
")",
".",
"click",
"find",
"(",
"'.select2-input'",
")",
".",
"set",
"(",
"user",
".",
"user_key",
")",
"sleep",
"1",
"first",
"(",
"'div.select2-result-label'",
")",
".",
"click",
"within",
"(",
"'div.add-users'",
")",
"do",
"select",
"(",
"role",
")",
"find",
"(",
"'input.edit-collection-add-sharing-button'",
")",
".",
"click",
"end",
"end"
] |
For use with javascript user selector that allows for searching for an existing user
and granting them permission to an object.
@param [User] user to select
@param [String] role granting the user permission (e.g. 'Manager' | 'Depositor' | 'Viewer')
|
[
"For",
"use",
"with",
"javascript",
"user",
"selector",
"that",
"allows",
"for",
"searching",
"for",
"an",
"existing",
"user",
"and",
"granting",
"them",
"permission",
"to",
"an",
"object",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/spec/support/selectors.rb#L13-L22
|
11,735
|
samvera/hyrax
|
spec/support/selectors.rb
|
Selectors.Dashboard.select_collection
|
def select_collection(collection)
first('a.select2-choice').click
find('.select2-input').set(collection.title.first)
expect(page).to have_css('div.select2-result-label')
first('div.select2-result-label').click
first('[data-behavior~=add-relationship]').click
within('[data-behavior~=collection-relationships]') do
within('table.table.table-striped') do
expect(page).to have_content(collection.title.first)
end
end
end
|
ruby
|
def select_collection(collection)
first('a.select2-choice').click
find('.select2-input').set(collection.title.first)
expect(page).to have_css('div.select2-result-label')
first('div.select2-result-label').click
first('[data-behavior~=add-relationship]').click
within('[data-behavior~=collection-relationships]') do
within('table.table.table-striped') do
expect(page).to have_content(collection.title.first)
end
end
end
|
[
"def",
"select_collection",
"(",
"collection",
")",
"first",
"(",
"'a.select2-choice'",
")",
".",
"click",
"find",
"(",
"'.select2-input'",
")",
".",
"set",
"(",
"collection",
".",
"title",
".",
"first",
")",
"expect",
"(",
"page",
")",
".",
"to",
"have_css",
"(",
"'div.select2-result-label'",
")",
"first",
"(",
"'div.select2-result-label'",
")",
".",
"click",
"first",
"(",
"'[data-behavior~=add-relationship]'",
")",
".",
"click",
"within",
"(",
"'[data-behavior~=collection-relationships]'",
")",
"do",
"within",
"(",
"'table.table.table-striped'",
")",
"do",
"expect",
"(",
"page",
")",
".",
"to",
"have_content",
"(",
"collection",
".",
"title",
".",
"first",
")",
"end",
"end",
"end"
] |
For use with javascript collection selector that allows for searching for an existing collection from works relationship tab.
Adds the collection and validates that the collection is listed in the Collection Relationship table once added.
@param [Collection] collection to select
|
[
"For",
"use",
"with",
"javascript",
"collection",
"selector",
"that",
"allows",
"for",
"searching",
"for",
"an",
"existing",
"collection",
"from",
"works",
"relationship",
"tab",
".",
"Adds",
"the",
"collection",
"and",
"validates",
"that",
"the",
"collection",
"is",
"listed",
"in",
"the",
"Collection",
"Relationship",
"table",
"once",
"added",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/spec/support/selectors.rb#L27-L38
|
11,736
|
samvera/hyrax
|
spec/support/selectors.rb
|
Selectors.Dashboard.select_member_of_collection
|
def select_member_of_collection(collection)
find('#s2id_member_of_collection_ids').click
find('.select2-input').set(collection.title.first)
# Crude way of waiting for the AJAX response
select2_results = []
time_elapsed = 0
while select2_results.empty? && time_elapsed < 30
begin_time = Time.now.to_f
doc = Nokogiri::XML.parse(page.body)
select2_results = doc.xpath('//html:li[contains(@class,"select2-result")]', html: 'http://www.w3.org/1999/xhtml')
end_time = Time.now.to_f
time_elapsed += end_time - begin_time
end
expect(page).to have_css('.select2-result')
within ".select2-result" do
find("span", text: collection.title.first).click
end
end
|
ruby
|
def select_member_of_collection(collection)
find('#s2id_member_of_collection_ids').click
find('.select2-input').set(collection.title.first)
# Crude way of waiting for the AJAX response
select2_results = []
time_elapsed = 0
while select2_results.empty? && time_elapsed < 30
begin_time = Time.now.to_f
doc = Nokogiri::XML.parse(page.body)
select2_results = doc.xpath('//html:li[contains(@class,"select2-result")]', html: 'http://www.w3.org/1999/xhtml')
end_time = Time.now.to_f
time_elapsed += end_time - begin_time
end
expect(page).to have_css('.select2-result')
within ".select2-result" do
find("span", text: collection.title.first).click
end
end
|
[
"def",
"select_member_of_collection",
"(",
"collection",
")",
"find",
"(",
"'#s2id_member_of_collection_ids'",
")",
".",
"click",
"find",
"(",
"'.select2-input'",
")",
".",
"set",
"(",
"collection",
".",
"title",
".",
"first",
")",
"# Crude way of waiting for the AJAX response",
"select2_results",
"=",
"[",
"]",
"time_elapsed",
"=",
"0",
"while",
"select2_results",
".",
"empty?",
"&&",
"time_elapsed",
"<",
"30",
"begin_time",
"=",
"Time",
".",
"now",
".",
"to_f",
"doc",
"=",
"Nokogiri",
"::",
"XML",
".",
"parse",
"(",
"page",
".",
"body",
")",
"select2_results",
"=",
"doc",
".",
"xpath",
"(",
"'//html:li[contains(@class,\"select2-result\")]'",
",",
"html",
":",
"'http://www.w3.org/1999/xhtml'",
")",
"end_time",
"=",
"Time",
".",
"now",
".",
"to_f",
"time_elapsed",
"+=",
"end_time",
"-",
"begin_time",
"end",
"expect",
"(",
"page",
")",
".",
"to",
"have_css",
"(",
"'.select2-result'",
")",
"within",
"\".select2-result\"",
"do",
"find",
"(",
"\"span\"",
",",
"text",
":",
"collection",
".",
"title",
".",
"first",
")",
".",
"click",
"end",
"end"
] |
For use with javascript collection selector that allows for searching for an existing collection from add to collection modal.
Does not save the selection. The calling test is expected to click Save and validate the collection membership was added to the work.
@param [Collection] collection to select
|
[
"For",
"use",
"with",
"javascript",
"collection",
"selector",
"that",
"allows",
"for",
"searching",
"for",
"an",
"existing",
"collection",
"from",
"add",
"to",
"collection",
"modal",
".",
"Does",
"not",
"save",
"the",
"selection",
".",
"The",
"calling",
"test",
"is",
"expected",
"to",
"click",
"Save",
"and",
"validate",
"the",
"collection",
"membership",
"was",
"added",
"to",
"the",
"work",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/spec/support/selectors.rb#L43-L60
|
11,737
|
samvera/hyrax
|
app/presenters/hyrax/displays_image.rb
|
Hyrax.DisplaysImage.display_image
|
def display_image
return nil unless ::FileSet.exists?(id) && solr_document.image? && current_ability.can?(:read, id)
# @todo this is slow, find a better way (perhaps index iiif url):
original_file = ::FileSet.find(id).original_file
url = Hyrax.config.iiif_image_url_builder.call(
original_file.id,
request.base_url,
Hyrax.config.iiif_image_size_default
)
# @see https://github.com/samvera-labs/iiif_manifest
IIIFManifest::DisplayImage.new(url,
width: 640,
height: 480,
iiif_endpoint: iiif_endpoint(original_file.id))
end
|
ruby
|
def display_image
return nil unless ::FileSet.exists?(id) && solr_document.image? && current_ability.can?(:read, id)
# @todo this is slow, find a better way (perhaps index iiif url):
original_file = ::FileSet.find(id).original_file
url = Hyrax.config.iiif_image_url_builder.call(
original_file.id,
request.base_url,
Hyrax.config.iiif_image_size_default
)
# @see https://github.com/samvera-labs/iiif_manifest
IIIFManifest::DisplayImage.new(url,
width: 640,
height: 480,
iiif_endpoint: iiif_endpoint(original_file.id))
end
|
[
"def",
"display_image",
"return",
"nil",
"unless",
"::",
"FileSet",
".",
"exists?",
"(",
"id",
")",
"&&",
"solr_document",
".",
"image?",
"&&",
"current_ability",
".",
"can?",
"(",
":read",
",",
"id",
")",
"# @todo this is slow, find a better way (perhaps index iiif url):",
"original_file",
"=",
"::",
"FileSet",
".",
"find",
"(",
"id",
")",
".",
"original_file",
"url",
"=",
"Hyrax",
".",
"config",
".",
"iiif_image_url_builder",
".",
"call",
"(",
"original_file",
".",
"id",
",",
"request",
".",
"base_url",
",",
"Hyrax",
".",
"config",
".",
"iiif_image_size_default",
")",
"# @see https://github.com/samvera-labs/iiif_manifest",
"IIIFManifest",
"::",
"DisplayImage",
".",
"new",
"(",
"url",
",",
"width",
":",
"640",
",",
"height",
":",
"480",
",",
"iiif_endpoint",
":",
"iiif_endpoint",
"(",
"original_file",
".",
"id",
")",
")",
"end"
] |
Creates a display image only where FileSet is an image.
@return [IIIFManifest::DisplayImage] the display image required by the manifest builder.
|
[
"Creates",
"a",
"display",
"image",
"only",
"where",
"FileSet",
"is",
"an",
"image",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/presenters/hyrax/displays_image.rb#L12-L27
|
11,738
|
samvera/hyrax
|
app/services/hyrax/file_set_fixity_check_service.rb
|
Hyrax.FileSetFixityCheckService.fixity_check_file_version
|
def fixity_check_file_version(file_id, version_uri)
latest_fixity_check = ChecksumAuditLog.logs_for(file_set.id, checked_uri: version_uri).first
return latest_fixity_check unless needs_fixity_check?(latest_fixity_check)
if async_jobs
FixityCheckJob.perform_later(version_uri.to_s, file_set_id: file_set.id, file_id: file_id)
else
FixityCheckJob.perform_now(version_uri.to_s, file_set_id: file_set.id, file_id: file_id)
end
end
|
ruby
|
def fixity_check_file_version(file_id, version_uri)
latest_fixity_check = ChecksumAuditLog.logs_for(file_set.id, checked_uri: version_uri).first
return latest_fixity_check unless needs_fixity_check?(latest_fixity_check)
if async_jobs
FixityCheckJob.perform_later(version_uri.to_s, file_set_id: file_set.id, file_id: file_id)
else
FixityCheckJob.perform_now(version_uri.to_s, file_set_id: file_set.id, file_id: file_id)
end
end
|
[
"def",
"fixity_check_file_version",
"(",
"file_id",
",",
"version_uri",
")",
"latest_fixity_check",
"=",
"ChecksumAuditLog",
".",
"logs_for",
"(",
"file_set",
".",
"id",
",",
"checked_uri",
":",
"version_uri",
")",
".",
"first",
"return",
"latest_fixity_check",
"unless",
"needs_fixity_check?",
"(",
"latest_fixity_check",
")",
"if",
"async_jobs",
"FixityCheckJob",
".",
"perform_later",
"(",
"version_uri",
".",
"to_s",
",",
"file_set_id",
":",
"file_set",
".",
"id",
",",
"file_id",
":",
"file_id",
")",
"else",
"FixityCheckJob",
".",
"perform_now",
"(",
"version_uri",
".",
"to_s",
",",
"file_set_id",
":",
"file_set",
".",
"id",
",",
"file_id",
":",
"file_id",
")",
"end",
"end"
] |
Retrieve or generate the fixity check for a specific version of a file
@param [String] file_id used to find the file within its parent object (usually "original_file")
@param [String] version_uri the version to be fixity checked (or the file uri for non-versioned files)
|
[
"Retrieve",
"or",
"generate",
"the",
"fixity",
"check",
"for",
"a",
"specific",
"version",
"of",
"a",
"file"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/services/hyrax/file_set_fixity_check_service.rb#L82-L91
|
11,739
|
samvera/hyrax
|
app/services/hyrax/file_set_fixity_check_service.rb
|
Hyrax.FileSetFixityCheckService.needs_fixity_check?
|
def needs_fixity_check?(latest_fixity_check)
return true unless latest_fixity_check
unless latest_fixity_check.updated_at
logger.warn "***FIXITY*** problem with fixity check log! Latest Fixity check is not nil, but updated_at is not set #{latest_fixity_check}"
return true
end
days_since_last_fixity_check(latest_fixity_check) >= max_days_between_fixity_checks
end
|
ruby
|
def needs_fixity_check?(latest_fixity_check)
return true unless latest_fixity_check
unless latest_fixity_check.updated_at
logger.warn "***FIXITY*** problem with fixity check log! Latest Fixity check is not nil, but updated_at is not set #{latest_fixity_check}"
return true
end
days_since_last_fixity_check(latest_fixity_check) >= max_days_between_fixity_checks
end
|
[
"def",
"needs_fixity_check?",
"(",
"latest_fixity_check",
")",
"return",
"true",
"unless",
"latest_fixity_check",
"unless",
"latest_fixity_check",
".",
"updated_at",
"logger",
".",
"warn",
"\"***FIXITY*** problem with fixity check log! Latest Fixity check is not nil, but updated_at is not set #{latest_fixity_check}\"",
"return",
"true",
"end",
"days_since_last_fixity_check",
"(",
"latest_fixity_check",
")",
">=",
"max_days_between_fixity_checks",
"end"
] |
Check if time since the last fixity check is greater than the maximum days allowed between fixity checks
@param [ChecksumAuditLog] latest_fixity_check the most recent fixity check
|
[
"Check",
"if",
"time",
"since",
"the",
"last",
"fixity",
"check",
"is",
"greater",
"than",
"the",
"maximum",
"days",
"allowed",
"between",
"fixity",
"checks"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/services/hyrax/file_set_fixity_check_service.rb#L95-L102
|
11,740
|
samvera/hyrax
|
app/controllers/concerns/hyrax/embargoes_controller_behavior.rb
|
Hyrax.EmbargoesControllerBehavior.destroy
|
def destroy
Hyrax::Actors::EmbargoActor.new(curation_concern).destroy
flash[:notice] = curation_concern.embargo_history.last
if curation_concern.work? && curation_concern.file_sets.present?
redirect_to confirm_permission_path
else
redirect_to edit_embargo_path
end
end
|
ruby
|
def destroy
Hyrax::Actors::EmbargoActor.new(curation_concern).destroy
flash[:notice] = curation_concern.embargo_history.last
if curation_concern.work? && curation_concern.file_sets.present?
redirect_to confirm_permission_path
else
redirect_to edit_embargo_path
end
end
|
[
"def",
"destroy",
"Hyrax",
"::",
"Actors",
"::",
"EmbargoActor",
".",
"new",
"(",
"curation_concern",
")",
".",
"destroy",
"flash",
"[",
":notice",
"]",
"=",
"curation_concern",
".",
"embargo_history",
".",
"last",
"if",
"curation_concern",
".",
"work?",
"&&",
"curation_concern",
".",
"file_sets",
".",
"present?",
"redirect_to",
"confirm_permission_path",
"else",
"redirect_to",
"edit_embargo_path",
"end",
"end"
] |
Removes a single embargo
|
[
"Removes",
"a",
"single",
"embargo"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb#L15-L23
|
11,741
|
samvera/hyrax
|
app/controllers/concerns/hyrax/embargoes_controller_behavior.rb
|
Hyrax.EmbargoesControllerBehavior.update
|
def update
filter_docs_with_edit_access!
copy_visibility = params[:embargoes].values.map { |h| h[:copy_visibility] }
ActiveFedora::Base.find(batch).each do |curation_concern|
Hyrax::Actors::EmbargoActor.new(curation_concern).destroy
# if the concern is a FileSet, set its visibility and skip the copy_visibility_to_files, which is built for Works
if curation_concern.file_set?
curation_concern.visibility = curation_concern.to_solr["visibility_after_embargo_ssim"]
curation_concern.save!
elsif copy_visibility.include?(curation_concern.id)
curation_concern.copy_visibility_to_files
end
end
redirect_to embargoes_path, notice: t('.embargo_deactivated')
end
|
ruby
|
def update
filter_docs_with_edit_access!
copy_visibility = params[:embargoes].values.map { |h| h[:copy_visibility] }
ActiveFedora::Base.find(batch).each do |curation_concern|
Hyrax::Actors::EmbargoActor.new(curation_concern).destroy
# if the concern is a FileSet, set its visibility and skip the copy_visibility_to_files, which is built for Works
if curation_concern.file_set?
curation_concern.visibility = curation_concern.to_solr["visibility_after_embargo_ssim"]
curation_concern.save!
elsif copy_visibility.include?(curation_concern.id)
curation_concern.copy_visibility_to_files
end
end
redirect_to embargoes_path, notice: t('.embargo_deactivated')
end
|
[
"def",
"update",
"filter_docs_with_edit_access!",
"copy_visibility",
"=",
"params",
"[",
":embargoes",
"]",
".",
"values",
".",
"map",
"{",
"|",
"h",
"|",
"h",
"[",
":copy_visibility",
"]",
"}",
"ActiveFedora",
"::",
"Base",
".",
"find",
"(",
"batch",
")",
".",
"each",
"do",
"|",
"curation_concern",
"|",
"Hyrax",
"::",
"Actors",
"::",
"EmbargoActor",
".",
"new",
"(",
"curation_concern",
")",
".",
"destroy",
"# if the concern is a FileSet, set its visibility and skip the copy_visibility_to_files, which is built for Works",
"if",
"curation_concern",
".",
"file_set?",
"curation_concern",
".",
"visibility",
"=",
"curation_concern",
".",
"to_solr",
"[",
"\"visibility_after_embargo_ssim\"",
"]",
"curation_concern",
".",
"save!",
"elsif",
"copy_visibility",
".",
"include?",
"(",
"curation_concern",
".",
"id",
")",
"curation_concern",
".",
"copy_visibility_to_files",
"end",
"end",
"redirect_to",
"embargoes_path",
",",
"notice",
":",
"t",
"(",
"'.embargo_deactivated'",
")",
"end"
] |
Updates a batch of embargos
|
[
"Updates",
"a",
"batch",
"of",
"embargos"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/controllers/concerns/hyrax/embargoes_controller_behavior.rb#L26-L40
|
11,742
|
samvera/hyrax
|
app/indexers/hyrax/indexes_workflow.rb
|
Hyrax.IndexesWorkflow.index_workflow_fields
|
def index_workflow_fields(solr_document)
return unless object.persisted?
entity = PowerConverter.convert_to_sipity_entity(object)
return if entity.nil?
solr_document[workflow_role_field] = workflow_roles(entity).map { |role| "#{entity.workflow.permission_template.source_id}-#{entity.workflow.name}-#{role}" }
solr_document[workflow_state_name_field] = entity.workflow_state.name if entity.workflow_state
end
|
ruby
|
def index_workflow_fields(solr_document)
return unless object.persisted?
entity = PowerConverter.convert_to_sipity_entity(object)
return if entity.nil?
solr_document[workflow_role_field] = workflow_roles(entity).map { |role| "#{entity.workflow.permission_template.source_id}-#{entity.workflow.name}-#{role}" }
solr_document[workflow_state_name_field] = entity.workflow_state.name if entity.workflow_state
end
|
[
"def",
"index_workflow_fields",
"(",
"solr_document",
")",
"return",
"unless",
"object",
".",
"persisted?",
"entity",
"=",
"PowerConverter",
".",
"convert_to_sipity_entity",
"(",
"object",
")",
"return",
"if",
"entity",
".",
"nil?",
"solr_document",
"[",
"workflow_role_field",
"]",
"=",
"workflow_roles",
"(",
"entity",
")",
".",
"map",
"{",
"|",
"role",
"|",
"\"#{entity.workflow.permission_template.source_id}-#{entity.workflow.name}-#{role}\"",
"}",
"solr_document",
"[",
"workflow_state_name_field",
"]",
"=",
"entity",
".",
"workflow_state",
".",
"name",
"if",
"entity",
".",
"workflow_state",
"end"
] |
Write the workflow roles and state so one can see where the document moves to next
@param [Hash] solr_document the solr document to add the field to
|
[
"Write",
"the",
"workflow",
"roles",
"and",
"state",
"so",
"one",
"can",
"see",
"where",
"the",
"document",
"moves",
"to",
"next"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/indexers/hyrax/indexes_workflow.rb#L25-L31
|
11,743
|
samvera/hyrax
|
app/models/sipity/workflow.rb
|
Sipity.Workflow.add_workflow_responsibilities
|
def add_workflow_responsibilities(role, agents)
Hyrax::Workflow::PermissionGenerator.call(roles: role,
workflow: self,
agents: agents)
end
|
ruby
|
def add_workflow_responsibilities(role, agents)
Hyrax::Workflow::PermissionGenerator.call(roles: role,
workflow: self,
agents: agents)
end
|
[
"def",
"add_workflow_responsibilities",
"(",
"role",
",",
"agents",
")",
"Hyrax",
"::",
"Workflow",
"::",
"PermissionGenerator",
".",
"call",
"(",
"roles",
":",
"role",
",",
"workflow",
":",
"self",
",",
"agents",
":",
"agents",
")",
"end"
] |
Give workflow responsibilites to the provided agents for the given role
@param [Sipity::Role] role
@param [Array<Sipity::Agent>] agents
|
[
"Give",
"workflow",
"responsibilites",
"to",
"the",
"provided",
"agents",
"for",
"the",
"given",
"role"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/models/sipity/workflow.rb#L74-L78
|
11,744
|
samvera/hyrax
|
app/models/sipity/workflow.rb
|
Sipity.Workflow.remove_workflow_responsibilities
|
def remove_workflow_responsibilities(role, allowed_agents)
wf_role = Sipity::WorkflowRole.find_by(workflow: self, role_id: role)
wf_role.workflow_responsibilities.where.not(agent: allowed_agents).destroy_all
end
|
ruby
|
def remove_workflow_responsibilities(role, allowed_agents)
wf_role = Sipity::WorkflowRole.find_by(workflow: self, role_id: role)
wf_role.workflow_responsibilities.where.not(agent: allowed_agents).destroy_all
end
|
[
"def",
"remove_workflow_responsibilities",
"(",
"role",
",",
"allowed_agents",
")",
"wf_role",
"=",
"Sipity",
"::",
"WorkflowRole",
".",
"find_by",
"(",
"workflow",
":",
"self",
",",
"role_id",
":",
"role",
")",
"wf_role",
".",
"workflow_responsibilities",
".",
"where",
".",
"not",
"(",
"agent",
":",
"allowed_agents",
")",
".",
"destroy_all",
"end"
] |
Find any workflow_responsibilities held by agents not in the allowed_agents
and remove them
@param [Sipity::Role] role
@param [Array<Sipity::Agent>] allowed_agents
|
[
"Find",
"any",
"workflow_responsibilities",
"held",
"by",
"agents",
"not",
"in",
"the",
"allowed_agents",
"and",
"remove",
"them"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/models/sipity/workflow.rb#L84-L87
|
11,745
|
samvera/hyrax
|
app/presenters/hyrax/presents_attributes.rb
|
Hyrax.PresentsAttributes.attribute_to_html
|
def attribute_to_html(field, options = {})
unless respond_to?(field)
Rails.logger.warn("#{self.class} attempted to render #{field}, but no method exists with that name.")
return
end
if options[:html_dl]
renderer_for(field, options).new(field, send(field), options).render_dl_row
else
renderer_for(field, options).new(field, send(field), options).render
end
end
|
ruby
|
def attribute_to_html(field, options = {})
unless respond_to?(field)
Rails.logger.warn("#{self.class} attempted to render #{field}, but no method exists with that name.")
return
end
if options[:html_dl]
renderer_for(field, options).new(field, send(field), options).render_dl_row
else
renderer_for(field, options).new(field, send(field), options).render
end
end
|
[
"def",
"attribute_to_html",
"(",
"field",
",",
"options",
"=",
"{",
"}",
")",
"unless",
"respond_to?",
"(",
"field",
")",
"Rails",
".",
"logger",
".",
"warn",
"(",
"\"#{self.class} attempted to render #{field}, but no method exists with that name.\"",
")",
"return",
"end",
"if",
"options",
"[",
":html_dl",
"]",
"renderer_for",
"(",
"field",
",",
"options",
")",
".",
"new",
"(",
"field",
",",
"send",
"(",
"field",
")",
",",
"options",
")",
".",
"render_dl_row",
"else",
"renderer_for",
"(",
"field",
",",
"options",
")",
".",
"new",
"(",
"field",
",",
"send",
"(",
"field",
")",
",",
"options",
")",
".",
"render",
"end",
"end"
] |
Present the attribute as an HTML table row or dl row.
@param [Hash] options
@option options [Symbol] :render_as use an alternate renderer
(e.g., :linked or :linked_attribute to use LinkedAttributeRenderer)
@option options [String] :search_field If the method_name of the attribute is different than
how the attribute name should appear on the search URL,
you can explicitly set the URL's search field name
@option options [String] :label The default label for the field if no translation is found
@option options [TrueClass, FalseClass] :include_empty should we display a row if there are no values?
@option options [String] :work_type name of work type class (e.g., "GenericWork")
|
[
"Present",
"the",
"attribute",
"as",
"an",
"HTML",
"table",
"row",
"or",
"dl",
"row",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/presenters/hyrax/presents_attributes.rb#L15-L26
|
11,746
|
samvera/hyrax
|
app/indexers/hyrax/deep_indexing_service.rb
|
Hyrax.DeepIndexingService.append_to_solr_doc
|
def append_to_solr_doc(solr_doc, solr_field_key, field_info, val)
return super unless object.controlled_properties.include?(solr_field_key.to_sym)
case val
when ActiveTriples::Resource
append_label_and_uri(solr_doc, solr_field_key, field_info, val)
when String
append_label(solr_doc, solr_field_key, field_info, val)
else
raise ArgumentError, "Can't handle #{val.class}"
end
end
|
ruby
|
def append_to_solr_doc(solr_doc, solr_field_key, field_info, val)
return super unless object.controlled_properties.include?(solr_field_key.to_sym)
case val
when ActiveTriples::Resource
append_label_and_uri(solr_doc, solr_field_key, field_info, val)
when String
append_label(solr_doc, solr_field_key, field_info, val)
else
raise ArgumentError, "Can't handle #{val.class}"
end
end
|
[
"def",
"append_to_solr_doc",
"(",
"solr_doc",
",",
"solr_field_key",
",",
"field_info",
",",
"val",
")",
"return",
"super",
"unless",
"object",
".",
"controlled_properties",
".",
"include?",
"(",
"solr_field_key",
".",
"to_sym",
")",
"case",
"val",
"when",
"ActiveTriples",
"::",
"Resource",
"append_label_and_uri",
"(",
"solr_doc",
",",
"solr_field_key",
",",
"field_info",
",",
"val",
")",
"when",
"String",
"append_label",
"(",
"solr_doc",
",",
"solr_field_key",
",",
"field_info",
",",
"val",
")",
"else",
"raise",
"ArgumentError",
",",
"\"Can't handle #{val.class}\"",
"end",
"end"
] |
We're overiding the default indexer in order to index the RDF labels. In order
for this to be called, you must specify at least one default indexer on the property.
@param [Hash] solr_doc
@param [String] solr_field_key
@param [Hash] field_info
@param [ActiveTriples::Resource, String] val
|
[
"We",
"re",
"overiding",
"the",
"default",
"indexer",
"in",
"order",
"to",
"index",
"the",
"RDF",
"labels",
".",
"In",
"order",
"for",
"this",
"to",
"be",
"called",
"you",
"must",
"specify",
"at",
"least",
"one",
"default",
"indexer",
"on",
"the",
"property",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/indexers/hyrax/deep_indexing_service.rb#L10-L20
|
11,747
|
samvera/hyrax
|
app/indexers/hyrax/deep_indexing_service.rb
|
Hyrax.DeepIndexingService.fetch_external
|
def fetch_external
object.controlled_properties.each do |property|
object[property].each do |value|
resource = value.respond_to?(:resource) ? value.resource : value
next unless resource.is_a?(ActiveTriples::Resource)
next if value.is_a?(ActiveFedora::Base)
fetch_with_persistence(resource)
end
end
end
|
ruby
|
def fetch_external
object.controlled_properties.each do |property|
object[property].each do |value|
resource = value.respond_to?(:resource) ? value.resource : value
next unless resource.is_a?(ActiveTriples::Resource)
next if value.is_a?(ActiveFedora::Base)
fetch_with_persistence(resource)
end
end
end
|
[
"def",
"fetch_external",
"object",
".",
"controlled_properties",
".",
"each",
"do",
"|",
"property",
"|",
"object",
"[",
"property",
"]",
".",
"each",
"do",
"|",
"value",
"|",
"resource",
"=",
"value",
".",
"respond_to?",
"(",
":resource",
")",
"?",
"value",
".",
"resource",
":",
"value",
"next",
"unless",
"resource",
".",
"is_a?",
"(",
"ActiveTriples",
"::",
"Resource",
")",
"next",
"if",
"value",
".",
"is_a?",
"(",
"ActiveFedora",
"::",
"Base",
")",
"fetch_with_persistence",
"(",
"resource",
")",
"end",
"end",
"end"
] |
Grab the labels for controlled properties from the remote sources
|
[
"Grab",
"the",
"labels",
"for",
"controlled",
"properties",
"from",
"the",
"remote",
"sources"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/indexers/hyrax/deep_indexing_service.rb#L30-L39
|
11,748
|
samvera/hyrax
|
app/indexers/hyrax/deep_indexing_service.rb
|
Hyrax.DeepIndexingService.append_label
|
def append_label(solr_doc, solr_field_key, field_info, val)
ActiveFedora::Indexing::Inserter.create_and_insert_terms(solr_field_key,
val,
field_info.behaviors, solr_doc)
ActiveFedora::Indexing::Inserter.create_and_insert_terms("#{solr_field_key}_label",
val,
field_info.behaviors, solr_doc)
end
|
ruby
|
def append_label(solr_doc, solr_field_key, field_info, val)
ActiveFedora::Indexing::Inserter.create_and_insert_terms(solr_field_key,
val,
field_info.behaviors, solr_doc)
ActiveFedora::Indexing::Inserter.create_and_insert_terms("#{solr_field_key}_label",
val,
field_info.behaviors, solr_doc)
end
|
[
"def",
"append_label",
"(",
"solr_doc",
",",
"solr_field_key",
",",
"field_info",
",",
"val",
")",
"ActiveFedora",
"::",
"Indexing",
"::",
"Inserter",
".",
"create_and_insert_terms",
"(",
"solr_field_key",
",",
"val",
",",
"field_info",
".",
"behaviors",
",",
"solr_doc",
")",
"ActiveFedora",
"::",
"Indexing",
"::",
"Inserter",
".",
"create_and_insert_terms",
"(",
"\"#{solr_field_key}_label\"",
",",
"val",
",",
"field_info",
".",
"behaviors",
",",
"solr_doc",
")",
"end"
] |
Use this method to append a string value from a controlled vocabulary field
to the solr document. It just puts a copy into the corresponding label field
@param [Hash] solr_doc
@param [String] solr_field_key
@param [Hash] field_info
@param [String] val
|
[
"Use",
"this",
"method",
"to",
"append",
"a",
"string",
"value",
"from",
"a",
"controlled",
"vocabulary",
"field",
"to",
"the",
"solr",
"document",
".",
"It",
"just",
"puts",
"a",
"copy",
"into",
"the",
"corresponding",
"label",
"field"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/indexers/hyrax/deep_indexing_service.rb#L85-L92
|
11,749
|
samvera/hyrax
|
app/search_builders/hyrax/deposit_search_builder.rb
|
Hyrax.DepositSearchBuilder.include_depositor_facet
|
def include_depositor_facet(solr_parameters)
solr_parameters[:"facet.field"].concat([DepositSearchBuilder.depositor_field])
# default facet limit is 10, which will only show the top 10 users.
# As we want to show all user deposits, so set the facet.limit to the
# the number of users in the database
solr_parameters[:"facet.limit"] = ::User.count
# we only want the facte counts not the actual data
solr_parameters[:rows] = 0
end
|
ruby
|
def include_depositor_facet(solr_parameters)
solr_parameters[:"facet.field"].concat([DepositSearchBuilder.depositor_field])
# default facet limit is 10, which will only show the top 10 users.
# As we want to show all user deposits, so set the facet.limit to the
# the number of users in the database
solr_parameters[:"facet.limit"] = ::User.count
# we only want the facte counts not the actual data
solr_parameters[:rows] = 0
end
|
[
"def",
"include_depositor_facet",
"(",
"solr_parameters",
")",
"solr_parameters",
"[",
":\"",
"\"",
"]",
".",
"concat",
"(",
"[",
"DepositSearchBuilder",
".",
"depositor_field",
"]",
")",
"# default facet limit is 10, which will only show the top 10 users.",
"# As we want to show all user deposits, so set the facet.limit to the",
"# the number of users in the database",
"solr_parameters",
"[",
":\"",
"\"",
"]",
"=",
"::",
"User",
".",
"count",
"# we only want the facte counts not the actual data",
"solr_parameters",
"[",
":rows",
"]",
"=",
"0",
"end"
] |
includes the depositor_facet to get information on deposits.
use caution when combining this with other searches as it sets the rows to
zero to just get the facet information
@param solr_parameters the current solr parameters
|
[
"includes",
"the",
"depositor_facet",
"to",
"get",
"information",
"on",
"deposits",
".",
"use",
"caution",
"when",
"combining",
"this",
"with",
"other",
"searches",
"as",
"it",
"sets",
"the",
"rows",
"to",
"zero",
"to",
"just",
"get",
"the",
"facet",
"information"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/search_builders/hyrax/deposit_search_builder.rb#L7-L17
|
11,750
|
samvera/hyrax
|
app/controllers/hyrax/users_controller.rb
|
Hyrax.UsersController.show
|
def show
user = ::User.from_url_component(params[:id])
return redirect_to root_path, alert: "User '#{params[:id]}' does not exist" if user.nil?
@presenter = Hyrax::UserProfilePresenter.new(user, current_ability)
end
|
ruby
|
def show
user = ::User.from_url_component(params[:id])
return redirect_to root_path, alert: "User '#{params[:id]}' does not exist" if user.nil?
@presenter = Hyrax::UserProfilePresenter.new(user, current_ability)
end
|
[
"def",
"show",
"user",
"=",
"::",
"User",
".",
"from_url_component",
"(",
"params",
"[",
":id",
"]",
")",
"return",
"redirect_to",
"root_path",
",",
"alert",
":",
"\"User '#{params[:id]}' does not exist\"",
"if",
"user",
".",
"nil?",
"@presenter",
"=",
"Hyrax",
"::",
"UserProfilePresenter",
".",
"new",
"(",
"user",
",",
"current_ability",
")",
"end"
] |
Display user profile
|
[
"Display",
"user",
"profile"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/controllers/hyrax/users_controller.rb#L14-L18
|
11,751
|
samvera/hyrax
|
app/presenters/hyrax/presenter_factory.rb
|
Hyrax.PresenterFactory.query
|
def query(query, args = {})
args[:q] = query
args[:qt] = 'standard'
conn = ActiveFedora::SolrService.instance.conn
result = conn.post('select', data: args)
result.fetch('response').fetch('docs')
end
|
ruby
|
def query(query, args = {})
args[:q] = query
args[:qt] = 'standard'
conn = ActiveFedora::SolrService.instance.conn
result = conn.post('select', data: args)
result.fetch('response').fetch('docs')
end
|
[
"def",
"query",
"(",
"query",
",",
"args",
"=",
"{",
"}",
")",
"args",
"[",
":q",
"]",
"=",
"query",
"args",
"[",
":qt",
"]",
"=",
"'standard'",
"conn",
"=",
"ActiveFedora",
"::",
"SolrService",
".",
"instance",
".",
"conn",
"result",
"=",
"conn",
".",
"post",
"(",
"'select'",
",",
"data",
":",
"args",
")",
"result",
".",
"fetch",
"(",
"'response'",
")",
".",
"fetch",
"(",
"'docs'",
")",
"end"
] |
Query solr using POST so that the query doesn't get too large for a URI
|
[
"Query",
"solr",
"using",
"POST",
"so",
"that",
"the",
"query",
"doesn",
"t",
"get",
"too",
"large",
"for",
"a",
"URI"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/presenters/hyrax/presenter_factory.rb#L58-L64
|
11,752
|
samvera/hyrax
|
lib/hyrax/redis_event_store.rb
|
Hyrax.RedisEventStore.push
|
def push(value)
RedisEventStore.instance.lpush(@key, value)
rescue Redis::CommandError, Redis::CannotConnectError
RedisEventStore.logger.error("unable to push event: #{@key}")
nil
end
|
ruby
|
def push(value)
RedisEventStore.instance.lpush(@key, value)
rescue Redis::CommandError, Redis::CannotConnectError
RedisEventStore.logger.error("unable to push event: #{@key}")
nil
end
|
[
"def",
"push",
"(",
"value",
")",
"RedisEventStore",
".",
"instance",
".",
"lpush",
"(",
"@key",
",",
"value",
")",
"rescue",
"Redis",
"::",
"CommandError",
",",
"Redis",
"::",
"CannotConnectError",
"RedisEventStore",
".",
"logger",
".",
"error",
"(",
"\"unable to push event: #{@key}\"",
")",
"nil",
"end"
] |
Adds a value to the end of a list identified by key
|
[
"Adds",
"a",
"value",
"to",
"the",
"end",
"of",
"a",
"list",
"identified",
"by",
"key"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/lib/hyrax/redis_event_store.rb#L51-L56
|
11,753
|
samvera/hyrax
|
app/models/hyrax/operation.rb
|
Hyrax.Operation.rollup_messages
|
def rollup_messages
[].tap do |messages|
messages << message if message.present?
children&.pluck(:message)&.uniq&.each do |child_message|
messages << child_message if child_message.present?
end
end
end
|
ruby
|
def rollup_messages
[].tap do |messages|
messages << message if message.present?
children&.pluck(:message)&.uniq&.each do |child_message|
messages << child_message if child_message.present?
end
end
end
|
[
"def",
"rollup_messages",
"[",
"]",
".",
"tap",
"do",
"|",
"messages",
"|",
"messages",
"<<",
"message",
"if",
"message",
".",
"present?",
"children",
"&.",
"pluck",
"(",
":message",
")",
"&.",
"uniq",
"&.",
"each",
"do",
"|",
"child_message",
"|",
"messages",
"<<",
"child_message",
"if",
"child_message",
".",
"present?",
"end",
"end",
"end"
] |
Roll up messages for an operation and all of its children
|
[
"Roll",
"up",
"messages",
"for",
"an",
"operation",
"and",
"all",
"of",
"its",
"children"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/models/hyrax/operation.rb#L45-L52
|
11,754
|
samvera/hyrax
|
app/models/hyrax/operation.rb
|
Hyrax.Operation.fail!
|
def fail!(message = nil)
run_callbacks :failure do
update(status: FAILURE, message: message)
parent&.rollup_status
end
end
|
ruby
|
def fail!(message = nil)
run_callbacks :failure do
update(status: FAILURE, message: message)
parent&.rollup_status
end
end
|
[
"def",
"fail!",
"(",
"message",
"=",
"nil",
")",
"run_callbacks",
":failure",
"do",
"update",
"(",
"status",
":",
"FAILURE",
",",
"message",
":",
"message",
")",
"parent",
"&.",
"rollup_status",
"end",
"end"
] |
Mark this operation as a FAILURE. If this is a child operation, roll up to
the parent any failures.
@param [String, nil] message record any failure message
@see Hyrax::Operation::FAILURE
@see #rollup_status
@note This will run any registered :failure callbacks
@todo Where are these callbacks defined? Document this
|
[
"Mark",
"this",
"operation",
"as",
"a",
"FAILURE",
".",
"If",
"this",
"is",
"a",
"child",
"operation",
"roll",
"up",
"to",
"the",
"parent",
"any",
"failures",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/models/hyrax/operation.rb#L76-L81
|
11,755
|
samvera/hyrax
|
app/models/hyrax/operation.rb
|
Hyrax.Operation.pending_job
|
def pending_job(job)
update(job_class: job.class.to_s, job_id: job.job_id, status: Hyrax::Operation::PENDING)
end
|
ruby
|
def pending_job(job)
update(job_class: job.class.to_s, job_id: job.job_id, status: Hyrax::Operation::PENDING)
end
|
[
"def",
"pending_job",
"(",
"job",
")",
"update",
"(",
"job_class",
":",
"job",
".",
"class",
".",
"to_s",
",",
"job_id",
":",
"job",
".",
"job_id",
",",
"status",
":",
"Hyrax",
"::",
"Operation",
"::",
"PENDING",
")",
"end"
] |
Sets the operation status to PENDING
@param [#class, #job_id] job - The job associated with this operation
@see Hyrax::Operation::PENDING
|
[
"Sets",
"the",
"operation",
"status",
"to",
"PENDING"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/models/hyrax/operation.rb#L92-L94
|
11,756
|
samvera/hyrax
|
app/controllers/hyrax/admin/admin_sets_controller.rb
|
Hyrax.Admin::AdminSetsController.files
|
def files
result = form.select_files.map { |label, id| { id: id, text: label } }
render json: result
end
|
ruby
|
def files
result = form.select_files.map { |label, id| { id: id, text: label } }
render json: result
end
|
[
"def",
"files",
"result",
"=",
"form",
".",
"select_files",
".",
"map",
"{",
"|",
"label",
",",
"id",
"|",
"{",
"id",
":",
"id",
",",
"text",
":",
"label",
"}",
"}",
"render",
"json",
":",
"result",
"end"
] |
Renders a JSON response with a list of files in this admin set.
This is used by the edit form to populate the thumbnail_id dropdown
|
[
"Renders",
"a",
"JSON",
"response",
"with",
"a",
"list",
"of",
"files",
"in",
"this",
"admin",
"set",
".",
"This",
"is",
"used",
"by",
"the",
"edit",
"form",
"to",
"populate",
"the",
"thumbnail_id",
"dropdown"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/controllers/hyrax/admin/admin_sets_controller.rb#L61-L64
|
11,757
|
samvera/hyrax
|
lib/wings/active_fedora_converter.rb
|
Wings.ActiveFedoraConverter.id
|
def id
id_attr = resource[:id]
return id_attr.to_s if id_attr.present? && id_attr.is_a?(::Valkyrie::ID) && !id_attr.blank?
return "" unless resource.respond_to?(:alternate_ids)
resource.alternate_ids.first.to_s
end
|
ruby
|
def id
id_attr = resource[:id]
return id_attr.to_s if id_attr.present? && id_attr.is_a?(::Valkyrie::ID) && !id_attr.blank?
return "" unless resource.respond_to?(:alternate_ids)
resource.alternate_ids.first.to_s
end
|
[
"def",
"id",
"id_attr",
"=",
"resource",
"[",
":id",
"]",
"return",
"id_attr",
".",
"to_s",
"if",
"id_attr",
".",
"present?",
"&&",
"id_attr",
".",
"is_a?",
"(",
"::",
"Valkyrie",
"::",
"ID",
")",
"&&",
"!",
"id_attr",
".",
"blank?",
"return",
"\"\"",
"unless",
"resource",
".",
"respond_to?",
"(",
":alternate_ids",
")",
"resource",
".",
"alternate_ids",
".",
"first",
".",
"to_s",
"end"
] |
In the context of a Valkyrie resource, prefer to use the id if it
is provided and fallback to the first of the alternate_ids. If all else fails
then the id hasn't been minted and shouldn't yet be set.
@return [String]
|
[
"In",
"the",
"context",
"of",
"a",
"Valkyrie",
"resource",
"prefer",
"to",
"use",
"the",
"id",
"if",
"it",
"is",
"provided",
"and",
"fallback",
"to",
"the",
"first",
"of",
"the",
"alternate_ids",
".",
"If",
"all",
"else",
"fails",
"then",
"the",
"id",
"hasn",
"t",
"been",
"minted",
"and",
"shouldn",
"t",
"yet",
"be",
"set",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/lib/wings/active_fedora_converter.rb#L69-L74
|
11,758
|
samvera/hyrax
|
lib/wings/active_fedora_converter.rb
|
Wings.ActiveFedoraConverter.add_access_control_attributes
|
def add_access_control_attributes(af_object)
af_object.visibility = attributes[:visibility] unless attributes[:visibility].blank?
af_object.read_users = attributes[:read_users] unless attributes[:read_users].blank?
af_object.edit_users = attributes[:edit_users] unless attributes[:edit_users].blank?
af_object.read_groups = attributes[:read_groups] unless attributes[:read_groups].blank?
af_object.edit_groups = attributes[:edit_groups] unless attributes[:edit_groups].blank?
end
|
ruby
|
def add_access_control_attributes(af_object)
af_object.visibility = attributes[:visibility] unless attributes[:visibility].blank?
af_object.read_users = attributes[:read_users] unless attributes[:read_users].blank?
af_object.edit_users = attributes[:edit_users] unless attributes[:edit_users].blank?
af_object.read_groups = attributes[:read_groups] unless attributes[:read_groups].blank?
af_object.edit_groups = attributes[:edit_groups] unless attributes[:edit_groups].blank?
end
|
[
"def",
"add_access_control_attributes",
"(",
"af_object",
")",
"af_object",
".",
"visibility",
"=",
"attributes",
"[",
":visibility",
"]",
"unless",
"attributes",
"[",
":visibility",
"]",
".",
"blank?",
"af_object",
".",
"read_users",
"=",
"attributes",
"[",
":read_users",
"]",
"unless",
"attributes",
"[",
":read_users",
"]",
".",
"blank?",
"af_object",
".",
"edit_users",
"=",
"attributes",
"[",
":edit_users",
"]",
"unless",
"attributes",
"[",
":edit_users",
"]",
".",
"blank?",
"af_object",
".",
"read_groups",
"=",
"attributes",
"[",
":read_groups",
"]",
"unless",
"attributes",
"[",
":read_groups",
"]",
".",
"blank?",
"af_object",
".",
"edit_groups",
"=",
"attributes",
"[",
":edit_groups",
"]",
"unless",
"attributes",
"[",
":edit_groups",
"]",
".",
"blank?",
"end"
] |
Add attributes from resource which aren't AF properties into af_object
|
[
"Add",
"attributes",
"from",
"resource",
"which",
"aren",
"t",
"AF",
"properties",
"into",
"af_object"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/lib/wings/active_fedora_converter.rb#L151-L157
|
11,759
|
samvera/hyrax
|
app/presenters/hyrax/collection_presenter.rb
|
Hyrax.CollectionPresenter.managed_access
|
def managed_access
return I18n.t('hyrax.dashboard.my.collection_list.managed_access.manage') if current_ability.can?(:edit, solr_document)
return I18n.t('hyrax.dashboard.my.collection_list.managed_access.deposit') if current_ability.can?(:deposit, solr_document)
return I18n.t('hyrax.dashboard.my.collection_list.managed_access.view') if current_ability.can?(:read, solr_document)
''
end
|
ruby
|
def managed_access
return I18n.t('hyrax.dashboard.my.collection_list.managed_access.manage') if current_ability.can?(:edit, solr_document)
return I18n.t('hyrax.dashboard.my.collection_list.managed_access.deposit') if current_ability.can?(:deposit, solr_document)
return I18n.t('hyrax.dashboard.my.collection_list.managed_access.view') if current_ability.can?(:read, solr_document)
''
end
|
[
"def",
"managed_access",
"return",
"I18n",
".",
"t",
"(",
"'hyrax.dashboard.my.collection_list.managed_access.manage'",
")",
"if",
"current_ability",
".",
"can?",
"(",
":edit",
",",
"solr_document",
")",
"return",
"I18n",
".",
"t",
"(",
"'hyrax.dashboard.my.collection_list.managed_access.deposit'",
")",
"if",
"current_ability",
".",
"can?",
"(",
":deposit",
",",
"solr_document",
")",
"return",
"I18n",
".",
"t",
"(",
"'hyrax.dashboard.my.collection_list.managed_access.view'",
")",
"if",
"current_ability",
".",
"can?",
"(",
":read",
",",
"solr_document",
")",
"''",
"end"
] |
For the Managed Collections tab, determine the label to use for the level of access the user has for this admin set.
Checks from most permissive to most restrictive.
@return String the access label (e.g. Manage, Deposit, View)
|
[
"For",
"the",
"Managed",
"Collections",
"tab",
"determine",
"the",
"label",
"to",
"use",
"for",
"the",
"level",
"of",
"access",
"the",
"user",
"has",
"for",
"this",
"admin",
"set",
".",
"Checks",
"from",
"most",
"permissive",
"to",
"most",
"restrictive",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/presenters/hyrax/collection_presenter.rb#L166-L171
|
11,760
|
samvera/hyrax
|
app/models/hyrax/collection_type.rb
|
Hyrax.CollectionType.gid
|
def gid
URI::GID.build(app: GlobalID.app, model_name: model_name.name.parameterize.to_sym, model_id: id).to_s if id
end
|
ruby
|
def gid
URI::GID.build(app: GlobalID.app, model_name: model_name.name.parameterize.to_sym, model_id: id).to_s if id
end
|
[
"def",
"gid",
"URI",
"::",
"GID",
".",
"build",
"(",
"app",
":",
"GlobalID",
".",
"app",
",",
"model_name",
":",
"model_name",
".",
"name",
".",
"parameterize",
".",
"to_sym",
",",
"model_id",
":",
"id",
")",
".",
"to_s",
"if",
"id",
"end"
] |
Return the Global Identifier for this collection type.
@return [String] Global Identifier (gid) for this collection_type (e.g. gid://internal/hyrax-collectiontype/3)
|
[
"Return",
"the",
"Global",
"Identifier",
"for",
"this",
"collection",
"type",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/models/hyrax/collection_type.rb#L58-L60
|
11,761
|
samvera/hyrax
|
app/models/hyrax/permission_template.rb
|
Hyrax.PermissionTemplate.release_date
|
def release_date
# If no release delays allowed, return today's date as release date
return Time.zone.today if release_no_delay?
# If this isn't an embargo, just return release_date from database
return self[:release_date] unless release_max_embargo?
# Otherwise (if an embargo), return latest embargo date by adding specified months to today's date
Time.zone.today + RELEASE_EMBARGO_PERIODS.fetch(release_period).months
end
|
ruby
|
def release_date
# If no release delays allowed, return today's date as release date
return Time.zone.today if release_no_delay?
# If this isn't an embargo, just return release_date from database
return self[:release_date] unless release_max_embargo?
# Otherwise (if an embargo), return latest embargo date by adding specified months to today's date
Time.zone.today + RELEASE_EMBARGO_PERIODS.fetch(release_period).months
end
|
[
"def",
"release_date",
"# If no release delays allowed, return today's date as release date",
"return",
"Time",
".",
"zone",
".",
"today",
"if",
"release_no_delay?",
"# If this isn't an embargo, just return release_date from database",
"return",
"self",
"[",
":release_date",
"]",
"unless",
"release_max_embargo?",
"# Otherwise (if an embargo), return latest embargo date by adding specified months to today's date",
"Time",
".",
"zone",
".",
"today",
"+",
"RELEASE_EMBARGO_PERIODS",
".",
"fetch",
"(",
"release_period",
")",
".",
"months",
"end"
] |
Override release_date getter to return a dynamically calculated date of release
based one release requirements. Returns embargo date when release_max_embargo?==true.
Returns today's date when release_no_delay?==true.
@see Hyrax::AdminSetService for usage
|
[
"Override",
"release_date",
"getter",
"to",
"return",
"a",
"dynamically",
"calculated",
"date",
"of",
"release",
"based",
"one",
"release",
"requirements",
".",
"Returns",
"embargo",
"date",
"when",
"release_max_embargo?",
"==",
"true",
".",
"Returns",
"today",
"s",
"date",
"when",
"release_no_delay?",
"==",
"true",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/models/hyrax/permission_template.rb#L109-L118
|
11,762
|
samvera/hyrax
|
app/models/concerns/hyrax/ability.rb
|
Hyrax.Ability.download_users
|
def download_users(id)
doc = permissions_doc(id)
return [] if doc.nil?
users = Array(doc[self.class.read_user_field]) + Array(doc[self.class.edit_user_field])
Rails.logger.debug("[CANCAN] download_users: #{users.inspect}")
users
end
|
ruby
|
def download_users(id)
doc = permissions_doc(id)
return [] if doc.nil?
users = Array(doc[self.class.read_user_field]) + Array(doc[self.class.edit_user_field])
Rails.logger.debug("[CANCAN] download_users: #{users.inspect}")
users
end
|
[
"def",
"download_users",
"(",
"id",
")",
"doc",
"=",
"permissions_doc",
"(",
"id",
")",
"return",
"[",
"]",
"if",
"doc",
".",
"nil?",
"users",
"=",
"Array",
"(",
"doc",
"[",
"self",
".",
"class",
".",
"read_user_field",
"]",
")",
"+",
"Array",
"(",
"doc",
"[",
"self",
".",
"class",
".",
"edit_user_field",
"]",
")",
"Rails",
".",
"logger",
".",
"debug",
"(",
"\"[CANCAN] download_users: #{users.inspect}\"",
")",
"users",
"end"
] |
Grant all users with read or edit access permission to download
|
[
"Grant",
"all",
"users",
"with",
"read",
"or",
"edit",
"access",
"permission",
"to",
"download"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/models/concerns/hyrax/ability.rb#L47-L53
|
11,763
|
samvera/hyrax
|
app/models/concerns/hyrax/ability.rb
|
Hyrax.Ability.trophy_abilities
|
def trophy_abilities
can [:create, :destroy], Trophy do |t|
doc = ActiveFedora::Base.search_by_id(t.work_id, fl: 'depositor_ssim')
current_user.user_key == doc.fetch('depositor_ssim').first
end
end
|
ruby
|
def trophy_abilities
can [:create, :destroy], Trophy do |t|
doc = ActiveFedora::Base.search_by_id(t.work_id, fl: 'depositor_ssim')
current_user.user_key == doc.fetch('depositor_ssim').first
end
end
|
[
"def",
"trophy_abilities",
"can",
"[",
":create",
",",
":destroy",
"]",
",",
"Trophy",
"do",
"|",
"t",
"|",
"doc",
"=",
"ActiveFedora",
"::",
"Base",
".",
"search_by_id",
"(",
"t",
".",
"work_id",
",",
"fl",
":",
"'depositor_ssim'",
")",
"current_user",
".",
"user_key",
"==",
"doc",
".",
"fetch",
"(",
"'depositor_ssim'",
")",
".",
"first",
"end",
"end"
] |
We check based on the depositor, because the depositor may not have edit
access to the work if it went through a mediated deposit workflow that
removes edit access for the depositor.
|
[
"We",
"check",
"based",
"on",
"the",
"depositor",
"because",
"the",
"depositor",
"may",
"not",
"have",
"edit",
"access",
"to",
"the",
"work",
"if",
"it",
"went",
"through",
"a",
"mediated",
"deposit",
"workflow",
"that",
"removes",
"edit",
"access",
"for",
"the",
"depositor",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/models/concerns/hyrax/ability.rb#L162-L167
|
11,764
|
samvera/hyrax
|
app/models/concerns/hyrax/ability.rb
|
Hyrax.Ability.user_is_depositor?
|
def user_is_depositor?(document_id)
Hyrax::WorkRelation.new.search_with_conditions(
id: document_id,
DepositSearchBuilder.depositor_field => current_user.user_key
).any?
end
|
ruby
|
def user_is_depositor?(document_id)
Hyrax::WorkRelation.new.search_with_conditions(
id: document_id,
DepositSearchBuilder.depositor_field => current_user.user_key
).any?
end
|
[
"def",
"user_is_depositor?",
"(",
"document_id",
")",
"Hyrax",
"::",
"WorkRelation",
".",
"new",
".",
"search_with_conditions",
"(",
"id",
":",
"document_id",
",",
"DepositSearchBuilder",
".",
"depositor_field",
"=>",
"current_user",
".",
"user_key",
")",
".",
"any?",
"end"
] |
Returns true if the current user is the depositor of the specified work
@param document_id [String] the id of the document.
|
[
"Returns",
"true",
"if",
"the",
"current",
"user",
"is",
"the",
"depositor",
"of",
"the",
"specified",
"work"
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/models/concerns/hyrax/ability.rb#L207-L212
|
11,765
|
samvera/hyrax
|
app/presenters/hyrax/characterization_behavior.rb
|
Hyrax.CharacterizationBehavior.primary_characterization_values
|
def primary_characterization_values(term)
values = values_for(term)
values.slice!(Hyrax.config.fits_message_length, (values.length - Hyrax.config.fits_message_length))
truncate_all(values)
end
|
ruby
|
def primary_characterization_values(term)
values = values_for(term)
values.slice!(Hyrax.config.fits_message_length, (values.length - Hyrax.config.fits_message_length))
truncate_all(values)
end
|
[
"def",
"primary_characterization_values",
"(",
"term",
")",
"values",
"=",
"values_for",
"(",
"term",
")",
"values",
".",
"slice!",
"(",
"Hyrax",
".",
"config",
".",
"fits_message_length",
",",
"(",
"values",
".",
"length",
"-",
"Hyrax",
".",
"config",
".",
"fits_message_length",
")",
")",
"truncate_all",
"(",
"values",
")",
"end"
] |
Returns an array of characterization values truncated to 250 characters limited
to the maximum number of configured values.
@param [Symbol] term found in the characterization_metadata hash
@return [Array] of truncated values
|
[
"Returns",
"an",
"array",
"of",
"characterization",
"values",
"truncated",
"to",
"250",
"characters",
"limited",
"to",
"the",
"maximum",
"number",
"of",
"configured",
"values",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/presenters/hyrax/characterization_behavior.rb#L49-L53
|
11,766
|
samvera/hyrax
|
app/presenters/hyrax/characterization_behavior.rb
|
Hyrax.CharacterizationBehavior.secondary_characterization_values
|
def secondary_characterization_values(term)
values = values_for(term)
additional_values = values.slice(Hyrax.config.fits_message_length, values.length - Hyrax.config.fits_message_length)
return [] unless additional_values
truncate_all(additional_values)
end
|
ruby
|
def secondary_characterization_values(term)
values = values_for(term)
additional_values = values.slice(Hyrax.config.fits_message_length, values.length - Hyrax.config.fits_message_length)
return [] unless additional_values
truncate_all(additional_values)
end
|
[
"def",
"secondary_characterization_values",
"(",
"term",
")",
"values",
"=",
"values_for",
"(",
"term",
")",
"additional_values",
"=",
"values",
".",
"slice",
"(",
"Hyrax",
".",
"config",
".",
"fits_message_length",
",",
"values",
".",
"length",
"-",
"Hyrax",
".",
"config",
".",
"fits_message_length",
")",
"return",
"[",
"]",
"unless",
"additional_values",
"truncate_all",
"(",
"additional_values",
")",
"end"
] |
Returns an array of characterization values truncated to 250 characters that are in
excess of the maximum number of configured values.
@param [Symbol] term found in the characterization_metadata hash
@return [Array] of truncated values
|
[
"Returns",
"an",
"array",
"of",
"characterization",
"values",
"truncated",
"to",
"250",
"characters",
"that",
"are",
"in",
"excess",
"of",
"the",
"maximum",
"number",
"of",
"configured",
"values",
"."
] |
e2b4f56e829a53b1f11296324736e9d5b8c9ee5f
|
https://github.com/samvera/hyrax/blob/e2b4f56e829a53b1f11296324736e9d5b8c9ee5f/app/presenters/hyrax/characterization_behavior.rb#L59-L64
|
11,767
|
hexgnu/linkedin
|
lib/linked_in/search.rb
|
LinkedIn.Search.search
|
def search(options={}, type='people')
path = "/#{type.to_s}-search"
if options.is_a?(Hash)
fields = options.delete(:fields)
path += field_selector(fields) if fields
end
options = { :keywords => options } if options.is_a?(String)
options = format_options_for_query(options)
result_json = get(to_uri(path, options))
Mash.from_json(result_json)
end
|
ruby
|
def search(options={}, type='people')
path = "/#{type.to_s}-search"
if options.is_a?(Hash)
fields = options.delete(:fields)
path += field_selector(fields) if fields
end
options = { :keywords => options } if options.is_a?(String)
options = format_options_for_query(options)
result_json = get(to_uri(path, options))
Mash.from_json(result_json)
end
|
[
"def",
"search",
"(",
"options",
"=",
"{",
"}",
",",
"type",
"=",
"'people'",
")",
"path",
"=",
"\"/#{type.to_s}-search\"",
"if",
"options",
".",
"is_a?",
"(",
"Hash",
")",
"fields",
"=",
"options",
".",
"delete",
"(",
":fields",
")",
"path",
"+=",
"field_selector",
"(",
"fields",
")",
"if",
"fields",
"end",
"options",
"=",
"{",
":keywords",
"=>",
"options",
"}",
"if",
"options",
".",
"is_a?",
"(",
"String",
")",
"options",
"=",
"format_options_for_query",
"(",
"options",
")",
"result_json",
"=",
"get",
"(",
"to_uri",
"(",
"path",
",",
"options",
")",
")",
"Mash",
".",
"from_json",
"(",
"result_json",
")",
"end"
] |
Retrieve search results of the given object type
Permissions: (for people search only) r_network
@note People Search API is a part of the Vetted API Access Program. You
must apply and get approval before using this API
@see http://developer.linkedin.com/documents/people-search-api People Search
@see http://developer.linkedin.com/documents/job-search-api Job Search
@see http://developer.linkedin.com/documents/company-search Company Search
@param [Hash] options search input fields
@param [String] type type of object to return ('people', 'job' or 'company')
@return [LinkedIn::Mash]
|
[
"Retrieve",
"search",
"results",
"of",
"the",
"given",
"object",
"type"
] |
a56f5381e7d84b934c53e891b1f0421fe8a6caf9
|
https://github.com/hexgnu/linkedin/blob/a56f5381e7d84b934c53e891b1f0421fe8a6caf9/lib/linked_in/search.rb#L19-L34
|
11,768
|
hexgnu/linkedin
|
lib/linked_in/mash.rb
|
LinkedIn.Mash.timestamp
|
def timestamp
value = self['timestamp']
if value.kind_of? Integer
value = value / 1000 if value > 9999999999
Time.at(value)
else
value
end
end
|
ruby
|
def timestamp
value = self['timestamp']
if value.kind_of? Integer
value = value / 1000 if value > 9999999999
Time.at(value)
else
value
end
end
|
[
"def",
"timestamp",
"value",
"=",
"self",
"[",
"'timestamp'",
"]",
"if",
"value",
".",
"kind_of?",
"Integer",
"value",
"=",
"value",
"/",
"1000",
"if",
"value",
">",
"9999999999",
"Time",
".",
"at",
"(",
"value",
")",
"else",
"value",
"end",
"end"
] |
Convert the 'timestamp' field from a string to a Time object
@return [Time]
|
[
"Convert",
"the",
"timestamp",
"field",
"from",
"a",
"string",
"to",
"a",
"Time",
"object"
] |
a56f5381e7d84b934c53e891b1f0421fe8a6caf9
|
https://github.com/hexgnu/linkedin/blob/a56f5381e7d84b934c53e891b1f0421fe8a6caf9/lib/linked_in/mash.rb#L44-L52
|
11,769
|
librariesio/bibliothecary
|
lib/bibliothecary/runner.rb
|
Bibliothecary.Runner.identify_manifests
|
def identify_manifests(file_list)
ignored_dirs_with_slash = ignored_dirs.map { |d| if d.end_with?("/") then d else d + "/" end }
allowed_file_list = file_list.reject do |f|
ignored_dirs.include?(f) || f.start_with?(*ignored_dirs_with_slash)
end
allowed_file_list = allowed_file_list.reject{|f| ignored_files.include?(f)}
package_managers.map do |pm|
allowed_file_list.select do |file_path|
# this is a call to match? without file contents, which will skip
# ambiguous filenames that are only possibly a manifest
pm.match?(file_path)
end
end.flatten.uniq.compact
end
|
ruby
|
def identify_manifests(file_list)
ignored_dirs_with_slash = ignored_dirs.map { |d| if d.end_with?("/") then d else d + "/" end }
allowed_file_list = file_list.reject do |f|
ignored_dirs.include?(f) || f.start_with?(*ignored_dirs_with_slash)
end
allowed_file_list = allowed_file_list.reject{|f| ignored_files.include?(f)}
package_managers.map do |pm|
allowed_file_list.select do |file_path|
# this is a call to match? without file contents, which will skip
# ambiguous filenames that are only possibly a manifest
pm.match?(file_path)
end
end.flatten.uniq.compact
end
|
[
"def",
"identify_manifests",
"(",
"file_list",
")",
"ignored_dirs_with_slash",
"=",
"ignored_dirs",
".",
"map",
"{",
"|",
"d",
"|",
"if",
"d",
".",
"end_with?",
"(",
"\"/\"",
")",
"then",
"d",
"else",
"d",
"+",
"\"/\"",
"end",
"}",
"allowed_file_list",
"=",
"file_list",
".",
"reject",
"do",
"|",
"f",
"|",
"ignored_dirs",
".",
"include?",
"(",
"f",
")",
"||",
"f",
".",
"start_with?",
"(",
"ignored_dirs_with_slash",
")",
"end",
"allowed_file_list",
"=",
"allowed_file_list",
".",
"reject",
"{",
"|",
"f",
"|",
"ignored_files",
".",
"include?",
"(",
"f",
")",
"}",
"package_managers",
".",
"map",
"do",
"|",
"pm",
"|",
"allowed_file_list",
".",
"select",
"do",
"|",
"file_path",
"|",
"# this is a call to match? without file contents, which will skip",
"# ambiguous filenames that are only possibly a manifest",
"pm",
".",
"match?",
"(",
"file_path",
")",
"end",
"end",
".",
"flatten",
".",
"uniq",
".",
"compact",
"end"
] |
this skips manifests sometimes because it doesn't look at file
contents and can't establish from only regexes that the thing
is a manifest. We exclude rather than include ambiguous filenames
because this API is used by libraries.io and we don't want to
download all .xml files from GitHub.
|
[
"this",
"skips",
"manifests",
"sometimes",
"because",
"it",
"doesn",
"t",
"look",
"at",
"file",
"contents",
"and",
"can",
"t",
"establish",
"from",
"only",
"regexes",
"that",
"the",
"thing",
"is",
"a",
"manifest",
".",
"We",
"exclude",
"rather",
"than",
"include",
"ambiguous",
"filenames",
"because",
"this",
"API",
"is",
"used",
"by",
"libraries",
".",
"io",
"and",
"we",
"don",
"t",
"want",
"to",
"download",
"all",
".",
"xml",
"files",
"from",
"GitHub",
"."
] |
c446640356d5d57ceebfd27327aecd1ef7a3cd01
|
https://github.com/librariesio/bibliothecary/blob/c446640356d5d57ceebfd27327aecd1ef7a3cd01/lib/bibliothecary/runner.rb#L79-L92
|
11,770
|
square/connect-ruby-sdk
|
lib/square_connect/models/create_order_request.rb
|
SquareConnect.CreateOrderRequest.to_hash
|
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end
|
ruby
|
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end
|
[
"def",
"to_hash",
"hash",
"=",
"{",
"}",
"self",
".",
"class",
".",
"attribute_map",
".",
"each_pair",
"do",
"|",
"attr",
",",
"param",
"|",
"value",
"=",
"self",
".",
"send",
"(",
"attr",
")",
"next",
"if",
"value",
".",
"nil?",
"hash",
"[",
"param",
"]",
"=",
"_to_hash",
"(",
"value",
")",
"end",
"hash",
"end"
] |
Returns the object in the form of hash
@return [Hash] Returns the object in the form of hash
|
[
"Returns",
"the",
"object",
"in",
"the",
"form",
"of",
"hash"
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/models/create_order_request.rb#L244-L252
|
11,771
|
square/connect-ruby-sdk
|
lib/square_connect/models/create_order_request.rb
|
SquareConnect.CreateOrderRequest._to_hash
|
def _to_hash(value)
if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
|
ruby
|
def _to_hash(value)
if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
|
[
"def",
"_to_hash",
"(",
"value",
")",
"if",
"value",
".",
"is_a?",
"(",
"Array",
")",
"value",
".",
"compact",
".",
"map",
"{",
"|",
"v",
"|",
"_to_hash",
"(",
"v",
")",
"}",
"elsif",
"value",
".",
"is_a?",
"(",
"Hash",
")",
"{",
"}",
".",
"tap",
"do",
"|",
"hash",
"|",
"value",
".",
"each",
"{",
"|",
"k",
",",
"v",
"|",
"hash",
"[",
"k",
"]",
"=",
"_to_hash",
"(",
"v",
")",
"}",
"end",
"elsif",
"value",
".",
"respond_to?",
":to_hash",
"value",
".",
"to_hash",
"else",
"value",
"end",
"end"
] |
Outputs non-array value in the form of hash
For object, use to_hash. Otherwise, just return the value
@param [Object] value Any valid value
@return [Hash] Returns the value in the form of hash
|
[
"Outputs",
"non",
"-",
"array",
"value",
"in",
"the",
"form",
"of",
"hash",
"For",
"object",
"use",
"to_hash",
".",
"Otherwise",
"just",
"return",
"the",
"value"
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/models/create_order_request.rb#L258-L270
|
11,772
|
square/connect-ruby-sdk
|
lib/square_connect/api_client.rb
|
SquareConnect.ApiClient.get_v1_batch_token_from_headers
|
def get_v1_batch_token_from_headers(headers)
if headers.is_a?(Hash) && headers.has_key?('Link')
match = /^<([^>]+)>;rel='next'$/.match(headers['Link'])
if match
uri = URI.parse(match[1])
params = CGI.parse(uri.query)
return params['batch_token'][0]
end
end
end
|
ruby
|
def get_v1_batch_token_from_headers(headers)
if headers.is_a?(Hash) && headers.has_key?('Link')
match = /^<([^>]+)>;rel='next'$/.match(headers['Link'])
if match
uri = URI.parse(match[1])
params = CGI.parse(uri.query)
return params['batch_token'][0]
end
end
end
|
[
"def",
"get_v1_batch_token_from_headers",
"(",
"headers",
")",
"if",
"headers",
".",
"is_a?",
"(",
"Hash",
")",
"&&",
"headers",
".",
"has_key?",
"(",
"'Link'",
")",
"match",
"=",
"/",
"/",
".",
"match",
"(",
"headers",
"[",
"'Link'",
"]",
")",
"if",
"match",
"uri",
"=",
"URI",
".",
"parse",
"(",
"match",
"[",
"1",
"]",
")",
"params",
"=",
"CGI",
".",
"parse",
"(",
"uri",
".",
"query",
")",
"return",
"params",
"[",
"'batch_token'",
"]",
"[",
"0",
"]",
"end",
"end",
"end"
] |
Extract batch_token from Link header if present
@param [Hash] headers hash with response headers
@return [String] batch_token or nil if no token is present
|
[
"Extract",
"batch_token",
"from",
"Link",
"header",
"if",
"present"
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api_client.rb#L388-L397
|
11,773
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_employees_api.rb
|
SquareConnect.V1EmployeesApi.list_cash_drawer_shifts
|
def list_cash_drawer_shifts(location_id, opts = {})
data, _status_code, _headers = list_cash_drawer_shifts_with_http_info(location_id, opts)
return data
end
|
ruby
|
def list_cash_drawer_shifts(location_id, opts = {})
data, _status_code, _headers = list_cash_drawer_shifts_with_http_info(location_id, opts)
return data
end
|
[
"def",
"list_cash_drawer_shifts",
"(",
"location_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"list_cash_drawer_shifts_with_http_info",
"(",
"location_id",
",",
"opts",
")",
"return",
"data",
"end"
] |
ListCashDrawerShifts
Provides the details for all of a location's cash drawer shifts during a date range. The date range you specify cannot exceed 90 days.
@param location_id The ID of the location to list cash drawer shifts for.
@param [Hash] opts the optional parameters
@option opts [String] :order The order in which cash drawer shifts are listed in the response, based on their created_at field. Default value: ASC
@option opts [String] :begin_time The beginning of the requested reporting period, in ISO 8601 format. Default value: The current time minus 90 days.
@option opts [String] :end_time The beginning of the requested reporting period, in ISO 8601 format. Default value: The current time.
@return [Array<V1CashDrawerShift>]
|
[
"ListCashDrawerShifts",
"Provides",
"the",
"details",
"for",
"all",
"of",
"a",
"location",
"s",
"cash",
"drawer",
"shifts",
"during",
"a",
"date",
"range",
".",
"The",
"date",
"range",
"you",
"specify",
"cannot",
"exceed",
"90",
"days",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_employees_api.rb#L248-L251
|
11,774
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_employees_api.rb
|
SquareConnect.V1EmployeesApi.retrieve_cash_drawer_shift
|
def retrieve_cash_drawer_shift(location_id, shift_id, opts = {})
data, _status_code, _headers = retrieve_cash_drawer_shift_with_http_info(location_id, shift_id, opts)
return data
end
|
ruby
|
def retrieve_cash_drawer_shift(location_id, shift_id, opts = {})
data, _status_code, _headers = retrieve_cash_drawer_shift_with_http_info(location_id, shift_id, opts)
return data
end
|
[
"def",
"retrieve_cash_drawer_shift",
"(",
"location_id",
",",
"shift_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"retrieve_cash_drawer_shift_with_http_info",
"(",
"location_id",
",",
"shift_id",
",",
"opts",
")",
"return",
"data",
"end"
] |
RetrieveCashDrawerShift
Provides the details for a single cash drawer shift, including all events that occurred during the shift.
@param location_id The ID of the location to list cash drawer shifts for.
@param shift_id The shift's ID.
@param [Hash] opts the optional parameters
@return [V1CashDrawerShift]
|
[
"RetrieveCashDrawerShift",
"Provides",
"the",
"details",
"for",
"a",
"single",
"cash",
"drawer",
"shift",
"including",
"all",
"events",
"that",
"occurred",
"during",
"the",
"shift",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_employees_api.rb#L602-L605
|
11,775
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_employees_api.rb
|
SquareConnect.V1EmployeesApi.retrieve_employee
|
def retrieve_employee(employee_id, opts = {})
data, _status_code, _headers = retrieve_employee_with_http_info(employee_id, opts)
return data
end
|
ruby
|
def retrieve_employee(employee_id, opts = {})
data, _status_code, _headers = retrieve_employee_with_http_info(employee_id, opts)
return data
end
|
[
"def",
"retrieve_employee",
"(",
"employee_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"retrieve_employee_with_http_info",
"(",
"employee_id",
",",
"opts",
")",
"return",
"data",
"end"
] |
RetrieveEmployee
Provides the details for a single employee.
@param employee_id The employee's ID.
@param [Hash] opts the optional parameters
@return [V1Employee]
|
[
"RetrieveEmployee",
"Provides",
"the",
"details",
"for",
"a",
"single",
"employee",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_employees_api.rb#L660-L663
|
11,776
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_employees_api.rb
|
SquareConnect.V1EmployeesApi.retrieve_employee_role
|
def retrieve_employee_role(role_id, opts = {})
data, _status_code, _headers = retrieve_employee_role_with_http_info(role_id, opts)
return data
end
|
ruby
|
def retrieve_employee_role(role_id, opts = {})
data, _status_code, _headers = retrieve_employee_role_with_http_info(role_id, opts)
return data
end
|
[
"def",
"retrieve_employee_role",
"(",
"role_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"retrieve_employee_role_with_http_info",
"(",
"role_id",
",",
"opts",
")",
"return",
"data",
"end"
] |
RetrieveEmployeeRole
Provides the details for a single employee role.
@param role_id The role's ID.
@param [Hash] opts the optional parameters
@return [V1EmployeeRole]
|
[
"RetrieveEmployeeRole",
"Provides",
"the",
"details",
"for",
"a",
"single",
"employee",
"role",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_employees_api.rb#L715-L718
|
11,777
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_employees_api.rb
|
SquareConnect.V1EmployeesApi.update_employee_role
|
def update_employee_role(role_id, body, opts = {})
data, _status_code, _headers = update_employee_role_with_http_info(role_id, body, opts)
return data
end
|
ruby
|
def update_employee_role(role_id, body, opts = {})
data, _status_code, _headers = update_employee_role_with_http_info(role_id, body, opts)
return data
end
|
[
"def",
"update_employee_role",
"(",
"role_id",
",",
"body",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"update_employee_role_with_http_info",
"(",
"role_id",
",",
"body",
",",
"opts",
")",
"return",
"data",
"end"
] |
UpdateEmployeeRole
Modifies the details of an employee role.
@param role_id The ID of the role to modify.
@param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@param [Hash] opts the optional parameters
@return [V1EmployeeRole]
|
[
"UpdateEmployeeRole",
"Modifies",
"the",
"details",
"of",
"an",
"employee",
"role",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_employees_api.rb#L885-L888
|
11,778
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_employees_api.rb
|
SquareConnect.V1EmployeesApi.update_timecard
|
def update_timecard(timecard_id, body, opts = {})
data, _status_code, _headers = update_timecard_with_http_info(timecard_id, body, opts)
return data
end
|
ruby
|
def update_timecard(timecard_id, body, opts = {})
data, _status_code, _headers = update_timecard_with_http_info(timecard_id, body, opts)
return data
end
|
[
"def",
"update_timecard",
"(",
"timecard_id",
",",
"body",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"update_timecard_with_http_info",
"(",
"timecard_id",
",",
"body",
",",
"opts",
")",
"return",
"data",
"end"
] |
UpdateTimecard
Modifies the details of a timecard with an `API_EDIT` event for the timecard. Updating an active timecard with a `clockout_time` clocks the employee out.
@param timecard_id TThe ID of the timecard to modify.
@param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@param [Hash] opts the optional parameters
@return [V1Timecard]
|
[
"UpdateTimecard",
"Modifies",
"the",
"details",
"of",
"a",
"timecard",
"with",
"an",
"API_EDIT",
"event",
"for",
"the",
"timecard",
".",
"Updating",
"an",
"active",
"timecard",
"with",
"a",
"clockout_time",
"clocks",
"the",
"employee",
"out",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_employees_api.rb#L944-L947
|
11,779
|
square/connect-ruby-sdk
|
lib/square_connect/api/customers_api.rb
|
SquareConnect.CustomersApi.create_customer_card
|
def create_customer_card(customer_id, body, opts = {})
data, _status_code, _headers = create_customer_card_with_http_info(customer_id, body, opts)
return data
end
|
ruby
|
def create_customer_card(customer_id, body, opts = {})
data, _status_code, _headers = create_customer_card_with_http_info(customer_id, body, opts)
return data
end
|
[
"def",
"create_customer_card",
"(",
"customer_id",
",",
"body",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"create_customer_card_with_http_info",
"(",
"customer_id",
",",
"body",
",",
"opts",
")",
"return",
"data",
"end"
] |
CreateCustomerCard
Adds a card on file to an existing customer. As with charges, calls to `CreateCustomerCard` are idempotent. Multiple calls with the same card nonce return the same card record that was created with the provided nonce during the _first_ call. Cards on file are automatically updated on a monthly basis to confirm they are still valid and can be charged.
@param customer_id The ID of the customer to link the card on file to.
@param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@param [Hash] opts the optional parameters
@return [CreateCustomerCardResponse]
|
[
"CreateCustomerCard",
"Adds",
"a",
"card",
"on",
"file",
"to",
"an",
"existing",
"customer",
".",
"As",
"with",
"charges",
"calls",
"to",
"CreateCustomerCard",
"are",
"idempotent",
".",
"Multiple",
"calls",
"with",
"the",
"same",
"card",
"nonce",
"return",
"the",
"same",
"card",
"record",
"that",
"was",
"created",
"with",
"the",
"provided",
"nonce",
"during",
"the",
"_first_",
"call",
".",
"Cards",
"on",
"file",
"are",
"automatically",
"updated",
"on",
"a",
"monthly",
"basis",
"to",
"confirm",
"they",
"are",
"still",
"valid",
"and",
"can",
"be",
"charged",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/customers_api.rb#L81-L84
|
11,780
|
square/connect-ruby-sdk
|
lib/square_connect/api/customers_api.rb
|
SquareConnect.CustomersApi.delete_customer
|
def delete_customer(customer_id, opts = {})
data, _status_code, _headers = delete_customer_with_http_info(customer_id, opts)
return data
end
|
ruby
|
def delete_customer(customer_id, opts = {})
data, _status_code, _headers = delete_customer_with_http_info(customer_id, opts)
return data
end
|
[
"def",
"delete_customer",
"(",
"customer_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"delete_customer_with_http_info",
"(",
"customer_id",
",",
"opts",
")",
"return",
"data",
"end"
] |
DeleteCustomer
Deletes a customer from a business, along with any linked cards on file. When two profiles are merged into a single profile, that profile is assigned a new `customer_id`. You must use the new `customer_id` to delete merged profiles.
@param customer_id The ID of the customer to delete.
@param [Hash] opts the optional parameters
@return [DeleteCustomerResponse]
|
[
"DeleteCustomer",
"Deletes",
"a",
"customer",
"from",
"a",
"business",
"along",
"with",
"any",
"linked",
"cards",
"on",
"file",
".",
"When",
"two",
"profiles",
"are",
"merged",
"into",
"a",
"single",
"profile",
"that",
"profile",
"is",
"assigned",
"a",
"new",
"customer_id",
".",
"You",
"must",
"use",
"the",
"new",
"customer_id",
"to",
"delete",
"merged",
"profiles",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/customers_api.rb#L139-L142
|
11,781
|
square/connect-ruby-sdk
|
lib/square_connect/api/customers_api.rb
|
SquareConnect.CustomersApi.delete_customer_card
|
def delete_customer_card(customer_id, card_id, opts = {})
data, _status_code, _headers = delete_customer_card_with_http_info(customer_id, card_id, opts)
return data
end
|
ruby
|
def delete_customer_card(customer_id, card_id, opts = {})
data, _status_code, _headers = delete_customer_card_with_http_info(customer_id, card_id, opts)
return data
end
|
[
"def",
"delete_customer_card",
"(",
"customer_id",
",",
"card_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"delete_customer_card_with_http_info",
"(",
"customer_id",
",",
"card_id",
",",
"opts",
")",
"return",
"data",
"end"
] |
DeleteCustomerCard
Removes a card on file from a customer.
@param customer_id The ID of the customer that the card on file belongs to.
@param card_id The ID of the card on file to delete.
@param [Hash] opts the optional parameters
@return [DeleteCustomerCardResponse]
|
[
"DeleteCustomerCard",
"Removes",
"a",
"card",
"on",
"file",
"from",
"a",
"customer",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/customers_api.rb#L195-L198
|
11,782
|
square/connect-ruby-sdk
|
lib/square_connect/api/customers_api.rb
|
SquareConnect.CustomersApi.retrieve_customer
|
def retrieve_customer(customer_id, opts = {})
data, _status_code, _headers = retrieve_customer_with_http_info(customer_id, opts)
return data
end
|
ruby
|
def retrieve_customer(customer_id, opts = {})
data, _status_code, _headers = retrieve_customer_with_http_info(customer_id, opts)
return data
end
|
[
"def",
"retrieve_customer",
"(",
"customer_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"retrieve_customer_with_http_info",
"(",
"customer_id",
",",
"opts",
")",
"return",
"data",
"end"
] |
RetrieveCustomer
Returns details for a single customer.
@param customer_id The ID of the customer to retrieve.
@param [Hash] opts the optional parameters
@return [RetrieveCustomerResponse]
|
[
"RetrieveCustomer",
"Returns",
"details",
"for",
"a",
"single",
"customer",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/customers_api.rb#L319-L322
|
11,783
|
square/connect-ruby-sdk
|
lib/square_connect/api/customers_api.rb
|
SquareConnect.CustomersApi.search_customers
|
def search_customers(body, opts = {})
data, _status_code, _headers = search_customers_with_http_info(body, opts)
return data
end
|
ruby
|
def search_customers(body, opts = {})
data, _status_code, _headers = search_customers_with_http_info(body, opts)
return data
end
|
[
"def",
"search_customers",
"(",
"body",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"search_customers_with_http_info",
"(",
"body",
",",
"opts",
")",
"return",
"data",
"end"
] |
SearchCustomers
Searches the customer profiles associated with a Square account. Calling SearchCustomers without an explicit query parameter returns all customer profiles ordered alphabetically based on `given_name` and `family_name`.
@param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@param [Hash] opts the optional parameters
@return [SearchCustomersResponse]
|
[
"SearchCustomers",
"Searches",
"the",
"customer",
"profiles",
"associated",
"with",
"a",
"Square",
"account",
".",
"Calling",
"SearchCustomers",
"without",
"an",
"explicit",
"query",
"parameter",
"returns",
"all",
"customer",
"profiles",
"ordered",
"alphabetically",
"based",
"on",
"given_name",
"and",
"family_name",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/customers_api.rb#L374-L377
|
11,784
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.adjust_inventory
|
def adjust_inventory(location_id, variation_id, body, opts = {})
data, _status_code, _headers = adjust_inventory_with_http_info(location_id, variation_id, body, opts)
return data
end
|
ruby
|
def adjust_inventory(location_id, variation_id, body, opts = {})
data, _status_code, _headers = adjust_inventory_with_http_info(location_id, variation_id, body, opts)
return data
end
|
[
"def",
"adjust_inventory",
"(",
"location_id",
",",
"variation_id",
",",
"body",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"adjust_inventory_with_http_info",
"(",
"location_id",
",",
"variation_id",
",",
"body",
",",
"opts",
")",
"return",
"data",
"end"
] |
AdjustInventory
Adjusts an item variation's current available inventory.
@param location_id The ID of the item's associated location.
@param variation_id The ID of the variation to adjust inventory information for.
@param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@param [Hash] opts the optional parameters
@return [V1InventoryEntry]
|
[
"AdjustInventory",
"Adjusts",
"an",
"item",
"variation",
"s",
"current",
"available",
"inventory",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L27-L30
|
11,785
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.apply_fee
|
def apply_fee(location_id, item_id, fee_id, opts = {})
data, _status_code, _headers = apply_fee_with_http_info(location_id, item_id, fee_id, opts)
return data
end
|
ruby
|
def apply_fee(location_id, item_id, fee_id, opts = {})
data, _status_code, _headers = apply_fee_with_http_info(location_id, item_id, fee_id, opts)
return data
end
|
[
"def",
"apply_fee",
"(",
"location_id",
",",
"item_id",
",",
"fee_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"apply_fee_with_http_info",
"(",
"location_id",
",",
"item_id",
",",
"fee_id",
",",
"opts",
")",
"return",
"data",
"end"
] |
ApplyFee
Associates a fee with an item, meaning the fee is automatically applied to the item in Square Register.
@param location_id The ID of the fee's associated location.
@param item_id The ID of the item to add the fee to.
@param fee_id The ID of the fee to apply.
@param [Hash] opts the optional parameters
@return [V1Item]
|
[
"ApplyFee",
"Associates",
"a",
"fee",
"with",
"an",
"item",
"meaning",
"the",
"fee",
"is",
"automatically",
"applied",
"to",
"the",
"item",
"in",
"Square",
"Register",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L90-L93
|
11,786
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.apply_modifier_list
|
def apply_modifier_list(location_id, modifier_list_id, item_id, opts = {})
data, _status_code, _headers = apply_modifier_list_with_http_info(location_id, modifier_list_id, item_id, opts)
return data
end
|
ruby
|
def apply_modifier_list(location_id, modifier_list_id, item_id, opts = {})
data, _status_code, _headers = apply_modifier_list_with_http_info(location_id, modifier_list_id, item_id, opts)
return data
end
|
[
"def",
"apply_modifier_list",
"(",
"location_id",
",",
"modifier_list_id",
",",
"item_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"apply_modifier_list_with_http_info",
"(",
"location_id",
",",
"modifier_list_id",
",",
"item_id",
",",
"opts",
")",
"return",
"data",
"end"
] |
ApplyModifierList
Associates a modifier list with an item, meaning modifier options from the list can be applied to the item.
@param location_id The ID of the item's associated location.
@param modifier_list_id The ID of the modifier list to apply.
@param item_id The ID of the item to add the modifier list to.
@param [Hash] opts the optional parameters
@return [V1Item]
|
[
"ApplyModifierList",
"Associates",
"a",
"modifier",
"list",
"with",
"an",
"item",
"meaning",
"modifier",
"options",
"from",
"the",
"list",
"can",
"be",
"applied",
"to",
"the",
"item",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L153-L156
|
11,787
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.create_category
|
def create_category(location_id, body, opts = {})
data, _status_code, _headers = create_category_with_http_info(location_id, body, opts)
return data
end
|
ruby
|
def create_category(location_id, body, opts = {})
data, _status_code, _headers = create_category_with_http_info(location_id, body, opts)
return data
end
|
[
"def",
"create_category",
"(",
"location_id",
",",
"body",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"create_category_with_http_info",
"(",
"location_id",
",",
"body",
",",
"opts",
")",
"return",
"data",
"end"
] |
CreateCategory
Creates an item category.
@param location_id The ID of the location to create an item for.
@param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@param [Hash] opts the optional parameters
@return [V1Category]
|
[
"CreateCategory",
"Creates",
"an",
"item",
"category",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L215-L218
|
11,788
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.create_discount
|
def create_discount(location_id, body, opts = {})
data, _status_code, _headers = create_discount_with_http_info(location_id, body, opts)
return data
end
|
ruby
|
def create_discount(location_id, body, opts = {})
data, _status_code, _headers = create_discount_with_http_info(location_id, body, opts)
return data
end
|
[
"def",
"create_discount",
"(",
"location_id",
",",
"body",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"create_discount_with_http_info",
"(",
"location_id",
",",
"body",
",",
"opts",
")",
"return",
"data",
"end"
] |
CreateDiscount
Creates a discount.
@param location_id The ID of the location to create an item for.
@param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@param [Hash] opts the optional parameters
@return [V1Discount]
|
[
"CreateDiscount",
"Creates",
"a",
"discount",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L274-L277
|
11,789
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.create_item
|
def create_item(location_id, body, opts = {})
data, _status_code, _headers = create_item_with_http_info(location_id, body, opts)
return data
end
|
ruby
|
def create_item(location_id, body, opts = {})
data, _status_code, _headers = create_item_with_http_info(location_id, body, opts)
return data
end
|
[
"def",
"create_item",
"(",
"location_id",
",",
"body",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"create_item_with_http_info",
"(",
"location_id",
",",
"body",
",",
"opts",
")",
"return",
"data",
"end"
] |
CreateItem
Creates an item and at least one variation for it. Item-related entities include fields you can use to associate them with entities in a non-Square system. When you create an item-related entity, you can optionally specify its `id`. This value must be unique among all IDs ever specified for the account, including those specified by other applications. You can never reuse an entity ID. If you do not specify an ID, Square generates one for the entity. Item variations have a `user_data` string that lets you associate arbitrary metadata with the variation. The string cannot exceed 255 characters.
@param location_id The ID of the location to create an item for.
@param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@param [Hash] opts the optional parameters
@return [V1Item]
|
[
"CreateItem",
"Creates",
"an",
"item",
"and",
"at",
"least",
"one",
"variation",
"for",
"it",
".",
"Item",
"-",
"related",
"entities",
"include",
"fields",
"you",
"can",
"use",
"to",
"associate",
"them",
"with",
"entities",
"in",
"a",
"non",
"-",
"Square",
"system",
".",
"When",
"you",
"create",
"an",
"item",
"-",
"related",
"entity",
"you",
"can",
"optionally",
"specify",
"its",
"id",
".",
"This",
"value",
"must",
"be",
"unique",
"among",
"all",
"IDs",
"ever",
"specified",
"for",
"the",
"account",
"including",
"those",
"specified",
"by",
"other",
"applications",
".",
"You",
"can",
"never",
"reuse",
"an",
"entity",
"ID",
".",
"If",
"you",
"do",
"not",
"specify",
"an",
"ID",
"Square",
"generates",
"one",
"for",
"the",
"entity",
".",
"Item",
"variations",
"have",
"a",
"user_data",
"string",
"that",
"lets",
"you",
"associate",
"arbitrary",
"metadata",
"with",
"the",
"variation",
".",
"The",
"string",
"cannot",
"exceed",
"255",
"characters",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L392-L395
|
11,790
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.create_modifier_list
|
def create_modifier_list(location_id, body, opts = {})
data, _status_code, _headers = create_modifier_list_with_http_info(location_id, body, opts)
return data
end
|
ruby
|
def create_modifier_list(location_id, body, opts = {})
data, _status_code, _headers = create_modifier_list_with_http_info(location_id, body, opts)
return data
end
|
[
"def",
"create_modifier_list",
"(",
"location_id",
",",
"body",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"create_modifier_list_with_http_info",
"(",
"location_id",
",",
"body",
",",
"opts",
")",
"return",
"data",
"end"
] |
CreateModifierList
Creates an item modifier list and at least one modifier option for it.
@param location_id The ID of the location to create a modifier list for.
@param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@param [Hash] opts the optional parameters
@return [V1ModifierList]
|
[
"CreateModifierList",
"Creates",
"an",
"item",
"modifier",
"list",
"and",
"at",
"least",
"one",
"modifier",
"option",
"for",
"it",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L451-L454
|
11,791
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.create_modifier_option
|
def create_modifier_option(location_id, modifier_list_id, body, opts = {})
data, _status_code, _headers = create_modifier_option_with_http_info(location_id, modifier_list_id, body, opts)
return data
end
|
ruby
|
def create_modifier_option(location_id, modifier_list_id, body, opts = {})
data, _status_code, _headers = create_modifier_option_with_http_info(location_id, modifier_list_id, body, opts)
return data
end
|
[
"def",
"create_modifier_option",
"(",
"location_id",
",",
"modifier_list_id",
",",
"body",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"create_modifier_option_with_http_info",
"(",
"location_id",
",",
"modifier_list_id",
",",
"body",
",",
"opts",
")",
"return",
"data",
"end"
] |
CreateModifierOption
Creates an item modifier option and adds it to a modifier list.
@param location_id The ID of the item's associated location.
@param modifier_list_id The ID of the modifier list to edit.
@param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@param [Hash] opts the optional parameters
@return [V1ModifierOption]
|
[
"CreateModifierOption",
"Creates",
"an",
"item",
"modifier",
"option",
"and",
"adds",
"it",
"to",
"a",
"modifier",
"list",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L511-L514
|
11,792
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.create_page
|
def create_page(location_id, body, opts = {})
data, _status_code, _headers = create_page_with_http_info(location_id, body, opts)
return data
end
|
ruby
|
def create_page(location_id, body, opts = {})
data, _status_code, _headers = create_page_with_http_info(location_id, body, opts)
return data
end
|
[
"def",
"create_page",
"(",
"location_id",
",",
"body",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"create_page_with_http_info",
"(",
"location_id",
",",
"body",
",",
"opts",
")",
"return",
"data",
"end"
] |
CreatePage
Creates a Favorites page in Square Register.
@param location_id The ID of the location to create an item for.
@param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@param [Hash] opts the optional parameters
@return [V1Page]
|
[
"CreatePage",
"Creates",
"a",
"Favorites",
"page",
"in",
"Square",
"Register",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L573-L576
|
11,793
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.create_variation
|
def create_variation(location_id, item_id, body, opts = {})
data, _status_code, _headers = create_variation_with_http_info(location_id, item_id, body, opts)
return data
end
|
ruby
|
def create_variation(location_id, item_id, body, opts = {})
data, _status_code, _headers = create_variation_with_http_info(location_id, item_id, body, opts)
return data
end
|
[
"def",
"create_variation",
"(",
"location_id",
",",
"item_id",
",",
"body",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"create_variation_with_http_info",
"(",
"location_id",
",",
"item_id",
",",
"body",
",",
"opts",
")",
"return",
"data",
"end"
] |
CreateVariation
Creates an item variation for an existing item.
@param location_id The ID of the item's associated location.
@param item_id The item's ID.
@param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
@param [Hash] opts the optional parameters
@return [V1Variation]
|
[
"CreateVariation",
"Creates",
"an",
"item",
"variation",
"for",
"an",
"existing",
"item",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L633-L636
|
11,794
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.list_categories
|
def list_categories(location_id, opts = {})
data, _status_code, _headers = list_categories_with_http_info(location_id, opts)
return data
end
|
ruby
|
def list_categories(location_id, opts = {})
data, _status_code, _headers = list_categories_with_http_info(location_id, opts)
return data
end
|
[
"def",
"list_categories",
"(",
"location_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"list_categories_with_http_info",
"(",
"location_id",
",",
"opts",
")",
"return",
"data",
"end"
] |
ListCategories
Lists all of a location's item categories.
@param location_id The ID of the location to list categories for.
@param [Hash] opts the optional parameters
@return [Array<V1Category>]
|
[
"ListCategories",
"Lists",
"all",
"of",
"a",
"location",
"s",
"item",
"categories",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L1239-L1242
|
11,795
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.list_discounts
|
def list_discounts(location_id, opts = {})
data, _status_code, _headers = list_discounts_with_http_info(location_id, opts)
return data
end
|
ruby
|
def list_discounts(location_id, opts = {})
data, _status_code, _headers = list_discounts_with_http_info(location_id, opts)
return data
end
|
[
"def",
"list_discounts",
"(",
"location_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"list_discounts_with_http_info",
"(",
"location_id",
",",
"opts",
")",
"return",
"data",
"end"
] |
ListDiscounts
Lists all of a location's discounts.
@param location_id The ID of the location to list categories for.
@param [Hash] opts the optional parameters
@return [Array<V1Discount>]
|
[
"ListDiscounts",
"Lists",
"all",
"of",
"a",
"location",
"s",
"discounts",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L1294-L1297
|
11,796
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.list_inventory
|
def list_inventory(location_id, opts = {})
data, _status_code, _headers = list_inventory_with_http_info(location_id, opts)
return data
end
|
ruby
|
def list_inventory(location_id, opts = {})
data, _status_code, _headers = list_inventory_with_http_info(location_id, opts)
return data
end
|
[
"def",
"list_inventory",
"(",
"location_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"list_inventory_with_http_info",
"(",
"location_id",
",",
"opts",
")",
"return",
"data",
"end"
] |
ListInventory
Provides inventory information for all of a merchant's inventory-enabled item variations.
@param location_id The ID of the item's associated location.
@param [Hash] opts the optional parameters
@option opts [Integer] :limit The maximum number of inventory entries to return in a single response. This value cannot exceed 1000.
@option opts [String] :batch_token A pagination cursor to retrieve the next set of results for your original query to the endpoint.
@return [Array<V1InventoryEntry>]
|
[
"ListInventory",
"Provides",
"inventory",
"information",
"for",
"all",
"of",
"a",
"merchant",
"s",
"inventory",
"-",
"enabled",
"item",
"variations",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L1406-L1409
|
11,797
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.list_items
|
def list_items(location_id, opts = {})
data, _status_code, _headers = list_items_with_http_info(location_id, opts)
return data
end
|
ruby
|
def list_items(location_id, opts = {})
data, _status_code, _headers = list_items_with_http_info(location_id, opts)
return data
end
|
[
"def",
"list_items",
"(",
"location_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"list_items_with_http_info",
"(",
"location_id",
",",
"opts",
")",
"return",
"data",
"end"
] |
ListItems
Provides summary information for all of a location's items.
@param location_id The ID of the location to list items for.
@param [Hash] opts the optional parameters
@option opts [String] :batch_token A pagination cursor to retrieve the next set of results for your original query to the endpoint.
@return [Array<V1Item>]
|
[
"ListItems",
"Provides",
"summary",
"information",
"for",
"all",
"of",
"a",
"location",
"s",
"items",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L1466-L1469
|
11,798
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.list_modifier_lists
|
def list_modifier_lists(location_id, opts = {})
data, _status_code, _headers = list_modifier_lists_with_http_info(location_id, opts)
return data
end
|
ruby
|
def list_modifier_lists(location_id, opts = {})
data, _status_code, _headers = list_modifier_lists_with_http_info(location_id, opts)
return data
end
|
[
"def",
"list_modifier_lists",
"(",
"location_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"list_modifier_lists_with_http_info",
"(",
"location_id",
",",
"opts",
")",
"return",
"data",
"end"
] |
ListModifierLists
Lists all of a location's modifier lists.
@param location_id The ID of the location to list modifier lists for.
@param [Hash] opts the optional parameters
@return [Array<V1ModifierList>]
|
[
"ListModifierLists",
"Lists",
"all",
"of",
"a",
"location",
"s",
"modifier",
"lists",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L1523-L1526
|
11,799
|
square/connect-ruby-sdk
|
lib/square_connect/api/v1_items_api.rb
|
SquareConnect.V1ItemsApi.list_pages
|
def list_pages(location_id, opts = {})
data, _status_code, _headers = list_pages_with_http_info(location_id, opts)
return data
end
|
ruby
|
def list_pages(location_id, opts = {})
data, _status_code, _headers = list_pages_with_http_info(location_id, opts)
return data
end
|
[
"def",
"list_pages",
"(",
"location_id",
",",
"opts",
"=",
"{",
"}",
")",
"data",
",",
"_status_code",
",",
"_headers",
"=",
"list_pages_with_http_info",
"(",
"location_id",
",",
"opts",
")",
"return",
"data",
"end"
] |
ListPages
Lists all of a location's Favorites pages in Square Register.
@param location_id The ID of the location to list Favorites pages for.
@param [Hash] opts the optional parameters
@return [Array<V1Page>]
|
[
"ListPages",
"Lists",
"all",
"of",
"a",
"location",
"s",
"Favorites",
"pages",
"in",
"Square",
"Register",
"."
] |
798eb9ded716f23b9f1518386f1c311a34bca8bf
|
https://github.com/square/connect-ruby-sdk/blob/798eb9ded716f23b9f1518386f1c311a34bca8bf/lib/square_connect/api/v1_items_api.rb#L1578-L1581
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.