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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
decidim/decidim | decidim-core/app/helpers/decidim/amendments_helper.rb | Decidim.AmendmentsHelper.allowed_to_promote? | def allowed_to_promote?(emendation)
return unless emendation.amendment.rejected? && emendation.created_by?(current_user)
return if promoted?(emendation)
true
end | ruby | def allowed_to_promote?(emendation)
return unless emendation.amendment.rejected? && emendation.created_by?(current_user)
return if promoted?(emendation)
true
end | [
"def",
"allowed_to_promote?",
"(",
"emendation",
")",
"return",
"unless",
"emendation",
".",
"amendment",
".",
"rejected?",
"&&",
"emendation",
".",
"created_by?",
"(",
"current_user",
")",
"return",
"if",
"promoted?",
"(",
"emendation",
")",
"true",
"end"
] | Checks if the user can promote the emendation | [
"Checks",
"if",
"the",
"user",
"can",
"promote",
"the",
"emendation"
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/amendments_helper.rb#L90-L95 | train |
decidim/decidim | decidim-core/app/helpers/decidim/amendments_helper.rb | Decidim.AmendmentsHelper.promoted? | def promoted?(emendation)
logs = Decidim::ActionLog.where(decidim_component_id: emendation.component)
.where(decidim_user_id: emendation.creator_author)
.where(action: "promote")
logs.select { |log| log.extra["promoted_from"] == emendation.id }.... | ruby | def promoted?(emendation)
logs = Decidim::ActionLog.where(decidim_component_id: emendation.component)
.where(decidim_user_id: emendation.creator_author)
.where(action: "promote")
logs.select { |log| log.extra["promoted_from"] == emendation.id }.... | [
"def",
"promoted?",
"(",
"emendation",
")",
"logs",
"=",
"Decidim",
"::",
"ActionLog",
".",
"where",
"(",
"decidim_component_id",
":",
"emendation",
".",
"component",
")",
".",
"where",
"(",
"decidim_user_id",
":",
"emendation",
".",
"creator_author",
")",
"."... | Checks if the unique ActionLog created in the promote command exists. | [
"Checks",
"if",
"the",
"unique",
"ActionLog",
"created",
"in",
"the",
"promote",
"command",
"exists",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/amendments_helper.rb#L98-L104 | train |
decidim/decidim | decidim-core/app/helpers/decidim/amendments_helper.rb | Decidim.AmendmentsHelper.user_group_select_field | def user_group_select_field(form, name)
form.select(name,
current_user.user_groups.verified.map { |g| [g.name, g.id] },
selected: form.object.user_group_id.presence,
include_blank: current_user.name,
label: t("new.amendment_author", scope: "d... | ruby | def user_group_select_field(form, name)
form.select(name,
current_user.user_groups.verified.map { |g| [g.name, g.id] },
selected: form.object.user_group_id.presence,
include_blank: current_user.name,
label: t("new.amendment_author", scope: "d... | [
"def",
"user_group_select_field",
"(",
"form",
",",
"name",
")",
"form",
".",
"select",
"(",
"name",
",",
"current_user",
".",
"user_groups",
".",
"verified",
".",
"map",
"{",
"|",
"g",
"|",
"[",
"g",
".",
"name",
",",
"g",
".",
"id",
"]",
"}",
","... | Renders a UserGroup select field in a form. | [
"Renders",
"a",
"UserGroup",
"select",
"field",
"in",
"a",
"form",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/amendments_helper.rb#L107-L113 | train |
decidim/decidim | decidim-core/app/helpers/decidim/amendments_helper.rb | Decidim.AmendmentsHelper.emendation_field_value | def emendation_field_value(form, original, key)
return params[:amendment][:emendation_params][key] if params[:amendment].present?
present(form.object.send(original)).send(key)
end | ruby | def emendation_field_value(form, original, key)
return params[:amendment][:emendation_params][key] if params[:amendment].present?
present(form.object.send(original)).send(key)
end | [
"def",
"emendation_field_value",
"(",
"form",
",",
"original",
",",
"key",
")",
"return",
"params",
"[",
":amendment",
"]",
"[",
":emendation_params",
"]",
"[",
"key",
"]",
"if",
"params",
"[",
":amendment",
"]",
".",
"present?",
"present",
"(",
"form",
".... | Return the edited field value or presents the original attribute value in a form. | [
"Return",
"the",
"edited",
"field",
"value",
"or",
"presents",
"the",
"original",
"attribute",
"value",
"in",
"a",
"form",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/amendments_helper.rb#L116-L120 | train |
decidim/decidim | decidim-core/app/helpers/decidim/map_helper.rb | Decidim.MapHelper.static_map_link | def static_map_link(resource, options = {})
return unless resource.geocoded?
zoom = options[:zoom] || 17
latitude = resource.latitude
longitude = resource.longitude
map_url = "https://www.openstreetmap.org/?mlat=#{latitude}&mlon=#{longitude}#map=#{zoom}/#{latitude}/#{longitude}"
l... | ruby | def static_map_link(resource, options = {})
return unless resource.geocoded?
zoom = options[:zoom] || 17
latitude = resource.latitude
longitude = resource.longitude
map_url = "https://www.openstreetmap.org/?mlat=#{latitude}&mlon=#{longitude}#map=#{zoom}/#{latitude}/#{longitude}"
l... | [
"def",
"static_map_link",
"(",
"resource",
",",
"options",
"=",
"{",
"}",
")",
"return",
"unless",
"resource",
".",
"geocoded?",
"zoom",
"=",
"options",
"[",
":zoom",
"]",
"||",
"17",
"latitude",
"=",
"resource",
".",
"latitude",
"longitude",
"=",
"resourc... | Renders a link to openstreetmaps with the resource latitude and longitude.
The link's content is a static map image.
resource - A geolocalizable resource
options - An optional hash of options (default: { zoom: 17 })
* zoom: A number to represent the zoom value of the map | [
"Renders",
"a",
"link",
"to",
"openstreetmaps",
"with",
"the",
"resource",
"latitude",
"and",
"longitude",
".",
"The",
"link",
"s",
"content",
"is",
"a",
"static",
"map",
"image",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/map_helper.rb#L12-L24 | train |
decidim/decidim | decidim-core/app/helpers/decidim/attachments_helper.rb | Decidim.AttachmentsHelper.attachment_title | def attachment_title(attachment)
attachment.title.is_a?(Hash) ? translated_attribute(attachment.title) : attachment.title
end | ruby | def attachment_title(attachment)
attachment.title.is_a?(Hash) ? translated_attribute(attachment.title) : attachment.title
end | [
"def",
"attachment_title",
"(",
"attachment",
")",
"attachment",
".",
"title",
".",
"is_a?",
"(",
"Hash",
")",
"?",
"translated_attribute",
"(",
"attachment",
".",
"title",
")",
":",
"attachment",
".",
"title",
"end"
] | Renders the attachment's title.
Checks if the attachment's title is translated or not and use
the correct render method.
attachment - An Attachment object
Returns String. | [
"Renders",
"the",
"attachment",
"s",
"title",
".",
"Checks",
"if",
"the",
"attachment",
"s",
"title",
"is",
"translated",
"or",
"not",
"and",
"use",
"the",
"correct",
"render",
"method",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/attachments_helper.rb#L23-L25 | train |
decidim/decidim | decidim-core/app/helpers/decidim/replace_buttons_helper.rb | Decidim.ReplaceButtonsHelper.submit_tag | def submit_tag(text = "Save changes", options = {})
options = options.stringify_keys
content_tag :button, text, { "type" => "submit", "name" => "commit" }.update(options)
end | ruby | def submit_tag(text = "Save changes", options = {})
options = options.stringify_keys
content_tag :button, text, { "type" => "submit", "name" => "commit" }.update(options)
end | [
"def",
"submit_tag",
"(",
"text",
"=",
"\"Save changes\"",
",",
"options",
"=",
"{",
"}",
")",
"options",
"=",
"options",
".",
"stringify_keys",
"content_tag",
":button",
",",
"text",
",",
"{",
"\"type\"",
"=>",
"\"submit\"",
",",
"\"name\"",
"=>",
"\"commit... | Overrides the submit tags to always be buttons instead of inputs.
Buttons are much more stylable and less prone to bugs.
value - The text of the button
options - Options to provide to the actual tag.
Returns a SafeString with the tag. | [
"Overrides",
"the",
"submit",
"tags",
"to",
"always",
"be",
"buttons",
"instead",
"of",
"inputs",
".",
"Buttons",
"are",
"much",
"more",
"stylable",
"and",
"less",
"prone",
"to",
"bugs",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/replace_buttons_helper.rb#L12-L16 | train |
decidim/decidim | decidim-core/app/services/decidim/traceability.rb | Decidim.Traceability.create | def create(klass, author, params, extra_log_info = {})
perform_action!(:create, klass, author, extra_log_info) do
klass.create(params)
end
end | ruby | def create(klass, author, params, extra_log_info = {})
perform_action!(:create, klass, author, extra_log_info) do
klass.create(params)
end
end | [
"def",
"create",
"(",
"klass",
",",
"author",
",",
"params",
",",
"extra_log_info",
"=",
"{",
"}",
")",
"perform_action!",
"(",
":create",
",",
"klass",
",",
"author",
",",
"extra_log_info",
")",
"do",
"klass",
".",
"create",
"(",
"params",
")",
"end",
... | Calls the `create` method to the given class and sets the author of the version.
klass - An ActiveRecord class that implements `Decidim::Traceable`
author - An object that implements `to_gid` or a String
params - a Hash with the attributes of the new resource
extra_log_info - a Hash with extra info that will be sa... | [
"Calls",
"the",
"create",
"method",
"to",
"the",
"given",
"class",
"and",
"sets",
"the",
"author",
"of",
"the",
"version",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/services/decidim/traceability.rb#L31-L35 | train |
decidim/decidim | decidim-core/app/services/decidim/traceability.rb | Decidim.Traceability.create! | def create!(klass, author, params, extra_log_info = {})
perform_action!(:create, klass, author, extra_log_info) do
klass.create!(params)
end
end | ruby | def create!(klass, author, params, extra_log_info = {})
perform_action!(:create, klass, author, extra_log_info) do
klass.create!(params)
end
end | [
"def",
"create!",
"(",
"klass",
",",
"author",
",",
"params",
",",
"extra_log_info",
"=",
"{",
"}",
")",
"perform_action!",
"(",
":create",
",",
"klass",
",",
"author",
",",
"extra_log_info",
")",
"do",
"klass",
".",
"create!",
"(",
"params",
")",
"end",... | Calls the `create!` method to the given class and sets the author of the version.
klass - An ActiveRecord class that implements `Decidim::Traceable`
author - An object that implements `to_gid` or a String
params - a Hash with the attributes of the new resource
extra_log_info - a Hash with extra info that will be s... | [
"Calls",
"the",
"create!",
"method",
"to",
"the",
"given",
"class",
"and",
"sets",
"the",
"author",
"of",
"the",
"version",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/services/decidim/traceability.rb#L45-L49 | train |
decidim/decidim | decidim-core/app/services/decidim/traceability.rb | Decidim.Traceability.perform_action! | def perform_action!(action, resource, author, extra_log_info = {})
PaperTrail.request(whodunnit: gid(author)) do
Decidim::ApplicationRecord.transaction do
result = block_given? ? yield : nil
loggable_resource = resource.is_a?(Class) ? result : resource
log(action, author, log... | ruby | def perform_action!(action, resource, author, extra_log_info = {})
PaperTrail.request(whodunnit: gid(author)) do
Decidim::ApplicationRecord.transaction do
result = block_given? ? yield : nil
loggable_resource = resource.is_a?(Class) ? result : resource
log(action, author, log... | [
"def",
"perform_action!",
"(",
"action",
",",
"resource",
",",
"author",
",",
"extra_log_info",
"=",
"{",
"}",
")",
"PaperTrail",
".",
"request",
"(",
"whodunnit",
":",
"gid",
"(",
"author",
")",
")",
"do",
"Decidim",
"::",
"ApplicationRecord",
".",
"trans... | Performs the given block and sets the author of the action.
It also logs the action with the given `action` parameter.
The action and the logging are run inside a transaction.
action - a String or Symbol representing the action performed
resource - An ActiveRecord instance that implements `Decidim::Traceable`
aut... | [
"Performs",
"the",
"given",
"block",
"and",
"sets",
"the",
"author",
"of",
"the",
"action",
".",
"It",
"also",
"logs",
"the",
"action",
"with",
"the",
"given",
"action",
"parameter",
".",
"The",
"action",
"and",
"the",
"logging",
"are",
"run",
"inside",
... | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/services/decidim/traceability.rb#L61-L70 | train |
decidim/decidim | decidim-core/app/services/decidim/traceability.rb | Decidim.Traceability.update! | def update!(resource, author, params, extra_log_info = {})
perform_action!(:update, resource, author, extra_log_info) do
resource.update!(params)
resource
end
end | ruby | def update!(resource, author, params, extra_log_info = {})
perform_action!(:update, resource, author, extra_log_info) do
resource.update!(params)
resource
end
end | [
"def",
"update!",
"(",
"resource",
",",
"author",
",",
"params",
",",
"extra_log_info",
"=",
"{",
"}",
")",
"perform_action!",
"(",
":update",
",",
"resource",
",",
"author",
",",
"extra_log_info",
")",
"do",
"resource",
".",
"update!",
"(",
"params",
")",... | Updates the `resource` with `update!` and sets the author of the version.
resource - An ActiveRecord instance that implements `Decidim::Traceable`
author - An object that implements `to_gid` or a String
params - a Hash with the attributes to update to the resource
extra_log_info - a Hash with extra info that will ... | [
"Updates",
"the",
"resource",
"with",
"update!",
"and",
"sets",
"the",
"author",
"of",
"the",
"version",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/services/decidim/traceability.rb#L80-L85 | train |
decidim/decidim | decidim-core/app/helpers/decidim/application_helper.rb | Decidim.ApplicationHelper.html_truncate | def html_truncate(text, options = {})
options[:max_length] = options.delete(:length) || options[:max_length]
options[:tail] = options.delete(:separator) || options[:tail] || "..."
options[:count_tags] ||= false
options[:count_tail] ||= false
options[:tail_before_final_tag] ||= true
... | ruby | def html_truncate(text, options = {})
options[:max_length] = options.delete(:length) || options[:max_length]
options[:tail] = options.delete(:separator) || options[:tail] || "..."
options[:count_tags] ||= false
options[:count_tail] ||= false
options[:tail_before_final_tag] ||= true
... | [
"def",
"html_truncate",
"(",
"text",
",",
"options",
"=",
"{",
"}",
")",
"options",
"[",
":max_length",
"]",
"=",
"options",
".",
"delete",
"(",
":length",
")",
"||",
"options",
"[",
":max_length",
"]",
"options",
"[",
":tail",
"]",
"=",
"options",
"."... | Truncates a given text respecting its HTML tags.
text - The String text to be truncated.
options - A Hash with the options to truncate the text (default: {}):
:length - An Integer number with the max length of the text.
:separator - A String to append to the text when it's being
t... | [
"Truncates",
"a",
"given",
"text",
"respecting",
"its",
"HTML",
"tags",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/application_helper.rb#L20-L28 | train |
decidim/decidim | decidim-core/app/helpers/decidim/application_helper.rb | Decidim.ApplicationHelper.edit_link | def edit_link(link, action, subject, extra_context = {})
return unless current_user
return unless admin_allowed_to?(action, subject, extra_context)
return if content_for?(:edit_link)
content_for(:edit_link, link)
end | ruby | def edit_link(link, action, subject, extra_context = {})
return unless current_user
return unless admin_allowed_to?(action, subject, extra_context)
return if content_for?(:edit_link)
content_for(:edit_link, link)
end | [
"def",
"edit_link",
"(",
"link",
",",
"action",
",",
"subject",
",",
"extra_context",
"=",
"{",
"}",
")",
"return",
"unless",
"current_user",
"return",
"unless",
"admin_allowed_to?",
"(",
"action",
",",
"subject",
",",
"extra_context",
")",
"return",
"if",
"... | Generates a link to be added to the global Edit link so admins
can easily manage data without having to look for it at the admin
panel when they're at a public page.
link - The String with the URL.
action - The Symbol action to check the permissions for.
subject - The Symbol subject to perfo... | [
"Generates",
"a",
"link",
"to",
"be",
"added",
"to",
"the",
"global",
"Edit",
"link",
"so",
"admins",
"can",
"easily",
"manage",
"data",
"without",
"having",
"to",
"look",
"for",
"it",
"at",
"the",
"admin",
"panel",
"when",
"they",
"re",
"at",
"a",
"pu... | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/application_helper.rb#L49-L55 | train |
decidim/decidim | decidim-core/lib/decidim/participatory_space_manifest.rb | Decidim.ParticipatorySpaceManifest.context | def context(name = :public, &block)
name = name.to_sym
@contexts ||= {}
if block
context = ParticipatorySpaceContextManifest.new
context.instance_eval(&block)
@contexts[name] = context
end
@contexts.fetch(name)
end | ruby | def context(name = :public, &block)
name = name.to_sym
@contexts ||= {}
if block
context = ParticipatorySpaceContextManifest.new
context.instance_eval(&block)
@contexts[name] = context
end
@contexts.fetch(name)
end | [
"def",
"context",
"(",
"name",
"=",
":public",
",",
"&",
"block",
")",
"name",
"=",
"name",
".",
"to_sym",
"@contexts",
"||=",
"{",
"}",
"if",
"block",
"context",
"=",
"ParticipatorySpaceContextManifest",
".",
"new",
"context",
".",
"instance_eval",
"(",
"... | A context used to set the layout and behavior of a participatory space. Full documentation can
be found looking at the `ParticipatorySpaceContextManifest` class.
Example:
context(:public) do |context|
context.layout "layouts/decidim/some_layout"
end
context(:public).layout
# => "layouts/... | [
"A",
"context",
"used",
"to",
"set",
"the",
"layout",
"and",
"behavior",
"of",
"a",
"participatory",
"space",
".",
"Full",
"documentation",
"can",
"be",
"found",
"looking",
"at",
"the",
"ParticipatorySpaceContextManifest",
"class",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/lib/decidim/participatory_space_manifest.rb#L62-L73 | train |
decidim/decidim | decidim-core/lib/decidim/friendly_dates.rb | Decidim.FriendlyDates.friendly_created_at | def friendly_created_at
current_datetime = Time.current
if created_at > current_datetime.beginning_of_day
I18n.l(created_at, format: :time_of_day)
elsif created_at > current_datetime.beginning_of_week
I18n.l(created_at, format: :day_of_week)
elsif created_at > current_datetime.b... | ruby | def friendly_created_at
current_datetime = Time.current
if created_at > current_datetime.beginning_of_day
I18n.l(created_at, format: :time_of_day)
elsif created_at > current_datetime.beginning_of_week
I18n.l(created_at, format: :day_of_week)
elsif created_at > current_datetime.b... | [
"def",
"friendly_created_at",
"current_datetime",
"=",
"Time",
".",
"current",
"if",
"created_at",
">",
"current_datetime",
".",
"beginning_of_day",
"I18n",
".",
"l",
"(",
"created_at",
",",
"format",
":",
":time_of_day",
")",
"elsif",
"created_at",
">",
"current_... | Returns the creation date in a friendly relative format. | [
"Returns",
"the",
"creation",
"date",
"in",
"a",
"friendly",
"relative",
"format",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/lib/decidim/friendly_dates.rb#L12-L24 | train |
decidim/decidim | decidim-core/app/queries/decidim/metric_manage.rb | Decidim.MetricManage.retrieve_participatory_spaces | def retrieve_participatory_spaces
Decidim.participatory_space_manifests.map do |space_manifest|
next unless space_manifest.name == :participatory_processes # Temporal limitation
space_manifest.participatory_spaces.call(@organization)
end.flatten.compact
end | ruby | def retrieve_participatory_spaces
Decidim.participatory_space_manifests.map do |space_manifest|
next unless space_manifest.name == :participatory_processes # Temporal limitation
space_manifest.participatory_spaces.call(@organization)
end.flatten.compact
end | [
"def",
"retrieve_participatory_spaces",
"Decidim",
".",
"participatory_space_manifests",
".",
"map",
"do",
"|",
"space_manifest",
"|",
"next",
"unless",
"space_manifest",
".",
"name",
"==",
":participatory_processes",
"# Temporal limitation",
"space_manifest",
".",
"partici... | Search for all Participatory Space manifests and then all records available
Limited to ParticipatoryProcesses only | [
"Search",
"for",
"all",
"Participatory",
"Space",
"manifests",
"and",
"then",
"all",
"records",
"available",
"Limited",
"to",
"ParticipatoryProcesses",
"only"
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/queries/decidim/metric_manage.rb#L61-L66 | train |
decidim/decidim | decidim-core/app/helpers/decidim/localized_locales_helper.rb | Decidim.LocalizedLocalesHelper.localized_locales | def localized_locales(collection = Decidim.available_locales)
klass = Class.new do
def initialize(locale)
@locale = locale
end
def id
@locale.to_s
end
def name
I18n.with_locale(@locale) { I18n.t("name", scope: "locale") }
end
en... | ruby | def localized_locales(collection = Decidim.available_locales)
klass = Class.new do
def initialize(locale)
@locale = locale
end
def id
@locale.to_s
end
def name
I18n.with_locale(@locale) { I18n.t("name", scope: "locale") }
end
en... | [
"def",
"localized_locales",
"(",
"collection",
"=",
"Decidim",
".",
"available_locales",
")",
"klass",
"=",
"Class",
".",
"new",
"do",
"def",
"initialize",
"(",
"locale",
")",
"@locale",
"=",
"locale",
"end",
"def",
"id",
"@locale",
".",
"to_s",
"end",
"de... | Converts a given array of strings to an array of Objects representing
locales.
collection - an Array of Strings. By default it uses all the available
locales in Decidim, but you can passa nother collection of locales (for
example, the available locales for an organization) | [
"Converts",
"a",
"given",
"array",
"of",
"strings",
"to",
"an",
"array",
"of",
"Objects",
"representing",
"locales",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/localized_locales_helper.rb#L26-L42 | train |
decidim/decidim | decidim-core/app/middleware/decidim/current_organization.rb | Decidim.CurrentOrganization.call | def call(env)
organization = detect_current_organization(env)
if organization
env["decidim.current_organization"] = organization
@app.call(env)
else
organization = find_secondary_host_org(env)
return @app.call(env) unless organization
location = new_location_fo... | ruby | def call(env)
organization = detect_current_organization(env)
if organization
env["decidim.current_organization"] = organization
@app.call(env)
else
organization = find_secondary_host_org(env)
return @app.call(env) unless organization
location = new_location_fo... | [
"def",
"call",
"(",
"env",
")",
"organization",
"=",
"detect_current_organization",
"(",
"env",
")",
"if",
"organization",
"env",
"[",
"\"decidim.current_organization\"",
"]",
"=",
"organization",
"@app",
".",
"call",
"(",
"env",
")",
"else",
"organization",
"="... | Initializes the Rack Middleware.
app - The Rack application
Main entry point for a Rack Middleware.
env - A Hash. | [
"Initializes",
"the",
"Rack",
"Middleware",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/middleware/decidim/current_organization.rb#L17-L30 | train |
decidim/decidim | decidim-core/app/commands/decidim/destroy_account.rb | Decidim.DestroyAccount.call | def call
return broadcast(:invalid) unless @form.valid?
Decidim::User.transaction do
destroy_user_account!
destroy_user_identities
destroy_user_group_memberships
destroy_follows
end
broadcast(:ok)
end | ruby | def call
return broadcast(:invalid) unless @form.valid?
Decidim::User.transaction do
destroy_user_account!
destroy_user_identities
destroy_user_group_memberships
destroy_follows
end
broadcast(:ok)
end | [
"def",
"call",
"return",
"broadcast",
"(",
":invalid",
")",
"unless",
"@form",
".",
"valid?",
"Decidim",
"::",
"User",
".",
"transaction",
"do",
"destroy_user_account!",
"destroy_user_identities",
"destroy_user_group_memberships",
"destroy_follows",
"end",
"broadcast",
... | Destroy a user's account.
user - The user to be updated.
form - The form with the data. | [
"Destroy",
"a",
"user",
"s",
"account",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/commands/decidim/destroy_account.rb#L15-L26 | train |
decidim/decidim | decidim-core/app/services/decidim/action_authorizer.rb | Decidim.ActionAuthorizer.authorize | def authorize
raise AuthorizationError, "Missing data" unless component && action
AuthorizationStatusCollection.new(authorization_handlers, user, component, resource)
end | ruby | def authorize
raise AuthorizationError, "Missing data" unless component && action
AuthorizationStatusCollection.new(authorization_handlers, user, component, resource)
end | [
"def",
"authorize",
"raise",
"AuthorizationError",
",",
"\"Missing data\"",
"unless",
"component",
"&&",
"action",
"AuthorizationStatusCollection",
".",
"new",
"(",
"authorization_handlers",
",",
"user",
",",
"component",
",",
"resource",
")",
"end"
] | Initializes the ActionAuthorizer.
user - The user to authorize against.
action - The action to authenticate.
component - The component to authenticate against.
resource - The resource to authenticate against. Can be nil.
Authorize user to perform an action in the context of a component.
Returns:
:... | [
"Initializes",
"the",
"ActionAuthorizer",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/services/decidim/action_authorizer.rb#L29-L33 | train |
decidim/decidim | decidim-core/app/commands/decidim/update_account.rb | Decidim.UpdateAccount.call | def call
return broadcast(:invalid) unless @form.valid?
update_personal_data
update_avatar
update_password
if @user.valid?
@user.save!
notify_followers
broadcast(:ok, @user.unconfirmed_email.present?)
else
@form.errors.add :avatar, @user.errors[:avat... | ruby | def call
return broadcast(:invalid) unless @form.valid?
update_personal_data
update_avatar
update_password
if @user.valid?
@user.save!
notify_followers
broadcast(:ok, @user.unconfirmed_email.present?)
else
@form.errors.add :avatar, @user.errors[:avat... | [
"def",
"call",
"return",
"broadcast",
"(",
":invalid",
")",
"unless",
"@form",
".",
"valid?",
"update_personal_data",
"update_avatar",
"update_password",
"if",
"@user",
".",
"valid?",
"@user",
".",
"save!",
"notify_followers",
"broadcast",
"(",
":ok",
",",
"@user"... | Updates a user's account.
user - The user to be updated.
form - The form with the data. | [
"Updates",
"a",
"user",
"s",
"account",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/commands/decidim/update_account.rb#L15-L30 | train |
decidim/decidim | decidim-core/app/helpers/decidim/resource_helper.rb | Decidim.ResourceHelper.linked_resources_for | def linked_resources_for(resource, type, link_name)
linked_resources = resource.linked_resources(type, link_name).group_by { |linked_resource| linked_resource.class.name }
safe_join(linked_resources.map do |klass, resources|
resource_manifest = klass.constantize.resource_manifest
content_ta... | ruby | def linked_resources_for(resource, type, link_name)
linked_resources = resource.linked_resources(type, link_name).group_by { |linked_resource| linked_resource.class.name }
safe_join(linked_resources.map do |klass, resources|
resource_manifest = klass.constantize.resource_manifest
content_ta... | [
"def",
"linked_resources_for",
"(",
"resource",
",",
"type",
",",
"link_name",
")",
"linked_resources",
"=",
"resource",
".",
"linked_resources",
"(",
"type",
",",
"link_name",
")",
".",
"group_by",
"{",
"|",
"linked_resource",
"|",
"linked_resource",
".",
"clas... | Renders a collection of linked resources for a resource.
resource - The resource to get the links from.
type - The String type fo the resources we want to render.
link_name - The String name of the link between the resources.
Example to render the proposals in a meeting view:
linked_resources_for(:meetin... | [
"Renders",
"a",
"collection",
"of",
"linked",
"resources",
"for",
"a",
"resource",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/resource_helper.rb#L17-L28 | train |
decidim/decidim | decidim-core/app/helpers/decidim/resource_helper.rb | Decidim.ResourceHelper.resource_title | def resource_title(resource)
title = resource.try(:title) || resource.try(:name) || resource.try(:subject) || "#{resource.model_name.human} ##{resource.id}"
title = translated_attribute(title) if title.is_a?(Hash)
title
end | ruby | def resource_title(resource)
title = resource.try(:title) || resource.try(:name) || resource.try(:subject) || "#{resource.model_name.human} ##{resource.id}"
title = translated_attribute(title) if title.is_a?(Hash)
title
end | [
"def",
"resource_title",
"(",
"resource",
")",
"title",
"=",
"resource",
".",
"try",
"(",
":title",
")",
"||",
"resource",
".",
"try",
"(",
":name",
")",
"||",
"resource",
".",
"try",
"(",
":subject",
")",
"||",
"\"#{resource.model_name.human} ##{resource.id}\... | Returns a descriptive title for the resource | [
"Returns",
"a",
"descriptive",
"title",
"for",
"the",
"resource"
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/resource_helper.rb#L74-L78 | train |
decidim/decidim | decidim-core/app/helpers/decidim/paginate_helper.rb | Decidim.PaginateHelper.decidim_paginate | def decidim_paginate(collection, paginate_params = {})
# Kaminari uses url_for to generate the url, but this doesn't play nice with our engine system
# and unless we remove these params they are added again as query string :(
default_params = {
participatory_process_id: nil,
component_... | ruby | def decidim_paginate(collection, paginate_params = {})
# Kaminari uses url_for to generate the url, but this doesn't play nice with our engine system
# and unless we remove these params they are added again as query string :(
default_params = {
participatory_process_id: nil,
component_... | [
"def",
"decidim_paginate",
"(",
"collection",
",",
"paginate_params",
"=",
"{",
"}",
")",
"# Kaminari uses url_for to generate the url, but this doesn't play nice with our engine system",
"# and unless we remove these params they are added again as query string :(",
"default_params",
"=",
... | Displays pagination links for the given collection, setting the correct
theme. This mostly acts as a proxy for the underlying pagination engine.
collection - a collection of elements that need to be paginated
paginate_params - a Hash with options to delegate to the pagination helper. | [
"Displays",
"pagination",
"links",
"for",
"the",
"given",
"collection",
"setting",
"the",
"correct",
"theme",
".",
"This",
"mostly",
"acts",
"as",
"a",
"proxy",
"for",
"the",
"underlying",
"pagination",
"engine",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/paginate_helper.rb#L11-L20 | train |
decidim/decidim | decidim-core/app/models/decidim/action_log.rb | Decidim.ActionLog.participatory_space_lazy | def participatory_space_lazy(cache: true)
return if participatory_space_id.blank? || participatory_space_type.blank?
return resouce_lazy if participatory_space_id == resource_id && participatory_space_type == resource_type
self.class.lazy_relation(participatory_space_id, participatory_space_type, cac... | ruby | def participatory_space_lazy(cache: true)
return if participatory_space_id.blank? || participatory_space_type.blank?
return resouce_lazy if participatory_space_id == resource_id && participatory_space_type == resource_type
self.class.lazy_relation(participatory_space_id, participatory_space_type, cac... | [
"def",
"participatory_space_lazy",
"(",
"cache",
":",
"true",
")",
"return",
"if",
"participatory_space_id",
".",
"blank?",
"||",
"participatory_space_type",
".",
"blank?",
"return",
"resouce_lazy",
"if",
"participatory_space_id",
"==",
"resource_id",
"&&",
"participato... | Lazy loads the `participatory_space` association through BatchLoader, can be used
as a regular object. | [
"Lazy",
"loads",
"the",
"participatory_space",
"association",
"through",
"BatchLoader",
"can",
"be",
"used",
"as",
"a",
"regular",
"object",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/models/decidim/action_log.rb#L79-L84 | train |
decidim/decidim | decidim-core/app/services/decidim/resource_search.rb | Decidim.ResourceSearch.search_scope_id | def search_scope_id
clean_scope_ids = if scope_id.is_a?(Hash)
scope_id.values
else
[scope_id].flatten
end
conditions = []
conditions << "decidim_scope_id IS NULL" if clean_scope_ids.delete("global")
... | ruby | def search_scope_id
clean_scope_ids = if scope_id.is_a?(Hash)
scope_id.values
else
[scope_id].flatten
end
conditions = []
conditions << "decidim_scope_id IS NULL" if clean_scope_ids.delete("global")
... | [
"def",
"search_scope_id",
"clean_scope_ids",
"=",
"if",
"scope_id",
".",
"is_a?",
"(",
"Hash",
")",
"scope_id",
".",
"values",
"else",
"[",
"scope_id",
"]",
".",
"flatten",
"end",
"conditions",
"=",
"[",
"]",
"conditions",
"<<",
"\"decidim_scope_id IS NULL\"",
... | Handles the scope_id filter. When we want to show only those that do not
have a scope_id set, we cannot pass an empty String or nil because Searchlight
will automatically filter out these params, so the method will not be used.
Instead, we need to pass a fake ID and then convert it inside. In this case,
in order to... | [
"Handles",
"the",
"scope_id",
"filter",
".",
"When",
"we",
"want",
"to",
"show",
"only",
"those",
"that",
"do",
"not",
"have",
"a",
"scope_id",
"set",
"we",
"cannot",
"pass",
"an",
"empty",
"String",
"or",
"nil",
"because",
"Searchlight",
"will",
"automati... | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/services/decidim/resource_search.rb#L40-L52 | train |
decidim/decidim | decidim-core/app/helpers/decidim/newsletters_helper.rb | Decidim.NewslettersHelper.custom_url_for_mail_root | def custom_url_for_mail_root(organization, newsletter_id = nil)
if newsletter_id.present?
decidim.root_url(host: organization.host) + utm_codes(organization.host, newsletter_id.to_s)
else
decidim.root_url(host: organization.host)
end
end | ruby | def custom_url_for_mail_root(organization, newsletter_id = nil)
if newsletter_id.present?
decidim.root_url(host: organization.host) + utm_codes(organization.host, newsletter_id.to_s)
else
decidim.root_url(host: organization.host)
end
end | [
"def",
"custom_url_for_mail_root",
"(",
"organization",
",",
"newsletter_id",
"=",
"nil",
")",
"if",
"newsletter_id",
".",
"present?",
"decidim",
".",
"root_url",
"(",
"host",
":",
"organization",
".",
"host",
")",
"+",
"utm_codes",
"(",
"organization",
".",
"... | this method is used to generate the root link on mail with the utm_codes
If the newsletter_id is nil, it returns the root_url | [
"this",
"method",
"is",
"used",
"to",
"generate",
"the",
"root",
"link",
"on",
"mail",
"with",
"the",
"utm_codes",
"If",
"the",
"newsletter_id",
"is",
"nil",
"it",
"returns",
"the",
"root_url"
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/newsletters_helper.rb#L35-L41 | train |
decidim/decidim | decidim-core/app/helpers/decidim/layout_helper.rb | Decidim.LayoutHelper.icon | def icon(name, options = {})
html_properties = {}
html_properties["width"] = options[:width]
html_properties["height"] = options[:height]
html_properties["aria-label"] = options[:aria_label]
html_properties["role"] = options[:role]
html_properties["aria-hidden"] = options[:aria_hidd... | ruby | def icon(name, options = {})
html_properties = {}
html_properties["width"] = options[:width]
html_properties["height"] = options[:height]
html_properties["aria-label"] = options[:aria_label]
html_properties["role"] = options[:role]
html_properties["aria-hidden"] = options[:aria_hidd... | [
"def",
"icon",
"(",
"name",
",",
"options",
"=",
"{",
"}",
")",
"html_properties",
"=",
"{",
"}",
"html_properties",
"[",
"\"width\"",
"]",
"=",
"options",
"[",
":width",
"]",
"html_properties",
"[",
"\"height\"",
"]",
"=",
"options",
"[",
":height",
"]"... | Outputs an SVG-based icon.
name - The String with the icon name.
options - The Hash options used to customize the icon (default {}):
:width - The Number of width in pixels (optional).
:height - The Number of height in pixels (optional).
:aria_label - The String to set as ar... | [
"Outputs",
"an",
"SVG",
"-",
"based",
"icon",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/layout_helper.rb#L30-L44 | train |
decidim/decidim | decidim-core/app/helpers/decidim/layout_helper.rb | Decidim.LayoutHelper.external_icon | def external_icon(path, options = {})
classes = _icon_classes(options) + ["external-icon"]
if path.split(".").last == "svg"
asset = Rails.application.assets_manifest.find_sources(path).first
asset.gsub("<svg ", "<svg class=\"#{classes.join(" ")}\" ").html_safe
else
image_tag(p... | ruby | def external_icon(path, options = {})
classes = _icon_classes(options) + ["external-icon"]
if path.split(".").last == "svg"
asset = Rails.application.assets_manifest.find_sources(path).first
asset.gsub("<svg ", "<svg class=\"#{classes.join(" ")}\" ").html_safe
else
image_tag(p... | [
"def",
"external_icon",
"(",
"path",
",",
"options",
"=",
"{",
"}",
")",
"classes",
"=",
"_icon_classes",
"(",
"options",
")",
"+",
"[",
"\"external-icon\"",
"]",
"if",
"path",
".",
"split",
"(",
"\".\"",
")",
".",
"last",
"==",
"\"svg\"",
"asset",
"="... | Outputs a SVG icon from an external file. It apparently renders an image
tag, but then a JS script kicks in and replaces it with an inlined SVG
version.
path - The asset's path
Returns an <img /> tag with the SVG icon. | [
"Outputs",
"a",
"SVG",
"icon",
"from",
"an",
"external",
"file",
".",
"It",
"apparently",
"renders",
"an",
"image",
"tag",
"but",
"then",
"a",
"JS",
"script",
"kicks",
"in",
"and",
"replaces",
"it",
"with",
"an",
"inlined",
"SVG",
"version",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/layout_helper.rb#L53-L62 | train |
decidim/decidim | decidim-core/app/services/decidim/continuity_badge_tracker.rb | Decidim.ContinuityBadgeTracker.track! | def track!(date)
@subject.with_lock do
last_session_at = status.try(:last_session_at) || date
current_streak = status.try(:current_streak) || 1
streak = if last_session_at == date
current_streak
elsif last_session_at == date - 1.day
c... | ruby | def track!(date)
@subject.with_lock do
last_session_at = status.try(:last_session_at) || date
current_streak = status.try(:current_streak) || 1
streak = if last_session_at == date
current_streak
elsif last_session_at == date - 1.day
c... | [
"def",
"track!",
"(",
"date",
")",
"@subject",
".",
"with_lock",
"do",
"last_session_at",
"=",
"status",
".",
"try",
"(",
":last_session_at",
")",
"||",
"date",
"current_streak",
"=",
"status",
".",
"try",
"(",
":current_streak",
")",
"||",
"1",
"streak",
... | Initializes the class with a polymorphic subject
subject - A in instance of a subclass of ActiveRecord::Base to be tracked
Public: Tracks the past activity of a user to update the continuity badge's
score. It will set it to the amount of consecutive days a user has logged into
the system.
date - The date of the... | [
"Initializes",
"the",
"class",
"with",
"a",
"polymorphic",
"subject"
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/services/decidim/continuity_badge_tracker.rb#L22-L38 | train |
decidim/decidim | decidim-core/app/mailers/decidim/decidim_devise_mailer.rb | Decidim.DecidimDeviseMailer.invitation_instructions | def invitation_instructions(user, token, opts = {})
with_user(user) do
@token = token
@organization = user.organization
@opts = opts
opts[:subject] = I18n.t("devise.mailer.#{opts[:invitation_instructions]}.subject", organization: user.organization.name) if opts[:invitation_instruc... | ruby | def invitation_instructions(user, token, opts = {})
with_user(user) do
@token = token
@organization = user.organization
@opts = opts
opts[:subject] = I18n.t("devise.mailer.#{opts[:invitation_instructions]}.subject", organization: user.organization.name) if opts[:invitation_instruc... | [
"def",
"invitation_instructions",
"(",
"user",
",",
"token",
",",
"opts",
"=",
"{",
"}",
")",
"with_user",
"(",
"user",
")",
"do",
"@token",
"=",
"token",
"@organization",
"=",
"user",
".",
"organization",
"@opts",
"=",
"opts",
"opts",
"[",
":subject",
"... | Sends an email with the invitation instructions to a new user.
user - The User that has been invited.
token - The String to be sent as a token to verify the invitation.
opts - A Hash with options to send the email (optional). | [
"Sends",
"an",
"email",
"with",
"the",
"invitation",
"instructions",
"to",
"a",
"new",
"user",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/mailers/decidim/decidim_devise_mailer.rb#L16-L26 | train |
decidim/decidim | decidim-core/app/cells/decidim/activities_cell.rb | Decidim.ActivitiesCell.show | def show
return if activities.blank?
activities.map do |activity|
activity.organization_lazy
activity.resource_lazy
activity.participatory_space_lazy
activity.component_lazy
end
render
end | ruby | def show
return if activities.blank?
activities.map do |activity|
activity.organization_lazy
activity.resource_lazy
activity.participatory_space_lazy
activity.component_lazy
end
render
end | [
"def",
"show",
"return",
"if",
"activities",
".",
"blank?",
"activities",
".",
"map",
"do",
"|",
"activity",
"|",
"activity",
".",
"organization_lazy",
"activity",
".",
"resource_lazy",
"activity",
".",
"participatory_space_lazy",
"activity",
".",
"component_lazy",
... | Since we're rendering each activity separatedly we need to trigger
BatchLoader in order to accumulate all the ids to be found later. | [
"Since",
"we",
"re",
"rendering",
"each",
"activity",
"separatedly",
"we",
"need",
"to",
"trigger",
"BatchLoader",
"in",
"order",
"to",
"accumulate",
"all",
"the",
"ids",
"to",
"be",
"found",
"later",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/cells/decidim/activities_cell.rb#L13-L24 | train |
decidim/decidim | decidim-core/app/helpers/decidim/component_path_helper.rb | Decidim.ComponentPathHelper.main_component_path | def main_component_path(component)
current_params = try(:params) || {}
EngineRouter.main_proxy(component).root_path(locale: current_params[:locale])
end | ruby | def main_component_path(component)
current_params = try(:params) || {}
EngineRouter.main_proxy(component).root_path(locale: current_params[:locale])
end | [
"def",
"main_component_path",
"(",
"component",
")",
"current_params",
"=",
"try",
"(",
":params",
")",
"||",
"{",
"}",
"EngineRouter",
".",
"main_proxy",
"(",
"component",
")",
".",
"root_path",
"(",
"locale",
":",
"current_params",
"[",
":locale",
"]",
")"... | Returns the defined root path for a given component.
component - the Component we want to find the root path for.
Returns a relative url. | [
"Returns",
"the",
"defined",
"root",
"path",
"for",
"a",
"given",
"component",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/component_path_helper.rb#L11-L14 | train |
decidim/decidim | decidim-core/app/helpers/decidim/component_path_helper.rb | Decidim.ComponentPathHelper.main_component_url | def main_component_url(component)
current_params = try(:params) || {}
EngineRouter.main_proxy(component).root_url(locale: current_params[:locale])
end | ruby | def main_component_url(component)
current_params = try(:params) || {}
EngineRouter.main_proxy(component).root_url(locale: current_params[:locale])
end | [
"def",
"main_component_url",
"(",
"component",
")",
"current_params",
"=",
"try",
"(",
":params",
")",
"||",
"{",
"}",
"EngineRouter",
".",
"main_proxy",
"(",
"component",
")",
".",
"root_url",
"(",
"locale",
":",
"current_params",
"[",
":locale",
"]",
")",
... | Returns the defined root url for a given component.
component - the Component we want to find the root path for.
Returns an absolute url. | [
"Returns",
"the",
"defined",
"root",
"url",
"for",
"a",
"given",
"component",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/component_path_helper.rb#L21-L24 | train |
decidim/decidim | decidim-core/app/helpers/decidim/component_path_helper.rb | Decidim.ComponentPathHelper.manage_component_path | def manage_component_path(component)
current_params = try(:params) || {}
EngineRouter.admin_proxy(component).root_path(locale: current_params[:locale])
end | ruby | def manage_component_path(component)
current_params = try(:params) || {}
EngineRouter.admin_proxy(component).root_path(locale: current_params[:locale])
end | [
"def",
"manage_component_path",
"(",
"component",
")",
"current_params",
"=",
"try",
"(",
":params",
")",
"||",
"{",
"}",
"EngineRouter",
".",
"admin_proxy",
"(",
"component",
")",
".",
"root_path",
"(",
"locale",
":",
"current_params",
"[",
":locale",
"]",
... | Returns the defined admin root path for a given component.
component - the Component we want to find the root path for.
Returns a relative url. | [
"Returns",
"the",
"defined",
"admin",
"root",
"path",
"for",
"a",
"given",
"component",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/component_path_helper.rb#L31-L34 | train |
decidim/decidim | decidim-core/app/helpers/decidim/searches_helper.rb | Decidim.SearchesHelper.searchable_resource_human_name | def searchable_resource_human_name(resource, count: 5)
resource = if resource.is_a?(String)
resource.constantize
else
resource
end
resource.model_name.human(count: count)
end | ruby | def searchable_resource_human_name(resource, count: 5)
resource = if resource.is_a?(String)
resource.constantize
else
resource
end
resource.model_name.human(count: count)
end | [
"def",
"searchable_resource_human_name",
"(",
"resource",
",",
"count",
":",
"5",
")",
"resource",
"=",
"if",
"resource",
".",
"is_a?",
"(",
"String",
")",
"resource",
".",
"constantize",
"else",
"resource",
"end",
"resource",
".",
"model_name",
".",
"human",
... | Renders the human name of the given class name.
klass_name - a String representing the class name of the resource to render
count - (optional) the number of resources so that the I18n backend
can decide to translate into singluar or plural form. | [
"Renders",
"the",
"human",
"name",
"of",
"the",
"given",
"class",
"name",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/searches_helper.rb#L11-L19 | train |
decidim/decidim | decidim-core/app/helpers/decidim/searches_helper.rb | Decidim.SearchesHelper.search_path_by | def search_path_by(resource_type: nil, space_state: nil)
new_params = {
utf8: params[:utf8],
filter: {
decidim_scope_id: params.dig(:filter, :decidim_scope_id),
term: params[:term] || params.dig(:filter, :term)
}
}
new_params[:filter][:resource_type] = resou... | ruby | def search_path_by(resource_type: nil, space_state: nil)
new_params = {
utf8: params[:utf8],
filter: {
decidim_scope_id: params.dig(:filter, :decidim_scope_id),
term: params[:term] || params.dig(:filter, :term)
}
}
new_params[:filter][:resource_type] = resou... | [
"def",
"search_path_by",
"(",
"resource_type",
":",
"nil",
",",
"space_state",
":",
"nil",
")",
"new_params",
"=",
"{",
"utf8",
":",
"params",
"[",
":utf8",
"]",
",",
"filter",
":",
"{",
"decidim_scope_id",
":",
"params",
".",
"dig",
"(",
":filter",
",",... | Generates a link to filter the current search by the given type. If no
type is given, it generates a link to the main results page.
resource_type - An optional String with the name of the model class to filter
space_state - An optional String with the name of the state of the space | [
"Generates",
"a",
"link",
"to",
"filter",
"the",
"current",
"search",
"by",
"the",
"given",
"type",
".",
"If",
"no",
"type",
"is",
"given",
"it",
"generates",
"a",
"link",
"to",
"the",
"main",
"results",
"page",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/searches_helper.rb#L26-L37 | train |
decidim/decidim | decidim-core/app/helpers/decidim/searches_helper.rb | Decidim.SearchesHelper.search_path_by_state_link | def search_path_by_state_link(state)
path = search_path_by(resource_type: params.dig(:filter, :resource_type), space_state: state)
is_active = params.dig(:filter, :space_state).to_s == state.to_s
link_to path, class: "order-by__tab#{" is-active" if is_active}" do
content_tag(:strong, t(state ... | ruby | def search_path_by_state_link(state)
path = search_path_by(resource_type: params.dig(:filter, :resource_type), space_state: state)
is_active = params.dig(:filter, :space_state).to_s == state.to_s
link_to path, class: "order-by__tab#{" is-active" if is_active}" do
content_tag(:strong, t(state ... | [
"def",
"search_path_by_state_link",
"(",
"state",
")",
"path",
"=",
"search_path_by",
"(",
"resource_type",
":",
"params",
".",
"dig",
"(",
":filter",
",",
":resource_type",
")",
",",
"space_state",
":",
"state",
")",
"is_active",
"=",
"params",
".",
"dig",
... | Generates the path and link to filter by space state, taking into account
the other filters applied. | [
"Generates",
"the",
"path",
"and",
"link",
"to",
"filter",
"by",
"space",
"state",
"taking",
"into",
"account",
"the",
"other",
"filters",
"applied",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/searches_helper.rb#L52-L59 | train |
decidim/decidim | decidim-core/app/helpers/decidim/decidim_form_helper.rb | Decidim.DecidimFormHelper.decidim_form_for | def decidim_form_for(record, options = {}, &block)
options[:data] ||= {}
options[:data].update(abide: true, "live-validate" => true, "validate-on-blur" => true)
options[:html] ||= {}
options[:html].update(novalidate: true)
output = ""
output += base_error_messages(record).to_s
... | ruby | def decidim_form_for(record, options = {}, &block)
options[:data] ||= {}
options[:data].update(abide: true, "live-validate" => true, "validate-on-blur" => true)
options[:html] ||= {}
options[:html].update(novalidate: true)
output = ""
output += base_error_messages(record).to_s
... | [
"def",
"decidim_form_for",
"(",
"record",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"options",
"[",
":data",
"]",
"||=",
"{",
"}",
"options",
"[",
":data",
"]",
".",
"update",
"(",
"abide",
":",
"true",
",",
"\"live-validate\"",
"=>",
"t... | A custom form for that injects client side validations with Abide.
record - The object to build the form for.
options - A Hash of options to pass to the form builder.
&block - The block to execute as content of the form.
Returns a String. | [
"A",
"custom",
"form",
"for",
"that",
"injects",
"client",
"side",
"validations",
"with",
"Abide",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/decidim_form_helper.rb#L13-L25 | train |
decidim/decidim | decidim-core/app/helpers/decidim/decidim_form_helper.rb | Decidim.DecidimFormHelper.editor_field_tag | def editor_field_tag(name, value, options = {})
options[:toolbar] ||= "basic"
options[:lines] ||= 10
content_tag(:div, class: "editor") do
template = ""
template += label_tag(name, options[:label]) if options[:label] != false
template += hidden_field_tag(name, value, options)
... | ruby | def editor_field_tag(name, value, options = {})
options[:toolbar] ||= "basic"
options[:lines] ||= 10
content_tag(:div, class: "editor") do
template = ""
template += label_tag(name, options[:label]) if options[:label] != false
template += hidden_field_tag(name, value, options)
... | [
"def",
"editor_field_tag",
"(",
"name",
",",
"value",
",",
"options",
"=",
"{",
"}",
")",
"options",
"[",
":toolbar",
"]",
"||=",
"\"basic\"",
"options",
"[",
":lines",
"]",
"||=",
"10",
"content_tag",
"(",
":div",
",",
"class",
":",
"\"editor\"",
")",
... | A custom helper to include an editor field without requiring a form object
name - The input name
value - The input value
options - The set of options to send to the field
:label - The Boolean value to create or not the input label (optional) (default: true)
:toolbar - The String value to con... | [
"A",
"custom",
"helper",
"to",
"include",
"an",
"editor",
"field",
"without",
"requiring",
"a",
"form",
"object"
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/decidim_form_helper.rb#L38-L51 | train |
decidim/decidim | decidim-core/app/helpers/decidim/decidim_form_helper.rb | Decidim.DecidimFormHelper.scopes_picker_field_tag | def scopes_picker_field_tag(name, value, id: nil)
picker_options = {
id: id || sanitize_to_id(name),
class: "picker-single",
name: name
}
prompt_params = yield(nil)
selected_scopes = value ? Decidim::Scope.where(id: value) : []
scopes = selected_scopes.map { |scope... | ruby | def scopes_picker_field_tag(name, value, id: nil)
picker_options = {
id: id || sanitize_to_id(name),
class: "picker-single",
name: name
}
prompt_params = yield(nil)
selected_scopes = value ? Decidim::Scope.where(id: value) : []
scopes = selected_scopes.map { |scope... | [
"def",
"scopes_picker_field_tag",
"(",
"name",
",",
"value",
",",
"id",
":",
"nil",
")",
"picker_options",
"=",
"{",
"id",
":",
"id",
"||",
"sanitize_to_id",
"(",
"name",
")",
",",
"class",
":",
"\"picker-single\"",
",",
"name",
":",
"name",
"}",
"prompt... | A custom helper to include a scope picker field without requiring a form
object
name - The input name
value - The input value as a scope id
options - The set of options to send to the field
:id - The id to generate for the element (optional)
Returns a scopes picker tag to be included in an html templa... | [
"A",
"custom",
"helper",
"to",
"include",
"a",
"scope",
"picker",
"field",
"without",
"requiring",
"a",
"form",
"object"
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/decidim_form_helper.rb#L62-L80 | train |
decidim/decidim | decidim-core/app/helpers/decidim/decidim_form_helper.rb | Decidim.DecidimFormHelper.translated_field_tag | def translated_field_tag(type, object_name, name, value = {}, options = {})
locales = available_locales
field_label = label_tag(name, options[:label])
if locales.count == 1
field_name = "#{name}_#{locales.first.to_s.gsub("-", "__")}"
field_input = send(
type,
"#{o... | ruby | def translated_field_tag(type, object_name, name, value = {}, options = {})
locales = available_locales
field_label = label_tag(name, options[:label])
if locales.count == 1
field_name = "#{name}_#{locales.first.to_s.gsub("-", "__")}"
field_input = send(
type,
"#{o... | [
"def",
"translated_field_tag",
"(",
"type",
",",
"object_name",
",",
"name",
",",
"value",
"=",
"{",
"}",
",",
"options",
"=",
"{",
"}",
")",
"locales",
"=",
"available_locales",
"field_label",
"=",
"label_tag",
"(",
"name",
",",
"options",
"[",
":label",
... | A custom helper to include a translated field without requiring a form object.
type - The type of the translated input field.
object_name - The object name used to identify the Foundation tabs.
name - The name of the input which will be suffixed with the corresponding locales.
value - A hash co... | [
"A",
"custom",
"helper",
"to",
"include",
"a",
"translated",
"field",
"without",
"requiring",
"a",
"form",
"object",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/decidim_form_helper.rb#L94-L143 | train |
decidim/decidim | decidim-core/app/helpers/decidim/decidim_form_helper.rb | Decidim.DecidimFormHelper.decidim_form_slug_url | def decidim_form_slug_url(prepend_path = "", value = "")
prepend_slug_path = if prepend_path.present?
"/#{prepend_path}/"
else
"/"
end
content_tag(:span, class: "slug-url") do
[
requ... | ruby | def decidim_form_slug_url(prepend_path = "", value = "")
prepend_slug_path = if prepend_path.present?
"/#{prepend_path}/"
else
"/"
end
content_tag(:span, class: "slug-url") do
[
requ... | [
"def",
"decidim_form_slug_url",
"(",
"prepend_path",
"=",
"\"\"",
",",
"value",
"=",
"\"\"",
")",
"prepend_slug_path",
"=",
"if",
"prepend_path",
".",
"present?",
"\"/#{prepend_path}/\"",
"else",
"\"/\"",
"end",
"content_tag",
"(",
":span",
",",
"class",
":",
"\... | Helper method to show how slugs will look like. Intended to be used in forms
together with some JavaScript code. More precisely, this will most probably
show in help texts in forms. The space slug is surrounded with a `span` so
the slug can be updated via JavaScript with the input value.
prepend_path - a path to p... | [
"Helper",
"method",
"to",
"show",
"how",
"slugs",
"will",
"look",
"like",
".",
"Intended",
"to",
"be",
"used",
"in",
"forms",
"together",
"with",
"some",
"JavaScript",
"code",
".",
"More",
"precisely",
"this",
"will",
"most",
"probably",
"show",
"in",
"hel... | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/decidim_form_helper.rb#L170-L184 | train |
decidim/decidim | decidim-core/app/helpers/decidim/traceability_helper.rb | Decidim.TraceabilityHelper.render_resource_last_editor | def render_resource_last_editor(resource)
render partial: "decidim/shared/version_author",
locals: {
author: Decidim.traceability.last_editor(resource)
}
end | ruby | def render_resource_last_editor(resource)
render partial: "decidim/shared/version_author",
locals: {
author: Decidim.traceability.last_editor(resource)
}
end | [
"def",
"render_resource_last_editor",
"(",
"resource",
")",
"render",
"partial",
":",
"\"decidim/shared/version_author\"",
",",
"locals",
":",
"{",
"author",
":",
"Decidim",
".",
"traceability",
".",
"last_editor",
"(",
"resource",
")",
"}",
"end"
] | Renders the avatar and author name of the author of the last version of the given
resource.
resource - an object implementing `Decidim::Traceable`
Returns an HTML-safe String representing the HTML to render the author. | [
"Renders",
"the",
"avatar",
"and",
"author",
"name",
"of",
"the",
"author",
"of",
"the",
"last",
"version",
"of",
"the",
"given",
"resource",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/traceability_helper.rb#L13-L18 | train |
decidim/decidim | decidim-core/app/helpers/decidim/traceability_helper.rb | Decidim.TraceabilityHelper.render_resource_editor | def render_resource_editor(version)
render partial: "decidim/shared/version_author",
locals: {
author: Decidim.traceability.version_editor(version)
}
end | ruby | def render_resource_editor(version)
render partial: "decidim/shared/version_author",
locals: {
author: Decidim.traceability.version_editor(version)
}
end | [
"def",
"render_resource_editor",
"(",
"version",
")",
"render",
"partial",
":",
"\"decidim/shared/version_author\"",
",",
"locals",
":",
"{",
"author",
":",
"Decidim",
".",
"traceability",
".",
"version_editor",
"(",
"version",
")",
"}",
"end"
] | Renders the avatar and author name of the author of the given version.
version - an object that responds to `whodunnit` and returns a String.
Returns an HTML-safe String representing the HTML to render the author. | [
"Renders",
"the",
"avatar",
"and",
"author",
"name",
"of",
"the",
"author",
"of",
"the",
"given",
"version",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/traceability_helper.rb#L25-L30 | train |
decidim/decidim | decidim-core/app/helpers/decidim/traceability_helper.rb | Decidim.TraceabilityHelper.diff_renderer | def diff_renderer
@diff_renderer ||= if current_version.item_type.include? "Decidim::Proposals"
Decidim::Proposals::DiffRenderer.new(current_version)
elsif current_version.item_type.include? "Decidim::Accountability"
Decidim::Accountab... | ruby | def diff_renderer
@diff_renderer ||= if current_version.item_type.include? "Decidim::Proposals"
Decidim::Proposals::DiffRenderer.new(current_version)
elsif current_version.item_type.include? "Decidim::Accountability"
Decidim::Accountab... | [
"def",
"diff_renderer",
"@diff_renderer",
"||=",
"if",
"current_version",
".",
"item_type",
".",
"include?",
"\"Decidim::Proposals\"",
"Decidim",
"::",
"Proposals",
"::",
"DiffRenderer",
".",
"new",
"(",
"current_version",
")",
"elsif",
"current_version",
".",
"item_t... | Caches a DiffRenderer instance for the `current_version`. | [
"Caches",
"a",
"DiffRenderer",
"instance",
"for",
"the",
"current_version",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/traceability_helper.rb#L33-L39 | train |
decidim/decidim | decidim-core/app/helpers/decidim/traceability_helper.rb | Decidim.TraceabilityHelper.render_diff_value | def render_diff_value(value, type, action, options = {})
return "".html_safe if value.blank?
value_to_render = case type
when :date
l value, format: :long
when :percentage
number_to_percentage value, precisi... | ruby | def render_diff_value(value, type, action, options = {})
return "".html_safe if value.blank?
value_to_render = case type
when :date
l value, format: :long
when :percentage
number_to_percentage value, precisi... | [
"def",
"render_diff_value",
"(",
"value",
",",
"type",
",",
"action",
",",
"options",
"=",
"{",
"}",
")",
"return",
"\"\"",
".",
"html_safe",
"if",
"value",
".",
"blank?",
"value_to_render",
"=",
"case",
"type",
"when",
":date",
"l",
"value",
",",
"forma... | Renders the given value in a user-friendly way based on the value class.
value - an object to be rendered
Returns an HTML-ready String. | [
"Renders",
"the",
"given",
"value",
"in",
"a",
"user",
"-",
"friendly",
"way",
"based",
"on",
"the",
"value",
"class",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/traceability_helper.rb#L72-L91 | train |
decidim/decidim | decidim-core/app/cells/decidim/activity_cell.rb | Decidim.ActivityCell.title | def title
resource_title = resource.try(:resource_title) || resource.try(:title)
return if resource_title.blank?
if resource_title.is_a?(String)
resource_title
elsif resource_title.is_a?(Hash)
translated_attribute(resource_title)
end
end | ruby | def title
resource_title = resource.try(:resource_title) || resource.try(:title)
return if resource_title.blank?
if resource_title.is_a?(String)
resource_title
elsif resource_title.is_a?(Hash)
translated_attribute(resource_title)
end
end | [
"def",
"title",
"resource_title",
"=",
"resource",
".",
"try",
"(",
":resource_title",
")",
"||",
"resource",
".",
"try",
"(",
":title",
")",
"return",
"if",
"resource_title",
".",
"blank?",
"if",
"resource_title",
".",
"is_a?",
"(",
"String",
")",
"resource... | The title to show at the card.
The card will also be displayed OK if there's no title. | [
"The",
"title",
"to",
"show",
"at",
"the",
"card",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/cells/decidim/activity_cell.rb#L34-L43 | train |
decidim/decidim | decidim-core/app/cells/decidim/activity_cell.rb | Decidim.ActivityCell.description | def description
resource_description = resource.try(:resource_description) || resource.try(:description)
return if resource_description.blank?
resource_description = if resource_description.is_a?(String)
resource_description
elsif resource_d... | ruby | def description
resource_description = resource.try(:resource_description) || resource.try(:description)
return if resource_description.blank?
resource_description = if resource_description.is_a?(String)
resource_description
elsif resource_d... | [
"def",
"description",
"resource_description",
"=",
"resource",
".",
"try",
"(",
":resource_description",
")",
"||",
"resource",
".",
"try",
"(",
":description",
")",
"return",
"if",
"resource_description",
".",
"blank?",
"resource_description",
"=",
"if",
"resource_... | The description to show at the card.
The card will also be displayed OK if there's no description. | [
"The",
"description",
"to",
"show",
"at",
"the",
"card",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/cells/decidim/activity_cell.rb#L48-L59 | train |
decidim/decidim | decidim-core/app/helpers/decidim/cta_button_helper.rb | Decidim.CtaButtonHelper.cta_button | def cta_button
button_text = translated_attribute(current_organization.cta_button_text).presence || t("decidim.pages.home.hero.participate")
link_to button_text, cta_button_path, class: "hero-cta button expanded large button--sc"
end | ruby | def cta_button
button_text = translated_attribute(current_organization.cta_button_text).presence || t("decidim.pages.home.hero.participate")
link_to button_text, cta_button_path, class: "hero-cta button expanded large button--sc"
end | [
"def",
"cta_button",
"button_text",
"=",
"translated_attribute",
"(",
"current_organization",
".",
"cta_button_text",
")",
".",
"presence",
"||",
"t",
"(",
"\"decidim.pages.home.hero.participate\"",
")",
"link_to",
"button_text",
",",
"cta_button_path",
",",
"class",
":... | Renders the Call To Action button. Link and text can be configured
per organization. | [
"Renders",
"the",
"Call",
"To",
"Action",
"button",
".",
"Link",
"and",
"text",
"can",
"be",
"configured",
"per",
"organization",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/cta_button_helper.rb#L8-L12 | train |
decidim/decidim | decidim-core/app/helpers/decidim/cta_button_helper.rb | Decidim.CtaButtonHelper.cta_button_path | def cta_button_path
if current_organization.cta_button_path.present?
current_organization.cta_button_path
elsif Decidim::ParticipatoryProcess.where(organization: current_organization).published.any?
decidim_participatory_processes.participatory_processes_path
elsif current_user
... | ruby | def cta_button_path
if current_organization.cta_button_path.present?
current_organization.cta_button_path
elsif Decidim::ParticipatoryProcess.where(organization: current_organization).published.any?
decidim_participatory_processes.participatory_processes_path
elsif current_user
... | [
"def",
"cta_button_path",
"if",
"current_organization",
".",
"cta_button_path",
".",
"present?",
"current_organization",
".",
"cta_button_path",
"elsif",
"Decidim",
"::",
"ParticipatoryProcess",
".",
"where",
"(",
"organization",
":",
"current_organization",
")",
".",
"... | Finds the CTA button path to reuse it in other places. | [
"Finds",
"the",
"CTA",
"button",
"path",
"to",
"reuse",
"it",
"in",
"other",
"places",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/cta_button_helper.rb#L15-L27 | train |
decidim/decidim | decidim-core/lib/decidim/data_portability_file_reader.rb | Decidim.DataPortabilityFileReader.file_path | def file_path
directory_name = Rails.root.join(Decidim::DataPortabilityUploader.new.store_dir)
FileUtils.mkdir_p(directory_name) unless File.exist?(directory_name)
directory_name + file_name
end | ruby | def file_path
directory_name = Rails.root.join(Decidim::DataPortabilityUploader.new.store_dir)
FileUtils.mkdir_p(directory_name) unless File.exist?(directory_name)
directory_name + file_name
end | [
"def",
"file_path",
"directory_name",
"=",
"Rails",
".",
"root",
".",
"join",
"(",
"Decidim",
"::",
"DataPortabilityUploader",
".",
"new",
".",
"store_dir",
")",
"FileUtils",
".",
"mkdir_p",
"(",
"directory_name",
")",
"unless",
"File",
".",
"exist?",
"(",
"... | Returns a String with the absolute file_path to be read or generate. | [
"Returns",
"a",
"String",
"with",
"the",
"absolute",
"file_path",
"to",
"be",
"read",
"or",
"generate",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/lib/decidim/data_portability_file_reader.rb#L30-L34 | train |
decidim/decidim | decidim-core/app/helpers/decidim/filters_helper.rb | Decidim.FiltersHelper.filter_form_for | def filter_form_for(filter, url = url_for)
content_tag :div, class: "filters" do
form_for filter, namespace: filter_form_namespace, builder: FilterFormBuilder, url: url, as: :filter, method: :get, remote: true, html: { id: nil } do |form|
yield form
end
end
end | ruby | def filter_form_for(filter, url = url_for)
content_tag :div, class: "filters" do
form_for filter, namespace: filter_form_namespace, builder: FilterFormBuilder, url: url, as: :filter, method: :get, remote: true, html: { id: nil } do |form|
yield form
end
end
end | [
"def",
"filter_form_for",
"(",
"filter",
",",
"url",
"=",
"url_for",
")",
"content_tag",
":div",
",",
"class",
":",
"\"filters\"",
"do",
"form_for",
"filter",
",",
"namespace",
":",
"filter_form_namespace",
",",
"builder",
":",
"FilterFormBuilder",
",",
"url",
... | This method wraps everything in a div with class filters and calls
the form_for helper with a custom builder
filter - A filter object
url - A String with the URL to post the from. Self URL by default.
block - A block to be called with the form builder
Returns the filter resource form wrapped in a div | [
"This",
"method",
"wraps",
"everything",
"in",
"a",
"div",
"with",
"class",
"filters",
"and",
"calls",
"the",
"form_for",
"helper",
"with",
"a",
"custom",
"builder"
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/helpers/decidim/filters_helper.rb#L14-L20 | train |
decidim/decidim | decidim-core/app/uploaders/decidim/attachment_uploader.rb | Decidim.AttachmentUploader.image? | def image?(new_file)
content_type = model.content_type || new_file.content_type
content_type.to_s.start_with? "image"
end | ruby | def image?(new_file)
content_type = model.content_type || new_file.content_type
content_type.to_s.start_with? "image"
end | [
"def",
"image?",
"(",
"new_file",
")",
"content_type",
"=",
"model",
".",
"content_type",
"||",
"new_file",
".",
"content_type",
"content_type",
".",
"to_s",
".",
"start_with?",
"\"image\"",
"end"
] | Checks if the file is an image based on the content type. We need this so
we only create different versions of the file when it's an image.
new_file - The uploaded file.
Returns a Boolean. | [
"Checks",
"if",
"the",
"file",
"is",
"an",
"image",
"based",
"on",
"the",
"content",
"type",
".",
"We",
"need",
"this",
"so",
"we",
"only",
"create",
"different",
"versions",
"of",
"the",
"file",
"when",
"it",
"s",
"an",
"image",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/uploaders/decidim/attachment_uploader.rb#L43-L46 | train |
decidim/decidim | decidim-core/app/uploaders/decidim/attachment_uploader.rb | Decidim.AttachmentUploader.set_content_type_and_size_in_model | def set_content_type_and_size_in_model
model.content_type = file.content_type if file.content_type
model.file_size = file.size
end | ruby | def set_content_type_and_size_in_model
model.content_type = file.content_type if file.content_type
model.file_size = file.size
end | [
"def",
"set_content_type_and_size_in_model",
"model",
".",
"content_type",
"=",
"file",
".",
"content_type",
"if",
"file",
".",
"content_type",
"model",
".",
"file_size",
"=",
"file",
".",
"size",
"end"
] | Copies the content type and file size to the model where this is mounted.
Returns nothing. | [
"Copies",
"the",
"content",
"type",
"and",
"file",
"size",
"to",
"the",
"model",
"where",
"this",
"is",
"mounted",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/app/uploaders/decidim/attachment_uploader.rb#L51-L54 | train |
decidim/decidim | decidim-core/lib/decidim/filter_form_builder.rb | Decidim.FilterFormBuilder.collection_radio_buttons | def collection_radio_buttons(method, collection, value_method, label_method, options = {}, html_options = {})
fieldset_wrapper options[:legend_title] do
super(method, collection, value_method, label_method, options, html_options) do |builder|
if block_given?
yield builder
e... | ruby | def collection_radio_buttons(method, collection, value_method, label_method, options = {}, html_options = {})
fieldset_wrapper options[:legend_title] do
super(method, collection, value_method, label_method, options, html_options) do |builder|
if block_given?
yield builder
e... | [
"def",
"collection_radio_buttons",
"(",
"method",
",",
"collection",
",",
"value_method",
",",
"label_method",
",",
"options",
"=",
"{",
"}",
",",
"html_options",
"=",
"{",
"}",
")",
"fieldset_wrapper",
"options",
"[",
":legend_title",
"]",
"do",
"super",
"(",... | Wrap the radio buttons collection in a custom fieldset.
It also renders the inputs inside its labels. | [
"Wrap",
"the",
"radio",
"buttons",
"collection",
"in",
"a",
"custom",
"fieldset",
".",
"It",
"also",
"renders",
"the",
"inputs",
"inside",
"its",
"labels",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/lib/decidim/filter_form_builder.rb#L10-L20 | train |
decidim/decidim | decidim-core/lib/decidim/filter_form_builder.rb | Decidim.FilterFormBuilder.collection_check_boxes | def collection_check_boxes(method, collection, value_method, label_method, options = {}, html_options = {})
fieldset_wrapper options[:legend_title] do
super(method, collection, value_method, label_method, options, html_options) do |builder|
if block_given?
yield builder
els... | ruby | def collection_check_boxes(method, collection, value_method, label_method, options = {}, html_options = {})
fieldset_wrapper options[:legend_title] do
super(method, collection, value_method, label_method, options, html_options) do |builder|
if block_given?
yield builder
els... | [
"def",
"collection_check_boxes",
"(",
"method",
",",
"collection",
",",
"value_method",
",",
"label_method",
",",
"options",
"=",
"{",
"}",
",",
"html_options",
"=",
"{",
"}",
")",
"fieldset_wrapper",
"options",
"[",
":legend_title",
"]",
"do",
"super",
"(",
... | Wrap the check_boxes collection in a custom fieldset.
It also renders the inputs inside its labels. | [
"Wrap",
"the",
"check_boxes",
"collection",
"in",
"a",
"custom",
"fieldset",
".",
"It",
"also",
"renders",
"the",
"inputs",
"inside",
"its",
"labels",
"."
] | 6e2b14e559a63088669904e3c5c49a5180700cf7 | https://github.com/decidim/decidim/blob/6e2b14e559a63088669904e3c5c49a5180700cf7/decidim-core/lib/decidim/filter_form_builder.rb#L24-L34 | train |
capistrano/capistrano | lib/capistrano/dsl.rb | Capistrano.DSL.execute | def execute(*)
file, line, = caller.first.split(":")
colors = SSHKit::Color.new($stderr)
$stderr.puts colors.colorize("Warning: `execute' should be wrapped in an `on' scope in #{file}:#{line}.", :red)
$stderr.puts
$stderr.puts " task :example do"
$stderr.puts colors.colorize(" on... | ruby | def execute(*)
file, line, = caller.first.split(":")
colors = SSHKit::Color.new($stderr)
$stderr.puts colors.colorize("Warning: `execute' should be wrapped in an `on' scope in #{file}:#{line}.", :red)
$stderr.puts
$stderr.puts " task :example do"
$stderr.puts colors.colorize(" on... | [
"def",
"execute",
"(",
"*",
")",
"file",
",",
"line",
",",
"=",
"caller",
".",
"first",
".",
"split",
"(",
"\":\"",
")",
"colors",
"=",
"SSHKit",
"::",
"Color",
".",
"new",
"(",
"$stderr",
")",
"$stderr",
".",
"puts",
"colors",
".",
"colorize",
"("... | Catch common beginner mistake and give a helpful error message on stderr | [
"Catch",
"common",
"beginner",
"mistake",
"and",
"give",
"a",
"helpful",
"error",
"message",
"on",
"stderr"
] | 7a14ddb47d64187c8a7ee14c7d78e874f30f08ef | https://github.com/capistrano/capistrano/blob/7a14ddb47d64187c8a7ee14c7d78e874f30f08ef/lib/capistrano/dsl.rb#L80-L92 | train |
tongueroo/jets | lib/jets/preheat.rb | Jets.Preheat.warm_all | def warm_all
threads = []
all_functions.each do |function_name|
next if function_name.include?('jets-public_controller') # handled by warm_public_controller_more
next if function_name.include?('jets-rack_controller') # handled by warm_rack_controller_more
threads << Thread.new do
... | ruby | def warm_all
threads = []
all_functions.each do |function_name|
next if function_name.include?('jets-public_controller') # handled by warm_public_controller_more
next if function_name.include?('jets-rack_controller') # handled by warm_rack_controller_more
threads << Thread.new do
... | [
"def",
"warm_all",
"threads",
"=",
"[",
"]",
"all_functions",
".",
"each",
"do",
"|",
"function_name",
"|",
"next",
"if",
"function_name",
".",
"include?",
"(",
"'jets-public_controller'",
")",
"# handled by warm_public_controller_more",
"next",
"if",
"function_name",... | Loop through all methods for each class and makes special prewarm call to each method. | [
"Loop",
"through",
"all",
"methods",
"for",
"each",
"class",
"and",
"makes",
"special",
"prewarm",
"call",
"to",
"each",
"method",
"."
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/preheat.rb#L30-L48 | train |
tongueroo/jets | lib/jets/job/dsl/iot_event.rb | Jets::Job::Dsl.IotEvent.iot_event | def iot_event(props={})
if props.is_a?(String) # SQL Statement
props = {sql: props}
topic_props = {topic_rule_payload: props}
elsif props.key?(:topic_rule_payload) # full properties structure
topic_props = props
else # just the topic_rule_payload
topic_props = {topic_ru... | ruby | def iot_event(props={})
if props.is_a?(String) # SQL Statement
props = {sql: props}
topic_props = {topic_rule_payload: props}
elsif props.key?(:topic_rule_payload) # full properties structure
topic_props = props
else # just the topic_rule_payload
topic_props = {topic_ru... | [
"def",
"iot_event",
"(",
"props",
"=",
"{",
"}",
")",
"if",
"props",
".",
"is_a?",
"(",
"String",
")",
"# SQL Statement",
"props",
"=",
"{",
"sql",
":",
"props",
"}",
"topic_props",
"=",
"{",
"topic_rule_payload",
":",
"props",
"}",
"elsif",
"props",
"... | The user must at least pass in an SQL statement | [
"The",
"user",
"must",
"at",
"least",
"pass",
"in",
"an",
"SQL",
"statement"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/job/dsl/iot_event.rb#L4-L15 | train |
tongueroo/jets | lib/jets/resource/lambda/function.rb | Jets::Resource::Lambda.Function.lookup_class_properties | def lookup_class_properties(klass)
all_classes = []
while klass != Object
all_classes << klass
klass = klass.superclass
end
class_properties = {}
# Go back down class heirachry top to down
all_classes.reverse.each do |k|
class_properties.merge!(k.class_propert... | ruby | def lookup_class_properties(klass)
all_classes = []
while klass != Object
all_classes << klass
klass = klass.superclass
end
class_properties = {}
# Go back down class heirachry top to down
all_classes.reverse.each do |k|
class_properties.merge!(k.class_propert... | [
"def",
"lookup_class_properties",
"(",
"klass",
")",
"all_classes",
"=",
"[",
"]",
"while",
"klass",
"!=",
"Object",
"all_classes",
"<<",
"klass",
"klass",
"=",
"klass",
".",
"superclass",
"end",
"class_properties",
"=",
"{",
"}",
"# Go back down class heirachry t... | Accounts for inherited class_properties | [
"Accounts",
"for",
"inherited",
"class_properties"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/resource/lambda/function.rb#L85-L97 | train |
tongueroo/jets | lib/jets/resource/lambda/function.rb | Jets::Resource::Lambda.Function.finalize_properties! | def finalize_properties!(props)
handler = full_handler(props)
runtime = get_runtime(props)
managed = {
handler: handler,
runtime: runtime,
description: description,
}
managed[:function_name] = function_name if function_name
layers = get_layers(runtime)
m... | ruby | def finalize_properties!(props)
handler = full_handler(props)
runtime = get_runtime(props)
managed = {
handler: handler,
runtime: runtime,
description: description,
}
managed[:function_name] = function_name if function_name
layers = get_layers(runtime)
m... | [
"def",
"finalize_properties!",
"(",
"props",
")",
"handler",
"=",
"full_handler",
"(",
"props",
")",
"runtime",
"=",
"get_runtime",
"(",
"props",
")",
"managed",
"=",
"{",
"handler",
":",
"handler",
",",
"runtime",
":",
"runtime",
",",
"description",
":",
... | Properties managed by Jets with merged with finality. | [
"Properties",
"managed",
"by",
"Jets",
"with",
"merged",
"with",
"finality",
"."
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/resource/lambda/function.rb#L124-L136 | train |
tongueroo/jets | lib/jets/resource/iam/policy_document.rb | Jets::Resource::Iam.PolicyDocument.standardize | def standardize(definition)
case definition
when String
# Expands simple string from: logs => logs:*
definition = "#{definition}:*" unless definition.include?(':')
@policy[:statement] << {
action: [definition],
effect: "Allow",
resource: "*",
}
... | ruby | def standardize(definition)
case definition
when String
# Expands simple string from: logs => logs:*
definition = "#{definition}:*" unless definition.include?(':')
@policy[:statement] << {
action: [definition],
effect: "Allow",
resource: "*",
}
... | [
"def",
"standardize",
"(",
"definition",
")",
"case",
"definition",
"when",
"String",
"# Expands simple string from: logs => logs:*",
"definition",
"=",
"\"#{definition}:*\"",
"unless",
"definition",
".",
"include?",
"(",
"':'",
")",
"@policy",
"[",
":statement",
"]",
... | only process policy_document once | [
"only",
"process",
"policy_document",
"once"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/resource/iam/policy_document.rb#L21-L39 | train |
tongueroo/jets | lib/jets/controller/rack/adapter.rb | Jets::Controller::Rack.Adapter.process | def process
status, headers, body = Jets.application.call(env)
convert_to_api_gateway(status, headers, body)
end | ruby | def process
status, headers, body = Jets.application.call(env)
convert_to_api_gateway(status, headers, body)
end | [
"def",
"process",
"status",
",",
"headers",
",",
"body",
"=",
"Jets",
".",
"application",
".",
"call",
"(",
"env",
")",
"convert_to_api_gateway",
"(",
"status",
",",
"headers",
",",
"body",
")",
"end"
] | 1. Convert API Gateway event event to Rack env
2. Process using full Rack middleware stack
3. Convert back to API gateway response structure payload | [
"1",
".",
"Convert",
"API",
"Gateway",
"event",
"event",
"to",
"Rack",
"env",
"2",
".",
"Process",
"using",
"full",
"Rack",
"middleware",
"stack",
"3",
".",
"Convert",
"back",
"to",
"API",
"gateway",
"response",
"structure",
"payload"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/controller/rack/adapter.rb#L20-L23 | train |
tongueroo/jets | lib/jets/router.rb | Jets.Router.check_collision! | def check_collision!
paths = self.routes.map(&:path)
collision = Jets::Resource::ApiGateway::RestApi::Routes::Collision.new
collide = collision.collision?(paths)
raise collision.exception if collide
end | ruby | def check_collision!
paths = self.routes.map(&:path)
collision = Jets::Resource::ApiGateway::RestApi::Routes::Collision.new
collide = collision.collision?(paths)
raise collision.exception if collide
end | [
"def",
"check_collision!",
"paths",
"=",
"self",
".",
"routes",
".",
"map",
"(",
":path",
")",
"collision",
"=",
"Jets",
"::",
"Resource",
"::",
"ApiGateway",
"::",
"RestApi",
"::",
"Routes",
"::",
"Collision",
".",
"new",
"collide",
"=",
"collision",
".",... | Validate routes that deployable | [
"Validate",
"routes",
"that",
"deployable"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/router.rb#L18-L23 | train |
tongueroo/jets | lib/jets/router.rb | Jets.Router.resources | def resources(name)
get "#{name}", to: "#{name}#index"
get "#{name}/new", to: "#{name}#new" unless api_mode?
get "#{name}/:id", to: "#{name}#show"
post "#{name}", to: "#{name}#create"
get "#{name}/:id/edit", to: "#{name}#edit" unless api_mode?
put "#{name}/:id", to: "#{name}#update"
... | ruby | def resources(name)
get "#{name}", to: "#{name}#index"
get "#{name}/new", to: "#{name}#new" unless api_mode?
get "#{name}/:id", to: "#{name}#show"
post "#{name}", to: "#{name}#create"
get "#{name}/:id/edit", to: "#{name}#edit" unless api_mode?
put "#{name}/:id", to: "#{name}#update"
... | [
"def",
"resources",
"(",
"name",
")",
"get",
"\"#{name}\"",
",",
"to",
":",
"\"#{name}#index\"",
"get",
"\"#{name}/new\"",
",",
"to",
":",
"\"#{name}#new\"",
"unless",
"api_mode?",
"get",
"\"#{name}/:id\"",
",",
"to",
":",
"\"#{name}#show\"",
"post",
"\"#{name}\""... | resources macro expands to all the routes | [
"resources",
"macro",
"expands",
"to",
"all",
"the",
"routes"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/router.rb#L60-L70 | train |
tongueroo/jets | lib/jets/router.rb | Jets.Router.all_paths | def all_paths
results = []
paths = routes.map(&:path)
paths.each do |p|
sub_paths = []
parts = p.split('/')
until parts.empty?
parts.pop
sub_path = parts.join('/')
sub_paths << sub_path unless sub_path == ''
end
results += sub_paths... | ruby | def all_paths
results = []
paths = routes.map(&:path)
paths.each do |p|
sub_paths = []
parts = p.split('/')
until parts.empty?
parts.pop
sub_path = parts.join('/')
sub_paths << sub_path unless sub_path == ''
end
results += sub_paths... | [
"def",
"all_paths",
"results",
"=",
"[",
"]",
"paths",
"=",
"routes",
".",
"map",
"(",
":path",
")",
"paths",
".",
"each",
"do",
"|",
"p",
"|",
"sub_paths",
"=",
"[",
"]",
"parts",
"=",
"p",
".",
"split",
"(",
"'/'",
")",
"until",
"parts",
".",
... | Useful for creating API Gateway Resources | [
"Useful",
"for",
"creating",
"API",
"Gateway",
"Resources"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/router.rb#L94-L108 | train |
tongueroo/jets | lib/jets/router.rb | Jets.Router.ordered_routes | def ordered_routes
length = Proc.new { |r| r.path.length * -1 }
capture_routes = routes.select { |r| r.path.include?(':') }.sort_by(&length)
wildcard_routes = routes.select { |r| r.path.include?('*') }.sort_by(&length)
simple_routes = (routes - capture_routes - wildcard_routes).sort_by(&length)
... | ruby | def ordered_routes
length = Proc.new { |r| r.path.length * -1 }
capture_routes = routes.select { |r| r.path.include?(':') }.sort_by(&length)
wildcard_routes = routes.select { |r| r.path.include?('*') }.sort_by(&length)
simple_routes = (routes - capture_routes - wildcard_routes).sort_by(&length)
... | [
"def",
"ordered_routes",
"length",
"=",
"Proc",
".",
"new",
"{",
"|",
"r",
"|",
"r",
".",
"path",
".",
"length",
"*",
"-",
"1",
"}",
"capture_routes",
"=",
"routes",
".",
"select",
"{",
"|",
"r",
"|",
"r",
".",
"path",
".",
"include?",
"(",
"':'"... | Useful for RouterMatcher
Precedence:
1. Routes with no captures get highest precedence: posts/new
2. Then consider the routes with captures: post/:id
3. Last consider the routes with wildcards: *catchall
Within these 2 groups we consider the routes with the longest path first
since posts/:id and posts/:id/edit ... | [
"Useful",
"for",
"RouterMatcher"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/router.rb#L119-L125 | train |
tongueroo/jets | lib/jets/controller/middleware/local.rb | Jets::Controller::Middleware.Local.routes_table | def routes_table
routes = Jets::Router.routes
return "Your routes table is empty." if routes.empty?
text = "Verb | Path | Controller#action\n"
text << "--- | --- | ---\n"
routes.each do |route|
text << "#{route.method} | #{route.path} | #{route.to}\n"
end
html = Kramd... | ruby | def routes_table
routes = Jets::Router.routes
return "Your routes table is empty." if routes.empty?
text = "Verb | Path | Controller#action\n"
text << "--- | --- | ---\n"
routes.each do |route|
text << "#{route.method} | #{route.path} | #{route.to}\n"
end
html = Kramd... | [
"def",
"routes_table",
"routes",
"=",
"Jets",
"::",
"Router",
".",
"routes",
"return",
"\"Your routes table is empty.\"",
"if",
"routes",
".",
"empty?",
"text",
"=",
"\"Verb | Path | Controller#action\\n\"",
"text",
"<<",
"\"--- | --- | ---\\n\"",
"routes",
".",
"each",... | Show pretty route table for user to help with debugging in non-production mode | [
"Show",
"pretty",
"route",
"table",
"for",
"user",
"to",
"help",
"with",
"debugging",
"in",
"non",
"-",
"production",
"mode"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/controller/middleware/local.rb#L105-L118 | train |
tongueroo/jets | lib/jets/resource/api_gateway/cors.rb | Jets::Resource::ApiGateway.Cors.cors_headers | def cors_headers
rack = Jets::Controller::Middleware::Cors.new(Jets.application)
rack.cors_headers(true)
end | ruby | def cors_headers
rack = Jets::Controller::Middleware::Cors.new(Jets.application)
rack.cors_headers(true)
end | [
"def",
"cors_headers",
"rack",
"=",
"Jets",
"::",
"Controller",
"::",
"Middleware",
"::",
"Cors",
".",
"new",
"(",
"Jets",
".",
"application",
")",
"rack",
".",
"cors_headers",
"(",
"true",
")",
"end"
] | Always the pre-flight headers in this case | [
"Always",
"the",
"pre",
"-",
"flight",
"headers",
"in",
"this",
"case"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/resource/api_gateway/cors.rb#L48-L51 | train |
tongueroo/jets | lib/jets/rack_server.rb | Jets.RackServer.serve | def serve
# Note, looks like stopping jets server with Ctrl-C sends the TERM signal
# down to the sub bin/rackup command cleans up the child process fine.
Bundler.with_clean_env do
args = ''
# only forward the host option, port is always 9292 for simplicity
if @options[:host]
... | ruby | def serve
# Note, looks like stopping jets server with Ctrl-C sends the TERM signal
# down to the sub bin/rackup command cleans up the child process fine.
Bundler.with_clean_env do
args = ''
# only forward the host option, port is always 9292 for simplicity
if @options[:host]
... | [
"def",
"serve",
"# Note, looks like stopping jets server with Ctrl-C sends the TERM signal",
"# down to the sub bin/rackup command cleans up the child process fine.",
"Bundler",
".",
"with_clean_env",
"do",
"args",
"=",
"''",
"# only forward the host option, port is always 9292 for simplicity"... | Runs in the child process | [
"Runs",
"in",
"the",
"child",
"process"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/rack_server.rb#L34-L51 | train |
tongueroo/jets | lib/jets/rack_server.rb | Jets.RackServer.wait_for_socket | def wait_for_socket
return unless Jets.rack?
retries = 0
max_retries = 30 # 15 seconds at a delay of 0.5s
delay = 0.5
if ENV['C9_USER'] # overrides for local testing
max_retries = 3
delay = 3
end
begin
server = TCPSocket.new('localhost', 9292)
s... | ruby | def wait_for_socket
return unless Jets.rack?
retries = 0
max_retries = 30 # 15 seconds at a delay of 0.5s
delay = 0.5
if ENV['C9_USER'] # overrides for local testing
max_retries = 3
delay = 3
end
begin
server = TCPSocket.new('localhost', 9292)
s... | [
"def",
"wait_for_socket",
"return",
"unless",
"Jets",
".",
"rack?",
"retries",
"=",
"0",
"max_retries",
"=",
"30",
"# 15 seconds at a delay of 0.5s",
"delay",
"=",
"0.5",
"if",
"ENV",
"[",
"'C9_USER'",
"]",
"# overrides for local testing",
"max_retries",
"=",
"3",
... | blocks until rack server is up | [
"blocks",
"until",
"rack",
"server",
"is",
"up"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/rack_server.rb#L54-L80 | train |
tongueroo/jets | lib/jets/logger.rb | Jets.Logger.add | def add(severity, message = nil, progname = nil)
# Taken from Logger#add source
# https://ruby-doc.org/stdlib-2.5.1/libdoc/logger/rdoc/Logger.html#method-i-add
if message.nil?
if block_given?
message = yield
else
message = progname
progname = @progname
... | ruby | def add(severity, message = nil, progname = nil)
# Taken from Logger#add source
# https://ruby-doc.org/stdlib-2.5.1/libdoc/logger/rdoc/Logger.html#method-i-add
if message.nil?
if block_given?
message = yield
else
message = progname
progname = @progname
... | [
"def",
"add",
"(",
"severity",
",",
"message",
"=",
"nil",
",",
"progname",
"=",
"nil",
")",
"# Taken from Logger#add source",
"# https://ruby-doc.org/stdlib-2.5.1/libdoc/logger/rdoc/Logger.html#method-i-add",
"if",
"message",
".",
"nil?",
"if",
"block_given?",
"message",
... | Only need to override the add method as the other calls all lead to it. | [
"Only",
"need",
"to",
"override",
"the",
"add",
"method",
"as",
"the",
"other",
"calls",
"all",
"lead",
"to",
"it",
"."
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/logger.rb#L6-L22 | train |
tongueroo/jets | lib/jets/commands/markdown/page.rb | Jets::Commands::Markdown.Page.long_description | def long_description
text = @command.long_description
return "" if text.nil? # empty description
lines = text.split("\n")
lines.map do |line|
# In the CLI help, we use 2 spaces to designate commands
# In Markdown we need 4 spaces.
line.sub(/^ \b/, ' ')
end.join... | ruby | def long_description
text = @command.long_description
return "" if text.nil? # empty description
lines = text.split("\n")
lines.map do |line|
# In the CLI help, we use 2 spaces to designate commands
# In Markdown we need 4 spaces.
line.sub(/^ \b/, ' ')
end.join... | [
"def",
"long_description",
"text",
"=",
"@command",
".",
"long_description",
"return",
"\"\"",
"if",
"text",
".",
"nil?",
"# empty description",
"lines",
"=",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
"lines",
".",
"map",
"do",
"|",
"line",
"|",
"# In the C... | Use command's long description as main description | [
"Use",
"command",
"s",
"long",
"description",
"as",
"main",
"description"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/commands/markdown/page.rb#L46-L56 | train |
tongueroo/jets | lib/jets/rdoc.rb | Jets.Rdoc.options | def options
exclude = %w[
docs
spec
vendor
core.rb
.js
templates
commands
internal
support
Dockerfile
Dockerfile.base
Gemfile
Gemfile.lock
Guardfile
LICENSE
Procfile
Rakefile
... | ruby | def options
exclude = %w[
docs
spec
vendor
core.rb
.js
templates
commands
internal
support
Dockerfile
Dockerfile.base
Gemfile
Gemfile.lock
Guardfile
LICENSE
Procfile
Rakefile
... | [
"def",
"options",
"exclude",
"=",
"%w[",
"docs",
"spec",
"vendor",
"core.rb",
".js",
"templates",
"commands",
"internal",
"support",
"Dockerfile",
"Dockerfile.base",
"Gemfile",
"Gemfile.lock",
"Guardfile",
"LICENSE",
"Procfile",
"Rakefile",
"bin",
"]",
"exclude",
"=... | Use for both jets.gemspec and rake rdoc task | [
"Use",
"for",
"both",
"jets",
".",
"gemspec",
"and",
"rake",
"rdoc",
"task"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/rdoc.rb#L4-L27 | train |
tongueroo/jets | lib/jets/middleware/default_stack.rb | Jets::Middleware.DefaultStack.use_webpacker | def use_webpacker(middleware)
return unless Jets.webpacker? # checks for local development if webpacker installed
# Different check for middleware because we need webpacker helpers for url helpers.
# But we dont want to actually serve via webpacker middleware when running on AWS.
# By this time ... | ruby | def use_webpacker(middleware)
return unless Jets.webpacker? # checks for local development if webpacker installed
# Different check for middleware because we need webpacker helpers for url helpers.
# But we dont want to actually serve via webpacker middleware when running on AWS.
# By this time ... | [
"def",
"use_webpacker",
"(",
"middleware",
")",
"return",
"unless",
"Jets",
".",
"webpacker?",
"# checks for local development if webpacker installed",
"# Different check for middleware because we need webpacker helpers for url helpers.",
"# But we dont want to actually serve via webpacker m... | Written as method to easily not include webpacker for case when either
webpacker not installed at all or disabled upon `jets deploy`. | [
"Written",
"as",
"method",
"to",
"easily",
"not",
"include",
"webpacker",
"for",
"case",
"when",
"either",
"webpacker",
"not",
"installed",
"at",
"all",
"or",
"disabled",
"upon",
"jets",
"deploy",
"."
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/middleware/default_stack.rb#L30-L38 | train |
tongueroo/jets | lib/jets/aws_info.rb | Jets.AwsInfo.account | def account
return '123456789' if test?
# ensure region set, required for sts.get_caller_identity.account to work
ENV['AWS_REGION'] ||= region
begin
sts.get_caller_identity.account
rescue Aws::Errors::MissingCredentialsError
puts "INFO: You're missing AWS credentials. Only ... | ruby | def account
return '123456789' if test?
# ensure region set, required for sts.get_caller_identity.account to work
ENV['AWS_REGION'] ||= region
begin
sts.get_caller_identity.account
rescue Aws::Errors::MissingCredentialsError
puts "INFO: You're missing AWS credentials. Only ... | [
"def",
"account",
"return",
"'123456789'",
"if",
"test?",
"# ensure region set, required for sts.get_caller_identity.account to work",
"ENV",
"[",
"'AWS_REGION'",
"]",
"||=",
"region",
"begin",
"sts",
".",
"get_caller_identity",
".",
"account",
"rescue",
"Aws",
"::",
"Err... | aws sts get-caller-identity | [
"aws",
"sts",
"get",
"-",
"caller",
"-",
"identity"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/aws_info.rb#L50-L59 | train |
tongueroo/jets | lib/jets/commands/deploy.rb | Jets::Commands.Deploy.check_route_connected_functions | def check_route_connected_functions
return if Jets::Router.all_routes_valid
puts "Deploy fail: The jets application contain invalid routes.".color(:red)
puts "Please double check the routes below map to valid controllers:"
Jets::Router.invalid_routes.each do |route|
puts " /#{route.pat... | ruby | def check_route_connected_functions
return if Jets::Router.all_routes_valid
puts "Deploy fail: The jets application contain invalid routes.".color(:red)
puts "Please double check the routes below map to valid controllers:"
Jets::Router.invalid_routes.each do |route|
puts " /#{route.pat... | [
"def",
"check_route_connected_functions",
"return",
"if",
"Jets",
"::",
"Router",
".",
"all_routes_valid",
"puts",
"\"Deploy fail: The jets application contain invalid routes.\"",
".",
"color",
"(",
":red",
")",
"puts",
"\"Please double check the routes below map to valid controlle... | Checks that all routes are validate and have corresponding lambda functions | [
"Checks",
"that",
"all",
"routes",
"are",
"validate",
"and",
"have",
"corresponding",
"lambda",
"functions"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/commands/deploy.rb#L67-L76 | train |
tongueroo/jets | lib/jets/commands/deploy.rb | Jets::Commands.Deploy.minimal_rollback_complete? | def minimal_rollback_complete?
stack = find_stack(stack_name)
return false unless stack
return false unless stack.stack_status == 'ROLLBACK_COMPLETE'
# Finally check if all the minimal resources in the parent template have been deleted
resp = cfn.describe_stack_resources(stack_name: stac... | ruby | def minimal_rollback_complete?
stack = find_stack(stack_name)
return false unless stack
return false unless stack.stack_status == 'ROLLBACK_COMPLETE'
# Finally check if all the minimal resources in the parent template have been deleted
resp = cfn.describe_stack_resources(stack_name: stac... | [
"def",
"minimal_rollback_complete?",
"stack",
"=",
"find_stack",
"(",
"stack_name",
")",
"return",
"false",
"unless",
"stack",
"return",
"false",
"unless",
"stack",
".",
"stack_status",
"==",
"'ROLLBACK_COMPLETE'",
"# Finally check if all the minimal resources in the parent t... | Checks for a few things before deciding to delete the parent stack
* Parent stack status status is ROLLBACK_COMPLETE
* Parent resources are in the DELETE_COMPLETE state | [
"Checks",
"for",
"a",
"few",
"things",
"before",
"deciding",
"to",
"delete",
"the",
"parent",
"stack"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/commands/deploy.rb#L98-L108 | train |
tongueroo/jets | lib/jets/resource/iam/class_role.rb | Jets::Resource::Iam.ClassRole.all_classes | def all_classes
klass = @app_class.constantize
all_classes = []
while klass != Object
all_classes << klass
klass = klass.superclass
end
all_classes.reverse
end | ruby | def all_classes
klass = @app_class.constantize
all_classes = []
while klass != Object
all_classes << klass
klass = klass.superclass
end
all_classes.reverse
end | [
"def",
"all_classes",
"klass",
"=",
"@app_class",
".",
"constantize",
"all_classes",
"=",
"[",
"]",
"while",
"klass",
"!=",
"Object",
"all_classes",
"<<",
"klass",
"klass",
"=",
"klass",
".",
"superclass",
"end",
"all_classes",
".",
"reverse",
"end"
] | Class heirachry in top to down order | [
"Class",
"heirachry",
"in",
"top",
"to",
"down",
"order"
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/resource/iam/class_role.rb#L63-L71 | train |
tongueroo/jets | lib/jets/lambda/function_constructor.rb | Jets::Lambda.FunctionConstructor.adjust_tasks | def adjust_tasks(klass)
class_name = @code_path.to_s.sub(/.*\/functions\//,'').sub(/\.rb$/, '')
class_name = class_name.classify
klass.tasks.each do |task|
task.class_name = class_name
task.type = "function"
end
end | ruby | def adjust_tasks(klass)
class_name = @code_path.to_s.sub(/.*\/functions\//,'').sub(/\.rb$/, '')
class_name = class_name.classify
klass.tasks.each do |task|
task.class_name = class_name
task.type = "function"
end
end | [
"def",
"adjust_tasks",
"(",
"klass",
")",
"class_name",
"=",
"@code_path",
".",
"to_s",
".",
"sub",
"(",
"/",
"\\/",
"\\/",
"/",
",",
"''",
")",
".",
"sub",
"(",
"/",
"\\.",
"/",
",",
"''",
")",
"class_name",
"=",
"class_name",
".",
"classify",
"kl... | For anonymous classes method_added during task registration contains ""
for the class name. We adjust it here. | [
"For",
"anonymous",
"classes",
"method_added",
"during",
"task",
"registration",
"contains",
"for",
"the",
"class",
"name",
".",
"We",
"adjust",
"it",
"here",
"."
] | 46943a519224067e58aa3e2d5656e3ca083150f9 | https://github.com/tongueroo/jets/blob/46943a519224067e58aa3e2d5656e3ca083150f9/lib/jets/lambda/function_constructor.rb#L45-L52 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/section.rb | GitHubChangelogGenerator.Section.generate_content | def generate_content
content = ""
if @issues.any?
content += "#{@prefix}\n\n" unless @options[:simple_list] || @prefix.blank?
@issues.each do |issue|
merge_string = get_string_for_issue(issue)
content += "- " unless @body_only
content += "#{merge_string}\n"
... | ruby | def generate_content
content = ""
if @issues.any?
content += "#{@prefix}\n\n" unless @options[:simple_list] || @prefix.blank?
@issues.each do |issue|
merge_string = get_string_for_issue(issue)
content += "- " unless @body_only
content += "#{merge_string}\n"
... | [
"def",
"generate_content",
"content",
"=",
"\"\"",
"if",
"@issues",
".",
"any?",
"content",
"+=",
"\"#{@prefix}\\n\\n\"",
"unless",
"@options",
"[",
":simple_list",
"]",
"||",
"@prefix",
".",
"blank?",
"@issues",
".",
"each",
"do",
"|",
"issue",
"|",
"merge_st... | Returns the content of a section.
@return [String] Generate section content | [
"Returns",
"the",
"content",
"of",
"a",
"section",
"."
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/section.rb#L24-L37 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/section.rb | GitHubChangelogGenerator.Section.get_string_for_issue | def get_string_for_issue(issue)
encapsulated_title = encapsulate_string issue["title"]
title_with_number = "#{encapsulated_title} [\\##{issue['number']}](#{issue['html_url']})"
title_with_number = "#{title_with_number}#{line_labels_for(issue)}" if @options[:issue_line_labels].present?
line = is... | ruby | def get_string_for_issue(issue)
encapsulated_title = encapsulate_string issue["title"]
title_with_number = "#{encapsulated_title} [\\##{issue['number']}](#{issue['html_url']})"
title_with_number = "#{title_with_number}#{line_labels_for(issue)}" if @options[:issue_line_labels].present?
line = is... | [
"def",
"get_string_for_issue",
"(",
"issue",
")",
"encapsulated_title",
"=",
"encapsulate_string",
"issue",
"[",
"\"title\"",
"]",
"title_with_number",
"=",
"\"#{encapsulated_title} [\\\\##{issue['number']}](#{issue['html_url']})\"",
"title_with_number",
"=",
"\"#{title_with_number... | Parse issue and generate single line formatted issue line.
Example output:
- Add coveralls integration [\#223](https://github.com/github-changelog-generator/github-changelog-generator/pull/223) (@github-changelog-generator)
@param [Hash] issue Fetched issue from GitHub
@return [String] Markdown-formatted single i... | [
"Parse",
"issue",
"and",
"generate",
"single",
"line",
"formatted",
"issue",
"line",
"."
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/section.rb#L48-L55 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/section.rb | GitHubChangelogGenerator.Section.encapsulate_string | def encapsulate_string(string)
string = string.gsub('\\', '\\\\')
ENCAPSULATED_CHARACTERS.each do |char|
string = string.gsub(char, "\\#{char}")
end
string
end | ruby | def encapsulate_string(string)
string = string.gsub('\\', '\\\\')
ENCAPSULATED_CHARACTERS.each do |char|
string = string.gsub(char, "\\#{char}")
end
string
end | [
"def",
"encapsulate_string",
"(",
"string",
")",
"string",
"=",
"string",
".",
"gsub",
"(",
"'\\\\'",
",",
"'\\\\\\\\'",
")",
"ENCAPSULATED_CHARACTERS",
".",
"each",
"do",
"|",
"char",
"|",
"string",
"=",
"string",
".",
"gsub",
"(",
"char",
",",
"\"\\\\#{c... | Encapsulate characters to make Markdown look as expected.
@param [String] string
@return [String] encapsulated input string | [
"Encapsulate",
"characters",
"to",
"make",
"Markdown",
"look",
"as",
"expected",
"."
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/section.rb#L94-L102 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/generator_fetcher.rb | GitHubChangelogGenerator.Generator.fetch_tags_dates | def fetch_tags_dates(tags)
print "Fetching tag dates...\r" if options[:verbose]
i = 0
tags.each do |tag|
get_time_of_tag(tag)
i += 1
end
puts "Fetching tags dates: #{i}/#{tags.count}" if options[:verbose]
end | ruby | def fetch_tags_dates(tags)
print "Fetching tag dates...\r" if options[:verbose]
i = 0
tags.each do |tag|
get_time_of_tag(tag)
i += 1
end
puts "Fetching tags dates: #{i}/#{tags.count}" if options[:verbose]
end | [
"def",
"fetch_tags_dates",
"(",
"tags",
")",
"print",
"\"Fetching tag dates...\\r\"",
"if",
"options",
"[",
":verbose",
"]",
"i",
"=",
"0",
"tags",
".",
"each",
"do",
"|",
"tag",
"|",
"get_time_of_tag",
"(",
"tag",
")",
"i",
"+=",
"1",
"end",
"puts",
"\"... | Async fetching of all tags dates | [
"Async",
"fetching",
"of",
"all",
"tags",
"dates"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/generator_fetcher.rb#L17-L25 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/generator_fetcher.rb | GitHubChangelogGenerator.Generator.detect_actual_closed_dates | def detect_actual_closed_dates(issues)
print "Fetching closed dates for issues...\r" if options[:verbose]
i = 0
issues.each do |issue|
find_closed_date_by_commit(issue)
i += 1
end
puts "Fetching closed dates for issues: #{i}/#{issues.count}" if options[:verbose]
end | ruby | def detect_actual_closed_dates(issues)
print "Fetching closed dates for issues...\r" if options[:verbose]
i = 0
issues.each do |issue|
find_closed_date_by_commit(issue)
i += 1
end
puts "Fetching closed dates for issues: #{i}/#{issues.count}" if options[:verbose]
end | [
"def",
"detect_actual_closed_dates",
"(",
"issues",
")",
"print",
"\"Fetching closed dates for issues...\\r\"",
"if",
"options",
"[",
":verbose",
"]",
"i",
"=",
"0",
"issues",
".",
"each",
"do",
"|",
"issue",
"|",
"find_closed_date_by_commit",
"(",
"issue",
")",
"... | Find correct closed dates, if issues was closed by commits | [
"Find",
"correct",
"closed",
"dates",
"if",
"issues",
"was",
"closed",
"by",
"commits"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/generator_fetcher.rb#L28-L37 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/generator_fetcher.rb | GitHubChangelogGenerator.Generator.add_first_occurring_tag_to_prs | def add_first_occurring_tag_to_prs(tags, prs)
total = prs.count
prs_left = associate_tagged_prs(tags, prs, total)
prs_left = associate_release_branch_prs(prs_left, total)
prs_left = associate_rebase_comment_prs(tags, prs_left, total) if prs_left.any?
# PRs in prs_left will be untagged, no... | ruby | def add_first_occurring_tag_to_prs(tags, prs)
total = prs.count
prs_left = associate_tagged_prs(tags, prs, total)
prs_left = associate_release_branch_prs(prs_left, total)
prs_left = associate_rebase_comment_prs(tags, prs_left, total) if prs_left.any?
# PRs in prs_left will be untagged, no... | [
"def",
"add_first_occurring_tag_to_prs",
"(",
"tags",
",",
"prs",
")",
"total",
"=",
"prs",
".",
"count",
"prs_left",
"=",
"associate_tagged_prs",
"(",
"tags",
",",
"prs",
",",
"total",
")",
"prs_left",
"=",
"associate_release_branch_prs",
"(",
"prs_left",
",",
... | Adds a key "first_occurring_tag" to each PR with a value of the oldest
tag that a PR's merge commit occurs in in the git history. This should
indicate the release of each PR by git's history regardless of dates and
divergent branches.
@param [Array] tags The tags sorted by time, newest to oldest.
@param [Array] p... | [
"Adds",
"a",
"key",
"first_occurring_tag",
"to",
"each",
"PR",
"with",
"a",
"value",
"of",
"the",
"oldest",
"tag",
"that",
"a",
"PR",
"s",
"merge",
"commit",
"occurs",
"in",
"in",
"the",
"git",
"history",
".",
"This",
"should",
"indicate",
"the",
"releas... | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/generator_fetcher.rb#L47-L58 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/generator_fetcher.rb | GitHubChangelogGenerator.Generator.associate_tagged_prs | def associate_tagged_prs(tags, prs, total)
@fetcher.fetch_tag_shas_async(tags)
i = 0
prs.reject do |pr|
found = false
# XXX Wish I could use merge_commit_sha, but gcg doesn't currently
# fetch that. See
# https://developer.github.com/v3/pulls/#get-a-single-pull-request... | ruby | def associate_tagged_prs(tags, prs, total)
@fetcher.fetch_tag_shas_async(tags)
i = 0
prs.reject do |pr|
found = false
# XXX Wish I could use merge_commit_sha, but gcg doesn't currently
# fetch that. See
# https://developer.github.com/v3/pulls/#get-a-single-pull-request... | [
"def",
"associate_tagged_prs",
"(",
"tags",
",",
"prs",
",",
"total",
")",
"@fetcher",
".",
"fetch_tag_shas_async",
"(",
"tags",
")",
"i",
"=",
"0",
"prs",
".",
"reject",
"do",
"|",
"pr",
"|",
"found",
"=",
"false",
"# XXX Wish I could use merge_commit_sha, bu... | Associate merged PRs by the merge SHA contained in each tag. If the
merge_commit_sha is not found in any tag's history, skip association.
@param [Array] tags The tags sorted by time, newest to oldest.
@param [Array] prs The PRs to associate.
@return [Array] PRs without their merge_commit_sha in a tag. | [
"Associate",
"merged",
"PRs",
"by",
"the",
"merge",
"SHA",
"contained",
"in",
"each",
"tag",
".",
"If",
"the",
"merge_commit_sha",
"is",
"not",
"found",
"in",
"any",
"tag",
"s",
"history",
"skip",
"association",
"."
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/generator_fetcher.rb#L66-L96 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/generator_fetcher.rb | GitHubChangelogGenerator.Generator.set_date_from_event | def set_date_from_event(event, issue)
if event["commit_id"].nil?
issue["actual_date"] = issue["closed_at"]
else
begin
commit = @fetcher.fetch_commit(event["commit_id"])
issue["actual_date"] = commit["commit"]["author"]["date"]
# issue['actual_date'] = commit['a... | ruby | def set_date_from_event(event, issue)
if event["commit_id"].nil?
issue["actual_date"] = issue["closed_at"]
else
begin
commit = @fetcher.fetch_commit(event["commit_id"])
issue["actual_date"] = commit["commit"]["author"]["date"]
# issue['actual_date'] = commit['a... | [
"def",
"set_date_from_event",
"(",
"event",
",",
"issue",
")",
"if",
"event",
"[",
"\"commit_id\"",
"]",
".",
"nil?",
"issue",
"[",
"\"actual_date\"",
"]",
"=",
"issue",
"[",
"\"closed_at\"",
"]",
"else",
"begin",
"commit",
"=",
"@fetcher",
".",
"fetch_commi... | Set closed date from this issue
@param [Hash] event
@param [Hash] issue | [
"Set",
"closed",
"date",
"from",
"this",
"issue"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/generator_fetcher.rb#L177-L191 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/octo_fetcher.rb | GitHubChangelogGenerator.OctoFetcher.calculate_pages | def calculate_pages(client, method, request_options)
# Makes the first API call so that we can call last_response
check_github_response do
client.send(method, user_project, DEFAULT_REQUEST_OPTIONS.merge(request_options))
end
last_response = client.last_response
if (last_pg = last... | ruby | def calculate_pages(client, method, request_options)
# Makes the first API call so that we can call last_response
check_github_response do
client.send(method, user_project, DEFAULT_REQUEST_OPTIONS.merge(request_options))
end
last_response = client.last_response
if (last_pg = last... | [
"def",
"calculate_pages",
"(",
"client",
",",
"method",
",",
"request_options",
")",
"# Makes the first API call so that we can call last_response",
"check_github_response",
"do",
"client",
".",
"send",
"(",
"method",
",",
"user_project",
",",
"DEFAULT_REQUEST_OPTIONS",
"."... | Returns the number of pages for a API call
@return [Integer] number of pages for this API call in total | [
"Returns",
"the",
"number",
"of",
"pages",
"for",
"a",
"API",
"call"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/octo_fetcher.rb#L91-L104 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/octo_fetcher.rb | GitHubChangelogGenerator.OctoFetcher.github_fetch_tags | def github_fetch_tags
tags = []
page_i = 0
count_pages = calculate_pages(@client, "tags", {})
iterate_pages(@client, "tags") do |new_tags|
page_i += PER_PAGE_NUMBER
print_in_same_line("Fetching tags... #{page_i}/#{count_pages * PER_PAGE_NUMBER}")
tags.concat(... | ruby | def github_fetch_tags
tags = []
page_i = 0
count_pages = calculate_pages(@client, "tags", {})
iterate_pages(@client, "tags") do |new_tags|
page_i += PER_PAGE_NUMBER
print_in_same_line("Fetching tags... #{page_i}/#{count_pages * PER_PAGE_NUMBER}")
tags.concat(... | [
"def",
"github_fetch_tags",
"tags",
"=",
"[",
"]",
"page_i",
"=",
"0",
"count_pages",
"=",
"calculate_pages",
"(",
"@client",
",",
"\"tags\"",
",",
"{",
"}",
")",
"iterate_pages",
"(",
"@client",
",",
"\"tags\"",
")",
"do",
"|",
"new_tags",
"|",
"page_i",
... | Fill input array with tags
@return [Array <Hash>] array of tags in repo | [
"Fill",
"input",
"array",
"with",
"tags"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/octo_fetcher.rb#L109-L129 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/octo_fetcher.rb | GitHubChangelogGenerator.OctoFetcher.fetch_events_async | def fetch_events_async(issues)
i = 0
threads = []
issues.each_slice(MAX_THREAD_NUMBER) do |issues_slice|
issues_slice.each do |issue|
threads << Thread.new do
issue["events"] = []
iterate_pages(@client, "issue_events", issue["number"]) do |new_event|
... | ruby | def fetch_events_async(issues)
i = 0
threads = []
issues.each_slice(MAX_THREAD_NUMBER) do |issues_slice|
issues_slice.each do |issue|
threads << Thread.new do
issue["events"] = []
iterate_pages(@client, "issue_events", issue["number"]) do |new_event|
... | [
"def",
"fetch_events_async",
"(",
"issues",
")",
"i",
"=",
"0",
"threads",
"=",
"[",
"]",
"issues",
".",
"each_slice",
"(",
"MAX_THREAD_NUMBER",
")",
"do",
"|",
"issues_slice",
"|",
"issues_slice",
".",
"each",
"do",
"|",
"issue",
"|",
"threads",
"<<",
"... | Fetch event for all issues and add them to 'events'
@param [Array] issues
@return [Void] | [
"Fetch",
"event",
"for",
"all",
"issues",
"and",
"add",
"them",
"to",
"events"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/octo_fetcher.rb#L187-L211 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/octo_fetcher.rb | GitHubChangelogGenerator.OctoFetcher.fetch_comments_async | def fetch_comments_async(prs)
threads = []
prs.each_slice(MAX_THREAD_NUMBER) do |prs_slice|
prs_slice.each do |pr|
threads << Thread.new do
pr["comments"] = []
iterate_pages(@client, "issue_comments", pr["number"]) do |new_comment|
pr["comments"].conc... | ruby | def fetch_comments_async(prs)
threads = []
prs.each_slice(MAX_THREAD_NUMBER) do |prs_slice|
prs_slice.each do |pr|
threads << Thread.new do
pr["comments"] = []
iterate_pages(@client, "issue_comments", pr["number"]) do |new_comment|
pr["comments"].conc... | [
"def",
"fetch_comments_async",
"(",
"prs",
")",
"threads",
"=",
"[",
"]",
"prs",
".",
"each_slice",
"(",
"MAX_THREAD_NUMBER",
")",
"do",
"|",
"prs_slice",
"|",
"prs_slice",
".",
"each",
"do",
"|",
"pr",
"|",
"threads",
"<<",
"Thread",
".",
"new",
"do",
... | Fetch comments for PRs and add them to "comments"
@param [Array] prs The array of PRs.
@return [Void] No return; PRs are updated in-place. | [
"Fetch",
"comments",
"for",
"PRs",
"and",
"add",
"them",
"to",
"comments"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/octo_fetcher.rb#L217-L234 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/octo_fetcher.rb | GitHubChangelogGenerator.OctoFetcher.fetch_date_of_tag | def fetch_date_of_tag(tag)
commit_data = fetch_commit(tag["commit"]["sha"])
commit_data = stringify_keys_deep(commit_data.to_hash)
commit_data["commit"]["committer"]["date"]
end | ruby | def fetch_date_of_tag(tag)
commit_data = fetch_commit(tag["commit"]["sha"])
commit_data = stringify_keys_deep(commit_data.to_hash)
commit_data["commit"]["committer"]["date"]
end | [
"def",
"fetch_date_of_tag",
"(",
"tag",
")",
"commit_data",
"=",
"fetch_commit",
"(",
"tag",
"[",
"\"commit\"",
"]",
"[",
"\"sha\"",
"]",
")",
"commit_data",
"=",
"stringify_keys_deep",
"(",
"commit_data",
".",
"to_hash",
")",
"commit_data",
"[",
"\"commit\"",
... | Fetch tag time from repo
@param [Hash] tag GitHub data item about a Tag
@return [Time] time of specified tag | [
"Fetch",
"tag",
"time",
"from",
"repo"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/octo_fetcher.rb#L241-L246 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/octo_fetcher.rb | GitHubChangelogGenerator.OctoFetcher.fetch_compare | def fetch_compare(older, newer)
unless @compares["#{older}...#{newer}"]
compare_data = check_github_response { @client.compare(user_project, older, newer || "HEAD") }
raise StandardError, "Sha #{older} and sha #{newer} are not related; please file a github-changelog-generator issues and describe h... | ruby | def fetch_compare(older, newer)
unless @compares["#{older}...#{newer}"]
compare_data = check_github_response { @client.compare(user_project, older, newer || "HEAD") }
raise StandardError, "Sha #{older} and sha #{newer} are not related; please file a github-changelog-generator issues and describe h... | [
"def",
"fetch_compare",
"(",
"older",
",",
"newer",
")",
"unless",
"@compares",
"[",
"\"#{older}...#{newer}\"",
"]",
"compare_data",
"=",
"check_github_response",
"{",
"@client",
".",
"compare",
"(",
"user_project",
",",
"older",
",",
"newer",
"||",
"\"HEAD\"",
... | Fetch and cache comparison between two github refs
@param [String] older The older sha/tag/branch.
@param [String] newer The newer sha/tag/branch.
@return [Hash] Github api response for comparison. | [
"Fetch",
"and",
"cache",
"comparison",
"between",
"two",
"github",
"refs"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/octo_fetcher.rb#L253-L261 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/octo_fetcher.rb | GitHubChangelogGenerator.OctoFetcher.fetch_commit | def fetch_commit(commit_id)
found = commits.find do |commit|
commit["sha"] == commit_id
end
if found
stringify_keys_deep(found.to_hash)
else
# cache miss; don't add to @commits because unsure of order.
check_github_response do
commit = @client.commit(use... | ruby | def fetch_commit(commit_id)
found = commits.find do |commit|
commit["sha"] == commit_id
end
if found
stringify_keys_deep(found.to_hash)
else
# cache miss; don't add to @commits because unsure of order.
check_github_response do
commit = @client.commit(use... | [
"def",
"fetch_commit",
"(",
"commit_id",
")",
"found",
"=",
"commits",
".",
"find",
"do",
"|",
"commit",
"|",
"commit",
"[",
"\"sha\"",
"]",
"==",
"commit_id",
"end",
"if",
"found",
"stringify_keys_deep",
"(",
"found",
".",
"to_hash",
")",
"else",
"# cache... | Fetch commit for specified event
@param [String] commit_id the SHA of a commit to fetch
@return [Hash] | [
"Fetch",
"commit",
"for",
"specified",
"event"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/octo_fetcher.rb#L267-L281 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/octo_fetcher.rb | GitHubChangelogGenerator.OctoFetcher.fetch_tag_shas_async | def fetch_tag_shas_async(tags)
i = 0
threads = []
print_in_same_line("Fetching SHAs for tags: #{i}/#{tags.count}\r") if @options[:verbose]
tags.each_slice(MAX_THREAD_NUMBER) do |tags_slice|
tags_slice.each do |tag|
threads << Thread.new do
# Use oldest commit becau... | ruby | def fetch_tag_shas_async(tags)
i = 0
threads = []
print_in_same_line("Fetching SHAs for tags: #{i}/#{tags.count}\r") if @options[:verbose]
tags.each_slice(MAX_THREAD_NUMBER) do |tags_slice|
tags_slice.each do |tag|
threads << Thread.new do
# Use oldest commit becau... | [
"def",
"fetch_tag_shas_async",
"(",
"tags",
")",
"i",
"=",
"0",
"threads",
"=",
"[",
"]",
"print_in_same_line",
"(",
"\"Fetching SHAs for tags: #{i}/#{tags.count}\\r\"",
")",
"if",
"@options",
"[",
":verbose",
"]",
"tags",
".",
"each_slice",
"(",
"MAX_THREAD_NUMBER"... | Fetch all SHAs occurring in or before a given tag and add them to
"shas_in_tag"
@param [Array] tags The array of tags.
@return [Nil] No return; tags are updated in-place. | [
"Fetch",
"all",
"SHAs",
"occurring",
"in",
"or",
"before",
"a",
"given",
"tag",
"and",
"add",
"them",
"to",
"shas_in_tag"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/octo_fetcher.rb#L312-L336 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/octo_fetcher.rb | GitHubChangelogGenerator.OctoFetcher.check_github_response | def check_github_response
Retriable.retriable(retry_options) do
yield
end
rescue MovedPermanentlyError => e
fail_with_message(e, "The repository has moved, update your configuration")
rescue Octokit::Forbidden => e
fail_with_message(e, "Exceeded retry limit")
rescue Octokit::... | ruby | def check_github_response
Retriable.retriable(retry_options) do
yield
end
rescue MovedPermanentlyError => e
fail_with_message(e, "The repository has moved, update your configuration")
rescue Octokit::Forbidden => e
fail_with_message(e, "Exceeded retry limit")
rescue Octokit::... | [
"def",
"check_github_response",
"Retriable",
".",
"retriable",
"(",
"retry_options",
")",
"do",
"yield",
"end",
"rescue",
"MovedPermanentlyError",
"=>",
"e",
"fail_with_message",
"(",
"e",
",",
"\"The repository has moved, update your configuration\"",
")",
"rescue",
"Oct... | This is wrapper with rescue block
@return [Object] returns exactly the same, what you put in the block, but wrap it with begin-rescue block | [
"This",
"is",
"wrapper",
"with",
"rescue",
"block"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/octo_fetcher.rb#L396-L406 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/generator_tags.rb | GitHubChangelogGenerator.Generator.fetch_and_filter_tags | def fetch_and_filter_tags
since_tag
due_tag
all_tags = @fetcher.get_all_tags
fetch_tags_dates(all_tags) # Creates a Hash @tag_times_hash
all_sorted_tags = sort_tags_by_date(all_tags)
@sorted_tags = filter_excluded_tags(all_sorted_tags)
@filtered_tags = get_filtered_tags(@so... | ruby | def fetch_and_filter_tags
since_tag
due_tag
all_tags = @fetcher.get_all_tags
fetch_tags_dates(all_tags) # Creates a Hash @tag_times_hash
all_sorted_tags = sort_tags_by_date(all_tags)
@sorted_tags = filter_excluded_tags(all_sorted_tags)
@filtered_tags = get_filtered_tags(@so... | [
"def",
"fetch_and_filter_tags",
"since_tag",
"due_tag",
"all_tags",
"=",
"@fetcher",
".",
"get_all_tags",
"fetch_tags_dates",
"(",
"all_tags",
")",
"# Creates a Hash @tag_times_hash",
"all_sorted_tags",
"=",
"sort_tags_by_date",
"(",
"all_tags",
")",
"@sorted_tags",
"=",
... | fetch, filter tags, fetch dates and sort them in time order | [
"fetch",
"filter",
"tags",
"fetch",
"dates",
"and",
"sort",
"them",
"in",
"time",
"order"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/generator_tags.rb#L6-L25 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/generator_tags.rb | GitHubChangelogGenerator.Generator.get_time_of_tag | def get_time_of_tag(tag_name)
raise ChangelogGeneratorError, "tag_name is nil" if tag_name.nil?
name_of_tag = tag_name.fetch("name")
time_for_tag_name = @tag_times_hash[name_of_tag]
return time_for_tag_name if time_for_tag_name
@fetcher.fetch_date_of_tag(tag_name).tap do |time_string|
... | ruby | def get_time_of_tag(tag_name)
raise ChangelogGeneratorError, "tag_name is nil" if tag_name.nil?
name_of_tag = tag_name.fetch("name")
time_for_tag_name = @tag_times_hash[name_of_tag]
return time_for_tag_name if time_for_tag_name
@fetcher.fetch_date_of_tag(tag_name).tap do |time_string|
... | [
"def",
"get_time_of_tag",
"(",
"tag_name",
")",
"raise",
"ChangelogGeneratorError",
",",
"\"tag_name is nil\"",
"if",
"tag_name",
".",
"nil?",
"name_of_tag",
"=",
"tag_name",
".",
"fetch",
"(",
"\"name\"",
")",
"time_for_tag_name",
"=",
"@tag_times_hash",
"[",
"name... | Returns date for given GitHub Tag hash
Memoize the date by tag name.
@param [Hash] tag_name
@return [Time] time of specified tag | [
"Returns",
"date",
"for",
"given",
"GitHub",
"Tag",
"hash"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/generator_tags.rb#L68-L78 | train |
Subsets and Splits
SQL Console for semeru/code-text-ruby
Retrieves 20,000 non-null code samples labeled as Ruby, providing a basic overview of the dataset but without deeper analysis.