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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/generator_tags.rb | GitHubChangelogGenerator.Generator.detect_link_tag_time | def detect_link_tag_time(newer_tag)
# if tag is nil - set current time
newer_tag_time = newer_tag.nil? ? Time.new : get_time_of_tag(newer_tag)
# if it's future release tag - set this value
if newer_tag.nil? && options[:future_release]
newer_tag_name = options[:future_release]
ne... | ruby | def detect_link_tag_time(newer_tag)
# if tag is nil - set current time
newer_tag_time = newer_tag.nil? ? Time.new : get_time_of_tag(newer_tag)
# if it's future release tag - set this value
if newer_tag.nil? && options[:future_release]
newer_tag_name = options[:future_release]
ne... | [
"def",
"detect_link_tag_time",
"(",
"newer_tag",
")",
"# if tag is nil - set current time",
"newer_tag_time",
"=",
"newer_tag",
".",
"nil?",
"?",
"Time",
".",
"new",
":",
"get_time_of_tag",
"(",
"newer_tag",
")",
"# if it's future release tag - set this value",
"if",
"new... | Detect link, name and time for specified tag.
@param [Hash] newer_tag newer tag. Can be nil, if it's Unreleased section.
@return [Array] link, name and time of the tag | [
"Detect",
"link",
"name",
"and",
"time",
"for",
"specified",
"tag",
"."
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/generator_tags.rb#L84-L98 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/reader.rb | GitHubChangelogGenerator.Reader.parse_heading | def parse_heading(heading)
captures = { "version" => nil, "url" => nil, "date" => nil }
@heading_structures.each do |regexp|
matches = Regexp.new(regexp).match(heading)
if matches
captures.merge!(Hash[matches.names.zip(matches.captures)])
break
end
end
... | ruby | def parse_heading(heading)
captures = { "version" => nil, "url" => nil, "date" => nil }
@heading_structures.each do |regexp|
matches = Regexp.new(regexp).match(heading)
if matches
captures.merge!(Hash[matches.names.zip(matches.captures)])
break
end
end
... | [
"def",
"parse_heading",
"(",
"heading",
")",
"captures",
"=",
"{",
"\"version\"",
"=>",
"nil",
",",
"\"url\"",
"=>",
"nil",
",",
"\"date\"",
"=>",
"nil",
"}",
"@heading_structures",
".",
"each",
"do",
"|",
"regexp",
"|",
"matches",
"=",
"Regexp",
".",
"n... | Parse a single heading and return a Hash
The following heading structures are currently valid:
- ## [v1.0.2](https://github.com/zanui/chef-thumbor/tree/v1.0.1) (2015-03-24)
- ## [v1.0.2](https://github.com/zanui/chef-thumbor/tree/v1.0.1)
- ## v1.0.2 (2015-03-24)
- ## v1.0.2
@param [String] heading Heading from ... | [
"Parse",
"a",
"single",
"heading",
"and",
"return",
"a",
"Hash"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/reader.rb#L53-L65 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/reader.rb | GitHubChangelogGenerator.Reader.parse | def parse(data)
sections = data.split(/^## .+?$/)
headings = data.scan(/^## .+?$/)
headings.each_with_index.map do |heading, index|
section = parse_heading(heading)
section["content"] = sections.at(index + 1)
section
end
end | ruby | def parse(data)
sections = data.split(/^## .+?$/)
headings = data.scan(/^## .+?$/)
headings.each_with_index.map do |heading, index|
section = parse_heading(heading)
section["content"] = sections.at(index + 1)
section
end
end | [
"def",
"parse",
"(",
"data",
")",
"sections",
"=",
"data",
".",
"split",
"(",
"/",
"/",
")",
"headings",
"=",
"data",
".",
"scan",
"(",
"/",
"/",
")",
"headings",
".",
"each_with_index",
".",
"map",
"do",
"|",
"heading",
",",
"index",
"|",
"section... | Parse the given ChangeLog data into a list of Hashes
@param [String] data File data from the ChangeLog.md
@return [Array<Hash>] Parsed data, e.g. [{ 'version' => ..., 'url' => ..., 'date' => ..., 'content' => ...}, ...] | [
"Parse",
"the",
"given",
"ChangeLog",
"data",
"into",
"a",
"list",
"of",
"Hashes"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/reader.rb#L71-L80 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/generator_processor.rb | GitHubChangelogGenerator.Generator.find_issues_to_add | def find_issues_to_add(all_issues, tag_name)
all_issues.select do |issue|
if issue["milestone"].nil?
false
else
# check, that this milestone in tag list:
milestone_is_tag = @filtered_tags.find do |tag|
tag["name"] == issue["milestone"]["title"]
e... | ruby | def find_issues_to_add(all_issues, tag_name)
all_issues.select do |issue|
if issue["milestone"].nil?
false
else
# check, that this milestone in tag list:
milestone_is_tag = @filtered_tags.find do |tag|
tag["name"] == issue["milestone"]["title"]
e... | [
"def",
"find_issues_to_add",
"(",
"all_issues",
",",
"tag_name",
")",
"all_issues",
".",
"select",
"do",
"|",
"issue",
"|",
"if",
"issue",
"[",
"\"milestone\"",
"]",
".",
"nil?",
"false",
"else",
"# check, that this milestone in tag list:",
"milestone_is_tag",
"=",
... | Add all issues, that should be in that tag, according milestone
@param [Array] all_issues
@param [String] tag_name
@return [Array] issues with milestone #tag_name | [
"Add",
"all",
"issues",
"that",
"should",
"be",
"in",
"that",
"tag",
"according",
"milestone"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/generator_processor.rb#L47-L64 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/generator_processor.rb | GitHubChangelogGenerator.Generator.filter_array_by_labels | def filter_array_by_labels(all_issues)
filtered_issues = include_issues_by_labels(all_issues)
filtered_issues = exclude_issues_by_labels(filtered_issues)
exclude_issues_without_labels(filtered_issues)
end | ruby | def filter_array_by_labels(all_issues)
filtered_issues = include_issues_by_labels(all_issues)
filtered_issues = exclude_issues_by_labels(filtered_issues)
exclude_issues_without_labels(filtered_issues)
end | [
"def",
"filter_array_by_labels",
"(",
"all_issues",
")",
"filtered_issues",
"=",
"include_issues_by_labels",
"(",
"all_issues",
")",
"filtered_issues",
"=",
"exclude_issues_by_labels",
"(",
"filtered_issues",
")",
"exclude_issues_without_labels",
"(",
"filtered_issues",
")",
... | General filtered function
@param [Array] all_issues PRs or issues
@return [Array] filtered issues | [
"General",
"filtered",
"function"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/generator_processor.rb#L186-L190 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/entry.rb | GitHubChangelogGenerator.Entry.generate_entry_for_tag | def generate_entry_for_tag(pull_requests, issues, newer_tag_name, newer_tag_link, newer_tag_time, older_tag_name) # rubocop:disable Metrics/ParameterLists
github_site = @options[:github_site] || "https://github.com"
project_url = "#{github_site}/#{@options[:user]}/#{@options[:project]}"
create_sectio... | ruby | def generate_entry_for_tag(pull_requests, issues, newer_tag_name, newer_tag_link, newer_tag_time, older_tag_name) # rubocop:disable Metrics/ParameterLists
github_site = @options[:github_site] || "https://github.com"
project_url = "#{github_site}/#{@options[:user]}/#{@options[:project]}"
create_sectio... | [
"def",
"generate_entry_for_tag",
"(",
"pull_requests",
",",
"issues",
",",
"newer_tag_name",
",",
"newer_tag_link",
",",
"newer_tag_time",
",",
"older_tag_name",
")",
"# rubocop:disable Metrics/ParameterLists",
"github_site",
"=",
"@options",
"[",
":github_site",
"]",
"||... | Generates log entry with header and body
@param [Array] pull_requests List or PR's in new section
@param [Array] issues List of issues in new section
@param [String] newer_tag_name Name of the newer tag. Could be nil for `Unreleased` section.
@param [String] newer_tag_link Name of the newer tag. Could be "HEAD" fo... | [
"Generates",
"log",
"entry",
"with",
"header",
"and",
"body"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/entry.rb#L32-L41 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/entry.rb | GitHubChangelogGenerator.Entry.generate_header | def generate_header(newer_tag_name, newer_tag_link, newer_tag_time, older_tag_name, project_url)
header = ""
# Generate date string:
time_string = newer_tag_time.strftime(@options[:date_format])
# Generate tag name and link
release_url = if @options[:release_url]
fo... | ruby | def generate_header(newer_tag_name, newer_tag_link, newer_tag_time, older_tag_name, project_url)
header = ""
# Generate date string:
time_string = newer_tag_time.strftime(@options[:date_format])
# Generate tag name and link
release_url = if @options[:release_url]
fo... | [
"def",
"generate_header",
"(",
"newer_tag_name",
",",
"newer_tag_link",
",",
"newer_tag_time",
",",
"older_tag_name",
",",
"project_url",
")",
"header",
"=",
"\"\"",
"# Generate date string:",
"time_string",
"=",
"newer_tag_time",
".",
"strftime",
"(",
"@options",
"["... | Generates header text for an entry.
@param [String] newer_tag_name The name of a newer tag
@param [String] newer_tag_link Used for URL generation. Could be same as #newer_tag_name or some specific value, like HEAD
@param [Time] newer_tag_time Time when the newer tag was created
@param [String] older_tag_name The n... | [
"Generates",
"header",
"text",
"for",
"an",
"entry",
"."
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/entry.rb#L87-L111 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/entry.rb | GitHubChangelogGenerator.Entry.sort_into_sections | def sort_into_sections(pull_requests, issues)
if @options[:issues]
unmapped_issues = sort_labeled_issues(issues)
add_unmapped_section(unmapped_issues)
end
if @options[:pulls]
unmapped_pull_requests = sort_labeled_issues(pull_requests)
add_unmapped_section(unmapped_pull_... | ruby | def sort_into_sections(pull_requests, issues)
if @options[:issues]
unmapped_issues = sort_labeled_issues(issues)
add_unmapped_section(unmapped_issues)
end
if @options[:pulls]
unmapped_pull_requests = sort_labeled_issues(pull_requests)
add_unmapped_section(unmapped_pull_... | [
"def",
"sort_into_sections",
"(",
"pull_requests",
",",
"issues",
")",
"if",
"@options",
"[",
":issues",
"]",
"unmapped_issues",
"=",
"sort_labeled_issues",
"(",
"issues",
")",
"add_unmapped_section",
"(",
"unmapped_issues",
")",
"end",
"if",
"@options",
"[",
":pu... | Sorts issues and PRs into entry sections by labels and lack of labels.
@param [Array] pull_requests
@param [Array] issues
@return [Nil] | [
"Sorts",
"issues",
"and",
"PRs",
"into",
"entry",
"sections",
"by",
"labels",
"and",
"lack",
"of",
"labels",
"."
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/entry.rb#L143-L153 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/entry.rb | GitHubChangelogGenerator.Entry.sort_labeled_issues | def sort_labeled_issues(issues)
sorted_issues = []
issues.each do |issue|
label_names = issue["labels"].collect { |l| l["name"] }
# Add PRs in the order of the @sections array. This will either be the
# default sections followed by any --add-sections sections in
# user-defin... | ruby | def sort_labeled_issues(issues)
sorted_issues = []
issues.each do |issue|
label_names = issue["labels"].collect { |l| l["name"] }
# Add PRs in the order of the @sections array. This will either be the
# default sections followed by any --add-sections sections in
# user-defin... | [
"def",
"sort_labeled_issues",
"(",
"issues",
")",
"sorted_issues",
"=",
"[",
"]",
"issues",
".",
"each",
"do",
"|",
"issue",
"|",
"label_names",
"=",
"issue",
"[",
"\"labels\"",
"]",
".",
"collect",
"{",
"|",
"l",
"|",
"l",
"[",
"\"name\"",
"]",
"}",
... | Iterates through sections and sorts labeled issues into them based on
the label mapping. Returns any unmapped or unlabeled issues.
@param [Array] issues Issues or pull requests.
@return [Array] Issues that were not mapped into any sections. | [
"Iterates",
"through",
"sections",
"and",
"sorts",
"labeled",
"issues",
"into",
"them",
"based",
"on",
"the",
"label",
"mapping",
".",
"Returns",
"any",
"unmapped",
"or",
"unlabeled",
"issues",
"."
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/entry.rb#L160-L179 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/parser_file.rb | GitHubChangelogGenerator.ParserFile.extract_pair | def extract_pair(line)
key, value = line.split("=", 2)
[key.tr("-", "_").to_sym, value.gsub(/[\n\r]+/, "")]
end | ruby | def extract_pair(line)
key, value = line.split("=", 2)
[key.tr("-", "_").to_sym, value.gsub(/[\n\r]+/, "")]
end | [
"def",
"extract_pair",
"(",
"line",
")",
"key",
",",
"value",
"=",
"line",
".",
"split",
"(",
"\"=\"",
",",
"2",
")",
"[",
"key",
".",
"tr",
"(",
"\"-\"",
",",
"\"_\"",
")",
".",
"to_sym",
",",
"value",
".",
"gsub",
"(",
"/",
"\\n",
"\\r",
"/",... | Returns a the option name as a symbol and its string value sans newlines.
@param line [String] unparsed line from config file
@return [Array<Symbol, String>] | [
"Returns",
"a",
"the",
"option",
"name",
"as",
"a",
"symbol",
"and",
"its",
"string",
"value",
"sans",
"newlines",
"."
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/parser_file.rb#L66-L69 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator.rb | GitHubChangelogGenerator.ChangelogGenerator.run | def run
log = @generator.compound_changelog
if @options.write_to_file?
output_filename = @options[:output].to_s
File.open(output_filename, "wb") { |file| file.write(log) }
puts "Done!"
puts "Generated log placed in #{Dir.pwd}/#{output_filename}"
else
puts log
... | ruby | def run
log = @generator.compound_changelog
if @options.write_to_file?
output_filename = @options[:output].to_s
File.open(output_filename, "wb") { |file| file.write(log) }
puts "Done!"
puts "Generated log placed in #{Dir.pwd}/#{output_filename}"
else
puts log
... | [
"def",
"run",
"log",
"=",
"@generator",
".",
"compound_changelog",
"if",
"@options",
".",
"write_to_file?",
"output_filename",
"=",
"@options",
"[",
":output",
"]",
".",
"to_s",
"File",
".",
"open",
"(",
"output_filename",
",",
"\"wb\"",
")",
"{",
"|",
"file... | Class, responsible for whole changelog generation cycle
@return initialised instance of ChangelogGenerator
The entry point of this script to generate changelog
@raise (ChangelogGeneratorError) Is thrown when one of specified tags was not found in list of tags. | [
"Class",
"responsible",
"for",
"whole",
"changelog",
"generation",
"cycle"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator.rb#L34-L45 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/generator.rb | GitHubChangelogGenerator.Generator.generate_entry_between_tags | def generate_entry_between_tags(older_tag, newer_tag)
filtered_issues, filtered_pull_requests = filter_issues_for_tags(newer_tag, older_tag)
if newer_tag.nil? && filtered_issues.empty? && filtered_pull_requests.empty?
# do not generate empty unreleased section
return ""
end
new... | ruby | def generate_entry_between_tags(older_tag, newer_tag)
filtered_issues, filtered_pull_requests = filter_issues_for_tags(newer_tag, older_tag)
if newer_tag.nil? && filtered_issues.empty? && filtered_pull_requests.empty?
# do not generate empty unreleased section
return ""
end
new... | [
"def",
"generate_entry_between_tags",
"(",
"older_tag",
",",
"newer_tag",
")",
"filtered_issues",
",",
"filtered_pull_requests",
"=",
"filter_issues_for_tags",
"(",
"newer_tag",
",",
"older_tag",
")",
"if",
"newer_tag",
".",
"nil?",
"&&",
"filtered_issues",
".",
"empt... | Generate log only between 2 specified tags
@param [String] older_tag all issues before this tag date will be excluded. May be nil, if it's first tag
@param [String] newer_tag all issue after this tag will be excluded. May be nil for unreleased section | [
"Generate",
"log",
"only",
"between",
"2",
"specified",
"tags"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/generator.rb#L73-L93 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/generator.rb | GitHubChangelogGenerator.Generator.filter_issues_for_tags | def filter_issues_for_tags(newer_tag, older_tag)
filtered_pull_requests = filter_by_tag(@pull_requests, newer_tag)
filtered_issues = delete_by_time(@issues, "actual_date", older_tag, newer_tag)
newer_tag_name = newer_tag.nil? ? nil : newer_tag["name"]
if options[:filter_issues_by_milest... | ruby | def filter_issues_for_tags(newer_tag, older_tag)
filtered_pull_requests = filter_by_tag(@pull_requests, newer_tag)
filtered_issues = delete_by_time(@issues, "actual_date", older_tag, newer_tag)
newer_tag_name = newer_tag.nil? ? nil : newer_tag["name"]
if options[:filter_issues_by_milest... | [
"def",
"filter_issues_for_tags",
"(",
"newer_tag",
",",
"older_tag",
")",
"filtered_pull_requests",
"=",
"filter_by_tag",
"(",
"@pull_requests",
",",
"newer_tag",
")",
"filtered_issues",
"=",
"delete_by_time",
"(",
"@issues",
",",
"\"actual_date\"",
",",
"older_tag",
... | Filters issues and pull requests based on, respectively, `actual_date`
and `merged_at` timestamp fields. `actual_date` is the detected form of
`closed_at` based on merge event SHA commit times.
@return [Array] filtered issues and pull requests | [
"Filters",
"issues",
"and",
"pull",
"requests",
"based",
"on",
"respectively",
"actual_date",
"and",
"merged_at",
"timestamp",
"fields",
".",
"actual_date",
"is",
"the",
"detected",
"form",
"of",
"closed_at",
"based",
"on",
"merge",
"event",
"SHA",
"commit",
"ti... | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/generator.rb#L100-L112 | train |
github-changelog-generator/github-changelog-generator | lib/github_changelog_generator/generator/generator.rb | GitHubChangelogGenerator.Generator.generate_entries_for_all_tags | def generate_entries_for_all_tags
puts "Generating entry..." if options[:verbose]
entries = generate_unreleased_entry
@tag_section_mapping.each_pair do |_tag_section, left_right_tags|
older_tag, newer_tag = left_right_tags
entries += generate_entry_between_tags(older_tag, newer_tag)
... | ruby | def generate_entries_for_all_tags
puts "Generating entry..." if options[:verbose]
entries = generate_unreleased_entry
@tag_section_mapping.each_pair do |_tag_section, left_right_tags|
older_tag, newer_tag = left_right_tags
entries += generate_entry_between_tags(older_tag, newer_tag)
... | [
"def",
"generate_entries_for_all_tags",
"puts",
"\"Generating entry...\"",
"if",
"options",
"[",
":verbose",
"]",
"entries",
"=",
"generate_unreleased_entry",
"@tag_section_mapping",
".",
"each_pair",
"do",
"|",
"_tag_section",
",",
"left_right_tags",
"|",
"older_tag",
",... | The full cycle of generation for whole project
@return [String] All entries in the changelog | [
"The",
"full",
"cycle",
"of",
"generation",
"for",
"whole",
"project"
] | f18c64b5cc0d7473b059275b88385ac11ca8b564 | https://github.com/github-changelog-generator/github-changelog-generator/blob/f18c64b5cc0d7473b059275b88385ac11ca8b564/lib/github_changelog_generator/generator/generator.rb#L116-L127 | train |
hanami/hanami | lib/hanami/environment.rb | Hanami.Environment.to_options | def to_options
@options.merge(
environment: environment,
env_config: env_config,
apps_path: apps_path,
rackup: rackup,
host: host,
port: port
)
end | ruby | def to_options
@options.merge(
environment: environment,
env_config: env_config,
apps_path: apps_path,
rackup: rackup,
host: host,
port: port
)
end | [
"def",
"to_options",
"@options",
".",
"merge",
"(",
"environment",
":",
"environment",
",",
"env_config",
":",
"env_config",
",",
"apps_path",
":",
"apps_path",
",",
"rackup",
":",
"rackup",
",",
"host",
":",
"host",
",",
"port",
":",
"port",
")",
"end"
] | Serialize the most relevant settings into a Hash
@return [::Hash]
@since 0.1.0
@api private | [
"Serialize",
"the",
"most",
"relevant",
"settings",
"into",
"a",
"Hash"
] | 8c6e5147e92ef869b25379448572da3698eacfdc | https://github.com/hanami/hanami/blob/8c6e5147e92ef869b25379448572da3698eacfdc/lib/hanami/environment.rb#L456-L465 | train |
hanami/hanami | lib/hanami/application_configuration.rb | Hanami.ApplicationConfiguration.root | def root(value = nil)
if value
@root = value
else
Utils::Kernel.Pathname(@root || Dir.pwd).realpath
end
end | ruby | def root(value = nil)
if value
@root = value
else
Utils::Kernel.Pathname(@root || Dir.pwd).realpath
end
end | [
"def",
"root",
"(",
"value",
"=",
"nil",
")",
"if",
"value",
"@root",
"=",
"value",
"else",
"Utils",
"::",
"Kernel",
".",
"Pathname",
"(",
"@root",
"||",
"Dir",
".",
"pwd",
")",
".",
"realpath",
"end",
"end"
] | The root of the application
By default it returns the current directory, for this reason, **all the
commands must be executed from the top level directory of the project**.
If for some reason, that constraint above cannot be satisfied, please
configure the root directory, so that commands can be executed from
ev... | [
"The",
"root",
"of",
"the",
"application"
] | 8c6e5147e92ef869b25379448572da3698eacfdc | https://github.com/hanami/hanami/blob/8c6e5147e92ef869b25379448572da3698eacfdc/lib/hanami/application_configuration.rb#L151-L157 | train |
hanami/hanami | lib/hanami/application_configuration.rb | Hanami.ApplicationConfiguration.routes | def routes(path = nil, &blk)
if path or block_given?
@routes = Config::Routes.new(root, path, &blk)
else
@routes
end
end | ruby | def routes(path = nil, &blk)
if path or block_given?
@routes = Config::Routes.new(root, path, &blk)
else
@routes
end
end | [
"def",
"routes",
"(",
"path",
"=",
"nil",
",",
"&",
"blk",
")",
"if",
"path",
"or",
"block_given?",
"@routes",
"=",
"Config",
"::",
"Routes",
".",
"new",
"(",
"root",
",",
"path",
",",
"blk",
")",
"else",
"@routes",
"end",
"end"
] | Application routes.
Specify a set of routes for the application, by passing a block, or a
relative path where to find the file that describes them.
By default it's `nil`.
This is part of a DSL, for this reason when this method is called with
an argument, it will set the corresponding instance variable. When
ca... | [
"Application",
"routes",
"."
] | 8c6e5147e92ef869b25379448572da3698eacfdc | https://github.com/hanami/hanami/blob/8c6e5147e92ef869b25379448572da3698eacfdc/lib/hanami/application_configuration.rb#L583-L589 | train |
hanami/hanami | lib/hanami/application_configuration.rb | Hanami.ApplicationConfiguration.port | def port(value = nil)
if value
@port = Integer(value)
else
return @port if defined?(@port)
return @env.port unless @env.default_port?
return DEFAULT_SSL_PORT if force_ssl
@env.port
end
end | ruby | def port(value = nil)
if value
@port = Integer(value)
else
return @port if defined?(@port)
return @env.port unless @env.default_port?
return DEFAULT_SSL_PORT if force_ssl
@env.port
end
end | [
"def",
"port",
"(",
"value",
"=",
"nil",
")",
"if",
"value",
"@port",
"=",
"Integer",
"(",
"value",
")",
"else",
"return",
"@port",
"if",
"defined?",
"(",
"@port",
")",
"return",
"@env",
".",
"port",
"unless",
"@env",
".",
"default_port?",
"return",
"D... | The URI port for this application.
This is used by the router helpers to generate absolute URLs.
By default this value is `2300`.
This is part of a DSL, for this reason when this method is called with
an argument, it will set the corresponding instance variable. When
called without, it will return the already se... | [
"The",
"URI",
"port",
"for",
"this",
"application",
".",
"This",
"is",
"used",
"by",
"the",
"router",
"helpers",
"to",
"generate",
"absolute",
"URLs",
"."
] | 8c6e5147e92ef869b25379448572da3698eacfdc | https://github.com/hanami/hanami/blob/8c6e5147e92ef869b25379448572da3698eacfdc/lib/hanami/application_configuration.rb#L1003-L1012 | train |
hanami/hanami | lib/hanami/env.rb | Hanami.Env.load! | def load!(path)
return unless defined?(Dotenv::Parser)
contents = ::File.open(path, "rb:bom|utf-8", &:read)
parsed = Dotenv::Parser.call(contents)
parsed.each do |k, v|
next if @env.has_key?(k)
@env[k] = v
end
nil
end | ruby | def load!(path)
return unless defined?(Dotenv::Parser)
contents = ::File.open(path, "rb:bom|utf-8", &:read)
parsed = Dotenv::Parser.call(contents)
parsed.each do |k, v|
next if @env.has_key?(k)
@env[k] = v
end
nil
end | [
"def",
"load!",
"(",
"path",
")",
"return",
"unless",
"defined?",
"(",
"Dotenv",
"::",
"Parser",
")",
"contents",
"=",
"::",
"File",
".",
"open",
"(",
"path",
",",
"\"rb:bom|utf-8\"",
",",
":read",
")",
"parsed",
"=",
"Dotenv",
"::",
"Parser",
".",
"ca... | Loads a dotenv file and updates self
@param path [String, Pathname] the path to the dotenv file
@return void
@since 0.9.0
@api private | [
"Loads",
"a",
"dotenv",
"file",
"and",
"updates",
"self"
] | 8c6e5147e92ef869b25379448572da3698eacfdc | https://github.com/hanami/hanami/blob/8c6e5147e92ef869b25379448572da3698eacfdc/lib/hanami/env.rb#L55-L67 | train |
hanami/hanami | lib/hanami/hanamirc.rb | Hanami.Hanamirc.default_options | def default_options
@default_options ||= Utils::Hash.symbolize({
PROJECT_NAME => project_name,
TEST_KEY => DEFAULT_TEST_SUITE,
TEMPLATE_KEY => DEFAULT_TEMPLATE
... | ruby | def default_options
@default_options ||= Utils::Hash.symbolize({
PROJECT_NAME => project_name,
TEST_KEY => DEFAULT_TEST_SUITE,
TEMPLATE_KEY => DEFAULT_TEMPLATE
... | [
"def",
"default_options",
"@default_options",
"||=",
"Utils",
"::",
"Hash",
".",
"symbolize",
"(",
"{",
"PROJECT_NAME",
"=>",
"project_name",
",",
"TEST_KEY",
"=>",
"DEFAULT_TEST_SUITE",
",",
"TEMPLATE_KEY",
"=>",
"DEFAULT_TEMPLATE",
"}",
")",
".",
"freeze",
"end"... | Default values for writing the hanamirc file
@since 0.5.1
@api private
@see Hanami::Hanamirc#options | [
"Default",
"values",
"for",
"writing",
"the",
"hanamirc",
"file"
] | 8c6e5147e92ef869b25379448572da3698eacfdc | https://github.com/hanami/hanami/blob/8c6e5147e92ef869b25379448572da3698eacfdc/lib/hanami/hanamirc.rb#L95-L101 | train |
hanami/hanami | lib/hanami/hanamirc.rb | Hanami.Hanamirc.parse_file | def parse_file(path)
{}.tap do |hash|
File.readlines(path).each do |line|
key, value = line.split(SEPARATOR)
hash[key] = value.strip
end
end
end | ruby | def parse_file(path)
{}.tap do |hash|
File.readlines(path).each do |line|
key, value = line.split(SEPARATOR)
hash[key] = value.strip
end
end
end | [
"def",
"parse_file",
"(",
"path",
")",
"{",
"}",
".",
"tap",
"do",
"|",
"hash",
"|",
"File",
".",
"readlines",
"(",
"path",
")",
".",
"each",
"do",
"|",
"line",
"|",
"key",
",",
"value",
"=",
"line",
".",
"split",
"(",
"SEPARATOR",
")",
"hash",
... | Read hanamirc file and parse it's values
@since 0.8.0
@api private
@return [Hash] hanamirc parsed values | [
"Read",
"hanamirc",
"file",
"and",
"parse",
"it",
"s",
"values"
] | 8c6e5147e92ef869b25379448572da3698eacfdc | https://github.com/hanami/hanami/blob/8c6e5147e92ef869b25379448572da3698eacfdc/lib/hanami/hanamirc.rb#L136-L143 | train |
hanami/hanami | lib/hanami/middleware_stack.rb | Hanami.MiddlewareStack.load! | def load!
load_default_stack
stack.each { |m, args, block| builder.use(load_middleware(m), *args, &block) }
builder.run routes
self
end | ruby | def load!
load_default_stack
stack.each { |m, args, block| builder.use(load_middleware(m), *args, &block) }
builder.run routes
self
end | [
"def",
"load!",
"load_default_stack",
"stack",
".",
"each",
"{",
"|",
"m",
",",
"args",
",",
"block",
"|",
"builder",
".",
"use",
"(",
"load_middleware",
"(",
"m",
")",
",",
"args",
",",
"block",
")",
"}",
"builder",
".",
"run",
"routes",
"self",
"en... | Instantiate a middleware stack
@param configuration [Hanami::ApplicationConfiguration] the application's configuration
@return [Hanami::MiddlewareStack] the new stack
@since 0.1.0
@api private
@see Hanami::ApplicationConfiguration
Load the middleware stack
@return [Hanami::MiddlewareStack] the loaded middle... | [
"Instantiate",
"a",
"middleware",
"stack"
] | 8c6e5147e92ef869b25379448572da3698eacfdc | https://github.com/hanami/hanami/blob/8c6e5147e92ef869b25379448572da3698eacfdc/lib/hanami/middleware_stack.rb#L34-L40 | train |
hanami/hanami | lib/hanami/middleware_stack.rb | Hanami.MiddlewareStack.use | def use(middleware, *args, &blk)
stack.push [middleware, args, blk]
stack.uniq!
end | ruby | def use(middleware, *args, &blk)
stack.push [middleware, args, blk]
stack.uniq!
end | [
"def",
"use",
"(",
"middleware",
",",
"*",
"args",
",",
"&",
"blk",
")",
"stack",
".",
"push",
"[",
"middleware",
",",
"args",
",",
"blk",
"]",
"stack",
".",
"uniq!",
"end"
] | Append a middleware to the stack.
@param middleware [Object] a Rack middleware
@param args [Array] optional arguments to pass to the Rack middleware
@param blk [Proc] an optional block to pass to the Rack middleware
@return [Array] the middleware that was added
@since 0.2.0
@see Hanami::MiddlewareStack#prepen... | [
"Append",
"a",
"middleware",
"to",
"the",
"stack",
"."
] | 8c6e5147e92ef869b25379448572da3698eacfdc | https://github.com/hanami/hanami/blob/8c6e5147e92ef869b25379448572da3698eacfdc/lib/hanami/middleware_stack.rb#L77-L80 | train |
hanami/hanami | lib/hanami/middleware_stack.rb | Hanami.MiddlewareStack.prepend | def prepend(middleware, *args, &blk)
stack.unshift [middleware, args, blk]
stack.uniq!
end | ruby | def prepend(middleware, *args, &blk)
stack.unshift [middleware, args, blk]
stack.uniq!
end | [
"def",
"prepend",
"(",
"middleware",
",",
"*",
"args",
",",
"&",
"blk",
")",
"stack",
".",
"unshift",
"[",
"middleware",
",",
"args",
",",
"blk",
"]",
"stack",
".",
"uniq!",
"end"
] | Prepend a middleware to the stack.
@param middleware [Object] a Rack middleware
@param args [Array] optional arguments to pass to the Rack middleware
@param blk [Proc] an optional block to pass to the Rack middleware
@return [Array] the middleware that was added
@since 0.6.0
@see Hanami::MiddlewareStack#use
... | [
"Prepend",
"a",
"middleware",
"to",
"the",
"stack",
"."
] | 8c6e5147e92ef869b25379448572da3698eacfdc | https://github.com/hanami/hanami/blob/8c6e5147e92ef869b25379448572da3698eacfdc/lib/hanami/middleware_stack.rb#L104-L107 | train |
hanami/hanami | lib/hanami/routes.rb | Hanami.Routes.path | def path(name, *args)
Utils::Escape::SafeString.new(@routes.path(name, *args))
end | ruby | def path(name, *args)
Utils::Escape::SafeString.new(@routes.path(name, *args))
end | [
"def",
"path",
"(",
"name",
",",
"*",
"args",
")",
"Utils",
"::",
"Escape",
"::",
"SafeString",
".",
"new",
"(",
"@routes",
".",
"path",
"(",
"name",
",",
"args",
")",
")",
"end"
] | Initialize the factory
@param routes [Hanami::Router] a routes set
@return [Hanami::Routes] the factory
@since 0.1.0
@api private
Return a relative path for the given route name
@param name [Symbol] the route name
@param args [Array,nil] an optional set of arguments that is passed down
to the wrapped rout... | [
"Initialize",
"the",
"factory"
] | 8c6e5147e92ef869b25379448572da3698eacfdc | https://github.com/hanami/hanami/blob/8c6e5147e92ef869b25379448572da3698eacfdc/lib/hanami/routes.rb#L75-L77 | train |
hanami/hanami | lib/hanami/routes.rb | Hanami.Routes.url | def url(name, *args)
Utils::Escape::SafeString.new(@routes.url(name, *args))
end | ruby | def url(name, *args)
Utils::Escape::SafeString.new(@routes.url(name, *args))
end | [
"def",
"url",
"(",
"name",
",",
"*",
"args",
")",
"Utils",
"::",
"Escape",
"::",
"SafeString",
".",
"new",
"(",
"@routes",
".",
"url",
"(",
"name",
",",
"args",
")",
")",
"end"
] | Return an absolute path for the given route name
@param name [Symbol] the route name
@param args [Array,nil] an optional set of arguments that is passed down
to the wrapped route set.
@return [Hanami::Utils::Escape::SafeString] the corresponding absolute URL
@raise Hanami::Routing::InvalidRouteException
@si... | [
"Return",
"an",
"absolute",
"path",
"for",
"the",
"given",
"route",
"name"
] | 8c6e5147e92ef869b25379448572da3698eacfdc | https://github.com/hanami/hanami/blob/8c6e5147e92ef869b25379448572da3698eacfdc/lib/hanami/routes.rb#L136-L138 | train |
puppetlabs/puppet | lib/puppet/util/windows/service.rb | Puppet::Util::Windows.Service.exists? | def exists?(service_name)
open_service(service_name, SC_MANAGER_CONNECT, SERVICE_QUERY_STATUS) do |_|
true
end
rescue Puppet::Util::Windows::Error => e
return false if e.code == ERROR_SERVICE_DOES_NOT_EXIST
raise e
end | ruby | def exists?(service_name)
open_service(service_name, SC_MANAGER_CONNECT, SERVICE_QUERY_STATUS) do |_|
true
end
rescue Puppet::Util::Windows::Error => e
return false if e.code == ERROR_SERVICE_DOES_NOT_EXIST
raise e
end | [
"def",
"exists?",
"(",
"service_name",
")",
"open_service",
"(",
"service_name",
",",
"SC_MANAGER_CONNECT",
",",
"SERVICE_QUERY_STATUS",
")",
"do",
"|",
"_",
"|",
"true",
"end",
"rescue",
"Puppet",
"::",
"Util",
"::",
"Windows",
"::",
"Error",
"=>",
"e",
"re... | Returns true if the service exists, false otherwise.
@param [String] service_name name of the service | [
"Returns",
"true",
"if",
"the",
"service",
"exists",
"false",
"otherwise",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/windows/service.rb#L286-L293 | train |
puppetlabs/puppet | lib/puppet/util/windows/service.rb | Puppet::Util::Windows.Service.start | def start(service_name, timeout: DEFAULT_TIMEOUT)
Puppet.debug _("Starting the %{service_name} service. Timeout set to: %{timeout} seconds") % { service_name: service_name, timeout: timeout }
valid_initial_states = [
SERVICE_STOP_PENDING,
SERVICE_STOPPED,
SERVICE_START_PENDING
... | ruby | def start(service_name, timeout: DEFAULT_TIMEOUT)
Puppet.debug _("Starting the %{service_name} service. Timeout set to: %{timeout} seconds") % { service_name: service_name, timeout: timeout }
valid_initial_states = [
SERVICE_STOP_PENDING,
SERVICE_STOPPED,
SERVICE_START_PENDING
... | [
"def",
"start",
"(",
"service_name",
",",
"timeout",
":",
"DEFAULT_TIMEOUT",
")",
"Puppet",
".",
"debug",
"_",
"(",
"\"Starting the %{service_name} service. Timeout set to: %{timeout} seconds\"",
")",
"%",
"{",
"service_name",
":",
"service_name",
",",
"timeout",
":",
... | Start a windows service
@param [String] service_name name of the service to start
@param optional [Integer] timeout the minumum number of seconds to wait before timing out | [
"Start",
"a",
"windows",
"service"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/windows/service.rb#L300-L316 | train |
puppetlabs/puppet | lib/puppet/util/windows/service.rb | Puppet::Util::Windows.Service.stop | def stop(service_name, timeout: DEFAULT_TIMEOUT)
Puppet.debug _("Stopping the %{service_name} service. Timeout set to: %{timeout} seconds") % { service_name: service_name, timeout: timeout }
valid_initial_states = SERVICE_STATES.keys - [SERVICE_STOPPED]
transition_service_state(service_name, valid_i... | ruby | def stop(service_name, timeout: DEFAULT_TIMEOUT)
Puppet.debug _("Stopping the %{service_name} service. Timeout set to: %{timeout} seconds") % { service_name: service_name, timeout: timeout }
valid_initial_states = SERVICE_STATES.keys - [SERVICE_STOPPED]
transition_service_state(service_name, valid_i... | [
"def",
"stop",
"(",
"service_name",
",",
"timeout",
":",
"DEFAULT_TIMEOUT",
")",
"Puppet",
".",
"debug",
"_",
"(",
"\"Stopping the %{service_name} service. Timeout set to: %{timeout} seconds\"",
")",
"%",
"{",
"service_name",
":",
"service_name",
",",
"timeout",
":",
... | Stop a windows service
@param [String] service_name name of the service to stop
@param optional [Integer] timeout the minumum number of seconds to wait before timing out | [
"Stop",
"a",
"windows",
"service"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/windows/service.rb#L323-L333 | train |
puppetlabs/puppet | lib/puppet/util/windows/service.rb | Puppet::Util::Windows.Service.resume | def resume(service_name, timeout: DEFAULT_TIMEOUT)
Puppet.debug _("Resuming the %{service_name} service. Timeout set to: %{timeout} seconds") % { service_name: service_name, timeout: timeout }
valid_initial_states = [
SERVICE_PAUSE_PENDING,
SERVICE_PAUSED,
SERVICE_CONTINUE_PENDING
... | ruby | def resume(service_name, timeout: DEFAULT_TIMEOUT)
Puppet.debug _("Resuming the %{service_name} service. Timeout set to: %{timeout} seconds") % { service_name: service_name, timeout: timeout }
valid_initial_states = [
SERVICE_PAUSE_PENDING,
SERVICE_PAUSED,
SERVICE_CONTINUE_PENDING
... | [
"def",
"resume",
"(",
"service_name",
",",
"timeout",
":",
"DEFAULT_TIMEOUT",
")",
"Puppet",
".",
"debug",
"_",
"(",
"\"Resuming the %{service_name} service. Timeout set to: %{timeout} seconds\"",
")",
"%",
"{",
"service_name",
":",
"service_name",
",",
"timeout",
":",
... | Resume a paused windows service
@param [String] service_name name of the service to resume
@param optional [Integer] :timeout the minumum number of seconds to wait before timing out | [
"Resume",
"a",
"paused",
"windows",
"service"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/windows/service.rb#L340-L358 | train |
puppetlabs/puppet | lib/puppet/util/windows/service.rb | Puppet::Util::Windows.Service.service_state | def service_state(service_name)
state = nil
open_service(service_name, SC_MANAGER_CONNECT, SERVICE_QUERY_STATUS) do |service|
query_status(service) do |status|
state = SERVICE_STATES[status[:dwCurrentState]]
end
end
if state.nil?
raise Puppet::Error.new(_("Unkno... | ruby | def service_state(service_name)
state = nil
open_service(service_name, SC_MANAGER_CONNECT, SERVICE_QUERY_STATUS) do |service|
query_status(service) do |status|
state = SERVICE_STATES[status[:dwCurrentState]]
end
end
if state.nil?
raise Puppet::Error.new(_("Unkno... | [
"def",
"service_state",
"(",
"service_name",
")",
"state",
"=",
"nil",
"open_service",
"(",
"service_name",
",",
"SC_MANAGER_CONNECT",
",",
"SERVICE_QUERY_STATUS",
")",
"do",
"|",
"service",
"|",
"query_status",
"(",
"service",
")",
"do",
"|",
"status",
"|",
"... | Query the state of a service using QueryServiceStatusEx
@param [string] service_name name of the service to query
@return [string] the status of the service | [
"Query",
"the",
"state",
"of",
"a",
"service",
"using",
"QueryServiceStatusEx"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/windows/service.rb#L365-L376 | train |
puppetlabs/puppet | lib/puppet/util/windows/service.rb | Puppet::Util::Windows.Service.service_start_type | def service_start_type(service_name)
start_type = nil
open_service(service_name, SC_MANAGER_CONNECT, SERVICE_QUERY_CONFIG) do |service|
query_config(service) do |config|
start_type = SERVICE_START_TYPES[config[:dwStartType]]
end
end
if start_type.nil?
raise Pupp... | ruby | def service_start_type(service_name)
start_type = nil
open_service(service_name, SC_MANAGER_CONNECT, SERVICE_QUERY_CONFIG) do |service|
query_config(service) do |config|
start_type = SERVICE_START_TYPES[config[:dwStartType]]
end
end
if start_type.nil?
raise Pupp... | [
"def",
"service_start_type",
"(",
"service_name",
")",
"start_type",
"=",
"nil",
"open_service",
"(",
"service_name",
",",
"SC_MANAGER_CONNECT",
",",
"SERVICE_QUERY_CONFIG",
")",
"do",
"|",
"service",
"|",
"query_config",
"(",
"service",
")",
"do",
"|",
"config",
... | Query the configuration of a service using QueryServiceConfigW
@param [String] service_name name of the service to query
@return [QUERY_SERVICE_CONFIGW.struct] the configuration of the service | [
"Query",
"the",
"configuration",
"of",
"a",
"service",
"using",
"QueryServiceConfigW"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/windows/service.rb#L383-L394 | train |
puppetlabs/puppet | lib/puppet/util/windows/service.rb | Puppet::Util::Windows.Service.set_startup_mode | def set_startup_mode(service_name, startup_type)
startup_code = SERVICE_START_TYPES.key(startup_type)
if startup_code.nil?
raise Puppet::Error.new(_("Unknown start type %{start_type}") % {startup_type: startup_type.to_s})
end
open_service(service_name, SC_MANAGER_CONNECT, SERVICE_CHANGE_... | ruby | def set_startup_mode(service_name, startup_type)
startup_code = SERVICE_START_TYPES.key(startup_type)
if startup_code.nil?
raise Puppet::Error.new(_("Unknown start type %{start_type}") % {startup_type: startup_type.to_s})
end
open_service(service_name, SC_MANAGER_CONNECT, SERVICE_CHANGE_... | [
"def",
"set_startup_mode",
"(",
"service_name",
",",
"startup_type",
")",
"startup_code",
"=",
"SERVICE_START_TYPES",
".",
"key",
"(",
"startup_type",
")",
"if",
"startup_code",
".",
"nil?",
"raise",
"Puppet",
"::",
"Error",
".",
"new",
"(",
"_",
"(",
"\"Unkno... | Change the startup mode of a windows service
@param [string] service_name the name of the service to modify
@param [Int] startup_type a code corresponding to a start type for
windows service, see the "Service start type codes" section in the
Puppet::Util::Windows::Service file for the list of available codes | [
"Change",
"the",
"startup",
"mode",
"of",
"a",
"windows",
"service"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/windows/service.rb#L403-L430 | train |
puppetlabs/puppet | lib/puppet/util/windows/service.rb | Puppet::Util::Windows.Service.services | def services
services = {}
open_scm(SC_MANAGER_ENUMERATE_SERVICE) do |scm|
size_required = 0
services_returned = 0
FFI::MemoryPointer.new(:dword) do |bytes_pointer|
FFI::MemoryPointer.new(:dword) do |svcs_ret_ptr|
FFI::MemoryPointer.new(:dword) do |resume_ptr|
... | ruby | def services
services = {}
open_scm(SC_MANAGER_ENUMERATE_SERVICE) do |scm|
size_required = 0
services_returned = 0
FFI::MemoryPointer.new(:dword) do |bytes_pointer|
FFI::MemoryPointer.new(:dword) do |svcs_ret_ptr|
FFI::MemoryPointer.new(:dword) do |resume_ptr|
... | [
"def",
"services",
"services",
"=",
"{",
"}",
"open_scm",
"(",
"SC_MANAGER_ENUMERATE_SERVICE",
")",
"do",
"|",
"scm",
"|",
"size_required",
"=",
"0",
"services_returned",
"=",
"0",
"FFI",
"::",
"MemoryPointer",
".",
"new",
"(",
":dword",
")",
"do",
"|",
"b... | enumerate over all services in all states and return them as a hash
@return [Hash] a hash containing services:
{ 'service name' => {
'display_name' => 'display name',
'service_status_process' => SERVICE_STATUS_PROCESS struct
}
} | [
"enumerate",
"over",
"all",
"services",
"in",
"all",
"states",
"and",
"return",
"them",
"as",
"a",
"hash"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/windows/service.rb#L441-L511 | train |
puppetlabs/puppet | lib/puppet/util/rdoc/generators/puppet_generator.rb | Generators.PuppetGenerator.gen_sub_directories | def gen_sub_directories
super
File.makedirs(MODULE_DIR)
File.makedirs(NODE_DIR)
File.makedirs(PLUGIN_DIR)
rescue
$stderr.puts $ERROR_INFO.message
exit 1
end | ruby | def gen_sub_directories
super
File.makedirs(MODULE_DIR)
File.makedirs(NODE_DIR)
File.makedirs(PLUGIN_DIR)
rescue
$stderr.puts $ERROR_INFO.message
exit 1
end | [
"def",
"gen_sub_directories",
"super",
"File",
".",
"makedirs",
"(",
"MODULE_DIR",
")",
"File",
".",
"makedirs",
"(",
"NODE_DIR",
")",
"File",
".",
"makedirs",
"(",
"PLUGIN_DIR",
")",
"rescue",
"$stderr",
".",
"puts",
"$ERROR_INFO",
".",
"message",
"exit",
"... | generate all the subdirectories, modules, classes and files | [
"generate",
"all",
"the",
"subdirectories",
"modules",
"classes",
"and",
"files"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/rdoc/generators/puppet_generator.rb#L195-L203 | train |
puppetlabs/puppet | lib/puppet/util/rdoc/generators/puppet_generator.rb | Generators.PuppetGenerator.gen_top_index | def gen_top_index(collection, title, template, filename)
template = TemplatePage.new(RDoc::Page::FR_INDEX_BODY, template)
res = []
collection.sort.each do |f|
if f.document_self
res << { "classlist" => CGI.escapeHTML("#{MODULE_DIR}/fr_#{f.index_name}.html"), "module" => CGI.escapeHTM... | ruby | def gen_top_index(collection, title, template, filename)
template = TemplatePage.new(RDoc::Page::FR_INDEX_BODY, template)
res = []
collection.sort.each do |f|
if f.document_self
res << { "classlist" => CGI.escapeHTML("#{MODULE_DIR}/fr_#{f.index_name}.html"), "module" => CGI.escapeHTM... | [
"def",
"gen_top_index",
"(",
"collection",
",",
"title",
",",
"template",
",",
"filename",
")",
"template",
"=",
"TemplatePage",
".",
"new",
"(",
"RDoc",
"::",
"Page",
"::",
"FR_INDEX_BODY",
",",
"template",
")",
"res",
"=",
"[",
"]",
"collection",
".",
... | generate a top index | [
"generate",
"a",
"top",
"index"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/rdoc/generators/puppet_generator.rb#L211-L231 | train |
puppetlabs/puppet | lib/puppet/util/rdoc/generators/puppet_generator.rb | Generators.PuppetGenerator.gen_class_index | def gen_class_index
gen_an_index(@classes, 'All Classes', RDoc::Page::CLASS_INDEX, "fr_class_index.html")
@allfiles.each do |file|
unless file['file'].context.file_relative_name =~ /\.rb$/
gen_composite_index(
file,
RDoc::Page::COMBO_INDEX,
"#{MODU... | ruby | def gen_class_index
gen_an_index(@classes, 'All Classes', RDoc::Page::CLASS_INDEX, "fr_class_index.html")
@allfiles.each do |file|
unless file['file'].context.file_relative_name =~ /\.rb$/
gen_composite_index(
file,
RDoc::Page::COMBO_INDEX,
"#{MODU... | [
"def",
"gen_class_index",
"gen_an_index",
"(",
"@classes",
",",
"'All Classes'",
",",
"RDoc",
"::",
"Page",
"::",
"CLASS_INDEX",
",",
"\"fr_class_index.html\"",
")",
"@allfiles",
".",
"each",
"do",
"|",
"file",
"|",
"unless",
"file",
"[",
"'file'",
"]",
".",
... | generate the all classes index file and the combo index | [
"generate",
"the",
"all",
"classes",
"index",
"file",
"and",
"the",
"combo",
"index"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/rdoc/generators/puppet_generator.rb#L234-L246 | train |
puppetlabs/puppet | lib/puppet/util/rdoc/generators/puppet_generator.rb | Generators.PuppetGenerator.main_url | def main_url
main_page = @options.main_page
ref = nil
if main_page
ref = AllReferences[main_page]
if ref
ref = ref.path
else
$stderr.puts "Could not find main page #{main_page}"
end
end
unless ref
for file in @files
if ... | ruby | def main_url
main_page = @options.main_page
ref = nil
if main_page
ref = AllReferences[main_page]
if ref
ref = ref.path
else
$stderr.puts "Could not find main page #{main_page}"
end
end
unless ref
for file in @files
if ... | [
"def",
"main_url",
"main_page",
"=",
"@options",
".",
"main_page",
"ref",
"=",
"nil",
"if",
"main_page",
"ref",
"=",
"AllReferences",
"[",
"main_page",
"]",
"if",
"ref",
"ref",
"=",
"ref",
".",
"path",
"else",
"$stderr",
".",
"puts",
"\"Could not find main p... | returns the initial_page url | [
"returns",
"the",
"initial_page",
"url"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/rdoc/generators/puppet_generator.rb#L310-L347 | train |
puppetlabs/puppet | lib/puppet/util/rdoc/generators/puppet_generator.rb | Generators.HTMLPuppetNode.http_url | def http_url(full_name, prefix)
path = full_name.dup
path.gsub!(/<<\s*(\w*)/) { "from-#$1" } if path['<<']
File.join(prefix, path.split("::").collect { |p| Digest::MD5.hexdigest(p) }) + ".html"
end | ruby | def http_url(full_name, prefix)
path = full_name.dup
path.gsub!(/<<\s*(\w*)/) { "from-#$1" } if path['<<']
File.join(prefix, path.split("::").collect { |p| Digest::MD5.hexdigest(p) }) + ".html"
end | [
"def",
"http_url",
"(",
"full_name",
",",
"prefix",
")",
"path",
"=",
"full_name",
".",
"dup",
"path",
".",
"gsub!",
"(",
"/",
"\\s",
"\\w",
"/",
")",
"{",
"\"from-#$1\"",
"}",
"if",
"path",
"[",
"'<<'",
"]",
"File",
".",
"join",
"(",
"prefix",
","... | return the relative file name to store this class in,
which is also its url | [
"return",
"the",
"relative",
"file",
"name",
"to",
"store",
"this",
"class",
"in",
"which",
"is",
"also",
"its",
"url"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/rdoc/generators/puppet_generator.rb#L482-L486 | train |
puppetlabs/puppet | lib/puppet/util/provider_features.rb | Puppet::Util::ProviderFeatures.ProviderFeature.methods_available? | def methods_available?(obj)
methods.each do |m|
if obj.is_a?(Class)
return false unless obj.public_method_defined?(m)
else
return false unless obj.respond_to?(m)
end
end
true
end | ruby | def methods_available?(obj)
methods.each do |m|
if obj.is_a?(Class)
return false unless obj.public_method_defined?(m)
else
return false unless obj.respond_to?(m)
end
end
true
end | [
"def",
"methods_available?",
"(",
"obj",
")",
"methods",
".",
"each",
"do",
"|",
"m",
"|",
"if",
"obj",
".",
"is_a?",
"(",
"Class",
")",
"return",
"false",
"unless",
"obj",
".",
"public_method_defined?",
"(",
"m",
")",
"else",
"return",
"false",
"unless"... | Checks whether all feature predicate methods are available.
@param obj [Object, Class] the object or class to check if feature predicates are available or not.
@return [Boolean] Returns whether all of the required methods are available or not in the given object. | [
"Checks",
"whether",
"all",
"feature",
"predicate",
"methods",
"are",
"available",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/provider_features.rb#L44-L53 | train |
puppetlabs/puppet | lib/puppet/module_tool/metadata.rb | Puppet::ModuleTool.Metadata.update | def update(data)
process_name(data) if data['name']
process_version(data) if data['version']
process_source(data) if data['source']
process_data_provider(data) if data['data_provider']
merge_dependencies(data) if data['dependencies']
@data.merge!(data)
return self
end | ruby | def update(data)
process_name(data) if data['name']
process_version(data) if data['version']
process_source(data) if data['source']
process_data_provider(data) if data['data_provider']
merge_dependencies(data) if data['dependencies']
@data.merge!(data)
return self
end | [
"def",
"update",
"(",
"data",
")",
"process_name",
"(",
"data",
")",
"if",
"data",
"[",
"'name'",
"]",
"process_version",
"(",
"data",
")",
"if",
"data",
"[",
"'version'",
"]",
"process_source",
"(",
"data",
")",
"if",
"data",
"[",
"'source'",
"]",
"pr... | Merges the current set of metadata with another metadata hash. This
method also handles the validation of module names and versions, in an
effort to be proactive about module publishing constraints. | [
"Merges",
"the",
"current",
"set",
"of",
"metadata",
"with",
"another",
"metadata",
"hash",
".",
"This",
"method",
"also",
"handles",
"the",
"validation",
"of",
"module",
"names",
"and",
"versions",
"in",
"an",
"effort",
"to",
"be",
"proactive",
"about",
"mo... | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/module_tool/metadata.rb#L51-L60 | train |
puppetlabs/puppet | lib/puppet/module_tool/metadata.rb | Puppet::ModuleTool.Metadata.add_dependency | def add_dependency(name, version_requirement=nil, repository=nil)
validate_name(name)
validate_version_range(version_requirement) if version_requirement
if dup = @data['dependencies'].find { |d| d.full_module_name == name && d.version_requirement != version_requirement }
raise ArgumentError, ... | ruby | def add_dependency(name, version_requirement=nil, repository=nil)
validate_name(name)
validate_version_range(version_requirement) if version_requirement
if dup = @data['dependencies'].find { |d| d.full_module_name == name && d.version_requirement != version_requirement }
raise ArgumentError, ... | [
"def",
"add_dependency",
"(",
"name",
",",
"version_requirement",
"=",
"nil",
",",
"repository",
"=",
"nil",
")",
"validate_name",
"(",
"name",
")",
"validate_version_range",
"(",
"version_requirement",
")",
"if",
"version_requirement",
"if",
"dup",
"=",
"@data",
... | Validates the name and version_requirement for a dependency, then creates
the Dependency and adds it.
Returns the Dependency that was added. | [
"Validates",
"the",
"name",
"and",
"version_requirement",
"for",
"a",
"dependency",
"then",
"creates",
"the",
"Dependency",
"and",
"adds",
"it",
".",
"Returns",
"the",
"Dependency",
"that",
"was",
"added",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/module_tool/metadata.rb#L65-L77 | train |
puppetlabs/puppet | lib/puppet/module_tool/metadata.rb | Puppet::ModuleTool.Metadata.process_name | def process_name(data)
validate_name(data['name'])
author, @module_name = data['name'].split(/[-\/]/, 2)
data['author'] ||= author if @data['author'] == DEFAULTS['author']
end | ruby | def process_name(data)
validate_name(data['name'])
author, @module_name = data['name'].split(/[-\/]/, 2)
data['author'] ||= author if @data['author'] == DEFAULTS['author']
end | [
"def",
"process_name",
"(",
"data",
")",
"validate_name",
"(",
"data",
"[",
"'name'",
"]",
")",
"author",
",",
"@module_name",
"=",
"data",
"[",
"'name'",
"]",
".",
"split",
"(",
"/",
"\\/",
"/",
",",
"2",
")",
"data",
"[",
"'author'",
"]",
"||=",
... | Do basic validation and parsing of the name parameter. | [
"Do",
"basic",
"validation",
"and",
"parsing",
"of",
"the",
"name",
"parameter",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/module_tool/metadata.rb#L120-L125 | train |
puppetlabs/puppet | lib/puppet/module_tool/metadata.rb | Puppet::ModuleTool.Metadata.process_source | def process_source(data)
if data['source'] =~ %r[://]
source_uri = URI.parse(data['source'])
else
source_uri = URI.parse("http://#{data['source']}")
end
if source_uri.host =~ /^(www\.)?github\.com$/
source_uri.scheme = 'https'
source_uri.path.sub!(/\.git$/, '')
... | ruby | def process_source(data)
if data['source'] =~ %r[://]
source_uri = URI.parse(data['source'])
else
source_uri = URI.parse("http://#{data['source']}")
end
if source_uri.host =~ /^(www\.)?github\.com$/
source_uri.scheme = 'https'
source_uri.path.sub!(/\.git$/, '')
... | [
"def",
"process_source",
"(",
"data",
")",
"if",
"data",
"[",
"'source'",
"]",
"=~",
"%r[",
"]",
"source_uri",
"=",
"URI",
".",
"parse",
"(",
"data",
"[",
"'source'",
"]",
")",
"else",
"source_uri",
"=",
"URI",
".",
"parse",
"(",
"\"http://#{data['source... | Do basic parsing of the source parameter. If the source is hosted on
GitHub, we can predict sensible defaults for both project_page and
issues_url. | [
"Do",
"basic",
"parsing",
"of",
"the",
"source",
"parameter",
".",
"If",
"the",
"source",
"is",
"hosted",
"on",
"GitHub",
"we",
"can",
"predict",
"sensible",
"defaults",
"for",
"both",
"project_page",
"and",
"issues_url",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/module_tool/metadata.rb#L139-L155 | train |
puppetlabs/puppet | lib/puppet/module_tool/metadata.rb | Puppet::ModuleTool.Metadata.merge_dependencies | def merge_dependencies(data)
data['dependencies'].each do |dep|
add_dependency(dep['name'], dep['version_requirement'], dep['repository'])
end
# Clear dependencies so @data dependencies are not overwritten
data.delete 'dependencies'
end | ruby | def merge_dependencies(data)
data['dependencies'].each do |dep|
add_dependency(dep['name'], dep['version_requirement'], dep['repository'])
end
# Clear dependencies so @data dependencies are not overwritten
data.delete 'dependencies'
end | [
"def",
"merge_dependencies",
"(",
"data",
")",
"data",
"[",
"'dependencies'",
"]",
".",
"each",
"do",
"|",
"dep",
"|",
"add_dependency",
"(",
"dep",
"[",
"'name'",
"]",
",",
"dep",
"[",
"'version_requirement'",
"]",
",",
"dep",
"[",
"'repository'",
"]",
... | Validates and parses the dependencies. | [
"Validates",
"and",
"parses",
"the",
"dependencies",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/module_tool/metadata.rb#L158-L165 | train |
puppetlabs/puppet | lib/puppet/module_tool/metadata.rb | Puppet::ModuleTool.Metadata.validate_name | def validate_name(name)
return if name =~ /\A[a-z0-9]+[-\/][a-z][a-z0-9_]*\Z/i
namespace, modname = name.split(/[-\/]/, 2)
modname = :namespace_missing if namespace == ''
err = case modname
when nil, '', :namespace_missing
_("the field must be a namespaced module name")
whe... | ruby | def validate_name(name)
return if name =~ /\A[a-z0-9]+[-\/][a-z][a-z0-9_]*\Z/i
namespace, modname = name.split(/[-\/]/, 2)
modname = :namespace_missing if namespace == ''
err = case modname
when nil, '', :namespace_missing
_("the field must be a namespaced module name")
whe... | [
"def",
"validate_name",
"(",
"name",
")",
"return",
"if",
"name",
"=~",
"/",
"\\A",
"\\/",
"\\Z",
"/i",
"namespace",
",",
"modname",
"=",
"name",
".",
"split",
"(",
"/",
"\\/",
"/",
",",
"2",
")",
"modname",
"=",
":namespace_missing",
"if",
"namespace"... | Validates that the given module name is both namespaced and well-formed. | [
"Validates",
"that",
"the",
"given",
"module",
"name",
"is",
"both",
"namespaced",
"and",
"well",
"-",
"formed",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/module_tool/metadata.rb#L168-L186 | train |
puppetlabs/puppet | lib/puppet/module_tool/metadata.rb | Puppet::ModuleTool.Metadata.validate_version | def validate_version(version)
return if SemanticPuppet::Version.valid?(version)
err = _("version string cannot be parsed as a valid Semantic Version")
raise ArgumentError, _("Invalid 'version' field in metadata.json: %{err}") % { err: err }
end | ruby | def validate_version(version)
return if SemanticPuppet::Version.valid?(version)
err = _("version string cannot be parsed as a valid Semantic Version")
raise ArgumentError, _("Invalid 'version' field in metadata.json: %{err}") % { err: err }
end | [
"def",
"validate_version",
"(",
"version",
")",
"return",
"if",
"SemanticPuppet",
"::",
"Version",
".",
"valid?",
"(",
"version",
")",
"err",
"=",
"_",
"(",
"\"version string cannot be parsed as a valid Semantic Version\"",
")",
"raise",
"ArgumentError",
",",
"_",
"... | Validates that the version string can be parsed as per SemVer. | [
"Validates",
"that",
"the",
"version",
"string",
"can",
"be",
"parsed",
"as",
"per",
"SemVer",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/module_tool/metadata.rb#L189-L194 | train |
puppetlabs/puppet | lib/puppet/module_tool/metadata.rb | Puppet::ModuleTool.Metadata.validate_data_provider | def validate_data_provider(value)
if value.is_a?(String)
unless value =~ /^[a-zA-Z][a-zA-Z0-9_]*$/
if value =~ /^[a-zA-Z]/
raise ArgumentError, _("field 'data_provider' contains non-alphanumeric characters")
else
raise ArgumentError, _("field 'data_provider' mus... | ruby | def validate_data_provider(value)
if value.is_a?(String)
unless value =~ /^[a-zA-Z][a-zA-Z0-9_]*$/
if value =~ /^[a-zA-Z]/
raise ArgumentError, _("field 'data_provider' contains non-alphanumeric characters")
else
raise ArgumentError, _("field 'data_provider' mus... | [
"def",
"validate_data_provider",
"(",
"value",
")",
"if",
"value",
".",
"is_a?",
"(",
"String",
")",
"unless",
"value",
"=~",
"/",
"/",
"if",
"value",
"=~",
"/",
"/",
"raise",
"ArgumentError",
",",
"_",
"(",
"\"field 'data_provider' contains non-alphanumeric cha... | Validates that the given _value_ is a symbolic name that starts with a letter
and then contains only letters, digits, or underscore. Will raise an ArgumentError
if that's not the case.
@param value [Object] The value to be tested | [
"Validates",
"that",
"the",
"given",
"_value_",
"is",
"a",
"symbolic",
"name",
"that",
"starts",
"with",
"a",
"letter",
"and",
"then",
"contains",
"only",
"letters",
"digits",
"or",
"underscore",
".",
"Will",
"raise",
"an",
"ArgumentError",
"if",
"that",
"s"... | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/module_tool/metadata.rb#L201-L213 | train |
puppetlabs/puppet | lib/puppet/module_tool/metadata.rb | Puppet::ModuleTool.Metadata.validate_version_range | def validate_version_range(version_range)
SemanticPuppet::VersionRange.parse(version_range)
rescue ArgumentError => e
raise ArgumentError, _("Invalid 'version_range' field in metadata.json: %{err}") % { err: e }
end | ruby | def validate_version_range(version_range)
SemanticPuppet::VersionRange.parse(version_range)
rescue ArgumentError => e
raise ArgumentError, _("Invalid 'version_range' field in metadata.json: %{err}") % { err: e }
end | [
"def",
"validate_version_range",
"(",
"version_range",
")",
"SemanticPuppet",
"::",
"VersionRange",
".",
"parse",
"(",
"version_range",
")",
"rescue",
"ArgumentError",
"=>",
"e",
"raise",
"ArgumentError",
",",
"_",
"(",
"\"Invalid 'version_range' field in metadata.json: %... | Validates that the version range can be parsed by Semantic. | [
"Validates",
"that",
"the",
"version",
"range",
"can",
"be",
"parsed",
"by",
"Semantic",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/module_tool/metadata.rb#L216-L220 | train |
puppetlabs/puppet | lib/puppet/network/authconfig.rb | Puppet.Network::DefaultAuthProvider.insert_default_acl | def insert_default_acl
self.class.default_acl.each do |acl|
unless rights[acl[:acl]]
Puppet.info _("Inserting default '%{acl}' (auth %{auth}) ACL") % { acl: acl[:acl], auth: acl[:authenticated] }
mk_acl(acl)
end
end
# queue an empty (ie deny all) right for every oth... | ruby | def insert_default_acl
self.class.default_acl.each do |acl|
unless rights[acl[:acl]]
Puppet.info _("Inserting default '%{acl}' (auth %{auth}) ACL") % { acl: acl[:acl], auth: acl[:authenticated] }
mk_acl(acl)
end
end
# queue an empty (ie deny all) right for every oth... | [
"def",
"insert_default_acl",
"self",
".",
"class",
".",
"default_acl",
".",
"each",
"do",
"|",
"acl",
"|",
"unless",
"rights",
"[",
"acl",
"[",
":acl",
"]",
"]",
"Puppet",
".",
"info",
"_",
"(",
"\"Inserting default '%{acl}' (auth %{auth}) ACL\"",
")",
"%",
... | force regular ACLs to be present | [
"force",
"regular",
"ACLs",
"to",
"be",
"present"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/network/authconfig.rb#L38-L51 | train |
puppetlabs/puppet | lib/puppet/util/windows/adsi.rb | Puppet::Util::Windows::ADSI.User.op_userflags | def op_userflags(*flags, &block)
# Avoid an unnecessary set + commit operation.
return if flags.empty?
unrecognized_flags = flags.reject { |flag| ADS_USERFLAGS.keys.include?(flag) }
unless unrecognized_flags.empty?
raise ArgumentError, _("Unrecognized ADS UserFlags: %{unrecognized_flags... | ruby | def op_userflags(*flags, &block)
# Avoid an unnecessary set + commit operation.
return if flags.empty?
unrecognized_flags = flags.reject { |flag| ADS_USERFLAGS.keys.include?(flag) }
unless unrecognized_flags.empty?
raise ArgumentError, _("Unrecognized ADS UserFlags: %{unrecognized_flags... | [
"def",
"op_userflags",
"(",
"*",
"flags",
",",
"&",
"block",
")",
"# Avoid an unnecessary set + commit operation.",
"return",
"if",
"flags",
".",
"empty?",
"unrecognized_flags",
"=",
"flags",
".",
"reject",
"{",
"|",
"flag",
"|",
"ADS_USERFLAGS",
".",
"keys",
".... | Common helper for set_userflags and unset_userflags.
@api private | [
"Common",
"helper",
"for",
"set_userflags",
"and",
"unset_userflags",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/windows/adsi.rb#L417-L427 | train |
puppetlabs/puppet | lib/puppet/network/resolver.rb | Puppet::Network.Resolver.each_srv_record | def each_srv_record(domain, service_name = :puppet, &block)
if (domain.nil? or domain.empty?)
Puppet.debug "Domain not known; skipping SRV lookup"
return
end
Puppet.debug "Searching for SRV records for domain: #{domain}"
case service_name
when :puppet then service = '_x... | ruby | def each_srv_record(domain, service_name = :puppet, &block)
if (domain.nil? or domain.empty?)
Puppet.debug "Domain not known; skipping SRV lookup"
return
end
Puppet.debug "Searching for SRV records for domain: #{domain}"
case service_name
when :puppet then service = '_x... | [
"def",
"each_srv_record",
"(",
"domain",
",",
"service_name",
"=",
":puppet",
",",
"&",
"block",
")",
"if",
"(",
"domain",
".",
"nil?",
"or",
"domain",
".",
"empty?",
")",
"Puppet",
".",
"debug",
"\"Domain not known; skipping SRV lookup\"",
"return",
"end",
"P... | Iterate through the list of records for this service
and yield each server and port pair. Records are only fetched
via DNS query the first time and cached for the duration of their
service's TTL thereafter.
@param [String] domain the domain to search for
@param [Symbol] service_name the key of the service we are q... | [
"Iterate",
"through",
"the",
"list",
"of",
"records",
"for",
"this",
"service",
"and",
"yield",
"each",
"server",
"and",
"port",
"pair",
".",
"Records",
"are",
"only",
"fetched",
"via",
"DNS",
"query",
"the",
"first",
"time",
"and",
"cached",
"for",
"the",... | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/network/resolver.rb#L42-L80 | train |
puppetlabs/puppet | lib/puppet/network/resolver.rb | Puppet::Network.Resolver.find_weighted_server | def find_weighted_server(records)
return nil if records.nil? || records.empty?
return records.first if records.size == 1
# Calculate the sum of all weights in the list of resource records,
# This is used to then select hosts until the weight exceeds what
# random number we selected. For ... | ruby | def find_weighted_server(records)
return nil if records.nil? || records.empty?
return records.first if records.size == 1
# Calculate the sum of all weights in the list of resource records,
# This is used to then select hosts until the weight exceeds what
# random number we selected. For ... | [
"def",
"find_weighted_server",
"(",
"records",
")",
"return",
"nil",
"if",
"records",
".",
"nil?",
"||",
"records",
".",
"empty?",
"return",
"records",
".",
"first",
"if",
"records",
".",
"size",
"==",
"1",
"# Calculate the sum of all weights in the list of resource... | Given a list of records of the same priority, chooses a random one
from among them, favoring those with higher weights.
@param [[Resolv::DNS::Resource::IN::SRV]] records a list of records
of the same priority
@return [Resolv::DNS::Resource::IN:SRV] the chosen record | [
"Given",
"a",
"list",
"of",
"records",
"of",
"the",
"same",
"priority",
"chooses",
"a",
"random",
"one",
"from",
"among",
"them",
"favoring",
"those",
"with",
"higher",
"weights",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/network/resolver.rb#L87-L110 | train |
puppetlabs/puppet | lib/puppet/network/resolver.rb | Puppet::Network.Resolver.expired? | def expired?(service_name)
if entry = @record_cache[service_name]
return Time.now > (entry.resolution_time + entry.ttl)
else
return true
end
end | ruby | def expired?(service_name)
if entry = @record_cache[service_name]
return Time.now > (entry.resolution_time + entry.ttl)
else
return true
end
end | [
"def",
"expired?",
"(",
"service_name",
")",
"if",
"entry",
"=",
"@record_cache",
"[",
"service_name",
"]",
"return",
"Time",
".",
"now",
">",
"(",
"entry",
".",
"resolution_time",
"+",
"entry",
".",
"ttl",
")",
"else",
"return",
"true",
"end",
"end"
] | Checks if the cached entry for the given service has expired.
@param [String] service_name the name of the service to check
@return [Boolean] true if the entry has expired, false otherwise.
Always returns true if the record had no TTL. | [
"Checks",
"if",
"the",
"cached",
"entry",
"for",
"the",
"given",
"service",
"has",
"expired",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/network/resolver.rb#L127-L133 | train |
puppetlabs/puppet | lib/puppet/util.rb | Puppet.Util.clear_environment | def clear_environment(mode = default_env)
case mode
when :posix
ENV.clear
when :windows
Puppet::Util::Windows::Process.get_environment_strings.each do |key, _|
Puppet::Util::Windows::Process.set_environment_variable(key, nil)
end
else
raise _("Unable to cl... | ruby | def clear_environment(mode = default_env)
case mode
when :posix
ENV.clear
when :windows
Puppet::Util::Windows::Process.get_environment_strings.each do |key, _|
Puppet::Util::Windows::Process.set_environment_variable(key, nil)
end
else
raise _("Unable to cl... | [
"def",
"clear_environment",
"(",
"mode",
"=",
"default_env",
")",
"case",
"mode",
"when",
":posix",
"ENV",
".",
"clear",
"when",
":windows",
"Puppet",
"::",
"Util",
"::",
"Windows",
"::",
"Process",
".",
"get_environment_strings",
".",
"each",
"do",
"|",
"ke... | Removes all environment variables
@param mode [Symbol] Which operating system mode to use e.g. :posix or :windows. Use nil to autodetect
@api private | [
"Removes",
"all",
"environment",
"variables"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util.rb#L72-L83 | train |
puppetlabs/puppet | lib/puppet/util.rb | Puppet.Util.which | def which(bin)
if absolute_path?(bin)
return bin if FileTest.file? bin and FileTest.executable? bin
else
exts = Puppet::Util.get_env('PATHEXT')
exts = exts ? exts.split(File::PATH_SEPARATOR) : %w[.COM .EXE .BAT .CMD]
Puppet::Util.get_env('PATH').split(File::PATH_SEPARATOR).each do |dir|
... | ruby | def which(bin)
if absolute_path?(bin)
return bin if FileTest.file? bin and FileTest.executable? bin
else
exts = Puppet::Util.get_env('PATHEXT')
exts = exts ? exts.split(File::PATH_SEPARATOR) : %w[.COM .EXE .BAT .CMD]
Puppet::Util.get_env('PATH').split(File::PATH_SEPARATOR).each do |dir|
... | [
"def",
"which",
"(",
"bin",
")",
"if",
"absolute_path?",
"(",
"bin",
")",
"return",
"bin",
"if",
"FileTest",
".",
"file?",
"bin",
"and",
"FileTest",
".",
"executable?",
"bin",
"else",
"exts",
"=",
"Puppet",
"::",
"Util",
".",
"get_env",
"(",
"'PATHEXT'",... | Resolve a path for an executable to the absolute path. This tries to behave
in the same manner as the unix `which` command and uses the `PATH`
environment variable.
@api public
@param bin [String] the name of the executable to find.
@return [String] the absolute path to the found executable. | [
"Resolve",
"a",
"path",
"for",
"an",
"executable",
"to",
"the",
"absolute",
"path",
".",
"This",
"tries",
"to",
"behave",
"in",
"the",
"same",
"manner",
"as",
"the",
"unix",
"which",
"command",
"and",
"uses",
"the",
"PATH",
"environment",
"variable",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util.rb#L248-L285 | train |
puppetlabs/puppet | lib/puppet/util.rb | Puppet.Util.path_to_uri | def path_to_uri(path)
return unless path
params = { :scheme => 'file' }
if Puppet::Util::Platform.windows?
path = path.gsub(/\\/, '/')
if unc = /^\/\/([^\/]+)(\/.+)/.match(path)
params[:host] = unc[1]
path = unc[2]
elsif path =~ /^[a-z]:\//i
path = '/' + path
... | ruby | def path_to_uri(path)
return unless path
params = { :scheme => 'file' }
if Puppet::Util::Platform.windows?
path = path.gsub(/\\/, '/')
if unc = /^\/\/([^\/]+)(\/.+)/.match(path)
params[:host] = unc[1]
path = unc[2]
elsif path =~ /^[a-z]:\//i
path = '/' + path
... | [
"def",
"path_to_uri",
"(",
"path",
")",
"return",
"unless",
"path",
"params",
"=",
"{",
":scheme",
"=>",
"'file'",
"}",
"if",
"Puppet",
"::",
"Util",
"::",
"Platform",
".",
"windows?",
"path",
"=",
"path",
".",
"gsub",
"(",
"/",
"\\\\",
"/",
",",
"'/... | Convert a path to a file URI | [
"Convert",
"a",
"path",
"to",
"a",
"file",
"URI"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util.rb#L319-L347 | train |
puppetlabs/puppet | lib/puppet/util.rb | Puppet.Util.uri_to_path | def uri_to_path(uri)
return unless uri.is_a?(URI)
# CGI.unescape doesn't handle space rules properly in uri paths
# URI.unescape does, but returns strings in their original encoding
path = URI.unescape(uri.path.encode(Encoding::UTF_8))
if Puppet::Util::Platform.windows? && uri.scheme == 'file'
... | ruby | def uri_to_path(uri)
return unless uri.is_a?(URI)
# CGI.unescape doesn't handle space rules properly in uri paths
# URI.unescape does, but returns strings in their original encoding
path = URI.unescape(uri.path.encode(Encoding::UTF_8))
if Puppet::Util::Platform.windows? && uri.scheme == 'file'
... | [
"def",
"uri_to_path",
"(",
"uri",
")",
"return",
"unless",
"uri",
".",
"is_a?",
"(",
"URI",
")",
"# CGI.unescape doesn't handle space rules properly in uri paths",
"# URI.unescape does, but returns strings in their original encoding",
"path",
"=",
"URI",
".",
"unescape",
"(",... | Get the path component of a URI | [
"Get",
"the",
"path",
"component",
"of",
"a",
"URI"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util.rb#L351-L367 | train |
puppetlabs/puppet | lib/puppet/util.rb | Puppet.Util.exit_on_fail | def exit_on_fail(message, code = 1)
yield
# First, we need to check and see if we are catching a SystemExit error. These will be raised
# when we daemonize/fork, and they do not necessarily indicate a failure case.
rescue SystemExit => err
raise err
# Now we need to catch *any* other kind of exceptio... | ruby | def exit_on_fail(message, code = 1)
yield
# First, we need to check and see if we are catching a SystemExit error. These will be raised
# when we daemonize/fork, and they do not necessarily indicate a failure case.
rescue SystemExit => err
raise err
# Now we need to catch *any* other kind of exceptio... | [
"def",
"exit_on_fail",
"(",
"message",
",",
"code",
"=",
"1",
")",
"yield",
"# First, we need to check and see if we are catching a SystemExit error. These will be raised",
"# when we daemonize/fork, and they do not necessarily indicate a failure case.",
"rescue",
"SystemExit",
"=>",
... | Executes a block of code, wrapped with some special exception handling. Causes the ruby interpreter to
exit if the block throws an exception.
@api public
@param [String] message a message to log if the block fails
@param [Integer] code the exit code that the ruby interpreter should return if the block fails
@yi... | [
"Executes",
"a",
"block",
"of",
"code",
"wrapped",
"with",
"some",
"special",
"exception",
"handling",
".",
"Causes",
"the",
"ruby",
"interpreter",
"to",
"exit",
"if",
"the",
"block",
"throws",
"an",
"exception",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util.rb#L683-L699 | train |
puppetlabs/puppet | lib/puppet/pops/evaluator/runtime3_converter.rb | Puppet::Pops::Evaluator.Runtime3Converter.map_args | def map_args(args, scope, undef_value)
args.map {|a| convert(a, scope, undef_value) }
end | ruby | def map_args(args, scope, undef_value)
args.map {|a| convert(a, scope, undef_value) }
end | [
"def",
"map_args",
"(",
"args",
",",
"scope",
",",
"undef_value",
")",
"args",
".",
"map",
"{",
"|",
"a",
"|",
"convert",
"(",
"a",
",",
"scope",
",",
"undef_value",
")",
"}",
"end"
] | Converts 4x supported values to a 3x values.
@param args [Array] Array of values to convert
@param scope [Puppet::Parser::Scope] The scope to use when converting
@param undef_value [Object] The value that nil is converted to
@return [Array] The converted values | [
"Converts",
"4x",
"supported",
"values",
"to",
"a",
"3x",
"values",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/pops/evaluator/runtime3_converter.rb#L48-L50 | train |
puppetlabs/puppet | lib/puppet/type.rb | Puppet.Type.delete | def delete(attr)
attr = attr.intern
if @parameters.has_key?(attr)
@parameters.delete(attr)
else
raise Puppet::DevError.new(_("Undefined attribute '%{attribute}' in %{name}") % { attribute: attr, name: self})
end
end | ruby | def delete(attr)
attr = attr.intern
if @parameters.has_key?(attr)
@parameters.delete(attr)
else
raise Puppet::DevError.new(_("Undefined attribute '%{attribute}' in %{name}") % { attribute: attr, name: self})
end
end | [
"def",
"delete",
"(",
"attr",
")",
"attr",
"=",
"attr",
".",
"intern",
"if",
"@parameters",
".",
"has_key?",
"(",
"attr",
")",
"@parameters",
".",
"delete",
"(",
"attr",
")",
"else",
"raise",
"Puppet",
"::",
"DevError",
".",
"new",
"(",
"_",
"(",
"\"... | Removes an attribute from the object; useful in testing or in cleanup
when an error has been encountered
@todo Don't know what the attr is (name or Property/Parameter?). Guessing it is a String name...
@todo Is it possible to delete a meta-parameter?
@todo What does delete mean? Is it deleted from the type or is it... | [
"Removes",
"an",
"attribute",
"from",
"the",
"object",
";",
"useful",
"in",
"testing",
"or",
"in",
"cleanup",
"when",
"an",
"error",
"has",
"been",
"encountered"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/type.rb#L700-L707 | train |
puppetlabs/puppet | lib/puppet/type.rb | Puppet.Type.managed? | def managed?
# Once an object is managed, it always stays managed; but an object
# that is listed as unmanaged might become managed later in the process,
# so we have to check that every time
if @managed
return @managed
else
@managed = false
properties.each { |property|
s =... | ruby | def managed?
# Once an object is managed, it always stays managed; but an object
# that is listed as unmanaged might become managed later in the process,
# so we have to check that every time
if @managed
return @managed
else
@managed = false
properties.each { |property|
s =... | [
"def",
"managed?",
"# Once an object is managed, it always stays managed; but an object",
"# that is listed as unmanaged might become managed later in the process,",
"# so we have to check that every time",
"if",
"@managed",
"return",
"@managed",
"else",
"@managed",
"=",
"false",
"properti... | Returns true if the instance is a managed instance.
A 'yes' here means that the instance was created from the language, vs. being created
in order resolve other questions, such as finding a package in a list.
@note An object that is managed always stays managed, but an object that is not managed
may become manage... | [
"Returns",
"true",
"if",
"the",
"instance",
"is",
"a",
"managed",
"instance",
".",
"A",
"yes",
"here",
"means",
"that",
"the",
"instance",
"was",
"created",
"from",
"the",
"language",
"vs",
".",
"being",
"created",
"in",
"order",
"resolve",
"other",
"quest... | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/type.rb#L927-L944 | train |
puppetlabs/puppet | lib/puppet/type.rb | Puppet.Type.retrieve | def retrieve
fail "Provider #{provider.class.name} is not functional on this host" if self.provider.is_a?(Puppet::Provider) and ! provider.class.suitable?
result = Puppet::Resource.new(self.class, title)
# Provide the name, so we know we'll always refer to a real thing
result[:name] = self[:name] unle... | ruby | def retrieve
fail "Provider #{provider.class.name} is not functional on this host" if self.provider.is_a?(Puppet::Provider) and ! provider.class.suitable?
result = Puppet::Resource.new(self.class, title)
# Provide the name, so we know we'll always refer to a real thing
result[:name] = self[:name] unle... | [
"def",
"retrieve",
"fail",
"\"Provider #{provider.class.name} is not functional on this host\"",
"if",
"self",
".",
"provider",
".",
"is_a?",
"(",
"Puppet",
"::",
"Provider",
")",
"and",
"!",
"provider",
".",
"class",
".",
"suitable?",
"result",
"=",
"Puppet",
"::",... | Retrieves the current value of all contained properties.
Parameters and meta-parameters are not included in the result.
@todo As opposed to all non contained properties? How is this different than any of the other
methods that also "gets" properties/parameters/etc. ?
@return [Puppet::Resource] array of all proper... | [
"Retrieves",
"the",
"current",
"value",
"of",
"all",
"contained",
"properties",
".",
"Parameters",
"and",
"meta",
"-",
"parameters",
"are",
"not",
"included",
"in",
"the",
"result",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/type.rb#L1068-L1092 | train |
puppetlabs/puppet | lib/puppet/type.rb | Puppet.Type.builddepends | def builddepends
# Handle the requires
self.class.relationship_params.collect do |klass|
if param = @parameters[klass.name]
param.to_edges
end
end.flatten.reject { |r| r.nil? }
end | ruby | def builddepends
# Handle the requires
self.class.relationship_params.collect do |klass|
if param = @parameters[klass.name]
param.to_edges
end
end.flatten.reject { |r| r.nil? }
end | [
"def",
"builddepends",
"# Handle the requires",
"self",
".",
"class",
".",
"relationship_params",
".",
"collect",
"do",
"|",
"klass",
"|",
"if",
"param",
"=",
"@parameters",
"[",
"klass",
".",
"name",
"]",
"param",
".",
"to_edges",
"end",
"end",
".",
"flatte... | Builds the dependencies associated with this resource.
@return [Array<Puppet::Relationship>] list of relationships to other resources | [
"Builds",
"the",
"dependencies",
"associated",
"with",
"this",
"resource",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/type.rb#L2194-L2201 | train |
puppetlabs/puppet | lib/puppet/type.rb | Puppet.Type.set_sensitive_parameters | def set_sensitive_parameters(sensitive_parameters)
sensitive_parameters.each do |name|
p = parameter(name)
if p.is_a?(Puppet::Property)
p.sensitive = true
elsif p.is_a?(Puppet::Parameter)
warning(_("Unable to mark '%{name}' as sensitive: %{name} is a parameter and not a property, a... | ruby | def set_sensitive_parameters(sensitive_parameters)
sensitive_parameters.each do |name|
p = parameter(name)
if p.is_a?(Puppet::Property)
p.sensitive = true
elsif p.is_a?(Puppet::Parameter)
warning(_("Unable to mark '%{name}' as sensitive: %{name} is a parameter and not a property, a... | [
"def",
"set_sensitive_parameters",
"(",
"sensitive_parameters",
")",
"sensitive_parameters",
".",
"each",
"do",
"|",
"name",
"|",
"p",
"=",
"parameter",
"(",
"name",
")",
"if",
"p",
".",
"is_a?",
"(",
"Puppet",
"::",
"Property",
")",
"p",
".",
"sensitive",
... | Mark parameters associated with this type as sensitive, based on the associated resource.
Currently, only instances of `Puppet::Property` can be easily marked for sensitive data handling
and information redaction is limited to redacting events generated while synchronizing
properties. While support for redaction wi... | [
"Mark",
"parameters",
"associated",
"with",
"this",
"type",
"as",
"sensitive",
"based",
"on",
"the",
"associated",
"resource",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/type.rb#L2439-L2460 | train |
puppetlabs/puppet | lib/puppet/type.rb | Puppet.Type.finish | def finish
# Call post_compile hook on every parameter that implements it. This includes all subclasses
# of parameter including, but not limited to, regular parameters, metaparameters, relationship
# parameters, and properties.
eachparameter do |parameter|
parameter.post_compile if parameter.resp... | ruby | def finish
# Call post_compile hook on every parameter that implements it. This includes all subclasses
# of parameter including, but not limited to, regular parameters, metaparameters, relationship
# parameters, and properties.
eachparameter do |parameter|
parameter.post_compile if parameter.resp... | [
"def",
"finish",
"# Call post_compile hook on every parameter that implements it. This includes all subclasses",
"# of parameter including, but not limited to, regular parameters, metaparameters, relationship",
"# parameters, and properties.",
"eachparameter",
"do",
"|",
"parameter",
"|",
"param... | Finishes any outstanding processing.
This method should be called as a final step in setup,
to allow the parameters that have associated auto-require needs to be processed.
@todo what is the expected sequence here - who is responsible for calling this? When?
Is the returned type correct?
@return [Array<Puppet::... | [
"Finishes",
"any",
"outstanding",
"processing",
".",
"This",
"method",
"should",
"be",
"called",
"as",
"a",
"final",
"step",
"in",
"setup",
"to",
"allow",
"the",
"parameters",
"that",
"have",
"associated",
"auto",
"-",
"require",
"needs",
"to",
"be",
"proces... | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/type.rb#L2528-L2543 | train |
puppetlabs/puppet | lib/puppet/environments.rb | Puppet::Environments.EnvironmentCreator.for | def for(module_path, manifest)
Puppet::Node::Environment.create(:anonymous,
module_path.split(File::PATH_SEPARATOR),
manifest)
end | ruby | def for(module_path, manifest)
Puppet::Node::Environment.create(:anonymous,
module_path.split(File::PATH_SEPARATOR),
manifest)
end | [
"def",
"for",
"(",
"module_path",
",",
"manifest",
")",
"Puppet",
"::",
"Node",
"::",
"Environment",
".",
"create",
"(",
":anonymous",
",",
"module_path",
".",
"split",
"(",
"File",
"::",
"PATH_SEPARATOR",
")",
",",
"manifest",
")",
"end"
] | Create an anonymous environment.
@param module_path [String] A list of module directories separated by the
PATH_SEPARATOR
@param manifest [String] The path to the manifest
@return A new environment with the `name` `:anonymous`
@api private | [
"Create",
"an",
"anonymous",
"environment",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/environments.rb#L21-L25 | train |
puppetlabs/puppet | lib/puppet/environments.rb | Puppet::Environments.Static.get_conf | def get_conf(name)
env = get(name)
if env
Puppet::Settings::EnvironmentConf.static_for(env, Puppet[:environment_timeout], Puppet[:static_catalogs], Puppet[:rich_data])
else
nil
end
end | ruby | def get_conf(name)
env = get(name)
if env
Puppet::Settings::EnvironmentConf.static_for(env, Puppet[:environment_timeout], Puppet[:static_catalogs], Puppet[:rich_data])
else
nil
end
end | [
"def",
"get_conf",
"(",
"name",
")",
"env",
"=",
"get",
"(",
"name",
")",
"if",
"env",
"Puppet",
"::",
"Settings",
"::",
"EnvironmentConf",
".",
"static_for",
"(",
"env",
",",
"Puppet",
"[",
":environment_timeout",
"]",
",",
"Puppet",
"[",
":static_catalog... | Returns a basic environment configuration object tied to the environment's
implementation values. Will not interpolate.
@!macro loader_get_conf | [
"Returns",
"a",
"basic",
"environment",
"configuration",
"object",
"tied",
"to",
"the",
"environment",
"s",
"implementation",
"values",
".",
"Will",
"not",
"interpolate",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/environments.rb#L115-L122 | train |
puppetlabs/puppet | lib/puppet/environments.rb | Puppet::Environments.Cached.add_entry | def add_entry(name, cache_entry)
Puppet.debug {"Caching environment '#{name}' #{cache_entry.label}"}
@cache[name] = cache_entry
expires = cache_entry.expires
@expirations.add(expires)
if @next_expiration > expires
@next_expiration = expires
end
end | ruby | def add_entry(name, cache_entry)
Puppet.debug {"Caching environment '#{name}' #{cache_entry.label}"}
@cache[name] = cache_entry
expires = cache_entry.expires
@expirations.add(expires)
if @next_expiration > expires
@next_expiration = expires
end
end | [
"def",
"add_entry",
"(",
"name",
",",
"cache_entry",
")",
"Puppet",
".",
"debug",
"{",
"\"Caching environment '#{name}' #{cache_entry.label}\"",
"}",
"@cache",
"[",
"name",
"]",
"=",
"cache_entry",
"expires",
"=",
"cache_entry",
".",
"expires",
"@expirations",
".",
... | Adds a cache entry to the cache | [
"Adds",
"a",
"cache",
"entry",
"to",
"the",
"cache"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/environments.rb#L365-L373 | train |
puppetlabs/puppet | lib/puppet/environments.rb | Puppet::Environments.Cached.clear_all_expired | def clear_all_expired()
t = Time.now
return if t < @next_expiration && ! @cache.any? {|name, _| @cache_expiration_service.expired?(name.to_sym) }
to_expire = @cache.select { |name, entry| entry.expires < t || @cache_expiration_service.expired?(name.to_sym) }
to_expire.each do |name, entry|
... | ruby | def clear_all_expired()
t = Time.now
return if t < @next_expiration && ! @cache.any? {|name, _| @cache_expiration_service.expired?(name.to_sym) }
to_expire = @cache.select { |name, entry| entry.expires < t || @cache_expiration_service.expired?(name.to_sym) }
to_expire.each do |name, entry|
... | [
"def",
"clear_all_expired",
"(",
")",
"t",
"=",
"Time",
".",
"now",
"return",
"if",
"t",
"<",
"@next_expiration",
"&&",
"!",
"@cache",
".",
"any?",
"{",
"|",
"name",
",",
"_",
"|",
"@cache_expiration_service",
".",
"expired?",
"(",
"name",
".",
"to_sym",... | Clears all environments that have expired, either by exceeding their time to live, or
through an explicit eviction determined by the cache expiration service. | [
"Clears",
"all",
"environments",
"that",
"have",
"expired",
"either",
"by",
"exceeding",
"their",
"time",
"to",
"live",
"or",
"through",
"an",
"explicit",
"eviction",
"determined",
"by",
"the",
"cache",
"expiration",
"service",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/environments.rb#L396-L408 | train |
puppetlabs/puppet | lib/puppet/environments.rb | Puppet::Environments.Cached.entry | def entry(env)
ttl = (conf = get_conf(env.name)) ? conf.environment_timeout : Puppet.settings.value(:environment_timeout)
case ttl
when 0
NotCachedEntry.new(env) # Entry that is always expired (avoids syscall to get time)
when Float::INFINITY
Entry.new(env) # Ent... | ruby | def entry(env)
ttl = (conf = get_conf(env.name)) ? conf.environment_timeout : Puppet.settings.value(:environment_timeout)
case ttl
when 0
NotCachedEntry.new(env) # Entry that is always expired (avoids syscall to get time)
when Float::INFINITY
Entry.new(env) # Ent... | [
"def",
"entry",
"(",
"env",
")",
"ttl",
"=",
"(",
"conf",
"=",
"get_conf",
"(",
"env",
".",
"name",
")",
")",
"?",
"conf",
".",
"environment_timeout",
":",
"Puppet",
".",
"settings",
".",
"value",
"(",
":environment_timeout",
")",
"case",
"ttl",
"when"... | Creates a suitable cache entry given the time to live for one environment | [
"Creates",
"a",
"suitable",
"cache",
"entry",
"given",
"the",
"time",
"to",
"live",
"for",
"one",
"environment"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/environments.rb#L425-L435 | train |
puppetlabs/puppet | lib/puppet/environments.rb | Puppet::Environments.Cached.evict_if_expired | def evict_if_expired(name)
if (result = @cache[name]) && (result.expired? || @cache_expiration_service.expired?(name))
Puppet.debug {"Evicting cache entry for environment '#{name}'"}
@cache_expiration_service.evicted(name)
clear(name)
Puppet.settings.clear_environment_settings(name... | ruby | def evict_if_expired(name)
if (result = @cache[name]) && (result.expired? || @cache_expiration_service.expired?(name))
Puppet.debug {"Evicting cache entry for environment '#{name}'"}
@cache_expiration_service.evicted(name)
clear(name)
Puppet.settings.clear_environment_settings(name... | [
"def",
"evict_if_expired",
"(",
"name",
")",
"if",
"(",
"result",
"=",
"@cache",
"[",
"name",
"]",
")",
"&&",
"(",
"result",
".",
"expired?",
"||",
"@cache_expiration_service",
".",
"expired?",
"(",
"name",
")",
")",
"Puppet",
".",
"debug",
"{",
"\"Evict... | Evicts the entry if it has expired
Also clears caches in Settings that may prevent the entry from being updated | [
"Evicts",
"the",
"entry",
"if",
"it",
"has",
"expired",
"Also",
"clears",
"caches",
"in",
"Settings",
"that",
"may",
"prevent",
"the",
"entry",
"from",
"being",
"updated"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/environments.rb#L439-L446 | train |
puppetlabs/puppet | lib/puppet/module_tool/checksums.rb | Puppet::ModuleTool.Checksums.data | def data
unless @data
@data = {}
@path.find do |descendant|
if Puppet::ModuleTool.artifact?(descendant)
Find.prune
elsif descendant.file?
path = descendant.relative_path_from(@path)
@data[path.to_s] = checksum(descendant)
end
... | ruby | def data
unless @data
@data = {}
@path.find do |descendant|
if Puppet::ModuleTool.artifact?(descendant)
Find.prune
elsif descendant.file?
path = descendant.relative_path_from(@path)
@data[path.to_s] = checksum(descendant)
end
... | [
"def",
"data",
"unless",
"@data",
"@data",
"=",
"{",
"}",
"@path",
".",
"find",
"do",
"|",
"descendant",
"|",
"if",
"Puppet",
"::",
"ModuleTool",
".",
"artifact?",
"(",
"descendant",
")",
"Find",
".",
"prune",
"elsif",
"descendant",
".",
"file?",
"path",... | Return checksums for object's +Pathname+, generate if it's needed.
Result is a hash of path strings to checksum strings. | [
"Return",
"checksums",
"for",
"object",
"s",
"+",
"Pathname",
"+",
"generate",
"if",
"it",
"s",
"needed",
".",
"Result",
"is",
"a",
"hash",
"of",
"path",
"strings",
"to",
"checksum",
"strings",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/module_tool/checksums.rb#L26-L39 | train |
puppetlabs/puppet | lib/puppet/rest/route.rb | Puppet::Rest.Route.with_base_url | def with_base_url(dns_resolver)
if @server && @port
# First try connecting to the previously selected server and port.
begin
return yield(base_url)
rescue SystemCallError => e
if Puppet[:use_srv_records]
Puppet.debug "Connection to cached server and port #{@... | ruby | def with_base_url(dns_resolver)
if @server && @port
# First try connecting to the previously selected server and port.
begin
return yield(base_url)
rescue SystemCallError => e
if Puppet[:use_srv_records]
Puppet.debug "Connection to cached server and port #{@... | [
"def",
"with_base_url",
"(",
"dns_resolver",
")",
"if",
"@server",
"&&",
"@port",
"# First try connecting to the previously selected server and port.",
"begin",
"return",
"yield",
"(",
"base_url",
")",
"rescue",
"SystemCallError",
"=>",
"e",
"if",
"Puppet",
"[",
":use_s... | Create a Route containing information for querying the given API,
hosted at a server determined either by SRV service or by the
fallback server on the fallback port.
@param [String] api the path leading to the root of the API. Must
contain a trailing slash for proper endpoint path
c... | [
"Create",
"a",
"Route",
"containing",
"information",
"for",
"querying",
"the",
"given",
"API",
"hosted",
"at",
"a",
"server",
"determined",
"either",
"by",
"SRV",
"service",
"or",
"by",
"the",
"fallback",
"server",
"on",
"the",
"fallback",
"port",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/rest/route.rb#L37-L74 | train |
puppetlabs/puppet | lib/puppet/application.rb | Puppet.Application.run | def run
# I don't really like the names of these lifecycle phases. It would be nice to change them to some more meaningful
# names, and make deprecated aliases. --cprice 2012-03-16
exit_on_fail(_("Could not get application-specific default settings")) do
initialize_app_defaults
end
Puppet... | ruby | def run
# I don't really like the names of these lifecycle phases. It would be nice to change them to some more meaningful
# names, and make deprecated aliases. --cprice 2012-03-16
exit_on_fail(_("Could not get application-specific default settings")) do
initialize_app_defaults
end
Puppet... | [
"def",
"run",
"# I don't really like the names of these lifecycle phases. It would be nice to change them to some more meaningful",
"# names, and make deprecated aliases. --cprice 2012-03-16",
"exit_on_fail",
"(",
"_",
"(",
"\"Could not get application-specific default settings\"",
")",
")",
... | Execute the application.
@api public
@return [void] | [
"Execute",
"the",
"application",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/application.rb#L361-L383 | train |
puppetlabs/puppet | lib/puppet/application.rb | Puppet.Application.log_runtime_environment | def log_runtime_environment(extra_info=nil)
runtime_info = {
'puppet_version' => Puppet.version,
'ruby_version' => RUBY_VERSION,
'run_mode' => self.class.run_mode.name,
}
runtime_info['default_encoding'] = Encoding.default_external
runtime_info.merge!(extra_info) unless extra_i... | ruby | def log_runtime_environment(extra_info=nil)
runtime_info = {
'puppet_version' => Puppet.version,
'ruby_version' => RUBY_VERSION,
'run_mode' => self.class.run_mode.name,
}
runtime_info['default_encoding'] = Encoding.default_external
runtime_info.merge!(extra_info) unless extra_i... | [
"def",
"log_runtime_environment",
"(",
"extra_info",
"=",
"nil",
")",
"runtime_info",
"=",
"{",
"'puppet_version'",
"=>",
"Puppet",
".",
"version",
",",
"'ruby_version'",
"=>",
"RUBY_VERSION",
",",
"'run_mode'",
"=>",
"self",
".",
"class",
".",
"run_mode",
".",
... | Output basic information about the runtime environment for debugging
purposes.
@api public
@param extra_info [Hash{String => #to_s}] a flat hash of extra information
to log. Intended to be passed to super by subclasses.
@return [void] | [
"Output",
"basic",
"information",
"about",
"the",
"runtime",
"environment",
"for",
"debugging",
"purposes",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/application.rb#L444-L454 | train |
puppetlabs/puppet | lib/puppet/functions.rb | Puppet::Functions.DispatcherBuilder.required_repeated_param | def required_repeated_param(type, name)
internal_param(type, name, true)
raise ArgumentError, _('A required repeated parameter cannot be added after an optional parameter') if @min != @max
@min += 1
@max = :default
end | ruby | def required_repeated_param(type, name)
internal_param(type, name, true)
raise ArgumentError, _('A required repeated parameter cannot be added after an optional parameter') if @min != @max
@min += 1
@max = :default
end | [
"def",
"required_repeated_param",
"(",
"type",
",",
"name",
")",
"internal_param",
"(",
"type",
",",
"name",
",",
"true",
")",
"raise",
"ArgumentError",
",",
"_",
"(",
"'A required repeated parameter cannot be added after an optional parameter'",
")",
"if",
"@min",
"!... | Defines a repeated positional parameter with _type_ and _name_ that may occur 1 to "infinite" number of times.
It may only appear last or just before a block parameter.
@param type [String] The type specification for the parameter.
@param name [Symbol] The name of the parameter. This is primarily used
for error ... | [
"Defines",
"a",
"repeated",
"positional",
"parameter",
"with",
"_type_",
"and",
"_name_",
"that",
"may",
"occur",
"1",
"to",
"infinite",
"number",
"of",
"times",
".",
"It",
"may",
"only",
"appear",
"last",
"or",
"just",
"before",
"a",
"block",
"parameter",
... | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/functions.rb#L461-L466 | train |
puppetlabs/puppet | lib/puppet/functions.rb | Puppet::Functions.DispatcherBuilder.block_param | def block_param(*type_and_name)
case type_and_name.size
when 0
type = @all_callables
name = :block
when 1
type = @all_callables
name = type_and_name[0]
when 2
type, name = type_and_name
type = Puppet::Pops::Types::TypeParser.singleton.parse(type, l... | ruby | def block_param(*type_and_name)
case type_and_name.size
when 0
type = @all_callables
name = :block
when 1
type = @all_callables
name = type_and_name[0]
when 2
type, name = type_and_name
type = Puppet::Pops::Types::TypeParser.singleton.parse(type, l... | [
"def",
"block_param",
"(",
"*",
"type_and_name",
")",
"case",
"type_and_name",
".",
"size",
"when",
"0",
"type",
"=",
"@all_callables",
"name",
"=",
":block",
"when",
"1",
"type",
"=",
"@all_callables",
"name",
"=",
"type_and_name",
"[",
"0",
"]",
"when",
... | Defines one required block parameter that may appear last. If type and name is missing the
default type is "Callable", and the name is "block". If only one
parameter is given, then that is the name and the type is "Callable".
@api public | [
"Defines",
"one",
"required",
"block",
"parameter",
"that",
"may",
"appear",
"last",
".",
"If",
"type",
"and",
"name",
"is",
"missing",
"the",
"default",
"type",
"is",
"Callable",
"and",
"the",
"name",
"is",
"block",
".",
"If",
"only",
"one",
"parameter",
... | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/functions.rb#L473-L502 | train |
puppetlabs/puppet | lib/puppet/functions.rb | Puppet::Functions.LocalTypeAliasesBuilder.type | def type(assignment_string)
# Get location to use in case of error - this produces ruby filename and where call to 'type' occurred
# but strips off the rest of the internal "where" as it is not meaningful to user.
#
rb_location = caller[0]
begin
result = parser.parse_string("type ... | ruby | def type(assignment_string)
# Get location to use in case of error - this produces ruby filename and where call to 'type' occurred
# but strips off the rest of the internal "where" as it is not meaningful to user.
#
rb_location = caller[0]
begin
result = parser.parse_string("type ... | [
"def",
"type",
"(",
"assignment_string",
")",
"# Get location to use in case of error - this produces ruby filename and where call to 'type' occurred",
"# but strips off the rest of the internal \"where\" as it is not meaningful to user.",
"#",
"rb_location",
"=",
"caller",
"[",
"0",
"]",
... | Defines a local type alias, the given string should be a Puppet Language type alias expression
in string form without the leading 'type' keyword.
Calls to local_type must be made before the first parameter definition or an error will
be raised.
@param assignment_string [String] a string on the form 'AliasType = Ex... | [
"Defines",
"a",
"local",
"type",
"alias",
"the",
"given",
"string",
"should",
"be",
"a",
"Puppet",
"Language",
"type",
"alias",
"expression",
"in",
"string",
"form",
"without",
"the",
"leading",
"type",
"keyword",
".",
"Calls",
"to",
"local_type",
"must",
"b... | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/functions.rb#L623-L651 | train |
puppetlabs/puppet | lib/puppet/pops/merge_strategy.rb | Puppet::Pops.MergeStrategy.lookup | def lookup(lookup_variants, lookup_invocation)
case lookup_variants.size
when 0
throw :no_such_key
when 1
merge_single(yield(lookup_variants[0]))
else
lookup_invocation.with(:merge, self) do
result = lookup_variants.reduce(NOT_FOUND) do |memo, lookup_variant|
... | ruby | def lookup(lookup_variants, lookup_invocation)
case lookup_variants.size
when 0
throw :no_such_key
when 1
merge_single(yield(lookup_variants[0]))
else
lookup_invocation.with(:merge, self) do
result = lookup_variants.reduce(NOT_FOUND) do |memo, lookup_variant|
... | [
"def",
"lookup",
"(",
"lookup_variants",
",",
"lookup_invocation",
")",
"case",
"lookup_variants",
".",
"size",
"when",
"0",
"throw",
":no_such_key",
"when",
"1",
"merge_single",
"(",
"yield",
"(",
"lookup_variants",
"[",
"0",
"]",
")",
")",
"else",
"lookup_in... | Merges the result of yielding the given _lookup_variants_ to a given block.
@param lookup_variants [Array] The variants to pass as second argument to the given block
@return [Object] the merged value.
@yield [} ]
@yieldparam variant [Object] each variant given in the _lookup_variants_ array.
@yieldreturn [Object]... | [
"Merges",
"the",
"result",
"of",
"yielding",
"the",
"given",
"_lookup_variants_",
"to",
"a",
"given",
"block",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/pops/merge_strategy.rb#L121-L146 | train |
puppetlabs/puppet | lib/puppet/network/http/compression.rb | Puppet::Network::HTTP::Compression.Active.uncompress_body | def uncompress_body(response)
case response['content-encoding']
when 'gzip'
# ZLib::GzipReader has an associated encoding, by default Encoding.default_external
return Zlib::GzipReader.new(StringIO.new(response.body), :encoding => Encoding::BINARY).read
when 'deflate'
return Zli... | ruby | def uncompress_body(response)
case response['content-encoding']
when 'gzip'
# ZLib::GzipReader has an associated encoding, by default Encoding.default_external
return Zlib::GzipReader.new(StringIO.new(response.body), :encoding => Encoding::BINARY).read
when 'deflate'
return Zli... | [
"def",
"uncompress_body",
"(",
"response",
")",
"case",
"response",
"[",
"'content-encoding'",
"]",
"when",
"'gzip'",
"# ZLib::GzipReader has an associated encoding, by default Encoding.default_external",
"return",
"Zlib",
"::",
"GzipReader",
".",
"new",
"(",
"StringIO",
".... | return an uncompressed body if the response has been
compressed | [
"return",
"an",
"uncompressed",
"body",
"if",
"the",
"response",
"has",
"been",
"compressed"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/network/http/compression.rb#L20-L32 | train |
puppetlabs/puppet | lib/puppet/network/rights.rb | Puppet::Network.Rights.newright | def newright(name, line=nil, file=nil)
add_right( Right.new(name, line, file) )
end | ruby | def newright(name, line=nil, file=nil)
add_right( Right.new(name, line, file) )
end | [
"def",
"newright",
"(",
"name",
",",
"line",
"=",
"nil",
",",
"file",
"=",
"nil",
")",
"add_right",
"(",
"Right",
".",
"new",
"(",
"name",
",",
"line",
",",
"file",
")",
")",
"end"
] | Define a new right to which access can be provided. | [
"Define",
"a",
"new",
"right",
"to",
"which",
"access",
"can",
"be",
"provided",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/network/rights.rb#L82-L84 | train |
puppetlabs/puppet | lib/puppet/network/authstore.rb | Puppet.Network::AuthStore.allowed? | def allowed?(name, ip)
if name or ip
# This is probably unnecessary, and can cause some weirdness in
# cases where we're operating over localhost but don't have a real
# IP defined.
raise Puppet::DevError, _("Name and IP must be passed to 'allowed?'") unless name and ip
# e... | ruby | def allowed?(name, ip)
if name or ip
# This is probably unnecessary, and can cause some weirdness in
# cases where we're operating over localhost but don't have a real
# IP defined.
raise Puppet::DevError, _("Name and IP must be passed to 'allowed?'") unless name and ip
# e... | [
"def",
"allowed?",
"(",
"name",
",",
"ip",
")",
"if",
"name",
"or",
"ip",
"# This is probably unnecessary, and can cause some weirdness in",
"# cases where we're operating over localhost but don't have a real",
"# IP defined.",
"raise",
"Puppet",
"::",
"DevError",
",",
"_",
"... | Is a given combination of name and ip address allowed? If either input
is non-nil, then both inputs must be provided. If neither input
is provided, then the authstore is considered local and defaults to "true". | [
"Is",
"a",
"given",
"combination",
"of",
"name",
"and",
"ip",
"address",
"allowed?",
"If",
"either",
"input",
"is",
"non",
"-",
"nil",
"then",
"both",
"inputs",
"must",
"be",
"provided",
".",
"If",
"neither",
"input",
"is",
"provided",
"then",
"the",
"au... | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/network/authstore.rb#L17-L38 | train |
puppetlabs/puppet | lib/puppet/metatype/manager.rb | Puppet::MetaType.Manager.type | def type(name)
# Avoid loading if name obviously is not a type name
if name.to_s.include?(':')
return nil
end
@types ||= {}
# We are overwhelmingly symbols here, which usually match, so it is worth
# having this special-case to return quickly. Like, 25K symbols vs. 300
# strings in ... | ruby | def type(name)
# Avoid loading if name obviously is not a type name
if name.to_s.include?(':')
return nil
end
@types ||= {}
# We are overwhelmingly symbols here, which usually match, so it is worth
# having this special-case to return quickly. Like, 25K symbols vs. 300
# strings in ... | [
"def",
"type",
"(",
"name",
")",
"# Avoid loading if name obviously is not a type name",
"if",
"name",
".",
"to_s",
".",
"include?",
"(",
"':'",
")",
"return",
"nil",
"end",
"@types",
"||=",
"{",
"}",
"# We are overwhelmingly symbols here, which usually match, so it is wo... | Returns a Type instance by name.
This will load the type if not already defined.
@param [String, Symbol] name of the wanted Type
@return [Puppet::Type, nil] the type or nil if the type was not defined and could not be loaded | [
"Returns",
"a",
"Type",
"instance",
"by",
"name",
".",
"This",
"will",
"load",
"the",
"type",
"if",
"not",
"already",
"defined",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/metatype/manager.rb#L153-L182 | train |
puppetlabs/puppet | lib/puppet/pops/loaders.rb | Puppet::Pops.Loaders.[] | def [](loader_name)
loader = @loaders_by_name[loader_name]
if loader.nil?
# Unable to find the module private loader. Try resolving the module
loader = private_loader_for_module(loader_name[0..-9]) if loader_name.end_with?(' private')
raise Puppet::ParseError, _("Unable to find loader named '%... | ruby | def [](loader_name)
loader = @loaders_by_name[loader_name]
if loader.nil?
# Unable to find the module private loader. Try resolving the module
loader = private_loader_for_module(loader_name[0..-9]) if loader_name.end_with?(' private')
raise Puppet::ParseError, _("Unable to find loader named '%... | [
"def",
"[]",
"(",
"loader_name",
")",
"loader",
"=",
"@loaders_by_name",
"[",
"loader_name",
"]",
"if",
"loader",
".",
"nil?",
"# Unable to find the module private loader. Try resolving the module",
"loader",
"=",
"private_loader_for_module",
"(",
"loader_name",
"[",
"0",... | Lookup a loader by its unique name.
@param [String] loader_name the name of the loader to lookup
@return [Loader] the found loader
@raise [Puppet::ParserError] if no loader is found | [
"Lookup",
"a",
"loader",
"by",
"its",
"unique",
"name",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/pops/loaders.rb#L183-L191 | train |
puppetlabs/puppet | lib/puppet/pops/loaders.rb | Puppet::Pops.Loaders.find_loader | def find_loader(module_name)
if module_name.nil? || EMPTY_STRING == module_name
# Use the public environment loader
public_environment_loader
else
# TODO : Later check if definition is private, and then add it to private_loader_for_module
#
loader = public_loader_for_module(module_... | ruby | def find_loader(module_name)
if module_name.nil? || EMPTY_STRING == module_name
# Use the public environment loader
public_environment_loader
else
# TODO : Later check if definition is private, and then add it to private_loader_for_module
#
loader = public_loader_for_module(module_... | [
"def",
"find_loader",
"(",
"module_name",
")",
"if",
"module_name",
".",
"nil?",
"||",
"EMPTY_STRING",
"==",
"module_name",
"# Use the public environment loader",
"public_environment_loader",
"else",
"# TODO : Later check if definition is private, and then add it to private_loader_fo... | Finds the appropriate loader for the given `module_name`, or for the environment in case `module_name`
is `nil` or empty.
@param module_name [String,nil] the name of the module
@return [Loader::Loader] the found loader
@raise [Puppet::ParseError] if no loader can be found
@api private | [
"Finds",
"the",
"appropriate",
"loader",
"for",
"the",
"given",
"module_name",
"or",
"for",
"the",
"environment",
"in",
"case",
"module_name",
"is",
"nil",
"or",
"empty",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/pops/loaders.rb#L200-L213 | train |
puppetlabs/puppet | lib/puppet/pops/loaders.rb | Puppet::Pops.Loaders.load_main_manifest | def load_main_manifest
parser = Parser::EvaluatingParser.singleton
parsed_code = Puppet[:code]
program = if parsed_code != ""
parser.parse_string(parsed_code, 'unknown-source-location')
else
file = @environment.manifest
# if the manifest file is a reference to a directory, parse and c... | ruby | def load_main_manifest
parser = Parser::EvaluatingParser.singleton
parsed_code = Puppet[:code]
program = if parsed_code != ""
parser.parse_string(parsed_code, 'unknown-source-location')
else
file = @environment.manifest
# if the manifest file is a reference to a directory, parse and c... | [
"def",
"load_main_manifest",
"parser",
"=",
"Parser",
"::",
"EvaluatingParser",
".",
"singleton",
"parsed_code",
"=",
"Puppet",
"[",
":code",
"]",
"program",
"=",
"if",
"parsed_code",
"!=",
"\"\"",
"parser",
".",
"parse_string",
"(",
"parsed_code",
",",
"'unknow... | Load the main manifest for the given environment
There are two sources that can be used for the initial parse:
1. The value of `Puppet[:code]`: Puppet can take a string from
its settings and parse that as a manifest. This is used by various
Puppet applications to read in a manifest and pass it to the
... | [
"Load",
"the",
"main",
"manifest",
"for",
"the",
"given",
"environment"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/pops/loaders.rb#L272-L302 | train |
puppetlabs/puppet | lib/puppet/pops/loaders.rb | Puppet::Pops.Loaders.instantiate_definitions | def instantiate_definitions(program, loader)
program.definitions.each { |d| instantiate_definition(d, loader) }
nil
end | ruby | def instantiate_definitions(program, loader)
program.definitions.each { |d| instantiate_definition(d, loader) }
nil
end | [
"def",
"instantiate_definitions",
"(",
"program",
",",
"loader",
")",
"program",
".",
"definitions",
".",
"each",
"{",
"|",
"d",
"|",
"instantiate_definition",
"(",
"d",
",",
"loader",
")",
"}",
"nil",
"end"
] | Add 4.x definitions found in the given program to the given loader. | [
"Add",
"4",
".",
"x",
"definitions",
"found",
"in",
"the",
"given",
"program",
"to",
"the",
"given",
"loader",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/pops/loaders.rb#L305-L308 | train |
puppetlabs/puppet | lib/puppet/pops/loaders.rb | Puppet::Pops.Loaders.instantiate_definition | def instantiate_definition(definition, loader)
case definition
when Model::PlanDefinition
instantiate_PlanDefinition(definition, loader)
when Model::FunctionDefinition
instantiate_FunctionDefinition(definition, loader)
when Model::TypeAlias
instantiate_TypeAlias(definition, loader)
... | ruby | def instantiate_definition(definition, loader)
case definition
when Model::PlanDefinition
instantiate_PlanDefinition(definition, loader)
when Model::FunctionDefinition
instantiate_FunctionDefinition(definition, loader)
when Model::TypeAlias
instantiate_TypeAlias(definition, loader)
... | [
"def",
"instantiate_definition",
"(",
"definition",
",",
"loader",
")",
"case",
"definition",
"when",
"Model",
"::",
"PlanDefinition",
"instantiate_PlanDefinition",
"(",
"definition",
",",
"loader",
")",
"when",
"Model",
"::",
"FunctionDefinition",
"instantiate_Function... | Add given 4.x definition to the given loader. | [
"Add",
"given",
"4",
".",
"x",
"definition",
"to",
"the",
"given",
"loader",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/pops/loaders.rb#L311-L324 | train |
puppetlabs/puppet | lib/puppet/util/inifile.rb | Puppet::Util::IniConfig.Section.[]= | def []=(key, value)
entry = find_entry(key)
@dirty = true
if entry.nil?
@entries << [key, value]
else
entry[1] = value
end
end | ruby | def []=(key, value)
entry = find_entry(key)
@dirty = true
if entry.nil?
@entries << [key, value]
else
entry[1] = value
end
end | [
"def",
"[]=",
"(",
"key",
",",
"value",
")",
"entry",
"=",
"find_entry",
"(",
"key",
")",
"@dirty",
"=",
"true",
"if",
"entry",
".",
"nil?",
"@entries",
"<<",
"[",
"key",
",",
"value",
"]",
"else",
"entry",
"[",
"1",
"]",
"=",
"value",
"end",
"en... | Set the entry 'key=value'. If no entry with the
given key exists, one is appended to the end of the section | [
"Set",
"the",
"entry",
"key",
"=",
"value",
".",
"If",
"no",
"entry",
"with",
"the",
"given",
"key",
"exists",
"one",
"is",
"appended",
"to",
"the",
"end",
"of",
"the",
"section"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/inifile.rb#L60-L68 | train |
puppetlabs/puppet | lib/puppet/util/inifile.rb | Puppet::Util::IniConfig.Section.format | def format
if @destroy
text = ""
else
text = "[#{name}]\n"
@entries.each do |entry|
if entry.is_a?(Array)
key, value = entry
text << "#{key}=#{value}\n" unless value.nil?
else
text << entry
end
end
end
... | ruby | def format
if @destroy
text = ""
else
text = "[#{name}]\n"
@entries.each do |entry|
if entry.is_a?(Array)
key, value = entry
text << "#{key}=#{value}\n" unless value.nil?
else
text << entry
end
end
end
... | [
"def",
"format",
"if",
"@destroy",
"text",
"=",
"\"\"",
"else",
"text",
"=",
"\"[#{name}]\\n\"",
"@entries",
".",
"each",
"do",
"|",
"entry",
"|",
"if",
"entry",
".",
"is_a?",
"(",
"Array",
")",
"key",
",",
"value",
"=",
"entry",
"text",
"<<",
"\"#{key... | Format the section as text in the way it should be
written to file | [
"Format",
"the",
"section",
"as",
"text",
"in",
"the",
"way",
"it",
"should",
"be",
"written",
"to",
"file"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/inifile.rb#L79-L94 | train |
puppetlabs/puppet | lib/puppet/util/inifile.rb | Puppet::Util::IniConfig.PhysicalFile.read | def read
text = @filetype.read
if text.nil?
raise IniParseError, _("Cannot read nonexistent file %{file}") % { file: @file.inspect }
end
parse(text)
end | ruby | def read
text = @filetype.read
if text.nil?
raise IniParseError, _("Cannot read nonexistent file %{file}") % { file: @file.inspect }
end
parse(text)
end | [
"def",
"read",
"text",
"=",
"@filetype",
".",
"read",
"if",
"text",
".",
"nil?",
"raise",
"IniParseError",
",",
"_",
"(",
"\"Cannot read nonexistent file %{file}\"",
")",
"%",
"{",
"file",
":",
"@file",
".",
"inspect",
"}",
"end",
"parse",
"(",
"text",
")"... | Read and parse the on-disk file associated with this object | [
"Read",
"and",
"parse",
"the",
"on",
"-",
"disk",
"file",
"associated",
"with",
"this",
"object"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/inifile.rb#L136-L142 | train |
puppetlabs/puppet | lib/puppet/util/inifile.rb | Puppet::Util::IniConfig.PhysicalFile.add_section | def add_section(name)
if section_exists?(name)
raise IniParseError.new(_("Section %{name} is already defined, cannot redefine") % { name: name.inspect }, @file)
end
section = Section.new(name, @file)
@contents << section
section
end | ruby | def add_section(name)
if section_exists?(name)
raise IniParseError.new(_("Section %{name} is already defined, cannot redefine") % { name: name.inspect }, @file)
end
section = Section.new(name, @file)
@contents << section
section
end | [
"def",
"add_section",
"(",
"name",
")",
"if",
"section_exists?",
"(",
"name",
")",
"raise",
"IniParseError",
".",
"new",
"(",
"_",
"(",
"\"Section %{name} is already defined, cannot redefine\"",
")",
"%",
"{",
"name",
":",
"name",
".",
"inspect",
"}",
",",
"@f... | Create a new section and store it in the file contents
@api private
@param name [String] The name of the section to create
@return [Puppet::Util::IniConfig::Section] | [
"Create",
"a",
"new",
"section",
"and",
"store",
"it",
"in",
"the",
"file",
"contents"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/inifile.rb#L238-L247 | train |
puppetlabs/puppet | lib/puppet/error.rb | Puppet.ExternalFileError.to_s | def to_s
msg = super
@file = nil if (@file.is_a?(String) && @file.empty?)
msg += Puppet::Util::Errors.error_location_with_space(@file, @line, @pos)
msg
end | ruby | def to_s
msg = super
@file = nil if (@file.is_a?(String) && @file.empty?)
msg += Puppet::Util::Errors.error_location_with_space(@file, @line, @pos)
msg
end | [
"def",
"to_s",
"msg",
"=",
"super",
"@file",
"=",
"nil",
"if",
"(",
"@file",
".",
"is_a?",
"(",
"String",
")",
"&&",
"@file",
".",
"empty?",
")",
"msg",
"+=",
"Puppet",
"::",
"Util",
"::",
"Errors",
".",
"error_location_with_space",
"(",
"@file",
",",
... | May be called with 3 arguments for message, file, line, and exception, or
4 args including the position on the line. | [
"May",
"be",
"called",
"with",
"3",
"arguments",
"for",
"message",
"file",
"line",
"and",
"exception",
"or",
"4",
"args",
"including",
"the",
"position",
"on",
"the",
"line",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/error.rb#L31-L36 | train |
puppetlabs/puppet | lib/puppet/network/http/connection.rb | Puppet::Network::HTTP.Connection.handle_retry_after | def handle_retry_after(response)
retry_after = response['Retry-After']
return response if retry_after.nil?
retry_sleep = parse_retry_after_header(retry_after)
# Recover remote hostname if Net::HTTPResponse was generated by a
# method that fills in the uri attribute.
#
server_h... | ruby | def handle_retry_after(response)
retry_after = response['Retry-After']
return response if retry_after.nil?
retry_sleep = parse_retry_after_header(retry_after)
# Recover remote hostname if Net::HTTPResponse was generated by a
# method that fills in the uri attribute.
#
server_h... | [
"def",
"handle_retry_after",
"(",
"response",
")",
"retry_after",
"=",
"response",
"[",
"'Retry-After'",
"]",
"return",
"response",
"if",
"retry_after",
".",
"nil?",
"retry_sleep",
"=",
"parse_retry_after_header",
"(",
"retry_after",
")",
"# Recover remote hostname if N... | Handles the Retry-After header of a HTTPResponse
This method checks the response for a Retry-After header and handles
it by sleeping for the indicated number of seconds. The response is
returned unmodified if no Retry-After header is present.
@param response [Net::HTTPResponse] A response received from the
HTT... | [
"Handles",
"the",
"Retry",
"-",
"After",
"header",
"of",
"a",
"HTTPResponse"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/network/http/connection.rb#L242-L278 | train |
puppetlabs/puppet | lib/puppet/network/http/connection.rb | Puppet::Network::HTTP.Connection.parse_retry_after_header | def parse_retry_after_header(header_value)
retry_after = begin
Integer(header_value)
rescue TypeError, ArgumentError
begin
DateTime.rfc2822(header_value)
rescue ArgumentError
retur... | ruby | def parse_retry_after_header(header_value)
retry_after = begin
Integer(header_value)
rescue TypeError, ArgumentError
begin
DateTime.rfc2822(header_value)
rescue ArgumentError
retur... | [
"def",
"parse_retry_after_header",
"(",
"header_value",
")",
"retry_after",
"=",
"begin",
"Integer",
"(",
"header_value",
")",
"rescue",
"TypeError",
",",
"ArgumentError",
"begin",
"DateTime",
".",
"rfc2822",
"(",
"header_value",
")",
"rescue",
"ArgumentError",
"ret... | Parse the value of a Retry-After header
Parses a string containing an Integer or RFC 2822 datestamp and returns
an integer number of seconds before a request can be retried.
@param header_value [String] The value of the Retry-After header.
@return [Integer] Number of seconds to wait before retrying the
reques... | [
"Parse",
"the",
"value",
"of",
"a",
"Retry",
"-",
"After",
"header"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/network/http/connection.rb#L292-L310 | train |
puppetlabs/puppet | lib/puppet/util/windows/registry.rb | Puppet::Util::Windows.Registry.values_by_name | def values_by_name(key, names)
vals = {}
names.each do |name|
FFI::Pointer.from_string_to_wide_string(name) do |subkeyname_ptr|
begin
_, vals[name] = read(key, subkeyname_ptr)
rescue Puppet::Util::Windows::Error => e
# ignore missing names, but raise other... | ruby | def values_by_name(key, names)
vals = {}
names.each do |name|
FFI::Pointer.from_string_to_wide_string(name) do |subkeyname_ptr|
begin
_, vals[name] = read(key, subkeyname_ptr)
rescue Puppet::Util::Windows::Error => e
# ignore missing names, but raise other... | [
"def",
"values_by_name",
"(",
"key",
",",
"names",
")",
"vals",
"=",
"{",
"}",
"names",
".",
"each",
"do",
"|",
"name",
"|",
"FFI",
"::",
"Pointer",
".",
"from_string_to_wide_string",
"(",
"name",
")",
"do",
"|",
"subkeyname_ptr",
"|",
"begin",
"_",
",... | Retrieve a set of values from a registry key given their names
Value names listed but not found in the registry will not be added to the
resultant Hashtable
@param key [RegistryKey] An open handle to a Registry Key
@param names [String[]] An array of names of registry values to return if they exist
@return [Hasht... | [
"Retrieve",
"a",
"set",
"of",
"values",
"from",
"a",
"registry",
"key",
"given",
"their",
"names",
"Value",
"names",
"listed",
"but",
"not",
"found",
"in",
"the",
"registry",
"will",
"not",
"be",
"added",
"to",
"the",
"resultant",
"Hashtable"
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/windows/registry.rb#L75-L88 | train |
puppetlabs/puppet | lib/puppet/util/fileparsing.rb | Puppet::Util::FileParsing.FileRecord.fields= | def fields=(fields)
@fields = fields.collect do |field|
r = field.intern
raise ArgumentError.new(_("Cannot have fields named %{name}") % { name: r }) if INVALID_FIELDS.include?(r)
r
end
end | ruby | def fields=(fields)
@fields = fields.collect do |field|
r = field.intern
raise ArgumentError.new(_("Cannot have fields named %{name}") % { name: r }) if INVALID_FIELDS.include?(r)
r
end
end | [
"def",
"fields",
"=",
"(",
"fields",
")",
"@fields",
"=",
"fields",
".",
"collect",
"do",
"|",
"field",
"|",
"r",
"=",
"field",
".",
"intern",
"raise",
"ArgumentError",
".",
"new",
"(",
"_",
"(",
"\"Cannot have fields named %{name}\"",
")",
"%",
"{",
"na... | Customize this so we can do a bit of validation. | [
"Customize",
"this",
"so",
"we",
"can",
"do",
"a",
"bit",
"of",
"validation",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/fileparsing.rb#L40-L46 | train |
puppetlabs/puppet | lib/puppet/util/fileparsing.rb | Puppet::Util::FileParsing.FileRecord.join | def join(details)
joinchar = self.joiner
fields.collect { |field|
# If the field is marked absent, use the appropriate replacement
if details[field] == :absent or details[field] == [:absent] or details[field].nil?
if self.optional.include?(field)
self.absent
... | ruby | def join(details)
joinchar = self.joiner
fields.collect { |field|
# If the field is marked absent, use the appropriate replacement
if details[field] == :absent or details[field] == [:absent] or details[field].nil?
if self.optional.include?(field)
self.absent
... | [
"def",
"join",
"(",
"details",
")",
"joinchar",
"=",
"self",
".",
"joiner",
"fields",
".",
"collect",
"{",
"|",
"field",
"|",
"# If the field is marked absent, use the appropriate replacement",
"if",
"details",
"[",
"field",
"]",
"==",
":absent",
"or",
"details",
... | Convert a record into a line by joining the fields together appropriately.
This is pulled into a separate method so it can be called by the hooks. | [
"Convert",
"a",
"record",
"into",
"a",
"line",
"by",
"joining",
"the",
"fields",
"together",
"appropriately",
".",
"This",
"is",
"pulled",
"into",
"a",
"separate",
"method",
"so",
"it",
"can",
"be",
"called",
"by",
"the",
"hooks",
"."
] | 4baeed97cbb7571ddc6635f0a24debe2e8b22cd3 | https://github.com/puppetlabs/puppet/blob/4baeed97cbb7571ddc6635f0a24debe2e8b22cd3/lib/puppet/util/fileparsing.rb#L102-L117 | train |
zendesk/ruby-kafka | lib/kafka/round_robin_assignment_strategy.rb | Kafka.RoundRobinAssignmentStrategy.assign | def assign(members:, topics:)
group_assignment = {}
members.each do |member_id|
group_assignment[member_id] = Protocol::MemberAssignment.new
end
topic_partitions = topics.flat_map do |topic|
begin
partitions = @cluster.partitions_for(topic).map(&:partition_id)
... | ruby | def assign(members:, topics:)
group_assignment = {}
members.each do |member_id|
group_assignment[member_id] = Protocol::MemberAssignment.new
end
topic_partitions = topics.flat_map do |topic|
begin
partitions = @cluster.partitions_for(topic).map(&:partition_id)
... | [
"def",
"assign",
"(",
"members",
":",
",",
"topics",
":",
")",
"group_assignment",
"=",
"{",
"}",
"members",
".",
"each",
"do",
"|",
"member_id",
"|",
"group_assignment",
"[",
"member_id",
"]",
"=",
"Protocol",
"::",
"MemberAssignment",
".",
"new",
"end",
... | Assign the topic partitions to the group members.
@param members [Array<String>] member ids
@param topics [Array<String>] topics
@return [Hash<String, Protocol::MemberAssignment>] a hash mapping member
ids to assignments. | [
"Assign",
"the",
"topic",
"partitions",
"to",
"the",
"group",
"members",
"."
] | 2a73471b6a607a52dc85c79301ba522acb4566b5 | https://github.com/zendesk/ruby-kafka/blob/2a73471b6a607a52dc85c79301ba522acb4566b5/lib/kafka/round_robin_assignment_strategy.rb#L20-L52 | 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.