id int32 0 24.9k | repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
18,700 | molybdenum-99/tlaw | lib/tlaw/data_table.rb | TLAW.DataTable.to_h | def to_h
keys.map { |k| [k, map { |h| h[k] }] }.to_h
end | ruby | def to_h
keys.map { |k| [k, map { |h| h[k] }] }.to_h
end | [
"def",
"to_h",
"keys",
".",
"map",
"{",
"|",
"k",
"|",
"[",
"k",
",",
"map",
"{",
"|",
"h",
"|",
"h",
"[",
"k",
"]",
"}",
"]",
"}",
".",
"to_h",
"end"
] | Represents DataTable as a `column name => all values in columns`
hash.
@return [Hash{String => Array}] | [
"Represents",
"DataTable",
"as",
"a",
"column",
"name",
"=",
">",
"all",
"values",
"in",
"columns",
"hash",
"."
] | 922ecb7994b91aafda56582d7a69e230d14a19db | https://github.com/molybdenum-99/tlaw/blob/922ecb7994b91aafda56582d7a69e230d14a19db/lib/tlaw/data_table.rb#L100-L102 |
18,701 | gdotdesign/elm-github-install | lib/elm_install/directory_source.rb | ElmInstall.DirectorySource.copy_to | def copy_to(_, directory)
# Delete the directory to make sure no pervious version remains
FileUtils.rm_rf(directory) if directory.exist?
# Create parent directory
FileUtils.mkdir_p(directory.parent)
# Create symlink
FileUtils.ln_s(@dir.expand_path, directory)
nil
end | ruby | def copy_to(_, directory)
# Delete the directory to make sure no pervious version remains
FileUtils.rm_rf(directory) if directory.exist?
# Create parent directory
FileUtils.mkdir_p(directory.parent)
# Create symlink
FileUtils.ln_s(@dir.expand_path, directory)
nil
end | [
"def",
"copy_to",
"(",
"_",
",",
"directory",
")",
"# Delete the directory to make sure no pervious version remains",
"FileUtils",
".",
"rm_rf",
"(",
"directory",
")",
"if",
"directory",
".",
"exist?",
"# Create parent directory",
"FileUtils",
".",
"mkdir_p",
"(",
"dire... | Copies the directory to the given other directory
@param _ [Semverse::Version] The version
@param directory [Pathname] The pathname
@return nil | [
"Copies",
"the",
"directory",
"to",
"the",
"given",
"other",
"directory"
] | 153b1b4c2bfa1a24175fe1d686b40b139674b5b3 | https://github.com/gdotdesign/elm-github-install/blob/153b1b4c2bfa1a24175fe1d686b40b139674b5b3/lib/elm_install/directory_source.rb#L35-L46 |
18,702 | gdotdesign/elm-github-install | lib/elm_install/identifier.rb | ElmInstall.Identifier.identify | def identify(directory)
raw = json(directory)
dependencies = raw['dependencies'].to_h
dependency_sources =
raw['dependency-sources']
.to_h
.merge(@dependency_sources)
dependencies.map do |package, constraint|
constraints = Utils.transform_constraint constraint
... | ruby | def identify(directory)
raw = json(directory)
dependencies = raw['dependencies'].to_h
dependency_sources =
raw['dependency-sources']
.to_h
.merge(@dependency_sources)
dependencies.map do |package, constraint|
constraints = Utils.transform_constraint constraint
... | [
"def",
"identify",
"(",
"directory",
")",
"raw",
"=",
"json",
"(",
"directory",
")",
"dependencies",
"=",
"raw",
"[",
"'dependencies'",
"]",
".",
"to_h",
"dependency_sources",
"=",
"raw",
"[",
"'dependency-sources'",
"]",
".",
"to_h",
".",
"merge",
"(",
"@... | Identifies dependencies from a directory
@param directory [Dir] The directory
@return [Array] The dependencies | [
"Identifies",
"dependencies",
"from",
"a",
"directory"
] | 153b1b4c2bfa1a24175fe1d686b40b139674b5b3 | https://github.com/gdotdesign/elm-github-install/blob/153b1b4c2bfa1a24175fe1d686b40b139674b5b3/lib/elm_install/identifier.rb#L72-L107 |
18,703 | gdotdesign/elm-github-install | lib/elm_install/identifier.rb | ElmInstall.Identifier.uri_type | def uri_type(url, branch)
uri = GitCloneUrl.parse(url)
case uri
when URI::SshGit::Generic
Type::Git(Uri::Ssh(uri), branch)
when URI::HTTP
Type::Git(Uri::Http(uri), branch)
end
end | ruby | def uri_type(url, branch)
uri = GitCloneUrl.parse(url)
case uri
when URI::SshGit::Generic
Type::Git(Uri::Ssh(uri), branch)
when URI::HTTP
Type::Git(Uri::Http(uri), branch)
end
end | [
"def",
"uri_type",
"(",
"url",
",",
"branch",
")",
"uri",
"=",
"GitCloneUrl",
".",
"parse",
"(",
"url",
")",
"case",
"uri",
"when",
"URI",
"::",
"SshGit",
"::",
"Generic",
"Type",
"::",
"Git",
"(",
"Uri",
"::",
"Ssh",
"(",
"uri",
")",
",",
"branch"... | Returns the type from the given arguments.
@param url [String] The base url
@param branch [Branch] The branch
@return [Type] The type | [
"Returns",
"the",
"type",
"from",
"the",
"given",
"arguments",
"."
] | 153b1b4c2bfa1a24175fe1d686b40b139674b5b3 | https://github.com/gdotdesign/elm-github-install/blob/153b1b4c2bfa1a24175fe1d686b40b139674b5b3/lib/elm_install/identifier.rb#L116-L124 |
18,704 | gdotdesign/elm-github-install | lib/elm_install/identifier.rb | ElmInstall.Identifier.json | def json(directory)
path = File.join(directory, 'elm-package.json')
JSON.parse(File.read(path))
rescue JSON::ParserError
warn "Invalid JSON in file: #{path.bold}"
rescue Errno::ENOENT
warn "Could not find file: #{path.bold}"
end | ruby | def json(directory)
path = File.join(directory, 'elm-package.json')
JSON.parse(File.read(path))
rescue JSON::ParserError
warn "Invalid JSON in file: #{path.bold}"
rescue Errno::ENOENT
warn "Could not find file: #{path.bold}"
end | [
"def",
"json",
"(",
"directory",
")",
"path",
"=",
"File",
".",
"join",
"(",
"directory",
",",
"'elm-package.json'",
")",
"JSON",
".",
"parse",
"(",
"File",
".",
"read",
"(",
"path",
")",
")",
"rescue",
"JSON",
"::",
"ParserError",
"warn",
"\"Invalid JSO... | Returns the contents of the 'elm-package.json' for the given directory.
@param directory [Dir] The directory
@return [Hash] The contents | [
"Returns",
"the",
"contents",
"of",
"the",
"elm",
"-",
"package",
".",
"json",
"for",
"the",
"given",
"directory",
"."
] | 153b1b4c2bfa1a24175fe1d686b40b139674b5b3 | https://github.com/gdotdesign/elm-github-install/blob/153b1b4c2bfa1a24175fe1d686b40b139674b5b3/lib/elm_install/identifier.rb#L132-L139 |
18,705 | gdotdesign/elm-github-install | lib/elm_install/utils.rb | ElmInstall.Utils.transform_constraint | def transform_constraint(elm_constraint)
elm_constraint.gsub!(/\s/, '')
CONVERTERS
.map { |regexp, prefix| [elm_constraint.match(regexp), prefix] }
.select { |(match)| match }
.map { |(match, prefix)| "#{prefix} #{match[1]}" }
.map { |constraint| Solve::Constraint.new constr... | ruby | def transform_constraint(elm_constraint)
elm_constraint.gsub!(/\s/, '')
CONVERTERS
.map { |regexp, prefix| [elm_constraint.match(regexp), prefix] }
.select { |(match)| match }
.map { |(match, prefix)| "#{prefix} #{match[1]}" }
.map { |constraint| Solve::Constraint.new constr... | [
"def",
"transform_constraint",
"(",
"elm_constraint",
")",
"elm_constraint",
".",
"gsub!",
"(",
"/",
"\\s",
"/",
",",
"''",
")",
"CONVERTERS",
".",
"map",
"{",
"|",
"regexp",
",",
"prefix",
"|",
"[",
"elm_constraint",
".",
"match",
"(",
"regexp",
")",
",... | Transform an 'elm' constraint into a proper one.
@param elm_constraint [String] The elm constraint
@return [Array] The transform constraints | [
"Transform",
"an",
"elm",
"constraint",
"into",
"a",
"proper",
"one",
"."
] | 153b1b4c2bfa1a24175fe1d686b40b139674b5b3 | https://github.com/gdotdesign/elm-github-install/blob/153b1b4c2bfa1a24175fe1d686b40b139674b5b3/lib/elm_install/utils.rb#L23-L31 |
18,706 | gdotdesign/elm-github-install | lib/elm_install/installer.rb | ElmInstall.Installer.results | def results
Solve
.it!(@graph, initial_solve_constraints)
.map do |name, version|
dep = @resolver.dependencies[name]
dep.version = Semverse::Version.new(version)
dep
end
end | ruby | def results
Solve
.it!(@graph, initial_solve_constraints)
.map do |name, version|
dep = @resolver.dependencies[name]
dep.version = Semverse::Version.new(version)
dep
end
end | [
"def",
"results",
"Solve",
".",
"it!",
"(",
"@graph",
",",
"initial_solve_constraints",
")",
".",
"map",
"do",
"|",
"name",
",",
"version",
"|",
"dep",
"=",
"@resolver",
".",
"dependencies",
"[",
"name",
"]",
"dep",
".",
"version",
"=",
"Semverse",
"::",... | Returns the results of solving
@return [Array] Array of dependencies | [
"Returns",
"the",
"results",
"of",
"solving"
] | 153b1b4c2bfa1a24175fe1d686b40b139674b5b3 | https://github.com/gdotdesign/elm-github-install/blob/153b1b4c2bfa1a24175fe1d686b40b139674b5b3/lib/elm_install/installer.rb#L41-L49 |
18,707 | gdotdesign/elm-github-install | lib/elm_install/installer.rb | ElmInstall.Installer.initial_solve_constraints | def initial_solve_constraints
@identifier.initial_dependencies.flat_map do |dependency|
dependency.constraints.map do |constraint|
[dependency.name, constraint]
end
end
end | ruby | def initial_solve_constraints
@identifier.initial_dependencies.flat_map do |dependency|
dependency.constraints.map do |constraint|
[dependency.name, constraint]
end
end
end | [
"def",
"initial_solve_constraints",
"@identifier",
".",
"initial_dependencies",
".",
"flat_map",
"do",
"|",
"dependency",
"|",
"dependency",
".",
"constraints",
".",
"map",
"do",
"|",
"constraint",
"|",
"[",
"dependency",
".",
"name",
",",
"constraint",
"]",
"en... | Returns the inital constraints
@return [Array] Array of dependency names and constraints | [
"Returns",
"the",
"inital",
"constraints"
] | 153b1b4c2bfa1a24175fe1d686b40b139674b5b3 | https://github.com/gdotdesign/elm-github-install/blob/153b1b4c2bfa1a24175fe1d686b40b139674b5b3/lib/elm_install/installer.rb#L55-L61 |
18,708 | gdotdesign/elm-github-install | lib/elm_install/resolver.rb | ElmInstall.Resolver.resolve_dependency | def resolve_dependency(dependency)
@dependencies[dependency.name] ||= dependency
dependency
.source
.versions(
dependency.constraints,
@identifier.initial_elm_version,
!@options[:skip_update],
@options[:only_update]
)
.each do |version... | ruby | def resolve_dependency(dependency)
@dependencies[dependency.name] ||= dependency
dependency
.source
.versions(
dependency.constraints,
@identifier.initial_elm_version,
!@options[:skip_update],
@options[:only_update]
)
.each do |version... | [
"def",
"resolve_dependency",
"(",
"dependency",
")",
"@dependencies",
"[",
"dependency",
".",
"name",
"]",
"||=",
"dependency",
"dependency",
".",
"source",
".",
"versions",
"(",
"dependency",
".",
"constraints",
",",
"@identifier",
".",
"initial_elm_version",
","... | Resolves the dependencies of a dependency
@param dependency [Dependency] The dependency
@return nil | [
"Resolves",
"the",
"dependencies",
"of",
"a",
"dependency"
] | 153b1b4c2bfa1a24175fe1d686b40b139674b5b3 | https://github.com/gdotdesign/elm-github-install/blob/153b1b4c2bfa1a24175fe1d686b40b139674b5b3/lib/elm_install/resolver.rb#L40-L57 |
18,709 | gdotdesign/elm-github-install | lib/elm_install/resolver.rb | ElmInstall.Resolver.resolve_dependencies | def resolve_dependencies(main, version)
dependencies = @identifier.identify(main.source.fetch(version))
artifact = @graph.artifact main.name, version
dependencies.each do |dependency|
dependency.constraints.each do |constraint|
artifact.depends dependency.name, constraint
en... | ruby | def resolve_dependencies(main, version)
dependencies = @identifier.identify(main.source.fetch(version))
artifact = @graph.artifact main.name, version
dependencies.each do |dependency|
dependency.constraints.each do |constraint|
artifact.depends dependency.name, constraint
en... | [
"def",
"resolve_dependencies",
"(",
"main",
",",
"version",
")",
"dependencies",
"=",
"@identifier",
".",
"identify",
"(",
"main",
".",
"source",
".",
"fetch",
"(",
"version",
")",
")",
"artifact",
"=",
"@graph",
".",
"artifact",
"main",
".",
"name",
",",
... | Resolves the dependencies of a dependency and version
@param main [Dependency] The dependency
@param version [Semverse::Version] The version
@return nil | [
"Resolves",
"the",
"dependencies",
"of",
"a",
"dependency",
"and",
"version"
] | 153b1b4c2bfa1a24175fe1d686b40b139674b5b3 | https://github.com/gdotdesign/elm-github-install/blob/153b1b4c2bfa1a24175fe1d686b40b139674b5b3/lib/elm_install/resolver.rb#L66-L79 |
18,710 | gdotdesign/elm-github-install | lib/elm_install/git_source.rb | ElmInstall.GitSource.fetch | def fetch(version)
# Get the reference from the branch
ref =
case @branch
when Branch::Just
@branch.ref
when Branch::Nothing
case version
when String
version
else
version.to_simple
end
end
reposi... | ruby | def fetch(version)
# Get the reference from the branch
ref =
case @branch
when Branch::Just
@branch.ref
when Branch::Nothing
case version
when String
version
else
version.to_simple
end
end
reposi... | [
"def",
"fetch",
"(",
"version",
")",
"# Get the reference from the branch",
"ref",
"=",
"case",
"@branch",
"when",
"Branch",
"::",
"Just",
"@branch",
".",
"ref",
"when",
"Branch",
"::",
"Nothing",
"case",
"version",
"when",
"String",
"version",
"else",
"version"... | Downloads the version into a temporary directory
@param version [Semverse::Version] The version to fetch
@return [Dir] The directory for the source of the version | [
"Downloads",
"the",
"version",
"into",
"a",
"temporary",
"directory"
] | 153b1b4c2bfa1a24175fe1d686b40b139674b5b3 | https://github.com/gdotdesign/elm-github-install/blob/153b1b4c2bfa1a24175fe1d686b40b139674b5b3/lib/elm_install/git_source.rb#L29-L45 |
18,711 | gdotdesign/elm-github-install | lib/elm_install/git_source.rb | ElmInstall.GitSource.copy_to | def copy_to(version, directory)
# Delete the directory to make sure no pervious version remains if
# we are using a branch or symlink if using Dir.
FileUtils.rm_rf(directory) if directory.exist?
# Create directory if not exists
FileUtils.mkdir_p directory
# Copy hole repository
... | ruby | def copy_to(version, directory)
# Delete the directory to make sure no pervious version remains if
# we are using a branch or symlink if using Dir.
FileUtils.rm_rf(directory) if directory.exist?
# Create directory if not exists
FileUtils.mkdir_p directory
# Copy hole repository
... | [
"def",
"copy_to",
"(",
"version",
",",
"directory",
")",
"# Delete the directory to make sure no pervious version remains if",
"# we are using a branch or symlink if using Dir.",
"FileUtils",
".",
"rm_rf",
"(",
"directory",
")",
"if",
"directory",
".",
"exist?",
"# Create direc... | Copies the version into the given directory
@param version [Semverse::Version] The version
@param directory [Pathname] The pathname
@return nil | [
"Copies",
"the",
"version",
"into",
"the",
"given",
"directory"
] | 153b1b4c2bfa1a24175fe1d686b40b139674b5b3 | https://github.com/gdotdesign/elm-github-install/blob/153b1b4c2bfa1a24175fe1d686b40b139674b5b3/lib/elm_install/git_source.rb#L54-L69 |
18,712 | gdotdesign/elm-github-install | lib/elm_install/git_source.rb | ElmInstall.GitSource.versions | def versions(constraints, elm_version, should_update, only_update)
if repository.cloned? &&
!repository.fetched &&
should_update &&
(!only_update || only_update == package_name)
# Get updates from upstream
Logger.arrow "Getting updates for: #{package_name.bold}"
... | ruby | def versions(constraints, elm_version, should_update, only_update)
if repository.cloned? &&
!repository.fetched &&
should_update &&
(!only_update || only_update == package_name)
# Get updates from upstream
Logger.arrow "Getting updates for: #{package_name.bold}"
... | [
"def",
"versions",
"(",
"constraints",
",",
"elm_version",
",",
"should_update",
",",
"only_update",
")",
"if",
"repository",
".",
"cloned?",
"&&",
"!",
"repository",
".",
"fetched",
"&&",
"should_update",
"&&",
"(",
"!",
"only_update",
"||",
"only_update",
"=... | Returns the available versions for a repository
@param constraints [Array] The constraints
@param elm_version [String] The Elm version to match against
@return [Array] The versions | [
"Returns",
"the",
"available",
"versions",
"for",
"a",
"repository"
] | 153b1b4c2bfa1a24175fe1d686b40b139674b5b3 | https://github.com/gdotdesign/elm-github-install/blob/153b1b4c2bfa1a24175fe1d686b40b139674b5b3/lib/elm_install/git_source.rb#L93-L109 |
18,713 | gdotdesign/elm-github-install | lib/elm_install/git_source.rb | ElmInstall.GitSource.matching_versions | def matching_versions(constraints, elm_version)
repository
.versions
.select do |version|
elm_version_of(version.to_s) == elm_version &&
constraints.all? { |constraint| constraint.satisfies?(version) }
end
.sort
.reverse
end | ruby | def matching_versions(constraints, elm_version)
repository
.versions
.select do |version|
elm_version_of(version.to_s) == elm_version &&
constraints.all? { |constraint| constraint.satisfies?(version) }
end
.sort
.reverse
end | [
"def",
"matching_versions",
"(",
"constraints",
",",
"elm_version",
")",
"repository",
".",
"versions",
".",
"select",
"do",
"|",
"version",
"|",
"elm_version_of",
"(",
"version",
".",
"to_s",
")",
"==",
"elm_version",
"&&",
"constraints",
".",
"all?",
"{",
... | Returns the matchign versions for a repository for the given constraints
@param constraints [Array] The constraints
@param elm_version [String] The Elm version to match against
@return [Array] The versions | [
"Returns",
"the",
"matchign",
"versions",
"for",
"a",
"repository",
"for",
"the",
"given",
"constraints"
] | 153b1b4c2bfa1a24175fe1d686b40b139674b5b3 | https://github.com/gdotdesign/elm-github-install/blob/153b1b4c2bfa1a24175fe1d686b40b139674b5b3/lib/elm_install/git_source.rb#L118-L127 |
18,714 | gdotdesign/elm-github-install | lib/elm_install/populator.rb | ElmInstall.Populator.log_dependency | def log_dependency(dependency)
log = "#{dependency.name} - "
log += dependency.source.to_log.to_s
log += " (#{dependency.version.to_simple})"
Logger.dot log
nil
end | ruby | def log_dependency(dependency)
log = "#{dependency.name} - "
log += dependency.source.to_log.to_s
log += " (#{dependency.version.to_simple})"
Logger.dot log
nil
end | [
"def",
"log_dependency",
"(",
"dependency",
")",
"log",
"=",
"\"#{dependency.name} - \"",
"log",
"+=",
"dependency",
".",
"source",
".",
"to_log",
".",
"to_s",
"log",
"+=",
"\" (#{dependency.version.to_simple})\"",
"Logger",
".",
"dot",
"log",
"nil",
"end"
] | Logs the dependency with a dot
@param dependency [Dependency] The dependency
@return nil | [
"Logs",
"the",
"dependency",
"with",
"a",
"dot"
] | 153b1b4c2bfa1a24175fe1d686b40b139674b5b3 | https://github.com/gdotdesign/elm-github-install/blob/153b1b4c2bfa1a24175fe1d686b40b139674b5b3/lib/elm_install/populator.rb#L70-L77 |
18,715 | gdotdesign/elm-github-install | lib/elm_install/repository.rb | ElmInstall.Repository.versions | def versions
@versions ||=
repo
.tags
.map(&:name)
.select { |tag| tag =~ /(.*\..*\..*)/ }
.map { |tag| Semverse::Version.try_new tag }
.compact
end | ruby | def versions
@versions ||=
repo
.tags
.map(&:name)
.select { |tag| tag =~ /(.*\..*\..*)/ }
.map { |tag| Semverse::Version.try_new tag }
.compact
end | [
"def",
"versions",
"@versions",
"||=",
"repo",
".",
"tags",
".",
"map",
"(",
":name",
")",
".",
"select",
"{",
"|",
"tag",
"|",
"tag",
"=~",
"/",
"\\.",
"\\.",
"/",
"}",
".",
"map",
"{",
"|",
"tag",
"|",
"Semverse",
"::",
"Version",
".",
"try_new... | Returns the versions of the repository
@return [Array<Semverse::Version>] The versions | [
"Returns",
"the",
"versions",
"of",
"the",
"repository"
] | 153b1b4c2bfa1a24175fe1d686b40b139674b5b3 | https://github.com/gdotdesign/elm-github-install/blob/153b1b4c2bfa1a24175fe1d686b40b139674b5b3/lib/elm_install/repository.rb#L68-L76 |
18,716 | lwe/simple_enum | lib/simple_enum/view_helpers.rb | SimpleEnum.ViewHelpers.enum_option_pairs | def enum_option_pairs(record, enum, encode_as_value = false)
reader = enum.to_s.pluralize
record = record.class unless record.respond_to?(reader)
record.send(reader).map { |key, value|
name = record.human_enum_name(enum, key) if record.respond_to?(:human_enum_name)
name ||= translate_... | ruby | def enum_option_pairs(record, enum, encode_as_value = false)
reader = enum.to_s.pluralize
record = record.class unless record.respond_to?(reader)
record.send(reader).map { |key, value|
name = record.human_enum_name(enum, key) if record.respond_to?(:human_enum_name)
name ||= translate_... | [
"def",
"enum_option_pairs",
"(",
"record",
",",
"enum",
",",
"encode_as_value",
"=",
"false",
")",
"reader",
"=",
"enum",
".",
"to_s",
".",
"pluralize",
"record",
"=",
"record",
".",
"class",
"unless",
"record",
".",
"respond_to?",
"(",
"reader",
")",
"rec... | A helper to build forms with Rails' form builder, built to be used with
f.select helper.
f.select :gender, enum_option_pairs(User, :gender), ...
record - The model or Class with the enum
enum - The Symbol with the name of the enum to create the options for
encode_as_value - The Boolean which defines if either... | [
"A",
"helper",
"to",
"build",
"forms",
"with",
"Rails",
"form",
"builder",
"built",
"to",
"be",
"used",
"with",
"f",
".",
"select",
"helper",
"."
] | 325de98b8505f2ecda8c9375e6dfb63cee294123 | https://github.com/lwe/simple_enum/blob/325de98b8505f2ecda8c9375e6dfb63cee294123/lib/simple_enum/view_helpers.rb#L21-L30 |
18,717 | wurmlab/genevalidator | lib/genevalidator/validation_alignment.rb | GeneValidator.AlignmentValidation.array_to_ranges | def array_to_ranges(ar)
prev = ar[0]
ranges = ar.slice_before do |e|
prev2 = prev
prev = e
prev2 + 1 != e
end.map { |a| a[0]..a[-1] }
ranges
end | ruby | def array_to_ranges(ar)
prev = ar[0]
ranges = ar.slice_before do |e|
prev2 = prev
prev = e
prev2 + 1 != e
end.map { |a| a[0]..a[-1] }
ranges
end | [
"def",
"array_to_ranges",
"(",
"ar",
")",
"prev",
"=",
"ar",
"[",
"0",
"]",
"ranges",
"=",
"ar",
".",
"slice_before",
"do",
"|",
"e",
"|",
"prev2",
"=",
"prev",
"prev",
"=",
"e",
"prev2",
"+",
"1",
"!=",
"e",
"end",
".",
"map",
"{",
"|",
"a",
... | converts an array of integers into array of ranges | [
"converts",
"an",
"array",
"of",
"integers",
"into",
"array",
"of",
"ranges"
] | b44a4a7e72eb8314c73d0cd7062d37a1c4c58299 | https://github.com/wurmlab/genevalidator/blob/b44a4a7e72eb8314c73d0cd7062d37a1c4c58299/lib/genevalidator/validation_alignment.rb#L379-L389 |
18,718 | wurmlab/genevalidator | lib/genevalidator/validation_duplication.rb | GeneValidator.DuplicationValidation.find_local_alignment | def find_local_alignment(hit, prediction, hsp)
# indexing in blast starts from 1
hit_local = hit.raw_sequence[hsp.hit_from - 1..hsp.hit_to - 1]
query_local = prediction.raw_sequence[hsp.match_query_from -
1..hsp.match_query_to - 1]
# in case of nucl... | ruby | def find_local_alignment(hit, prediction, hsp)
# indexing in blast starts from 1
hit_local = hit.raw_sequence[hsp.hit_from - 1..hsp.hit_to - 1]
query_local = prediction.raw_sequence[hsp.match_query_from -
1..hsp.match_query_to - 1]
# in case of nucl... | [
"def",
"find_local_alignment",
"(",
"hit",
",",
"prediction",
",",
"hsp",
")",
"# indexing in blast starts from 1",
"hit_local",
"=",
"hit",
".",
"raw_sequence",
"[",
"hsp",
".",
"hit_from",
"-",
"1",
"..",
"hsp",
".",
"hit_to",
"-",
"1",
"]",
"query_local",
... | Only run if the BLAST output does not contain hit alignmment | [
"Only",
"run",
"if",
"the",
"BLAST",
"output",
"does",
"not",
"contain",
"hit",
"alignmment"
] | b44a4a7e72eb8314c73d0cd7062d37a1c4c58299 | https://github.com/wurmlab/genevalidator/blob/b44a4a7e72eb8314c73d0cd7062d37a1c4c58299/lib/genevalidator/validation_duplication.rb#L199-L224 |
18,719 | wurmlab/genevalidator | lib/genevalidator/clusterization.rb | GeneValidator.Cluster.print | def print
warn "Cluster: mean = #{mean}, density = #{density}"
lengths.sort { |a, b| a <=> b }.each do |elem|
warn "#{elem[0]}, #{elem[1]}"
end
warn '--------------------------'
end | ruby | def print
warn "Cluster: mean = #{mean}, density = #{density}"
lengths.sort { |a, b| a <=> b }.each do |elem|
warn "#{elem[0]}, #{elem[1]}"
end
warn '--------------------------'
end | [
"def",
"print",
"warn",
"\"Cluster: mean = #{mean}, density = #{density}\"",
"lengths",
".",
"sort",
"{",
"|",
"a",
",",
"b",
"|",
"a",
"<=>",
"b",
"}",
".",
"each",
"do",
"|",
"elem",
"|",
"warn",
"\"#{elem[0]}, #{elem[1]}\"",
"end",
"warn",
"'-----------------... | Prints the current cluster | [
"Prints",
"the",
"current",
"cluster"
] | b44a4a7e72eb8314c73d0cd7062d37a1c4c58299 | https://github.com/wurmlab/genevalidator/blob/b44a4a7e72eb8314c73d0cd7062d37a1c4c58299/lib/genevalidator/clusterization.rb#L275-L281 |
18,720 | wurmlab/genevalidator | lib/genevalidator/validation.rb | GeneValidator.Validations.get_info_on_query_sequence | def get_info_on_query_sequence(seq_type = @config[:type],
index = @config[:idx])
query = GeneValidator.extract_input_fasta_sequence(index)
parse_query = query.scan(/^>([^\n]*)\n([A-Za-z\n]*)/)[0]
prediction = Query.new
prediction.definit... | ruby | def get_info_on_query_sequence(seq_type = @config[:type],
index = @config[:idx])
query = GeneValidator.extract_input_fasta_sequence(index)
parse_query = query.scan(/^>([^\n]*)\n([A-Za-z\n]*)/)[0]
prediction = Query.new
prediction.definit... | [
"def",
"get_info_on_query_sequence",
"(",
"seq_type",
"=",
"@config",
"[",
":type",
"]",
",",
"index",
"=",
"@config",
"[",
":idx",
"]",
")",
"query",
"=",
"GeneValidator",
".",
"extract_input_fasta_sequence",
"(",
"index",
")",
"parse_query",
"=",
"query",
".... | get info about the query | [
"get",
"info",
"about",
"the",
"query"
] | b44a4a7e72eb8314c73d0cd7062d37a1c4c58299 | https://github.com/wurmlab/genevalidator/blob/b44a4a7e72eb8314c73d0cd7062d37a1c4c58299/lib/genevalidator/validation.rb#L69-L82 |
18,721 | wurmlab/genevalidator | lib/genevalidator/validation.rb | GeneValidator.Validate.length_validation_scores | def length_validation_scores(validations, scores)
lcv = validations.select { |v| v.class == LengthClusterValidationOutput }
lrv = validations.select { |v| v.class == LengthRankValidationOutput }
if lcv.length == 1 && lrv.length == 1
score_lcv = (lcv[0].result == lcv[0].expected)
score_... | ruby | def length_validation_scores(validations, scores)
lcv = validations.select { |v| v.class == LengthClusterValidationOutput }
lrv = validations.select { |v| v.class == LengthRankValidationOutput }
if lcv.length == 1 && lrv.length == 1
score_lcv = (lcv[0].result == lcv[0].expected)
score_... | [
"def",
"length_validation_scores",
"(",
"validations",
",",
"scores",
")",
"lcv",
"=",
"validations",
".",
"select",
"{",
"|",
"v",
"|",
"v",
".",
"class",
"==",
"LengthClusterValidationOutput",
"}",
"lrv",
"=",
"validations",
".",
"select",
"{",
"|",
"v",
... | Since there are two length validations, it is necessary to adjust the
scores accordingly | [
"Since",
"there",
"are",
"two",
"length",
"validations",
"it",
"is",
"necessary",
"to",
"adjust",
"the",
"scores",
"accordingly"
] | b44a4a7e72eb8314c73d0cd7062d37a1c4c58299 | https://github.com/wurmlab/genevalidator/blob/b44a4a7e72eb8314c73d0cd7062d37a1c4c58299/lib/genevalidator/validation.rb#L243-L259 |
18,722 | wurmlab/genevalidator | lib/genevalidator/output_files.rb | GeneValidator.OutputFiles.turn_off_automated_sorting | def turn_off_automated_sorting
js_file = File.join(@dirs[:output_dir], 'html_files/js/gv.compiled.min.js')
original_content = File.read(js_file)
# removes the automatic sort on page load
updated_content = original_content.gsub(',sortList:[[0,0]]', '')
File.open("#{script_file}.tmp", 'w') {... | ruby | def turn_off_automated_sorting
js_file = File.join(@dirs[:output_dir], 'html_files/js/gv.compiled.min.js')
original_content = File.read(js_file)
# removes the automatic sort on page load
updated_content = original_content.gsub(',sortList:[[0,0]]', '')
File.open("#{script_file}.tmp", 'w') {... | [
"def",
"turn_off_automated_sorting",
"js_file",
"=",
"File",
".",
"join",
"(",
"@dirs",
"[",
":output_dir",
"]",
",",
"'html_files/js/gv.compiled.min.js'",
")",
"original_content",
"=",
"File",
".",
"read",
"(",
"js_file",
")",
"# removes the automatic sort on page load... | By default, on page load, the results are automatically sorted by the
index. However since the whole idea is that users would sort by JSON,
this is not wanted here. | [
"By",
"default",
"on",
"page",
"load",
"the",
"results",
"are",
"automatically",
"sorted",
"by",
"the",
"index",
".",
"However",
"since",
"the",
"whole",
"idea",
"is",
"that",
"users",
"would",
"sort",
"by",
"JSON",
"this",
"is",
"not",
"wanted",
"here",
... | b44a4a7e72eb8314c73d0cd7062d37a1c4c58299 | https://github.com/wurmlab/genevalidator/blob/b44a4a7e72eb8314c73d0cd7062d37a1c4c58299/lib/genevalidator/output_files.rb#L87-L94 |
18,723 | wurmlab/genevalidator | lib/genevalidator/output_files.rb | GeneValidator.OutputFiles.overview_html_hash | def overview_html_hash(evaluation, less)
data = [@overview[:scores].group_by { |a| a }.map do |k, vs|
{ 'key': k, 'value': vs.length, 'main': false }
end]
{ data: data, type: :simplebars, aux1: 10, aux2: '',
title: 'Overall GeneValidator Score Evaluation', footer: '',
xtitle: '... | ruby | def overview_html_hash(evaluation, less)
data = [@overview[:scores].group_by { |a| a }.map do |k, vs|
{ 'key': k, 'value': vs.length, 'main': false }
end]
{ data: data, type: :simplebars, aux1: 10, aux2: '',
title: 'Overall GeneValidator Score Evaluation', footer: '',
xtitle: '... | [
"def",
"overview_html_hash",
"(",
"evaluation",
",",
"less",
")",
"data",
"=",
"[",
"@overview",
"[",
":scores",
"]",
".",
"group_by",
"{",
"|",
"a",
"|",
"a",
"}",
".",
"map",
"do",
"|",
"k",
",",
"vs",
"|",
"{",
"'key'",
":",
"k",
",",
"'value'... | make the historgram with the resulted scores | [
"make",
"the",
"historgram",
"with",
"the",
"resulted",
"scores"
] | b44a4a7e72eb8314c73d0cd7062d37a1c4c58299 | https://github.com/wurmlab/genevalidator/blob/b44a4a7e72eb8314c73d0cd7062d37a1c4c58299/lib/genevalidator/output_files.rb#L105-L113 |
18,724 | calonso/rails-push-notifications | lib/rails-push-notifications/apps/base_app.rb | RailsPushNotifications.BaseApp.push_notifications | def push_notifications
pending = find_pending
to_send = pending.map do |notification|
notification_type.new notification.destinations, notification.data
end
pusher = build_pusher
pusher.push to_send
pending.each_with_index do |p, i|
p.update_attributes! results: to_se... | ruby | def push_notifications
pending = find_pending
to_send = pending.map do |notification|
notification_type.new notification.destinations, notification.data
end
pusher = build_pusher
pusher.push to_send
pending.each_with_index do |p, i|
p.update_attributes! results: to_se... | [
"def",
"push_notifications",
"pending",
"=",
"find_pending",
"to_send",
"=",
"pending",
".",
"map",
"do",
"|",
"notification",
"|",
"notification_type",
".",
"new",
"notification",
".",
"destinations",
",",
"notification",
".",
"data",
"end",
"pusher",
"=",
"bui... | This method will find all notifications owned by this app and
push them. | [
"This",
"method",
"will",
"find",
"all",
"notifications",
"owned",
"by",
"this",
"app",
"and",
"push",
"them",
"."
] | 820a5bc4a32384624d6ced8f06f2da478497b001 | https://github.com/calonso/rails-push-notifications/blob/820a5bc4a32384624d6ced8f06f2da478497b001/lib/rails-push-notifications/apps/base_app.rb#L18-L28 |
18,725 | joker1007/activemodel-associations | lib/active_record/associations/has_many_for_active_model_association.rb | ActiveRecord::Associations.HasManyForActiveModelAssociation.replace | def replace(other_array)
original_target = load_target.dup
other_array.each { |val| raise_on_type_mismatch!(val) }
target_ids = reflection.options[:target_ids]
owner[target_ids] = other_array.map(&:id)
old_records = original_target - other_array
old_records.each do |record|
... | ruby | def replace(other_array)
original_target = load_target.dup
other_array.each { |val| raise_on_type_mismatch!(val) }
target_ids = reflection.options[:target_ids]
owner[target_ids] = other_array.map(&:id)
old_records = original_target - other_array
old_records.each do |record|
... | [
"def",
"replace",
"(",
"other_array",
")",
"original_target",
"=",
"load_target",
".",
"dup",
"other_array",
".",
"each",
"{",
"|",
"val",
"|",
"raise_on_type_mismatch!",
"(",
"val",
")",
"}",
"target_ids",
"=",
"reflection",
".",
"options",
"[",
":target_ids"... | full replace simplely | [
"full",
"replace",
"simplely"
] | 8bbea47e774c73f77ccaad8839c111b71e380ce8 | https://github.com/joker1007/activemodel-associations/blob/8bbea47e774c73f77ccaad8839c111b71e380ce8/lib/active_record/associations/has_many_for_active_model_association.rb#L23-L41 |
18,726 | joker1007/activemodel-associations | lib/active_record/associations/has_many_for_active_model_association.rb | ActiveRecord::Associations.HasManyForActiveModelAssociation.concat | def concat(*records)
load_target
flatten_records = records.flatten
flatten_records.each { |val| raise_on_type_mismatch!(val) }
target_ids = reflection.options[:target_ids]
owner[target_ids] ||= []
owner[target_ids].concat(flatten_records.map(&:id))
flatten_records.each do |rec... | ruby | def concat(*records)
load_target
flatten_records = records.flatten
flatten_records.each { |val| raise_on_type_mismatch!(val) }
target_ids = reflection.options[:target_ids]
owner[target_ids] ||= []
owner[target_ids].concat(flatten_records.map(&:id))
flatten_records.each do |rec... | [
"def",
"concat",
"(",
"*",
"records",
")",
"load_target",
"flatten_records",
"=",
"records",
".",
"flatten",
"flatten_records",
".",
"each",
"{",
"|",
"val",
"|",
"raise_on_type_mismatch!",
"(",
"val",
")",
"}",
"target_ids",
"=",
"reflection",
".",
"options",... | no need transaction | [
"no",
"need",
"transaction"
] | 8bbea47e774c73f77ccaad8839c111b71e380ce8 | https://github.com/joker1007/activemodel-associations/blob/8bbea47e774c73f77ccaad8839c111b71e380ce8/lib/active_record/associations/has_many_for_active_model_association.rb#L44-L61 |
18,727 | joker1007/activemodel-associations | lib/active_model/associations/override_methods.rb | ActiveModel::Associations.OverrideMethods.association | def association(name) #:nodoc:
association = association_instance_get(name)
if association.nil?
reflection = self.class.reflect_on_association(name)
if reflection.options[:active_model]
association = ActiveRecord::Associations::HasManyForActiveModelAssociation.new(self, reflectio... | ruby | def association(name) #:nodoc:
association = association_instance_get(name)
if association.nil?
reflection = self.class.reflect_on_association(name)
if reflection.options[:active_model]
association = ActiveRecord::Associations::HasManyForActiveModelAssociation.new(self, reflectio... | [
"def",
"association",
"(",
"name",
")",
"#:nodoc:",
"association",
"=",
"association_instance_get",
"(",
"name",
")",
"if",
"association",
".",
"nil?",
"reflection",
"=",
"self",
".",
"class",
".",
"reflect_on_association",
"(",
"name",
")",
"if",
"reflection",
... | use by association accessor | [
"use",
"by",
"association",
"accessor"
] | 8bbea47e774c73f77ccaad8839c111b71e380ce8 | https://github.com/joker1007/activemodel-associations/blob/8bbea47e774c73f77ccaad8839c111b71e380ce8/lib/active_model/associations/override_methods.rb#L64-L78 |
18,728 | frenesim/schema_to_scaffold | lib/schema_to_scaffold/path.rb | SchemaToScaffold.Path.choose | def choose
validate_path
search_paths_list = search_paths
if search_paths_list.empty?
puts "\nThere is no /schema[^\/]*.rb$/ in the directory #{@path}"
exit
end
search_paths_list.each_with_index {|path,indx| puts "#{indx}. #{path}" }
begin
print ... | ruby | def choose
validate_path
search_paths_list = search_paths
if search_paths_list.empty?
puts "\nThere is no /schema[^\/]*.rb$/ in the directory #{@path}"
exit
end
search_paths_list.each_with_index {|path,indx| puts "#{indx}. #{path}" }
begin
print ... | [
"def",
"choose",
"validate_path",
"search_paths_list",
"=",
"search_paths",
"if",
"search_paths_list",
".",
"empty?",
"puts",
"\"\\nThere is no /schema[^\\/]*.rb$/ in the directory #{@path}\"",
"exit",
"end",
"search_paths_list",
".",
"each_with_index",
"{",
"|",
"path",
",",... | Return the chosen path | [
"Return",
"the",
"chosen",
"path"
] | 957770cc9f245ab6dc2ab7947c0b791d5341ae0e | https://github.com/frenesim/schema_to_scaffold/blob/957770cc9f245ab6dc2ab7947c0b791d5341ae0e/lib/schema_to_scaffold/path.rb#L14-L29 |
18,729 | simplymadeapps/simple_scheduler | lib/simple_scheduler/scheduler_job.rb | SimpleScheduler.SchedulerJob.load_config | def load_config
@config = YAML.safe_load(ERB.new(File.read(config_path)).result)
@queue_ahead = @config["queue_ahead"] || Task::DEFAULT_QUEUE_AHEAD_MINUTES
@queue_name = @config["queue_name"] || "default"
@time_zone = @config["tz"] || Time.zone.tzinfo.name
@config.delete("queue_ahead")
... | ruby | def load_config
@config = YAML.safe_load(ERB.new(File.read(config_path)).result)
@queue_ahead = @config["queue_ahead"] || Task::DEFAULT_QUEUE_AHEAD_MINUTES
@queue_name = @config["queue_name"] || "default"
@time_zone = @config["tz"] || Time.zone.tzinfo.name
@config.delete("queue_ahead")
... | [
"def",
"load_config",
"@config",
"=",
"YAML",
".",
"safe_load",
"(",
"ERB",
".",
"new",
"(",
"File",
".",
"read",
"(",
"config_path",
")",
")",
".",
"result",
")",
"@queue_ahead",
"=",
"@config",
"[",
"\"queue_ahead\"",
"]",
"||",
"Task",
"::",
"DEFAULT_... | Load the global scheduler config from the YAML file. | [
"Load",
"the",
"global",
"scheduler",
"config",
"from",
"the",
"YAML",
"file",
"."
] | 4d186042507c1397ee79a5e8fe929cc14008c026 | https://github.com/simplymadeapps/simple_scheduler/blob/4d186042507c1397ee79a5e8fe929cc14008c026/lib/simple_scheduler/scheduler_job.rb#L18-L26 |
18,730 | simplymadeapps/simple_scheduler | lib/simple_scheduler/scheduler_job.rb | SimpleScheduler.SchedulerJob.queue_future_jobs | def queue_future_jobs
tasks.each do |task|
# Schedule the new run times using the future job wrapper.
new_run_times = task.future_run_times - task.existing_run_times
new_run_times.each do |time|
SimpleScheduler::FutureJob.set(queue: @queue_name, wait_until: time)
... | ruby | def queue_future_jobs
tasks.each do |task|
# Schedule the new run times using the future job wrapper.
new_run_times = task.future_run_times - task.existing_run_times
new_run_times.each do |time|
SimpleScheduler::FutureJob.set(queue: @queue_name, wait_until: time)
... | [
"def",
"queue_future_jobs",
"tasks",
".",
"each",
"do",
"|",
"task",
"|",
"# Schedule the new run times using the future job wrapper.",
"new_run_times",
"=",
"task",
".",
"future_run_times",
"-",
"task",
".",
"existing_run_times",
"new_run_times",
".",
"each",
"do",
"|"... | Queue each of the future jobs into Sidekiq from the defined tasks. | [
"Queue",
"each",
"of",
"the",
"future",
"jobs",
"into",
"Sidekiq",
"from",
"the",
"defined",
"tasks",
"."
] | 4d186042507c1397ee79a5e8fe929cc14008c026 | https://github.com/simplymadeapps/simple_scheduler/blob/4d186042507c1397ee79a5e8fe929cc14008c026/lib/simple_scheduler/scheduler_job.rb#L29-L38 |
18,731 | simplymadeapps/simple_scheduler | lib/simple_scheduler/scheduler_job.rb | SimpleScheduler.SchedulerJob.tasks | def tasks
@config.map do |task_name, options|
task_params = options.symbolize_keys
task_params[:queue_ahead] ||= @queue_ahead
task_params[:name] = task_name
task_params[:tz] ||= @time_zone
Task.new(task_params)
end
end | ruby | def tasks
@config.map do |task_name, options|
task_params = options.symbolize_keys
task_params[:queue_ahead] ||= @queue_ahead
task_params[:name] = task_name
task_params[:tz] ||= @time_zone
Task.new(task_params)
end
end | [
"def",
"tasks",
"@config",
".",
"map",
"do",
"|",
"task_name",
",",
"options",
"|",
"task_params",
"=",
"options",
".",
"symbolize_keys",
"task_params",
"[",
":queue_ahead",
"]",
"||=",
"@queue_ahead",
"task_params",
"[",
":name",
"]",
"=",
"task_name",
"task_... | The array of tasks loaded from the config YAML.
@return [Array<SimpleScheduler::Task] | [
"The",
"array",
"of",
"tasks",
"loaded",
"from",
"the",
"config",
"YAML",
"."
] | 4d186042507c1397ee79a5e8fe929cc14008c026 | https://github.com/simplymadeapps/simple_scheduler/blob/4d186042507c1397ee79a5e8fe929cc14008c026/lib/simple_scheduler/scheduler_job.rb#L42-L50 |
18,732 | simplymadeapps/simple_scheduler | lib/simple_scheduler/task.rb | SimpleScheduler.Task.existing_jobs | def existing_jobs
@existing_jobs ||= SimpleScheduler::Task.scheduled_set.select do |job|
next unless job.display_class == "SimpleScheduler::FutureJob"
task_params = job.display_args[0].symbolize_keys
task_params[:class] == job_class_name && task_params[:name] == name
end.to_a
en... | ruby | def existing_jobs
@existing_jobs ||= SimpleScheduler::Task.scheduled_set.select do |job|
next unless job.display_class == "SimpleScheduler::FutureJob"
task_params = job.display_args[0].symbolize_keys
task_params[:class] == job_class_name && task_params[:name] == name
end.to_a
en... | [
"def",
"existing_jobs",
"@existing_jobs",
"||=",
"SimpleScheduler",
"::",
"Task",
".",
"scheduled_set",
".",
"select",
"do",
"|",
"job",
"|",
"next",
"unless",
"job",
".",
"display_class",
"==",
"\"SimpleScheduler::FutureJob\"",
"task_params",
"=",
"job",
".",
"di... | Returns an array of existing jobs matching the job class of the task.
@return [Array<Sidekiq::SortedEntry>] | [
"Returns",
"an",
"array",
"of",
"existing",
"jobs",
"matching",
"the",
"job",
"class",
"of",
"the",
"task",
"."
] | 4d186042507c1397ee79a5e8fe929cc14008c026 | https://github.com/simplymadeapps/simple_scheduler/blob/4d186042507c1397ee79a5e8fe929cc14008c026/lib/simple_scheduler/task.rb#L42-L49 |
18,733 | simplymadeapps/simple_scheduler | lib/simple_scheduler/task.rb | SimpleScheduler.Task.future_run_times | def future_run_times
future_run_times = existing_run_times.dup
last_run_time = future_run_times.last || at - frequency
last_run_time = last_run_time.in_time_zone(time_zone)
# Ensure there are at least two future jobs scheduled and that the queue ahead time is filled
while future_run_times... | ruby | def future_run_times
future_run_times = existing_run_times.dup
last_run_time = future_run_times.last || at - frequency
last_run_time = last_run_time.in_time_zone(time_zone)
# Ensure there are at least two future jobs scheduled and that the queue ahead time is filled
while future_run_times... | [
"def",
"future_run_times",
"future_run_times",
"=",
"existing_run_times",
".",
"dup",
"last_run_time",
"=",
"future_run_times",
".",
"last",
"||",
"at",
"-",
"frequency",
"last_run_time",
"=",
"last_run_time",
".",
"in_time_zone",
"(",
"time_zone",
")",
"# Ensure ther... | Returns an array Time objects for future run times based on
the current time and the given minutes to look ahead.
@return [Array<Time>]
rubocop:disable Metrics/AbcSize | [
"Returns",
"an",
"array",
"Time",
"objects",
"for",
"future",
"run",
"times",
"based",
"on",
"the",
"current",
"time",
"and",
"the",
"given",
"minutes",
"to",
"look",
"ahead",
"."
] | 4d186042507c1397ee79a5e8fe929cc14008c026 | https://github.com/simplymadeapps/simple_scheduler/blob/4d186042507c1397ee79a5e8fe929cc14008c026/lib/simple_scheduler/task.rb#L67-L82 |
18,734 | simplymadeapps/simple_scheduler | lib/simple_scheduler/future_job.rb | SimpleScheduler.FutureJob.perform | def perform(task_params, scheduled_time)
@task = Task.new(task_params)
@scheduled_time = Time.at(scheduled_time).in_time_zone(@task.time_zone)
raise Expired if expired?
queue_task
end | ruby | def perform(task_params, scheduled_time)
@task = Task.new(task_params)
@scheduled_time = Time.at(scheduled_time).in_time_zone(@task.time_zone)
raise Expired if expired?
queue_task
end | [
"def",
"perform",
"(",
"task_params",
",",
"scheduled_time",
")",
"@task",
"=",
"Task",
".",
"new",
"(",
"task_params",
")",
"@scheduled_time",
"=",
"Time",
".",
"at",
"(",
"scheduled_time",
")",
".",
"in_time_zone",
"(",
"@task",
".",
"time_zone",
")",
"r... | Perform the future job as defined by the task.
@param task_params [Hash] The params from the scheduled task
@param scheduled_time [Integer] The epoch time for when the job was scheduled to be run | [
"Perform",
"the",
"future",
"job",
"as",
"defined",
"by",
"the",
"task",
"."
] | 4d186042507c1397ee79a5e8fe929cc14008c026 | https://github.com/simplymadeapps/simple_scheduler/blob/4d186042507c1397ee79a5e8fe929cc14008c026/lib/simple_scheduler/future_job.rb#L22-L28 |
18,735 | simplymadeapps/simple_scheduler | lib/simple_scheduler/future_job.rb | SimpleScheduler.FutureJob.expire_duration | def expire_duration
split_duration = @task.expires_after.split(".")
duration = split_duration[0].to_i
duration_units = split_duration[1]
duration.send(duration_units)
end | ruby | def expire_duration
split_duration = @task.expires_after.split(".")
duration = split_duration[0].to_i
duration_units = split_duration[1]
duration.send(duration_units)
end | [
"def",
"expire_duration",
"split_duration",
"=",
"@task",
".",
"expires_after",
".",
"split",
"(",
"\".\"",
")",
"duration",
"=",
"split_duration",
"[",
"0",
"]",
".",
"to_i",
"duration_units",
"=",
"split_duration",
"[",
"1",
"]",
"duration",
".",
"send",
"... | The duration between the scheduled run time and actual run time that
will cause the job to expire. Expired jobs will not be executed.
@return [ActiveSupport::Duration] | [
"The",
"duration",
"between",
"the",
"scheduled",
"run",
"time",
"and",
"actual",
"run",
"time",
"that",
"will",
"cause",
"the",
"job",
"to",
"expire",
".",
"Expired",
"jobs",
"will",
"not",
"be",
"executed",
"."
] | 4d186042507c1397ee79a5e8fe929cc14008c026 | https://github.com/simplymadeapps/simple_scheduler/blob/4d186042507c1397ee79a5e8fe929cc14008c026/lib/simple_scheduler/future_job.rb#L42-L47 |
18,736 | simplymadeapps/simple_scheduler | lib/simple_scheduler/future_job.rb | SimpleScheduler.FutureJob.expired? | def expired?
return false if @task.expires_after.blank?
expire_duration.from_now(@scheduled_time) < Time.now.in_time_zone(@task.time_zone)
end | ruby | def expired?
return false if @task.expires_after.blank?
expire_duration.from_now(@scheduled_time) < Time.now.in_time_zone(@task.time_zone)
end | [
"def",
"expired?",
"return",
"false",
"if",
"@task",
".",
"expires_after",
".",
"blank?",
"expire_duration",
".",
"from_now",
"(",
"@scheduled_time",
")",
"<",
"Time",
".",
"now",
".",
"in_time_zone",
"(",
"@task",
".",
"time_zone",
")",
"end"
] | Returns whether or not the job has expired based on the time
between the scheduled run time and the current time.
@return [Boolean] | [
"Returns",
"whether",
"or",
"not",
"the",
"job",
"has",
"expired",
"based",
"on",
"the",
"time",
"between",
"the",
"scheduled",
"run",
"time",
"and",
"the",
"current",
"time",
"."
] | 4d186042507c1397ee79a5e8fe929cc14008c026 | https://github.com/simplymadeapps/simple_scheduler/blob/4d186042507c1397ee79a5e8fe929cc14008c026/lib/simple_scheduler/future_job.rb#L52-L56 |
18,737 | simplymadeapps/simple_scheduler | lib/simple_scheduler/future_job.rb | SimpleScheduler.FutureJob.handle_expired_task | def handle_expired_task(exception)
exception.run_time = Time.now.in_time_zone(@task.time_zone)
exception.scheduled_time = @scheduled_time
exception.task = @task
SimpleScheduler.expired_task_blocks.each do |block|
block.call(exception)
end
end | ruby | def handle_expired_task(exception)
exception.run_time = Time.now.in_time_zone(@task.time_zone)
exception.scheduled_time = @scheduled_time
exception.task = @task
SimpleScheduler.expired_task_blocks.each do |block|
block.call(exception)
end
end | [
"def",
"handle_expired_task",
"(",
"exception",
")",
"exception",
".",
"run_time",
"=",
"Time",
".",
"now",
".",
"in_time_zone",
"(",
"@task",
".",
"time_zone",
")",
"exception",
".",
"scheduled_time",
"=",
"@scheduled_time",
"exception",
".",
"task",
"=",
"@t... | Handle the expired task by passing the task and run time information
to a block that can be creating in a Rails initializer file. | [
"Handle",
"the",
"expired",
"task",
"by",
"passing",
"the",
"task",
"and",
"run",
"time",
"information",
"to",
"a",
"block",
"that",
"can",
"be",
"creating",
"in",
"a",
"Rails",
"initializer",
"file",
"."
] | 4d186042507c1397ee79a5e8fe929cc14008c026 | https://github.com/simplymadeapps/simple_scheduler/blob/4d186042507c1397ee79a5e8fe929cc14008c026/lib/simple_scheduler/future_job.rb#L60-L68 |
18,738 | simplymadeapps/simple_scheduler | lib/simple_scheduler/future_job.rb | SimpleScheduler.FutureJob.queue_task | def queue_task
if @task.job_class.instance_method(:perform).arity.zero?
@task.job_class.send(perform_method)
else
@task.job_class.send(perform_method, @scheduled_time.to_i)
end
end | ruby | def queue_task
if @task.job_class.instance_method(:perform).arity.zero?
@task.job_class.send(perform_method)
else
@task.job_class.send(perform_method, @scheduled_time.to_i)
end
end | [
"def",
"queue_task",
"if",
"@task",
".",
"job_class",
".",
"instance_method",
"(",
":perform",
")",
".",
"arity",
".",
"zero?",
"@task",
".",
"job_class",
".",
"send",
"(",
"perform_method",
")",
"else",
"@task",
".",
"job_class",
".",
"send",
"(",
"perfor... | Queue the task with the scheduled time if the job allows. | [
"Queue",
"the",
"task",
"with",
"the",
"scheduled",
"time",
"if",
"the",
"job",
"allows",
"."
] | 4d186042507c1397ee79a5e8fe929cc14008c026 | https://github.com/simplymadeapps/simple_scheduler/blob/4d186042507c1397ee79a5e8fe929cc14008c026/lib/simple_scheduler/future_job.rb#L81-L87 |
18,739 | simplymadeapps/simple_scheduler | lib/simple_scheduler/at.rb | SimpleScheduler.At.parsed_time | def parsed_time
return @parsed_time if @parsed_time
@parsed_time = parsed_day
change_hour = next_hour
# There is no hour 24, so we need to move to the next day
if change_hour == 24
@parsed_time = 1.day.from_now(@parsed_time)
change_hour = 0
end
@parsed_time =... | ruby | def parsed_time
return @parsed_time if @parsed_time
@parsed_time = parsed_day
change_hour = next_hour
# There is no hour 24, so we need to move to the next day
if change_hour == 24
@parsed_time = 1.day.from_now(@parsed_time)
change_hour = 0
end
@parsed_time =... | [
"def",
"parsed_time",
"return",
"@parsed_time",
"if",
"@parsed_time",
"@parsed_time",
"=",
"parsed_day",
"change_hour",
"=",
"next_hour",
"# There is no hour 24, so we need to move to the next day",
"if",
"change_hour",
"==",
"24",
"@parsed_time",
"=",
"1",
".",
"day",
".... | Returns the very first time a job should be run for the scheduled task.
@return [Time] | [
"Returns",
"the",
"very",
"first",
"time",
"a",
"job",
"should",
"be",
"run",
"for",
"the",
"scheduled",
"task",
"."
] | 4d186042507c1397ee79a5e8fe929cc14008c026 | https://github.com/simplymadeapps/simple_scheduler/blob/4d186042507c1397ee79a5e8fe929cc14008c026/lib/simple_scheduler/at.rb#L109-L127 |
18,740 | mxenabled/action_subscriber | lib/action_subscriber/dsl.rb | ActionSubscriber.DSL.exchange_names | def exchange_names(*names)
@_exchange_names ||= []
@_exchange_names += names.flatten.map(&:to_s)
if @_exchange_names.empty?
return [ ::ActionSubscriber.config.default_exchange ]
else
return @_exchange_names.compact.uniq
end
end | ruby | def exchange_names(*names)
@_exchange_names ||= []
@_exchange_names += names.flatten.map(&:to_s)
if @_exchange_names.empty?
return [ ::ActionSubscriber.config.default_exchange ]
else
return @_exchange_names.compact.uniq
end
end | [
"def",
"exchange_names",
"(",
"*",
"names",
")",
"@_exchange_names",
"||=",
"[",
"]",
"@_exchange_names",
"+=",
"names",
".",
"flatten",
".",
"map",
"(",
":to_s",
")",
"if",
"@_exchange_names",
".",
"empty?",
"return",
"[",
"::",
"ActionSubscriber",
".",
"co... | Explicitly set the name of the exchange | [
"Explicitly",
"set",
"the",
"name",
"of",
"the",
"exchange"
] | 4bfd11b09b649d06bc5c8734ceb9e8f99211fa0c | https://github.com/mxenabled/action_subscriber/blob/4bfd11b09b649d06bc5c8734ceb9e8f99211fa0c/lib/action_subscriber/dsl.rb#L36-L45 |
18,741 | mxenabled/action_subscriber | lib/action_subscriber/subscribable.rb | ActionSubscriber.Subscribable.queue_name_for_method | def queue_name_for_method(method_name)
return queue_names[method_name] if queue_names[method_name]
queue_name = generate_queue_name(method_name)
queue_for(method_name, queue_name)
return queue_name
end | ruby | def queue_name_for_method(method_name)
return queue_names[method_name] if queue_names[method_name]
queue_name = generate_queue_name(method_name)
queue_for(method_name, queue_name)
return queue_name
end | [
"def",
"queue_name_for_method",
"(",
"method_name",
")",
"return",
"queue_names",
"[",
"method_name",
"]",
"if",
"queue_names",
"[",
"method_name",
"]",
"queue_name",
"=",
"generate_queue_name",
"(",
"method_name",
")",
"queue_for",
"(",
"method_name",
",",
"queue_n... | Build the `queue` for a given method.
If the queue name is not set, the queue name is
"local.remote.resoure.action"
Example
"bob.alice.user.created" | [
"Build",
"the",
"queue",
"for",
"a",
"given",
"method",
"."
] | 4bfd11b09b649d06bc5c8734ceb9e8f99211fa0c | https://github.com/mxenabled/action_subscriber/blob/4bfd11b09b649d06bc5c8734ceb9e8f99211fa0c/lib/action_subscriber/subscribable.rb#L57-L63 |
18,742 | mxenabled/action_subscriber | lib/action_subscriber/subscribable.rb | ActionSubscriber.Subscribable.routing_key_name_for_method | def routing_key_name_for_method(method_name)
return routing_key_names[method_name] if routing_key_names[method_name]
routing_key_name = generate_routing_key_name(method_name)
routing_key_for(method_name, routing_key_name)
return routing_key_name
end | ruby | def routing_key_name_for_method(method_name)
return routing_key_names[method_name] if routing_key_names[method_name]
routing_key_name = generate_routing_key_name(method_name)
routing_key_for(method_name, routing_key_name)
return routing_key_name
end | [
"def",
"routing_key_name_for_method",
"(",
"method_name",
")",
"return",
"routing_key_names",
"[",
"method_name",
"]",
"if",
"routing_key_names",
"[",
"method_name",
"]",
"routing_key_name",
"=",
"generate_routing_key_name",
"(",
"method_name",
")",
"routing_key_for",
"("... | Build the `routing_key` for a given method.
If the routing_key name is not set, the routing_key name is
"remote.resoure.action"
Example
"amigo.user.created" | [
"Build",
"the",
"routing_key",
"for",
"a",
"given",
"method",
"."
] | 4bfd11b09b649d06bc5c8734ceb9e8f99211fa0c | https://github.com/mxenabled/action_subscriber/blob/4bfd11b09b649d06bc5c8734ceb9e8f99211fa0c/lib/action_subscriber/subscribable.rb#L80-L86 |
18,743 | DavidEGrayson/ruby_ecdsa | lib/ecdsa/point.rb | ECDSA.Point.double | def double
return self if infinity?
gamma = field.mod((3 * x * x + @group.param_a) * field.inverse(2 * y))
new_x = field.mod(gamma * gamma - 2 * x)
new_y = field.mod(gamma * (x - new_x) - y)
self.class.new(group, new_x, new_y)
end | ruby | def double
return self if infinity?
gamma = field.mod((3 * x * x + @group.param_a) * field.inverse(2 * y))
new_x = field.mod(gamma * gamma - 2 * x)
new_y = field.mod(gamma * (x - new_x) - y)
self.class.new(group, new_x, new_y)
end | [
"def",
"double",
"return",
"self",
"if",
"infinity?",
"gamma",
"=",
"field",
".",
"mod",
"(",
"(",
"3",
"*",
"x",
"*",
"x",
"+",
"@group",
".",
"param_a",
")",
"*",
"field",
".",
"inverse",
"(",
"2",
"*",
"y",
")",
")",
"new_x",
"=",
"field",
"... | Returns the point added to itself.
This algorithm is defined in
[SEC1](http://www.secg.org/collateral/sec1_final.pdf), Section 2.2.1,
Rule 5.
@return (Point) | [
"Returns",
"the",
"point",
"added",
"to",
"itself",
"."
] | 2216043b38170b9603c05bf1d4e43e184fc6181e | https://github.com/DavidEGrayson/ruby_ecdsa/blob/2216043b38170b9603c05bf1d4e43e184fc6181e/lib/ecdsa/point.rb#L104-L110 |
18,744 | DavidEGrayson/ruby_ecdsa | lib/ecdsa/point.rb | ECDSA.Point.multiply_by_scalar | def multiply_by_scalar(i)
raise ArgumentError, 'Scalar is not an integer.' if !i.is_a?(Integer)
raise ArgumentError, 'Scalar is negative.' if i < 0
result = group.infinity
v = self
while i > 0
result = result.add_to_point(v) if i.odd?
v = v.double
i >>= 1
end
... | ruby | def multiply_by_scalar(i)
raise ArgumentError, 'Scalar is not an integer.' if !i.is_a?(Integer)
raise ArgumentError, 'Scalar is negative.' if i < 0
result = group.infinity
v = self
while i > 0
result = result.add_to_point(v) if i.odd?
v = v.double
i >>= 1
end
... | [
"def",
"multiply_by_scalar",
"(",
"i",
")",
"raise",
"ArgumentError",
",",
"'Scalar is not an integer.'",
"if",
"!",
"i",
".",
"is_a?",
"(",
"Integer",
")",
"raise",
"ArgumentError",
",",
"'Scalar is negative.'",
"if",
"i",
"<",
"0",
"result",
"=",
"group",
".... | Returns the point multiplied by a non-negative integer.
@param i (Integer)
@return (Point) | [
"Returns",
"the",
"point",
"multiplied",
"by",
"a",
"non",
"-",
"negative",
"integer",
"."
] | 2216043b38170b9603c05bf1d4e43e184fc6181e | https://github.com/DavidEGrayson/ruby_ecdsa/blob/2216043b38170b9603c05bf1d4e43e184fc6181e/lib/ecdsa/point.rb#L116-L127 |
18,745 | DavidEGrayson/ruby_ecdsa | lib/ecdsa/prime_field.rb | ECDSA.PrimeField.square_roots | def square_roots(n)
raise ArgumentError, "Not a member of the field: #{n}." if !include?(n)
case
when prime == 2 then [n]
when (prime % 4) == 3 then square_roots_for_p_3_mod_4(n)
when (prime % 8) == 5 then square_roots_for_p_5_mod_8(n)
else square_roots_default(n)
end
end | ruby | def square_roots(n)
raise ArgumentError, "Not a member of the field: #{n}." if !include?(n)
case
when prime == 2 then [n]
when (prime % 4) == 3 then square_roots_for_p_3_mod_4(n)
when (prime % 8) == 5 then square_roots_for_p_5_mod_8(n)
else square_roots_default(n)
end
end | [
"def",
"square_roots",
"(",
"n",
")",
"raise",
"ArgumentError",
",",
"\"Not a member of the field: #{n}.\"",
"if",
"!",
"include?",
"(",
"n",
")",
"case",
"when",
"prime",
"==",
"2",
"then",
"[",
"n",
"]",
"when",
"(",
"prime",
"%",
"4",
")",
"==",
"3",
... | Finds all possible square roots of the given field element.
@param n (Integer)
@return (Array) A sorted array of numbers whose square is equal to `n`. | [
"Finds",
"all",
"possible",
"square",
"roots",
"of",
"the",
"given",
"field",
"element",
"."
] | 2216043b38170b9603c05bf1d4e43e184fc6181e | https://github.com/DavidEGrayson/ruby_ecdsa/blob/2216043b38170b9603c05bf1d4e43e184fc6181e/lib/ecdsa/prime_field.rb#L94-L102 |
18,746 | jstrait/wavefile | lib/wavefile/writer.rb | WaveFile.Writer.write_header | def write_header(sample_frame_count)
extensible = @format.channels > 2 ||
(@format.sample_format == :pcm && @format.bits_per_sample != 8 && @format.bits_per_sample != 16) ||
(@format.channels == 1 && @format.speaker_mapping != [:front_center]) ||
(@format.c... | ruby | def write_header(sample_frame_count)
extensible = @format.channels > 2 ||
(@format.sample_format == :pcm && @format.bits_per_sample != 8 && @format.bits_per_sample != 16) ||
(@format.channels == 1 && @format.speaker_mapping != [:front_center]) ||
(@format.c... | [
"def",
"write_header",
"(",
"sample_frame_count",
")",
"extensible",
"=",
"@format",
".",
"channels",
">",
"2",
"||",
"(",
"@format",
".",
"sample_format",
"==",
":pcm",
"&&",
"@format",
".",
"bits_per_sample",
"!=",
"8",
"&&",
"@format",
".",
"bits_per_sample... | Internal
Writes the RIFF chunk header, format chunk, and the header for the data chunk. After this
method is called the file will be "queued up" and ready for writing actual sample data. | [
"Internal",
"Writes",
"the",
"RIFF",
"chunk",
"header",
"format",
"chunk",
"and",
"the",
"header",
"for",
"the",
"data",
"chunk",
".",
"After",
"this",
"method",
"is",
"called",
"the",
"file",
"will",
"be",
"queued",
"up",
"and",
"ready",
"for",
"writing",... | 3efe8099ee996dfcf9d3b2e656aa9ec4fa983222 | https://github.com/jstrait/wavefile/blob/3efe8099ee996dfcf9d3b2e656aa9ec4fa983222/lib/wavefile/writer.rb#L283-L341 |
18,747 | namick/obfuscate_id | lib/obfuscate_id.rb | ObfuscateId.ClassMethods.obfuscate_id_default_spin | def obfuscate_id_default_spin
alphabet = Array("a".."z")
number = name.split("").collect do |char|
alphabet.index(char)
end
number.shift(12).join.to_i
end | ruby | def obfuscate_id_default_spin
alphabet = Array("a".."z")
number = name.split("").collect do |char|
alphabet.index(char)
end
number.shift(12).join.to_i
end | [
"def",
"obfuscate_id_default_spin",
"alphabet",
"=",
"Array",
"(",
"\"a\"",
"..",
"\"z\"",
")",
"number",
"=",
"name",
".",
"split",
"(",
"\"\"",
")",
".",
"collect",
"do",
"|",
"char",
"|",
"alphabet",
".",
"index",
"(",
"char",
")",
"end",
"number",
... | Generate a default spin from the Model name
This makes it easy to drop obfuscate_id onto any model
and produce different obfuscated ids for different models | [
"Generate",
"a",
"default",
"spin",
"from",
"the",
"Model",
"name",
"This",
"makes",
"it",
"easy",
"to",
"drop",
"obfuscate_id",
"onto",
"any",
"model",
"and",
"produce",
"different",
"obfuscated",
"ids",
"for",
"different",
"models"
] | bd3ee63bbe3bf2de93023947478831f4ee01a1bf | https://github.com/namick/obfuscate_id/blob/bd3ee63bbe3bf2de93023947478831f4ee01a1bf/lib/obfuscate_id.rb#L44-L51 |
18,748 | praxis/praxis | lib/praxis/validation_handler.rb | Praxis.ValidationHandler.handle! | def handle!(summary:, request:, stage:, errors: nil, exception: nil, **opts)
documentation = Docs::LinkBuilder.instance.for_request request
Responses::ValidationError.new(summary: summary, errors: errors, exception: exception, documentation: documentation, **opts)
end | ruby | def handle!(summary:, request:, stage:, errors: nil, exception: nil, **opts)
documentation = Docs::LinkBuilder.instance.for_request request
Responses::ValidationError.new(summary: summary, errors: errors, exception: exception, documentation: documentation, **opts)
end | [
"def",
"handle!",
"(",
"summary",
":",
",",
"request",
":",
",",
"stage",
":",
",",
"errors",
":",
"nil",
",",
"exception",
":",
"nil",
",",
"**",
"opts",
")",
"documentation",
"=",
"Docs",
"::",
"LinkBuilder",
".",
"instance",
".",
"for_request",
"req... | Should return the Response to send back | [
"Should",
"return",
"the",
"Response",
"to",
"send",
"back"
] | 37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635 | https://github.com/praxis/praxis/blob/37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635/lib/praxis/validation_handler.rb#L5-L8 |
18,749 | praxis/praxis | lib/praxis/response.rb | Praxis.Response.validate | def validate(action, validate_body: false)
return if response_name == :validation_error
unless (response_definition = action.responses[response_name])
raise Exceptions::Validation, "Attempting to return a response with name #{response_name} " \
"but no response definition with that name c... | ruby | def validate(action, validate_body: false)
return if response_name == :validation_error
unless (response_definition = action.responses[response_name])
raise Exceptions::Validation, "Attempting to return a response with name #{response_name} " \
"but no response definition with that name c... | [
"def",
"validate",
"(",
"action",
",",
"validate_body",
":",
"false",
")",
"return",
"if",
"response_name",
"==",
":validation_error",
"unless",
"(",
"response_definition",
"=",
"action",
".",
"responses",
"[",
"response_name",
"]",
")",
"raise",
"Exceptions",
"... | Validates the response
@param [Object] action | [
"Validates",
"the",
"response"
] | 37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635 | https://github.com/praxis/praxis/blob/37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635/lib/praxis/response.rb#L116-L125 |
18,750 | praxis/praxis | lib/praxis/config.rb | Praxis.Config.define | def define(key=nil, type=Attributor::Struct, **opts, &block)
if key.nil? && type != Attributor::Struct
raise Exceptions::InvalidConfiguration.new(
"You cannot define the top level configuration with a non-Struct type. Got: #{type.inspect}"
)
end
case key
when Str... | ruby | def define(key=nil, type=Attributor::Struct, **opts, &block)
if key.nil? && type != Attributor::Struct
raise Exceptions::InvalidConfiguration.new(
"You cannot define the top level configuration with a non-Struct type. Got: #{type.inspect}"
)
end
case key
when Str... | [
"def",
"define",
"(",
"key",
"=",
"nil",
",",
"type",
"=",
"Attributor",
"::",
"Struct",
",",
"**",
"opts",
",",
"&",
"block",
")",
"if",
"key",
".",
"nil?",
"&&",
"type",
"!=",
"Attributor",
"::",
"Struct",
"raise",
"Exceptions",
"::",
"InvalidConfigu... | You can define the configuration in different ways
Add a key to the top struct
define do
attribute :added_to_top, String
end
Add a key to the top struct (that is a struct itself)
define do
attribute :app do
attribute :one String
end
end
Which you could expand too in this way
define do
attribu... | [
"You",
"can",
"define",
"the",
"configuration",
"in",
"different",
"ways"
] | 37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635 | https://github.com/praxis/praxis/blob/37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635/lib/praxis/config.rb#L39-L67 |
18,751 | praxis/praxis | lib/praxis/multipart/part.rb | Praxis.MultipartPart.derive_content_type | def derive_content_type(handler_name)
possible_values = if self.content_type.match 'text/plain'
_, content_type_attribute = self.headers_attribute && self.headers_attribute.attributes.find { |k,v| k.to_s =~ /^content[-_]{1}type$/i }
if content_type_attribute && content_type_attribute.options.key?(... | ruby | def derive_content_type(handler_name)
possible_values = if self.content_type.match 'text/plain'
_, content_type_attribute = self.headers_attribute && self.headers_attribute.attributes.find { |k,v| k.to_s =~ /^content[-_]{1}type$/i }
if content_type_attribute && content_type_attribute.options.key?(... | [
"def",
"derive_content_type",
"(",
"handler_name",
")",
"possible_values",
"=",
"if",
"self",
".",
"content_type",
".",
"match",
"'text/plain'",
"_",
",",
"content_type_attribute",
"=",
"self",
".",
"headers_attribute",
"&&",
"self",
".",
"headers_attribute",
".",
... | Determine an appropriate default content_type for this part given
the preferred handler_name, if possible.
Considers any pre-defined set of values on the content_type attributge
of the headers. | [
"Determine",
"an",
"appropriate",
"default",
"content_type",
"for",
"this",
"part",
"given",
"the",
"preferred",
"handler_name",
"if",
"possible",
"."
] | 37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635 | https://github.com/praxis/praxis/blob/37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635/lib/praxis/multipart/part.rb#L224-L258 |
18,752 | praxis/praxis | lib/praxis/action_definition.rb | Praxis.ActionDefinition.precomputed_header_keys_for_rack | def precomputed_header_keys_for_rack
@precomputed_header_keys_for_rack ||= begin
@headers.attributes.keys.each_with_object(Hash.new) do |key,hash|
name = key.to_s
name = "HTTP_#{name.gsub('-','_').upcase}" unless ( name == "CONTENT_TYPE" || name == "CONTENT_LENGTH" )
hash[nam... | ruby | def precomputed_header_keys_for_rack
@precomputed_header_keys_for_rack ||= begin
@headers.attributes.keys.each_with_object(Hash.new) do |key,hash|
name = key.to_s
name = "HTTP_#{name.gsub('-','_').upcase}" unless ( name == "CONTENT_TYPE" || name == "CONTENT_LENGTH" )
hash[nam... | [
"def",
"precomputed_header_keys_for_rack",
"@precomputed_header_keys_for_rack",
"||=",
"begin",
"@headers",
".",
"attributes",
".",
"keys",
".",
"each_with_object",
"(",
"Hash",
".",
"new",
")",
"do",
"|",
"key",
",",
"hash",
"|",
"name",
"=",
"key",
".",
"to_s"... | Good optimization to avoid creating lots of strings and comparisons
on a per-request basis.
However, this is hacky, as it is rack-specific, and does not really belong here | [
"Good",
"optimization",
"to",
"avoid",
"creating",
"lots",
"of",
"strings",
"and",
"comparisons",
"on",
"a",
"per",
"-",
"request",
"basis",
".",
"However",
"this",
"is",
"hacky",
"as",
"it",
"is",
"rack",
"-",
"specific",
"and",
"does",
"not",
"really",
... | 37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635 | https://github.com/praxis/praxis/blob/37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635/lib/praxis/action_definition.rb#L168-L176 |
18,753 | praxis/praxis | lib/praxis/action_definition.rb | Praxis.ActionDefinition.derive_content_type | def derive_content_type(example, handler_name)
# MultipartArrays *must* use the provided content_type
if example.kind_of? Praxis::Types::MultipartArray
return MediaTypeIdentifier.load(example.content_type)
end
_, content_type_attribute = self.headers && self.headers.attributes.find { |... | ruby | def derive_content_type(example, handler_name)
# MultipartArrays *must* use the provided content_type
if example.kind_of? Praxis::Types::MultipartArray
return MediaTypeIdentifier.load(example.content_type)
end
_, content_type_attribute = self.headers && self.headers.attributes.find { |... | [
"def",
"derive_content_type",
"(",
"example",
",",
"handler_name",
")",
"# MultipartArrays *must* use the provided content_type",
"if",
"example",
".",
"kind_of?",
"Praxis",
"::",
"Types",
"::",
"MultipartArray",
"return",
"MediaTypeIdentifier",
".",
"load",
"(",
"example... | Determine the content_type to report for a given example,
using handler_name if possible.
Considers any pre-defined set of values on the content_type attributge
of the headers. | [
"Determine",
"the",
"content_type",
"to",
"report",
"for",
"a",
"given",
"example",
"using",
"handler_name",
"if",
"possible",
"."
] | 37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635 | https://github.com/praxis/praxis/blob/37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635/lib/praxis/action_definition.rb#L286-L315 |
18,754 | praxis/praxis | lib/praxis/media_type_identifier.rb | Praxis.MediaTypeIdentifier.without_parameters | def without_parameters
if self.parameters.empty?
self
else
MediaTypeIdentifier.load(type: self.type, subtype: self.subtype, suffix: self.suffix)
end
end | ruby | def without_parameters
if self.parameters.empty?
self
else
MediaTypeIdentifier.load(type: self.type, subtype: self.subtype, suffix: self.suffix)
end
end | [
"def",
"without_parameters",
"if",
"self",
".",
"parameters",
".",
"empty?",
"self",
"else",
"MediaTypeIdentifier",
".",
"load",
"(",
"type",
":",
"self",
".",
"type",
",",
"subtype",
":",
"self",
".",
"subtype",
",",
"suffix",
":",
"self",
".",
"suffix",
... | If parameters are empty, return self; otherwise return a new object consisting of this type
minus parameters.
@return [MediaTypeIdentifier] | [
"If",
"parameters",
"are",
"empty",
"return",
"self",
";",
"otherwise",
"return",
"a",
"new",
"object",
"consisting",
"of",
"this",
"type",
"minus",
"parameters",
"."
] | 37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635 | https://github.com/praxis/praxis/blob/37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635/lib/praxis/media_type_identifier.rb#L145-L151 |
18,755 | praxis/praxis | lib/praxis/response_definition.rb | Praxis.ResponseDefinition.validate_status! | def validate_status!(response)
return unless status
# Validate status code if defined in the spec
if response.status != status
raise Exceptions::Validation.new(
"Invalid response code detected. Response %s dictates status of %s but this response is returning %s." %
[name, s... | ruby | def validate_status!(response)
return unless status
# Validate status code if defined in the spec
if response.status != status
raise Exceptions::Validation.new(
"Invalid response code detected. Response %s dictates status of %s but this response is returning %s." %
[name, s... | [
"def",
"validate_status!",
"(",
"response",
")",
"return",
"unless",
"status",
"# Validate status code if defined in the spec",
"if",
"response",
".",
"status",
"!=",
"status",
"raise",
"Exceptions",
"::",
"Validation",
".",
"new",
"(",
"\"Invalid response code detected. ... | Validates Status code
@raise [Exceptions::Validation] When response returns an unexpected status. | [
"Validates",
"Status",
"code"
] | 37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635 | https://github.com/praxis/praxis/blob/37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635/lib/praxis/response_definition.rb#L214-L223 |
18,756 | praxis/praxis | lib/praxis/response_definition.rb | Praxis.ResponseDefinition.validate_location! | def validate_location!(response)
return if location.nil? || location === response.headers['Location']
raise Exceptions::Validation.new("LOCATION does not match #{location.inspect}")
end | ruby | def validate_location!(response)
return if location.nil? || location === response.headers['Location']
raise Exceptions::Validation.new("LOCATION does not match #{location.inspect}")
end | [
"def",
"validate_location!",
"(",
"response",
")",
"return",
"if",
"location",
".",
"nil?",
"||",
"location",
"===",
"response",
".",
"headers",
"[",
"'Location'",
"]",
"raise",
"Exceptions",
"::",
"Validation",
".",
"new",
"(",
"\"LOCATION does not match #{locati... | Validates 'Location' header
@raise [Exceptions::Validation] When location header does not match to the defined one. | [
"Validates",
"Location",
"header"
] | 37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635 | https://github.com/praxis/praxis/blob/37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635/lib/praxis/response_definition.rb#L230-L233 |
18,757 | praxis/praxis | lib/praxis/response_definition.rb | Praxis.ResponseDefinition.validate_content_type! | def validate_content_type!(response)
return unless media_type
response_content_type = response.content_type
expected_content_type = Praxis::MediaTypeIdentifier.load(media_type.identifier)
unless expected_content_type.match(response_content_type)
raise Exceptions::Validation.new(
... | ruby | def validate_content_type!(response)
return unless media_type
response_content_type = response.content_type
expected_content_type = Praxis::MediaTypeIdentifier.load(media_type.identifier)
unless expected_content_type.match(response_content_type)
raise Exceptions::Validation.new(
... | [
"def",
"validate_content_type!",
"(",
"response",
")",
"return",
"unless",
"media_type",
"response_content_type",
"=",
"response",
".",
"content_type",
"expected_content_type",
"=",
"Praxis",
"::",
"MediaTypeIdentifier",
".",
"load",
"(",
"media_type",
".",
"identifier"... | Validates Content-Type header and response media type
@param [Object] response
@raise [Exceptions::Validation] When there is a missing required header | [
"Validates",
"Content",
"-",
"Type",
"header",
"and",
"response",
"media",
"type"
] | 37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635 | https://github.com/praxis/praxis/blob/37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635/lib/praxis/response_definition.rb#L279-L291 |
18,758 | praxis/praxis | lib/praxis/response_definition.rb | Praxis.ResponseDefinition.validate_body! | def validate_body!(response)
return unless media_type
return if media_type.kind_of? SimpleMediaType
errors = self.media_type.validate(self.media_type.load(response.body))
if errors.any?
message = "Invalid response body for #{media_type.identifier}." +
"Errors: #{errors.inspect... | ruby | def validate_body!(response)
return unless media_type
return if media_type.kind_of? SimpleMediaType
errors = self.media_type.validate(self.media_type.load(response.body))
if errors.any?
message = "Invalid response body for #{media_type.identifier}." +
"Errors: #{errors.inspect... | [
"def",
"validate_body!",
"(",
"response",
")",
"return",
"unless",
"media_type",
"return",
"if",
"media_type",
".",
"kind_of?",
"SimpleMediaType",
"errors",
"=",
"self",
".",
"media_type",
".",
"validate",
"(",
"self",
".",
"media_type",
".",
"load",
"(",
"res... | Validates response body
@param [Object] response
@raise [Exceptions::Validation] When there is a missing required header.. | [
"Validates",
"response",
"body"
] | 37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635 | https://github.com/praxis/praxis/blob/37b97f2d72116cd3ae7c2e90f03dfe37fa3b5635/lib/praxis/response_definition.rb#L298-L309 |
18,759 | mynyml/harmony | lib/harmony/page.rb | Harmony.Page.load | def load(*paths)
paths.flatten.each do |path|
window.load(path.to_s)
end
self
end | ruby | def load(*paths)
paths.flatten.each do |path|
window.load(path.to_s)
end
self
end | [
"def",
"load",
"(",
"*",
"paths",
")",
"paths",
".",
"flatten",
".",
"each",
"do",
"|",
"path",
"|",
"window",
".",
"load",
"(",
"path",
".",
"to_s",
")",
"end",
"self",
"end"
] | Create new page containing given document.
@param [String] document
HTML document. Defaults to an "about:blank" window, with the basic
structure: `<html><head><title></title></head><body></body></html>`
Load one or more javascript files in page's context
@param [#to_s, #to_s, ...] paths
paths to js file
... | [
"Create",
"new",
"page",
"containing",
"given",
"document",
"."
] | dc80bd2b686d1dcfb04dec0ef22355fea5c2acbb | https://github.com/mynyml/harmony/blob/dc80bd2b686d1dcfb04dec0ef22355fea5c2acbb/lib/harmony/page.rb#L74-L79 |
18,760 | fredjean/middleman-s3_sync | lib/middleman-s3_sync/extension.rb | Middleman.S3SyncExtension.read_config | def read_config(io = nil)
unless io
root_path = ::Middleman::Application.root
config_file_path = File.join(root_path, ".s3_sync")
# skip if config file does not exist
return unless File.exists?(config_file_path)
io = File.open(config_file_path, "r")
end
confi... | ruby | def read_config(io = nil)
unless io
root_path = ::Middleman::Application.root
config_file_path = File.join(root_path, ".s3_sync")
# skip if config file does not exist
return unless File.exists?(config_file_path)
io = File.open(config_file_path, "r")
end
confi... | [
"def",
"read_config",
"(",
"io",
"=",
"nil",
")",
"unless",
"io",
"root_path",
"=",
"::",
"Middleman",
"::",
"Application",
".",
"root",
"config_file_path",
"=",
"File",
".",
"join",
"(",
"root_path",
",",
"\".s3_sync\"",
")",
"# skip if config file does not exi... | Read config options from an IO stream and set them on `self`. Defaults
to reading from the `.s3_sync` file in the MM project root if it exists.
@param io [IO] an IO stream to read from
@return [void] | [
"Read",
"config",
"options",
"from",
"an",
"IO",
"stream",
"and",
"set",
"them",
"on",
"self",
".",
"Defaults",
"to",
"reading",
"from",
"the",
".",
"s3_sync",
"file",
"in",
"the",
"MM",
"project",
"root",
"if",
"it",
"exists",
"."
] | 32f98ac1acf613ba3ac5a203c095f74ebe4d304d | https://github.com/fredjean/middleman-s3_sync/blob/32f98ac1acf613ba3ac5a203c095f74ebe4d304d/lib/middleman-s3_sync/extension.rb#L74-L90 |
18,761 | zverok/geo_coord | lib/geo/coord.rb | Geo.Coord.strfcoord | def strfcoord(formatstr)
h = full_hash
DIRECTIVES.reduce(formatstr) do |memo, (from, to)|
memo.gsub(from) do
to = to.call(Regexp.last_match) if to.is_a?(Proc)
res = to % h
res, carrymin = guard_seconds(to, res)
h[carrymin] += 1 if carrymin
res
... | ruby | def strfcoord(formatstr)
h = full_hash
DIRECTIVES.reduce(formatstr) do |memo, (from, to)|
memo.gsub(from) do
to = to.call(Regexp.last_match) if to.is_a?(Proc)
res = to % h
res, carrymin = guard_seconds(to, res)
h[carrymin] += 1 if carrymin
res
... | [
"def",
"strfcoord",
"(",
"formatstr",
")",
"h",
"=",
"full_hash",
"DIRECTIVES",
".",
"reduce",
"(",
"formatstr",
")",
"do",
"|",
"memo",
",",
"(",
"from",
",",
"to",
")",
"|",
"memo",
".",
"gsub",
"(",
"from",
")",
"do",
"to",
"=",
"to",
".",
"ca... | Formats coordinates according to directives in +formatstr+.
Each directive starts with +%+ and can contain some modifiers before
its name.
Acceptable modifiers:
- unsigned integers: none;
- signed integers: <tt>+</tt> for mandatory sign printing;
- floats: same as integers and number of digits modifier, like
... | [
"Formats",
"coordinates",
"according",
"to",
"directives",
"in",
"+",
"formatstr",
"+",
"."
] | 08b6595cc679eac7beadda2efc2cf13a5344ad4c | https://github.com/zverok/geo_coord/blob/08b6595cc679eac7beadda2efc2cf13a5344ad4c/lib/geo/coord.rb#L555-L567 |
18,762 | adhearsion/ruby_speech | lib/ruby_speech/generic_element.rb | RubySpeech.GenericElement.read_attr | def read_attr(attr_name, to_call = nil)
val = self[attr_name]
val && to_call ? val.__send__(to_call) : val
end | ruby | def read_attr(attr_name, to_call = nil)
val = self[attr_name]
val && to_call ? val.__send__(to_call) : val
end | [
"def",
"read_attr",
"(",
"attr_name",
",",
"to_call",
"=",
"nil",
")",
"val",
"=",
"self",
"[",
"attr_name",
"]",
"val",
"&&",
"to_call",
"?",
"val",
".",
"__send__",
"(",
"to_call",
")",
":",
"val",
"end"
] | Helper method to read an attribute
@param [#to_sym] attr_name the name of the attribute
@param [String, Symbol, nil] to_call the name of the method to call on
the returned value
@return nil or the value | [
"Helper",
"method",
"to",
"read",
"an",
"attribute"
] | 57562548608ddee2a09b8b63ba13e51ad25eb982 | https://github.com/adhearsion/ruby_speech/blob/57562548608ddee2a09b8b63ba13e51ad25eb982/lib/ruby_speech/generic_element.rb#L193-L196 |
18,763 | adhearsion/ruby_speech | lib/ruby_speech/generic_element.rb | RubySpeech.GenericElement.write_attr | def write_attr(attr_name, value, to_call = nil)
self[attr_name] = value && to_call ? value.__send__(to_call) : value
end | ruby | def write_attr(attr_name, value, to_call = nil)
self[attr_name] = value && to_call ? value.__send__(to_call) : value
end | [
"def",
"write_attr",
"(",
"attr_name",
",",
"value",
",",
"to_call",
"=",
"nil",
")",
"self",
"[",
"attr_name",
"]",
"=",
"value",
"&&",
"to_call",
"?",
"value",
".",
"__send__",
"(",
"to_call",
")",
":",
"value",
"end"
] | Helper method to write a value to an attribute
@param [#to_sym] attr_name the name of the attribute
@param [#to_s] value the value to set the attribute to | [
"Helper",
"method",
"to",
"write",
"a",
"value",
"to",
"an",
"attribute"
] | 57562548608ddee2a09b8b63ba13e51ad25eb982 | https://github.com/adhearsion/ruby_speech/blob/57562548608ddee2a09b8b63ba13e51ad25eb982/lib/ruby_speech/generic_element.rb#L202-L204 |
18,764 | adhearsion/ruby_speech | lib/ruby_speech/generic_element.rb | RubySpeech.GenericElement.namespace= | def namespace=(namespaces)
case namespaces
when Nokogiri::XML::Namespace
super namespaces
when String
ns = self.add_namespace nil, namespaces
super ns
end
end | ruby | def namespace=(namespaces)
case namespaces
when Nokogiri::XML::Namespace
super namespaces
when String
ns = self.add_namespace nil, namespaces
super ns
end
end | [
"def",
"namespace",
"=",
"(",
"namespaces",
")",
"case",
"namespaces",
"when",
"Nokogiri",
"::",
"XML",
"::",
"Namespace",
"super",
"namespaces",
"when",
"String",
"ns",
"=",
"self",
".",
"add_namespace",
"nil",
",",
"namespaces",
"super",
"ns",
"end",
"end"... | Attach a namespace to the node
@overload namespace=(ns)
Attach an already created XML::Namespace
@param [XML::Namespace] ns the namespace object
@overload namespace=(ns)
Create a new namespace and attach it
@param [String] ns the namespace uri | [
"Attach",
"a",
"namespace",
"to",
"the",
"node"
] | 57562548608ddee2a09b8b63ba13e51ad25eb982 | https://github.com/adhearsion/ruby_speech/blob/57562548608ddee2a09b8b63ba13e51ad25eb982/lib/ruby_speech/generic_element.rb#L214-L222 |
18,765 | Agrimatics/activemodel-datastore | lib/active_model/datastore/property_values.rb | ActiveModel::Datastore.PropertyValues.default_property_value | def default_property_value(attr, value)
if value.is_a?(TrueClass) || value.is_a?(FalseClass)
send("#{attr.to_sym}=", value) if send(attr.to_sym).nil?
else
send("#{attr.to_sym}=", send(attr.to_sym).presence || value)
end
end | ruby | def default_property_value(attr, value)
if value.is_a?(TrueClass) || value.is_a?(FalseClass)
send("#{attr.to_sym}=", value) if send(attr.to_sym).nil?
else
send("#{attr.to_sym}=", send(attr.to_sym).presence || value)
end
end | [
"def",
"default_property_value",
"(",
"attr",
",",
"value",
")",
"if",
"value",
".",
"is_a?",
"(",
"TrueClass",
")",
"||",
"value",
".",
"is_a?",
"(",
"FalseClass",
")",
"send",
"(",
"\"#{attr.to_sym}=\"",
",",
"value",
")",
"if",
"send",
"(",
"attr",
".... | Sets a default value for the property if not currently set.
Example:
default_property_value :state, 0
is equivalent to:
self.state = state.presence || 0
Example:
default_property_value :enabled, false
is equivalent to:
self.enabled = false if enabled.nil? | [
"Sets",
"a",
"default",
"value",
"for",
"the",
"property",
"if",
"not",
"currently",
"set",
"."
] | ac66520ca57f3bedf03461a4d2f3679f5e5f1d56 | https://github.com/Agrimatics/activemodel-datastore/blob/ac66520ca57f3bedf03461a4d2f3679f5e5f1d56/lib/active_model/datastore/property_values.rb#L22-L28 |
18,766 | Agrimatics/activemodel-datastore | lib/active_model/datastore/property_values.rb | ActiveModel::Datastore.PropertyValues.format_property_value | def format_property_value(attr, type)
return unless send(attr.to_sym).present?
case type.to_sym
when :integer
send("#{attr.to_sym}=", send(attr.to_sym).to_i)
when :float
send("#{attr.to_sym}=", send(attr.to_sym).to_f)
when :boolean
send("#{attr.to_sym}=", ActiveMod... | ruby | def format_property_value(attr, type)
return unless send(attr.to_sym).present?
case type.to_sym
when :integer
send("#{attr.to_sym}=", send(attr.to_sym).to_i)
when :float
send("#{attr.to_sym}=", send(attr.to_sym).to_f)
when :boolean
send("#{attr.to_sym}=", ActiveMod... | [
"def",
"format_property_value",
"(",
"attr",
",",
"type",
")",
"return",
"unless",
"send",
"(",
"attr",
".",
"to_sym",
")",
".",
"present?",
"case",
"type",
".",
"to_sym",
"when",
":integer",
"send",
"(",
"\"#{attr.to_sym}=\"",
",",
"send",
"(",
"attr",
".... | Converts the type of the property.
Example:
format_property_value :weight, :float
is equivalent to:
self.weight = weight.to_f if weight.present? | [
"Converts",
"the",
"type",
"of",
"the",
"property",
"."
] | ac66520ca57f3bedf03461a4d2f3679f5e5f1d56 | https://github.com/Agrimatics/activemodel-datastore/blob/ac66520ca57f3bedf03461a4d2f3679f5e5f1d56/lib/active_model/datastore/property_values.rb#L39-L52 |
18,767 | Agrimatics/activemodel-datastore | lib/active_model/datastore/nested_attr.rb | ActiveModel::Datastore.NestedAttr.nested_models | def nested_models
model_entities = []
nested_attributes.each { |attr| model_entities << send(attr.to_sym) } if nested_attributes?
model_entities.flatten
end | ruby | def nested_models
model_entities = []
nested_attributes.each { |attr| model_entities << send(attr.to_sym) } if nested_attributes?
model_entities.flatten
end | [
"def",
"nested_models",
"model_entities",
"=",
"[",
"]",
"nested_attributes",
".",
"each",
"{",
"|",
"attr",
"|",
"model_entities",
"<<",
"send",
"(",
"attr",
".",
"to_sym",
")",
"}",
"if",
"nested_attributes?",
"model_entities",
".",
"flatten",
"end"
] | For each attribute name in nested_attributes extract and return the nested model objects. | [
"For",
"each",
"attribute",
"name",
"in",
"nested_attributes",
"extract",
"and",
"return",
"the",
"nested",
"model",
"objects",
"."
] | ac66520ca57f3bedf03461a4d2f3679f5e5f1d56 | https://github.com/Agrimatics/activemodel-datastore/blob/ac66520ca57f3bedf03461a4d2f3679f5e5f1d56/lib/active_model/datastore/nested_attr.rb#L100-L104 |
18,768 | Agrimatics/activemodel-datastore | lib/active_model/datastore/nested_attr.rb | ActiveModel::Datastore.NestedAttr.assign_nested_attributes | def assign_nested_attributes(association_name, attributes, options = {})
attributes = validate_attributes(attributes)
association_name = association_name.to_sym
send("#{association_name}=", []) if send(association_name).nil?
attributes.each_value do |params|
if params['id'].blank?
... | ruby | def assign_nested_attributes(association_name, attributes, options = {})
attributes = validate_attributes(attributes)
association_name = association_name.to_sym
send("#{association_name}=", []) if send(association_name).nil?
attributes.each_value do |params|
if params['id'].blank?
... | [
"def",
"assign_nested_attributes",
"(",
"association_name",
",",
"attributes",
",",
"options",
"=",
"{",
"}",
")",
"attributes",
"=",
"validate_attributes",
"(",
"attributes",
")",
"association_name",
"=",
"association_name",
".",
"to_sym",
"send",
"(",
"\"#{associa... | Assigns the given nested child attributes.
Attribute hashes with an +:id+ value matching an existing associated object will update
that object. Hashes without an +:id+ value will build a new object for the association.
Hashes with a matching +:id+ value and a +:_destroy+ key set to a truthy value will mark
the mat... | [
"Assigns",
"the",
"given",
"nested",
"child",
"attributes",
"."
] | ac66520ca57f3bedf03461a4d2f3679f5e5f1d56 | https://github.com/Agrimatics/activemodel-datastore/blob/ac66520ca57f3bedf03461a4d2f3679f5e5f1d56/lib/active_model/datastore/nested_attr.rb#L155-L172 |
18,769 | Agrimatics/activemodel-datastore | lib/active_model/datastore/nested_attr.rb | ActiveModel::Datastore.NestedAttr.assign_to_or_mark_for_destruction | def assign_to_or_mark_for_destruction(record, attributes)
record.assign_attributes(attributes.except(*UNASSIGNABLE_KEYS))
record.mark_for_destruction if destroy_flag?(attributes)
end | ruby | def assign_to_or_mark_for_destruction(record, attributes)
record.assign_attributes(attributes.except(*UNASSIGNABLE_KEYS))
record.mark_for_destruction if destroy_flag?(attributes)
end | [
"def",
"assign_to_or_mark_for_destruction",
"(",
"record",
",",
"attributes",
")",
"record",
".",
"assign_attributes",
"(",
"attributes",
".",
"except",
"(",
"UNASSIGNABLE_KEYS",
")",
")",
"record",
".",
"mark_for_destruction",
"if",
"destroy_flag?",
"(",
"attributes"... | Updates an object with attributes or marks it for destruction if has_destroy_flag?. | [
"Updates",
"an",
"object",
"with",
"attributes",
"or",
"marks",
"it",
"for",
"destruction",
"if",
"has_destroy_flag?",
"."
] | ac66520ca57f3bedf03461a4d2f3679f5e5f1d56 | https://github.com/Agrimatics/activemodel-datastore/blob/ac66520ca57f3bedf03461a4d2f3679f5e5f1d56/lib/active_model/datastore/nested_attr.rb#L190-L193 |
18,770 | Agrimatics/activemodel-datastore | lib/active_model/datastore.rb | ActiveModel::Datastore.ClassMethods.find_entity | def find_entity(id_or_name, parent = nil)
key = CloudDatastore.dataset.key name, id_or_name
key.parent = parent if parent.present?
retry_on_exception { CloudDatastore.dataset.find key }
end | ruby | def find_entity(id_or_name, parent = nil)
key = CloudDatastore.dataset.key name, id_or_name
key.parent = parent if parent.present?
retry_on_exception { CloudDatastore.dataset.find key }
end | [
"def",
"find_entity",
"(",
"id_or_name",
",",
"parent",
"=",
"nil",
")",
"key",
"=",
"CloudDatastore",
".",
"dataset",
".",
"key",
"name",
",",
"id_or_name",
"key",
".",
"parent",
"=",
"parent",
"if",
"parent",
".",
"present?",
"retry_on_exception",
"{",
"... | Retrieves an entity by id or name and by an optional parent.
@param [Integer or String] id_or_name The id or name value of the entity Key.
@param [Google::Cloud::Datastore::Key] parent The parent Key of the entity.
@return [Entity, nil] a Google::Cloud::Datastore::Entity object or nil. | [
"Retrieves",
"an",
"entity",
"by",
"id",
"or",
"name",
"and",
"by",
"an",
"optional",
"parent",
"."
] | ac66520ca57f3bedf03461a4d2f3679f5e5f1d56 | https://github.com/Agrimatics/activemodel-datastore/blob/ac66520ca57f3bedf03461a4d2f3679f5e5f1d56/lib/active_model/datastore.rb#L229-L233 |
18,771 | Agrimatics/activemodel-datastore | lib/active_model/datastore.rb | ActiveModel::Datastore.ClassMethods.all | def all(options = {})
next_cursor = nil
query = build_query(options)
query_results = retry_on_exception { CloudDatastore.dataset.run query }
if options[:limit]
next_cursor = query_results.cursor if query_results.size == options[:limit]
return from_entities(query_results.all), nex... | ruby | def all(options = {})
next_cursor = nil
query = build_query(options)
query_results = retry_on_exception { CloudDatastore.dataset.run query }
if options[:limit]
next_cursor = query_results.cursor if query_results.size == options[:limit]
return from_entities(query_results.all), nex... | [
"def",
"all",
"(",
"options",
"=",
"{",
"}",
")",
"next_cursor",
"=",
"nil",
"query",
"=",
"build_query",
"(",
"options",
")",
"query_results",
"=",
"retry_on_exception",
"{",
"CloudDatastore",
".",
"dataset",
".",
"run",
"query",
"}",
"if",
"options",
"["... | Queries entities from Cloud Datastore by named kind and using the provided options.
When a limit option is provided queries up to the limit and returns results with a cursor.
This method may make several API calls until all query results are retrieved. The `run`
method returns a QueryResults object, which is a spec... | [
"Queries",
"entities",
"from",
"Cloud",
"Datastore",
"by",
"named",
"kind",
"and",
"using",
"the",
"provided",
"options",
".",
"When",
"a",
"limit",
"option",
"is",
"provided",
"queries",
"up",
"to",
"the",
"limit",
"and",
"returns",
"results",
"with",
"a",
... | ac66520ca57f3bedf03461a4d2f3679f5e5f1d56 | https://github.com/Agrimatics/activemodel-datastore/blob/ac66520ca57f3bedf03461a4d2f3679f5e5f1d56/lib/active_model/datastore.rb#L290-L299 |
18,772 | Agrimatics/activemodel-datastore | lib/active_model/datastore.rb | ActiveModel::Datastore.ClassMethods.find_by | def find_by(args)
query = CloudDatastore.dataset.query name
query.ancestor(args[:ancestor]) if args[:ancestor]
query.limit(1)
query.where(args.keys[0].to_s, '=', args.values[0])
query_results = retry_on_exception { CloudDatastore.dataset.run query }
from_entity(query_results.first)
... | ruby | def find_by(args)
query = CloudDatastore.dataset.query name
query.ancestor(args[:ancestor]) if args[:ancestor]
query.limit(1)
query.where(args.keys[0].to_s, '=', args.values[0])
query_results = retry_on_exception { CloudDatastore.dataset.run query }
from_entity(query_results.first)
... | [
"def",
"find_by",
"(",
"args",
")",
"query",
"=",
"CloudDatastore",
".",
"dataset",
".",
"query",
"name",
"query",
".",
"ancestor",
"(",
"args",
"[",
":ancestor",
"]",
")",
"if",
"args",
"[",
":ancestor",
"]",
"query",
".",
"limit",
"(",
"1",
")",
"q... | Finds the first entity matching the specified condition.
@param [Hash] args In which the key is the property and the value is the value to look for.
@option args [Google::Cloud::Datastore::Key] :ancestor filter for inherited results
@return [Model, nil] An ActiveModel object or nil.
@example
User.find_by(name... | [
"Finds",
"the",
"first",
"entity",
"matching",
"the",
"specified",
"condition",
"."
] | ac66520ca57f3bedf03461a4d2f3679f5e5f1d56 | https://github.com/Agrimatics/activemodel-datastore/blob/ac66520ca57f3bedf03461a4d2f3679f5e5f1d56/lib/active_model/datastore.rb#L340-L347 |
18,773 | Agrimatics/activemodel-datastore | lib/active_model/datastore.rb | ActiveModel::Datastore.ClassMethods.query_sort | def query_sort(query, options)
query.order(options[:order]) if options[:order]
query.order(options[:desc_order], :desc) if options[:desc_order]
query
end | ruby | def query_sort(query, options)
query.order(options[:order]) if options[:order]
query.order(options[:desc_order], :desc) if options[:desc_order]
query
end | [
"def",
"query_sort",
"(",
"query",
",",
"options",
")",
"query",
".",
"order",
"(",
"options",
"[",
":order",
"]",
")",
"if",
"options",
"[",
":order",
"]",
"query",
".",
"order",
"(",
"options",
"[",
":desc_order",
"]",
",",
":desc",
")",
"if",
"opt... | Adds sorting to the results by a property name if included in the options. | [
"Adds",
"sorting",
"to",
"the",
"results",
"by",
"a",
"property",
"name",
"if",
"included",
"in",
"the",
"options",
"."
] | ac66520ca57f3bedf03461a4d2f3679f5e5f1d56 | https://github.com/Agrimatics/activemodel-datastore/blob/ac66520ca57f3bedf03461a4d2f3679f5e5f1d56/lib/active_model/datastore.rb#L459-L463 |
18,774 | czycha/pxlsrt | lib/pxlsrt/image.rb | Pxlsrt.Image.diagonalColumnRow | def diagonalColumnRow(d, i)
{
'column' => (d.to_i < 0 ? i : d.to_i + i).to_i,
'row' => (d.to_i < 0 ? d.to_i.abs + i : i).to_i
}
end | ruby | def diagonalColumnRow(d, i)
{
'column' => (d.to_i < 0 ? i : d.to_i + i).to_i,
'row' => (d.to_i < 0 ? d.to_i.abs + i : i).to_i
}
end | [
"def",
"diagonalColumnRow",
"(",
"d",
",",
"i",
")",
"{",
"'column'",
"=>",
"(",
"d",
".",
"to_i",
"<",
"0",
"?",
"i",
":",
"d",
".",
"to_i",
"+",
"i",
")",
".",
"to_i",
",",
"'row'",
"=>",
"(",
"d",
".",
"to_i",
"<",
"0",
"?",
"d",
".",
... | Get the column and row based on the diagonal hash created using diagonalLines. | [
"Get",
"the",
"column",
"and",
"row",
"based",
"on",
"the",
"diagonal",
"hash",
"created",
"using",
"diagonalLines",
"."
] | f65880032f441887d77ddfbe5ebb0760edc96e1c | https://github.com/czycha/pxlsrt/blob/f65880032f441887d77ddfbe5ebb0760edc96e1c/lib/pxlsrt/image.rb#L75-L80 |
18,775 | czycha/pxlsrt | lib/pxlsrt/image.rb | Pxlsrt.Image.getSobel | def getSobel(x, y)
if !defined?(@sobels)
@sobel_x ||= [[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]
@sobel_y ||= [[-1, -2, -1], [0, 0, 0], [1, 2, 1]]
return 0 if x.zero? || (x == (@width - 1)) || y.zero? || (y == (@height - 1))
t1 = @grey[y - 1][x - 1]
t2 = @grey[y - 1][x]
t... | ruby | def getSobel(x, y)
if !defined?(@sobels)
@sobel_x ||= [[-1, 0, 1], [-2, 0, 2], [-1, 0, 1]]
@sobel_y ||= [[-1, -2, -1], [0, 0, 0], [1, 2, 1]]
return 0 if x.zero? || (x == (@width - 1)) || y.zero? || (y == (@height - 1))
t1 = @grey[y - 1][x - 1]
t2 = @grey[y - 1][x]
t... | [
"def",
"getSobel",
"(",
"x",
",",
"y",
")",
"if",
"!",
"defined?",
"(",
"@sobels",
")",
"@sobel_x",
"||=",
"[",
"[",
"-",
"1",
",",
"0",
",",
"1",
"]",
",",
"[",
"-",
"2",
",",
"0",
",",
"2",
"]",
",",
"[",
"-",
"1",
",",
"0",
",",
"1",... | Retrieve Sobel value for a given pixel. | [
"Retrieve",
"Sobel",
"value",
"for",
"a",
"given",
"pixel",
"."
] | f65880032f441887d77ddfbe5ebb0760edc96e1c | https://github.com/czycha/pxlsrt/blob/f65880032f441887d77ddfbe5ebb0760edc96e1c/lib/pxlsrt/image.rb#L124-L144 |
18,776 | czycha/pxlsrt | lib/pxlsrt/image.rb | Pxlsrt.Image.getSobels | def getSobels
unless defined?(@sobels)
l = []
(0...(@width * @height)).each do |xy|
s = getSobel(xy % @width, (xy / @width).floor)
l.push(s)
end
@sobels = l
end
@sobels
end | ruby | def getSobels
unless defined?(@sobels)
l = []
(0...(@width * @height)).each do |xy|
s = getSobel(xy % @width, (xy / @width).floor)
l.push(s)
end
@sobels = l
end
@sobels
end | [
"def",
"getSobels",
"unless",
"defined?",
"(",
"@sobels",
")",
"l",
"=",
"[",
"]",
"(",
"0",
"...",
"(",
"@width",
"*",
"@height",
")",
")",
".",
"each",
"do",
"|",
"xy",
"|",
"s",
"=",
"getSobel",
"(",
"xy",
"%",
"@width",
",",
"(",
"xy",
"/",... | Retrieve the Sobel values for every pixel and set it as @sobel. | [
"Retrieve",
"the",
"Sobel",
"values",
"for",
"every",
"pixel",
"and",
"set",
"it",
"as"
] | f65880032f441887d77ddfbe5ebb0760edc96e1c | https://github.com/czycha/pxlsrt/blob/f65880032f441887d77ddfbe5ebb0760edc96e1c/lib/pxlsrt/image.rb#L148-L158 |
18,777 | Ibsciss/ruby-middleware | lib/middleware/runner.rb | Middleware.Runner.build_call_chain | def build_call_chain(stack)
# We need to instantiate the middleware stack in reverse
# order so that each middleware can have a reference to
# the next middleware it has to call. The final middleware
# is always the empty middleware, which does nothing but return.
stack.reverse.inject(EMPT... | ruby | def build_call_chain(stack)
# We need to instantiate the middleware stack in reverse
# order so that each middleware can have a reference to
# the next middleware it has to call. The final middleware
# is always the empty middleware, which does nothing but return.
stack.reverse.inject(EMPT... | [
"def",
"build_call_chain",
"(",
"stack",
")",
"# We need to instantiate the middleware stack in reverse",
"# order so that each middleware can have a reference to",
"# the next middleware it has to call. The final middleware",
"# is always the empty middleware, which does nothing but return.",
"st... | This takes a stack of middlewares and initializes them in a way
that each middleware properly calls the next middleware. | [
"This",
"takes",
"a",
"stack",
"of",
"middlewares",
"and",
"initializes",
"them",
"in",
"a",
"way",
"that",
"each",
"middleware",
"properly",
"calls",
"the",
"next",
"middleware",
"."
] | 51bb6504737b126fcfb9c4845a806244fad3493b | https://github.com/Ibsciss/ruby-middleware/blob/51bb6504737b126fcfb9c4845a806244fad3493b/lib/middleware/runner.rb#L38-L66 |
18,778 | Ibsciss/ruby-middleware | lib/middleware/builder.rb | Middleware.Builder.insert_before_each | def insert_before_each(middleware, *args, &block)
self.stack = stack.reduce([]) do |carry, item|
carry.push([middleware, args, block], item)
end
end | ruby | def insert_before_each(middleware, *args, &block)
self.stack = stack.reduce([]) do |carry, item|
carry.push([middleware, args, block], item)
end
end | [
"def",
"insert_before_each",
"(",
"middleware",
",",
"*",
"args",
",",
"&",
"block",
")",
"self",
".",
"stack",
"=",
"stack",
".",
"reduce",
"(",
"[",
"]",
")",
"do",
"|",
"carry",
",",
"item",
"|",
"carry",
".",
"push",
"(",
"[",
"middleware",
","... | Inserts a middleware before each middleware object | [
"Inserts",
"a",
"middleware",
"before",
"each",
"middleware",
"object"
] | 51bb6504737b126fcfb9c4845a806244fad3493b | https://github.com/Ibsciss/ruby-middleware/blob/51bb6504737b126fcfb9c4845a806244fad3493b/lib/middleware/builder.rb#L104-L108 |
18,779 | Ibsciss/ruby-middleware | lib/middleware/builder.rb | Middleware.Builder.delete | def delete(index)
index = self.index(index) unless index.is_a?(Integer)
stack.delete_at(index)
end | ruby | def delete(index)
index = self.index(index) unless index.is_a?(Integer)
stack.delete_at(index)
end | [
"def",
"delete",
"(",
"index",
")",
"index",
"=",
"self",
".",
"index",
"(",
"index",
")",
"unless",
"index",
".",
"is_a?",
"(",
"Integer",
")",
"stack",
".",
"delete_at",
"(",
"index",
")",
"end"
] | Deletes the given middleware object or index | [
"Deletes",
"the",
"given",
"middleware",
"object",
"or",
"index"
] | 51bb6504737b126fcfb9c4845a806244fad3493b | https://github.com/Ibsciss/ruby-middleware/blob/51bb6504737b126fcfb9c4845a806244fad3493b/lib/middleware/builder.rb#L126-L129 |
18,780 | bradleypriest/pxpay | lib/pxpay/notification.rb | Pxpay.Notification.to_hash | def to_hash
doc = ::Nokogiri::XML( self.response )
hash = {}
doc.at_css("Response").element_children.each do |attribute|
hash[attribute.name.underscore.to_sym] = attribute.inner_text
end
hash[:valid] = doc.at_css("Response")['valid']
hash
end | ruby | def to_hash
doc = ::Nokogiri::XML( self.response )
hash = {}
doc.at_css("Response").element_children.each do |attribute|
hash[attribute.name.underscore.to_sym] = attribute.inner_text
end
hash[:valid] = doc.at_css("Response")['valid']
hash
end | [
"def",
"to_hash",
"doc",
"=",
"::",
"Nokogiri",
"::",
"XML",
"(",
"self",
".",
"response",
")",
"hash",
"=",
"{",
"}",
"doc",
".",
"at_css",
"(",
"\"Response\"",
")",
".",
"element_children",
".",
"each",
"do",
"|",
"attribute",
"|",
"hash",
"[",
"at... | Return the response as a hash | [
"Return",
"the",
"response",
"as",
"a",
"hash"
] | ba8822adb2349007b85ad2ddeb8d924695983dfa | https://github.com/bradleypriest/pxpay/blob/ba8822adb2349007b85ad2ddeb8d924695983dfa/lib/pxpay/notification.rb#L17-L25 |
18,781 | frodenas/cloudfoundry-client | lib/cloudfoundry/client.rb | CloudFoundry.Client.valid_target_url? | def valid_target_url?
return false unless cloud_info = cloud_info()
return false unless cloud_info[:name]
return false unless cloud_info[:build]
return false unless cloud_info[:support]
return false unless cloud_info[:version]
true
rescue
false
end | ruby | def valid_target_url?
return false unless cloud_info = cloud_info()
return false unless cloud_info[:name]
return false unless cloud_info[:build]
return false unless cloud_info[:support]
return false unless cloud_info[:version]
true
rescue
false
end | [
"def",
"valid_target_url?",
"return",
"false",
"unless",
"cloud_info",
"=",
"cloud_info",
"(",
")",
"return",
"false",
"unless",
"cloud_info",
"[",
":name",
"]",
"return",
"false",
"unless",
"cloud_info",
"[",
":build",
"]",
"return",
"false",
"unless",
"cloud_i... | Checks if the target_url is a valid CloudFoundry target.
@return [Boolean] Returns true if target_url is a valid CloudFoundry API URL, false otherwise. | [
"Checks",
"if",
"the",
"target_url",
"is",
"a",
"valid",
"CloudFoundry",
"target",
"."
] | 831d6045d29f4d34388c61d34023b201480f0591 | https://github.com/frodenas/cloudfoundry-client/blob/831d6045d29f4d34388c61d34023b201480f0591/lib/cloudfoundry/client.rb#L75-L84 |
18,782 | Zerocchi/jikan.rb | lib/jikan/models/search.rb | Jikan.Search.result | def result
case @type
when :anime
iter { |i| Jikan::AnimeResult.new(i) }
when :manga
iter { |i| Jikan::MangaResult.new(i) }
when :character
iter { |i| Jikan::CharacterResult.new(i) }
when :person
iter { |i| Jikan::PersonResult.new(i) }
end
end | ruby | def result
case @type
when :anime
iter { |i| Jikan::AnimeResult.new(i) }
when :manga
iter { |i| Jikan::MangaResult.new(i) }
when :character
iter { |i| Jikan::CharacterResult.new(i) }
when :person
iter { |i| Jikan::PersonResult.new(i) }
end
end | [
"def",
"result",
"case",
"@type",
"when",
":anime",
"iter",
"{",
"|",
"i",
"|",
"Jikan",
"::",
"AnimeResult",
".",
"new",
"(",
"i",
")",
"}",
"when",
":manga",
"iter",
"{",
"|",
"i",
"|",
"Jikan",
"::",
"MangaResult",
".",
"new",
"(",
"i",
")",
"... | returns each result items wrapped in their respective objects | [
"returns",
"each",
"result",
"items",
"wrapped",
"in",
"their",
"respective",
"objects"
] | 498a779e9f85a191e8d6375f7ca83039e984cd4a | https://github.com/Zerocchi/jikan.rb/blob/498a779e9f85a191e8d6375f7ca83039e984cd4a/lib/jikan/models/search.rb#L27-L38 |
18,783 | github/octocatalog-diff | lib/octocatalog-diff/puppetdb.rb | OctocatalogDiff.PuppetDB.parse_url | def parse_url(url)
uri = URI(url)
if URI.split(url)[3].nil?
uri.port = uri.scheme == 'https' ? DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT
end
raise ArgumentError, "URL #{url} has invalid scheme" unless uri.scheme =~ /^https?$/
parsed_url = { ssl: uri.scheme == 'https', host: uri.host,... | ruby | def parse_url(url)
uri = URI(url)
if URI.split(url)[3].nil?
uri.port = uri.scheme == 'https' ? DEFAULT_HTTPS_PORT : DEFAULT_HTTP_PORT
end
raise ArgumentError, "URL #{url} has invalid scheme" unless uri.scheme =~ /^https?$/
parsed_url = { ssl: uri.scheme == 'https', host: uri.host,... | [
"def",
"parse_url",
"(",
"url",
")",
"uri",
"=",
"URI",
"(",
"url",
")",
"if",
"URI",
".",
"split",
"(",
"url",
")",
"[",
"3",
"]",
".",
"nil?",
"uri",
".",
"port",
"=",
"uri",
".",
"scheme",
"==",
"'https'",
"?",
"DEFAULT_HTTPS_PORT",
":",
"DEFA... | Parse a URL to determine hostname, port number, and whether or not SSL is used.
@param url [String] URL to parse
@return [Hash] { ssl: true/false, host: <String>, port: <Integer> } | [
"Parse",
"a",
"URL",
"to",
"determine",
"hostname",
"port",
"number",
"and",
"whether",
"or",
"not",
"SSL",
"is",
"used",
"."
] | c0ec977e7bd4e6d1b925f8697028901f2aca40eb | https://github.com/github/octocatalog-diff/blob/c0ec977e7bd4e6d1b925f8697028901f2aca40eb/lib/octocatalog-diff/puppetdb.rb#L156-L172 |
18,784 | github/octocatalog-diff | lib/octocatalog-diff/catalog.rb | OctocatalogDiff.Catalog.resources | def resources
build
raise OctocatalogDiff::Errors::CatalogError, 'Catalog does not appear to have been built' if !valid? && error_message.nil?
raise OctocatalogDiff::Errors::CatalogError, error_message unless valid?
return @catalog['data']['resources'] if @catalog['data'].is_a?(Hash) && @catalog... | ruby | def resources
build
raise OctocatalogDiff::Errors::CatalogError, 'Catalog does not appear to have been built' if !valid? && error_message.nil?
raise OctocatalogDiff::Errors::CatalogError, error_message unless valid?
return @catalog['data']['resources'] if @catalog['data'].is_a?(Hash) && @catalog... | [
"def",
"resources",
"build",
"raise",
"OctocatalogDiff",
"::",
"Errors",
"::",
"CatalogError",
",",
"'Catalog does not appear to have been built'",
"if",
"!",
"valid?",
"&&",
"error_message",
".",
"nil?",
"raise",
"OctocatalogDiff",
"::",
"Errors",
"::",
"CatalogError",... | This is a compatibility layer for the resources, which are in a different place in Puppet 3.x and Puppet 4.x
@return [Array] Resource array | [
"This",
"is",
"a",
"compatibility",
"layer",
"for",
"the",
"resources",
"which",
"are",
"in",
"a",
"different",
"place",
"in",
"Puppet",
"3",
".",
"x",
"and",
"Puppet",
"4",
".",
"x"
] | c0ec977e7bd4e6d1b925f8697028901f2aca40eb | https://github.com/github/octocatalog-diff/blob/c0ec977e7bd4e6d1b925f8697028901f2aca40eb/lib/octocatalog-diff/catalog.rb#L190-L200 |
18,785 | github/octocatalog-diff | lib/octocatalog-diff/facts.rb | OctocatalogDiff.Facts.facts | def facts(node = @node, timestamp = false)
raise "Expected @facts to be a hash but it is a #{@facts.class}" unless @facts.is_a?(Hash)
raise "Expected @facts['values'] to be a hash but it is a #{@facts['values'].class}" unless @facts['values'].is_a?(Hash)
f = @facts.dup
f['name'] = node unless no... | ruby | def facts(node = @node, timestamp = false)
raise "Expected @facts to be a hash but it is a #{@facts.class}" unless @facts.is_a?(Hash)
raise "Expected @facts['values'] to be a hash but it is a #{@facts['values'].class}" unless @facts['values'].is_a?(Hash)
f = @facts.dup
f['name'] = node unless no... | [
"def",
"facts",
"(",
"node",
"=",
"@node",
",",
"timestamp",
"=",
"false",
")",
"raise",
"\"Expected @facts to be a hash but it is a #{@facts.class}\"",
"unless",
"@facts",
".",
"is_a?",
"(",
"Hash",
")",
"raise",
"\"Expected @facts['values'] to be a hash but it is a #{@fac... | Facts - returned the 'cleansed' facts.
Clean up facts by setting 'name' to the node if given, and deleting _timestamp and expiration
which may cause Puppet catalog compilation to fail if the facts are old.
@param node [String] Node name to override returned facts
@return [Hash] Facts hash { 'name' => '...', 'values... | [
"Facts",
"-",
"returned",
"the",
"cleansed",
"facts",
".",
"Clean",
"up",
"facts",
"by",
"setting",
"name",
"to",
"the",
"node",
"if",
"given",
"and",
"deleting",
"_timestamp",
"and",
"expiration",
"which",
"may",
"cause",
"Puppet",
"catalog",
"compilation",
... | c0ec977e7bd4e6d1b925f8697028901f2aca40eb | https://github.com/github/octocatalog-diff/blob/c0ec977e7bd4e6d1b925f8697028901f2aca40eb/lib/octocatalog-diff/facts.rb#L57-L70 |
18,786 | github/octocatalog-diff | lib/octocatalog-diff/facts.rb | OctocatalogDiff.Facts.without | def without(remove)
r = remove.is_a?(Array) ? remove : [remove]
obj = dup
r.each { |fact| obj.remove_fact_from_list(fact) }
obj
end | ruby | def without(remove)
r = remove.is_a?(Array) ? remove : [remove]
obj = dup
r.each { |fact| obj.remove_fact_from_list(fact) }
obj
end | [
"def",
"without",
"(",
"remove",
")",
"r",
"=",
"remove",
".",
"is_a?",
"(",
"Array",
")",
"?",
"remove",
":",
"[",
"remove",
"]",
"obj",
"=",
"dup",
"r",
".",
"each",
"{",
"|",
"fact",
"|",
"obj",
".",
"remove_fact_from_list",
"(",
"fact",
")",
... | Facts - remove one or more facts from the list.
@param remove [String|Array<String>] Fact(s) to remove
@return self | [
"Facts",
"-",
"remove",
"one",
"or",
"more",
"facts",
"from",
"the",
"list",
"."
] | c0ec977e7bd4e6d1b925f8697028901f2aca40eb | https://github.com/github/octocatalog-diff/blob/c0ec977e7bd4e6d1b925f8697028901f2aca40eb/lib/octocatalog-diff/facts.rb#L82-L87 |
18,787 | github/octocatalog-diff | lib/octocatalog-diff/facts.rb | OctocatalogDiff.Facts.facts_to_yaml | def facts_to_yaml(node = @node)
# Add the header that Puppet needs to treat this as facts. Save the results
# as a string in the option.
f = facts(node)
fact_file = f.to_yaml.split(/\n/)
fact_file[0] = '--- !ruby/object:Puppet::Node::Facts' if fact_file[0] =~ /^---/
fact_file.join("\... | ruby | def facts_to_yaml(node = @node)
# Add the header that Puppet needs to treat this as facts. Save the results
# as a string in the option.
f = facts(node)
fact_file = f.to_yaml.split(/\n/)
fact_file[0] = '--- !ruby/object:Puppet::Node::Facts' if fact_file[0] =~ /^---/
fact_file.join("\... | [
"def",
"facts_to_yaml",
"(",
"node",
"=",
"@node",
")",
"# Add the header that Puppet needs to treat this as facts. Save the results",
"# as a string in the option.",
"f",
"=",
"facts",
"(",
"node",
")",
"fact_file",
"=",
"f",
".",
"to_yaml",
".",
"split",
"(",
"/",
"... | Turn hash of facts into appropriate YAML for Puppet
@param node [String] Node name to override returned facts
@return [String] Puppet-compatible YAML facts | [
"Turn",
"hash",
"of",
"facts",
"into",
"appropriate",
"YAML",
"for",
"Puppet"
] | c0ec977e7bd4e6d1b925f8697028901f2aca40eb | https://github.com/github/octocatalog-diff/blob/c0ec977e7bd4e6d1b925f8697028901f2aca40eb/lib/octocatalog-diff/facts.rb#L98-L105 |
18,788 | fortesinformatica/jasper-rails | lib/jasper-rails/jasper_reports_renderer.rb | JasperRails.JasperReportsRenderer.parameter_value_of | def parameter_value_of(param)
_String = Rjb::import 'java.lang.String'
# Using Rjb::import('java.util.HashMap').new, it returns an instance of
# Rjb::Rjb_JavaProxy, so the Rjb_JavaProxy parent is the Rjb module itself.
if param.class.parent == Rjb
param
else
_String.new(par... | ruby | def parameter_value_of(param)
_String = Rjb::import 'java.lang.String'
# Using Rjb::import('java.util.HashMap').new, it returns an instance of
# Rjb::Rjb_JavaProxy, so the Rjb_JavaProxy parent is the Rjb module itself.
if param.class.parent == Rjb
param
else
_String.new(par... | [
"def",
"parameter_value_of",
"(",
"param",
")",
"_String",
"=",
"Rjb",
"::",
"import",
"'java.lang.String'",
"# Using Rjb::import('java.util.HashMap').new, it returns an instance of",
"# Rjb::Rjb_JavaProxy, so the Rjb_JavaProxy parent is the Rjb module itself.",
"if",
"param",
".",
"... | Returns the value without conversion when it's converted to Java Types.
When isn't a Rjb class, returns a Java String of it. | [
"Returns",
"the",
"value",
"without",
"conversion",
"when",
"it",
"s",
"converted",
"to",
"Java",
"Types",
".",
"When",
"isn",
"t",
"a",
"Rjb",
"class",
"returns",
"a",
"Java",
"String",
"of",
"it",
"."
] | d04e8046f3824a71dbfe9375039c0ed38d2ea71f | https://github.com/fortesinformatica/jasper-rails/blob/d04e8046f3824a71dbfe9375039c0ed38d2ea71f/lib/jasper-rails/jasper_reports_renderer.rb#L129-L138 |
18,789 | amitree/delayed_job_recurring | lib/delayed/recurring_job.rb | Delayed.RecurringJob.schedule! | def schedule! options = {}
options = options.dup
if run_every = options.delete(:run_every)
options[:run_interval] = serialize_duration(run_every)
end
@schedule_options = options.reverse_merge(@schedule_options || {}).reverse_merge(
run_at: self.class.run_at,
timezone: s... | ruby | def schedule! options = {}
options = options.dup
if run_every = options.delete(:run_every)
options[:run_interval] = serialize_duration(run_every)
end
@schedule_options = options.reverse_merge(@schedule_options || {}).reverse_merge(
run_at: self.class.run_at,
timezone: s... | [
"def",
"schedule!",
"options",
"=",
"{",
"}",
"options",
"=",
"options",
".",
"dup",
"if",
"run_every",
"=",
"options",
".",
"delete",
"(",
":run_every",
")",
"options",
"[",
":run_interval",
"]",
"=",
"serialize_duration",
"(",
"run_every",
")",
"end",
"@... | Schedule this "repeating" job | [
"Schedule",
"this",
"repeating",
"job"
] | c0eb8c6f53f49319e9b029f0cc1993603718bfa6 | https://github.com/amitree/delayed_job_recurring/blob/c0eb8c6f53f49319e9b029f0cc1993603718bfa6/lib/delayed/recurring_job.rb#L25-L51 |
18,790 | Yelp/yelp-ruby | lib/yelp/client.rb | Yelp.Client.create_methods_from_instance | def create_methods_from_instance(instance)
instance.public_methods(false).each do |method_name|
add_method(instance, method_name)
end
end | ruby | def create_methods_from_instance(instance)
instance.public_methods(false).each do |method_name|
add_method(instance, method_name)
end
end | [
"def",
"create_methods_from_instance",
"(",
"instance",
")",
"instance",
".",
"public_methods",
"(",
"false",
")",
".",
"each",
"do",
"|",
"method_name",
"|",
"add_method",
"(",
"instance",
",",
"method_name",
")",
"end",
"end"
] | Loop through all of the endpoint instances' public singleton methods to
add the method to client | [
"Loop",
"through",
"all",
"of",
"the",
"endpoint",
"instances",
"public",
"singleton",
"methods",
"to",
"add",
"the",
"method",
"to",
"client"
] | cca275c39dbb01b59fcb40902aa00a482352a35d | https://github.com/Yelp/yelp-ruby/blob/cca275c39dbb01b59fcb40902aa00a482352a35d/lib/yelp/client.rb#L92-L96 |
18,791 | Yelp/yelp-ruby | lib/yelp/client.rb | Yelp.Client.add_method | def add_method(instance, method_name)
define_singleton_method(method_name) do |*args|
instance.public_send(method_name, *args)
end
end | ruby | def add_method(instance, method_name)
define_singleton_method(method_name) do |*args|
instance.public_send(method_name, *args)
end
end | [
"def",
"add_method",
"(",
"instance",
",",
"method_name",
")",
"define_singleton_method",
"(",
"method_name",
")",
"do",
"|",
"*",
"args",
"|",
"instance",
".",
"public_send",
"(",
"method_name",
",",
"args",
")",
"end",
"end"
] | Define the method on the client and send it to the endpoint instance
with the args passed in | [
"Define",
"the",
"method",
"on",
"the",
"client",
"and",
"send",
"it",
"to",
"the",
"endpoint",
"instance",
"with",
"the",
"args",
"passed",
"in"
] | cca275c39dbb01b59fcb40902aa00a482352a35d | https://github.com/Yelp/yelp-ruby/blob/cca275c39dbb01b59fcb40902aa00a482352a35d/lib/yelp/client.rb#L100-L104 |
18,792 | Yelp/yelp-ruby | lib/yelp/configuration.rb | Yelp.Configuration.auth_keys | def auth_keys
AUTH_KEYS.inject({}) do |keys_hash, key|
keys_hash[key] = send(key)
keys_hash
end
end | ruby | def auth_keys
AUTH_KEYS.inject({}) do |keys_hash, key|
keys_hash[key] = send(key)
keys_hash
end
end | [
"def",
"auth_keys",
"AUTH_KEYS",
".",
"inject",
"(",
"{",
"}",
")",
"do",
"|",
"keys_hash",
",",
"key",
"|",
"keys_hash",
"[",
"key",
"]",
"=",
"send",
"(",
"key",
")",
"keys_hash",
"end",
"end"
] | Creates the configuration
@param [Hash] hash containing configuration parameters and their values
@return [Configuration] a new configuration with the values from the
config_hash set
Returns a hash of api keys and their values | [
"Creates",
"the",
"configuration"
] | cca275c39dbb01b59fcb40902aa00a482352a35d | https://github.com/Yelp/yelp-ruby/blob/cca275c39dbb01b59fcb40902aa00a482352a35d/lib/yelp/configuration.rb#L20-L25 |
18,793 | mowens/cocoapods-links | lib/pod/lockfile.rb | Pod.Lockfile.write_to_disk | def write_to_disk(path)
# code here mimics the original method but with link filtering
filename = File.basename(path)
path.dirname.mkpath unless path.dirname.exist?
yaml = to_link_yaml
File.open(path, 'w') { |f| f.write(yaml) }
self.defined_in_file = path
end | ruby | def write_to_disk(path)
# code here mimics the original method but with link filtering
filename = File.basename(path)
path.dirname.mkpath unless path.dirname.exist?
yaml = to_link_yaml
File.open(path, 'w') { |f| f.write(yaml) }
self.defined_in_file = path
end | [
"def",
"write_to_disk",
"(",
"path",
")",
"# code here mimics the original method but with link filtering",
"filename",
"=",
"File",
".",
"basename",
"(",
"path",
")",
"path",
".",
"dirname",
".",
"mkpath",
"unless",
"path",
".",
"dirname",
".",
"exist?",
"yaml",
... | Hook the Podfile.lock file generation to allow us to filter out the links added to the
Podfile.lock. The logic here is to replace the new Podfile.lock link content with what existed
before the link was added. Currently, this is called for both Podfile.lock and Manifest.lock
file so we only want to alter the Podfile.... | [
"Hook",
"the",
"Podfile",
".",
"lock",
"file",
"generation",
"to",
"allow",
"us",
"to",
"filter",
"out",
"the",
"links",
"added",
"to",
"the",
"Podfile",
".",
"lock",
".",
"The",
"logic",
"here",
"is",
"to",
"replace",
"the",
"new",
"Podfile",
".",
"lo... | 148611a98f8258862a8b03e11c8fea095544d770 | https://github.com/mowens/cocoapods-links/blob/148611a98f8258862a8b03e11c8fea095544d770/lib/pod/lockfile.rb#L27-L35 |
18,794 | mowens/cocoapods-links | lib/pod/lockfile.rb | Pod.Lockfile.to_link_hash | def to_link_hash
# retrieve the lock contents with links
after_hash = to_hash
unless File.exists?(PODFILE_LOCK)
return after_hash
end
# retrieve the lock content before the links
before_hash = YAML.load(File.read(PODFILE_LOCK))
# retrieve installed links
links... | ruby | def to_link_hash
# retrieve the lock contents with links
after_hash = to_hash
unless File.exists?(PODFILE_LOCK)
return after_hash
end
# retrieve the lock content before the links
before_hash = YAML.load(File.read(PODFILE_LOCK))
# retrieve installed links
links... | [
"def",
"to_link_hash",
"# retrieve the lock contents with links",
"after_hash",
"=",
"to_hash",
"unless",
"File",
".",
"exists?",
"(",
"PODFILE_LOCK",
")",
"return",
"after_hash",
"end",
"# retrieve the lock content before the links",
"before_hash",
"=",
"YAML",
".",
"load"... | Will get the Podfile.lock contents hash after replacing the linked content with its previous
Podfile.lock information keeping the Podfile and Podfile.lock in sync and clear of any link
data
@returns hash that is to be dumped to the Podfile.lock file without link content | [
"Will",
"get",
"the",
"Podfile",
".",
"lock",
"contents",
"hash",
"after",
"replacing",
"the",
"linked",
"content",
"with",
"its",
"previous",
"Podfile",
".",
"lock",
"information",
"keeping",
"the",
"Podfile",
"and",
"Podfile",
".",
"lock",
"in",
"sync",
"a... | 148611a98f8258862a8b03e11c8fea095544d770 | https://github.com/mowens/cocoapods-links/blob/148611a98f8258862a8b03e11c8fea095544d770/lib/pod/lockfile.rb#L63-L108 |
18,795 | mowens/cocoapods-links | lib/pod/lockfile.rb | Pod.Lockfile.merge_dependencies | def merge_dependencies(links, before, after)
links.each do |link|
before_index = find_dependency_index before, link
after_index = find_dependency_index after, link
unless before_index.nil? || after_index.nil?
after[after_index] = before[before_index]
end
end
r... | ruby | def merge_dependencies(links, before, after)
links.each do |link|
before_index = find_dependency_index before, link
after_index = find_dependency_index after, link
unless before_index.nil? || after_index.nil?
after[after_index] = before[before_index]
end
end
r... | [
"def",
"merge_dependencies",
"(",
"links",
",",
"before",
",",
"after",
")",
"links",
".",
"each",
"do",
"|",
"link",
"|",
"before_index",
"=",
"find_dependency_index",
"before",
",",
"link",
"after_index",
"=",
"find_dependency_index",
"after",
",",
"link",
"... | Will merge the DEPENDENCIES of the Podfile.lock before a link and after a link
@param links the installed links
@param before the DEPENDENCIES in the Podfile.lock before the link occurs
@param after the DEPENDENCIES after the link (includes new link that we want to filter out)
@returns the merged DEPENDENCIES rep... | [
"Will",
"merge",
"the",
"DEPENDENCIES",
"of",
"the",
"Podfile",
".",
"lock",
"before",
"a",
"link",
"and",
"after",
"a",
"link"
] | 148611a98f8258862a8b03e11c8fea095544d770 | https://github.com/mowens/cocoapods-links/blob/148611a98f8258862a8b03e11c8fea095544d770/lib/pod/lockfile.rb#L157-L166 |
18,796 | mowens/cocoapods-links | lib/pod/lockfile.rb | Pod.Lockfile.merge_hashes | def merge_hashes(links, before, after)
if before.nil?
return after
end
links.each do |link|
if before.has_key?(link)
after[link] = before[link]
else
if after.has_key?(link)
after.delete(link)
end
end
end
return after... | ruby | def merge_hashes(links, before, after)
if before.nil?
return after
end
links.each do |link|
if before.has_key?(link)
after[link] = before[link]
else
if after.has_key?(link)
after.delete(link)
end
end
end
return after... | [
"def",
"merge_hashes",
"(",
"links",
",",
"before",
",",
"after",
")",
"if",
"before",
".",
"nil?",
"return",
"after",
"end",
"links",
".",
"each",
"do",
"|",
"link",
"|",
"if",
"before",
".",
"has_key?",
"(",
"link",
")",
"after",
"[",
"link",
"]",
... | Will merge the hashes of the Podfile.lock before a link and after a link
@param links the installed links
@param before the hash in the Podfile.lock before the link occurs
@param after the hash after the link (includes new link that we want to filter out)
@returns the merged hash replacing any links that were add... | [
"Will",
"merge",
"the",
"hashes",
"of",
"the",
"Podfile",
".",
"lock",
"before",
"a",
"link",
"and",
"after",
"a",
"link"
] | 148611a98f8258862a8b03e11c8fea095544d770 | https://github.com/mowens/cocoapods-links/blob/148611a98f8258862a8b03e11c8fea095544d770/lib/pod/lockfile.rb#L177-L191 |
18,797 | michelson/chaskiq | app/jobs/chaskiq/ses_sender_job.rb | Chaskiq.SesSenderJob.perform | def perform(campaign, subscription)
subscriber = subscription.subscriber
return if subscriber.blank?
mailer = campaign.prepare_mail_to(subscription)
response = mailer.deliver
message_id = response.message_id.gsub("@email.amazonses.com", "")
campaign.metrics.create(
... | ruby | def perform(campaign, subscription)
subscriber = subscription.subscriber
return if subscriber.blank?
mailer = campaign.prepare_mail_to(subscription)
response = mailer.deliver
message_id = response.message_id.gsub("@email.amazonses.com", "")
campaign.metrics.create(
... | [
"def",
"perform",
"(",
"campaign",
",",
"subscription",
")",
"subscriber",
"=",
"subscription",
".",
"subscriber",
"return",
"if",
"subscriber",
".",
"blank?",
"mailer",
"=",
"campaign",
".",
"prepare_mail_to",
"(",
"subscription",
")",
"response",
"=",
"mailer"... | send to ses | [
"send",
"to",
"ses"
] | 1f0d0e6cf7f198e888d421471619bdfdedffa1d2 | https://github.com/michelson/chaskiq/blob/1f0d0e6cf7f198e888d421471619bdfdedffa1d2/app/jobs/chaskiq/ses_sender_job.rb#L7-L22 |
18,798 | michelson/chaskiq | app/models/chaskiq/campaign.rb | Chaskiq.Campaign.clean_inline_css | def clean_inline_css(url)
premailer = Premailer.new(url, :adapter => :nokogiri, :escape_url_attributes => false)
premailer.to_inline_css.gsub("Drop Content Blocks Here", "")
end | ruby | def clean_inline_css(url)
premailer = Premailer.new(url, :adapter => :nokogiri, :escape_url_attributes => false)
premailer.to_inline_css.gsub("Drop Content Blocks Here", "")
end | [
"def",
"clean_inline_css",
"(",
"url",
")",
"premailer",
"=",
"Premailer",
".",
"new",
"(",
"url",
",",
":adapter",
"=>",
":nokogiri",
",",
":escape_url_attributes",
"=>",
"false",
")",
"premailer",
".",
"to_inline_css",
".",
"gsub",
"(",
"\"Drop Content Blocks ... | will remove content blocks text | [
"will",
"remove",
"content",
"blocks",
"text"
] | 1f0d0e6cf7f198e888d421471619bdfdedffa1d2 | https://github.com/michelson/chaskiq/blob/1f0d0e6cf7f198e888d421471619bdfdedffa1d2/app/models/chaskiq/campaign.rb#L97-L100 |
18,799 | michelson/chaskiq | app/jobs/chaskiq/mail_sender_job.rb | Chaskiq.MailSenderJob.perform | def perform(campaign)
campaign.apply_premailer
campaign.list.subscriptions.availables.each do |s|
campaign.push_notification(s)
end
end | ruby | def perform(campaign)
campaign.apply_premailer
campaign.list.subscriptions.availables.each do |s|
campaign.push_notification(s)
end
end | [
"def",
"perform",
"(",
"campaign",
")",
"campaign",
".",
"apply_premailer",
"campaign",
".",
"list",
".",
"subscriptions",
".",
"availables",
".",
"each",
"do",
"|",
"s",
"|",
"campaign",
".",
"push_notification",
"(",
"s",
")",
"end",
"end"
] | send to all list with state passive & subscribed | [
"send",
"to",
"all",
"list",
"with",
"state",
"passive",
"&",
"subscribed"
] | 1f0d0e6cf7f198e888d421471619bdfdedffa1d2 | https://github.com/michelson/chaskiq/blob/1f0d0e6cf7f198e888d421471619bdfdedffa1d2/app/jobs/chaskiq/mail_sender_job.rb#L7-L12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.