query stringlengths 7 9.5k | document stringlengths 10 1.07M | negatives listlengths 19 19 | metadata dict |
|---|---|---|---|
:callseq: extract_version() => this_version Extract the current version number from the buildfile. Raise an error if not found. | def extract_version
buildfile = File.read(Rake.application.rakefile).force_encoding("ISO-8859-1").encode("utf-8", replace: nil)
buildfile.scan(THIS_VERSION_PATTERN)[0][2]
rescue
fail 'Looking for THIS_VERSION = "1.0.0-rc1" in your Buildfile, none found'
end | [
"def extract_version\n buildfile = File.read(version_file)\n buildfile.scan(THIS_VERSION_PATTERN)[0][2]\n rescue\n fail 'Looking for THIS_VERSION = \"...\" in your Buildfile, none found'\n end",
"def extract_version( directory='.' )\n\t\trelease = nil\n\n\t\tDir::chdir( directory ) do\n\t\t\t... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Move the version to next and save the updated buildfile | def update_buildfile
buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT
resolve_next_version(this_version) # THIS_VERSION
}
File.open(Rake.application.rakefile.to_s, 'w') { |file| file.write buildfile }
end | [
"def update_buildfile\n buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT\n resolve_next_version(this_version) # THIS_VERSION\n }\n File.open(version_file, 'w') { |file| file.write buildfile }\n end",
"def update_build_number\n @build_number = file.read.to_i + ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return the message to use to commit the buildfile with the next version | def message
version = extract_version
msg = Release.commit_message || "Changed version number to #{version}"
msg = msg.call(version) if Proc === msg
msg
end | [
"def update_buildfile\n buildfile = change_version { |version| # THIS_VERSION minus SNAPSHOT\n resolve_next_version(this_version) # THIS_VERSION\n }\n File.open(version_file, 'w') { |file| file.write buildfile }\n end",
"def update_buildfile\n buildfile = change_version { |version| #... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
:callseq: git(args) Executes a Git command and returns the output. Throws exception if the exit status is not zero. For example: git 'commit' git 'remote', 'show', 'origin' | def git(*args)
cmd = "git #{args.shift} #{args.map { |arg| arg.inspect }.join(' ')}"
output = `#{cmd}`
fail "GIT command \"#{cmd}\" failed with status #{$?.exitstatus}\n#{output}" unless $?.exitstatus == 0
return output
end | [
"def execute_git(repo_dir, *args)\n system('git', '-C', repo_dir, *args)\n end",
"def run_cmd(git_cmd)\n cmd = \"git #{git_cmd}\"\n output = `#{cmd}`.chomp\n exit_status = $?.exitstatus\n if exit_status > 1\n @@log.fail \"Command `#{cmd} has failed. Exit status: #{exit_status}`\"\n e... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns list of uncommited/untracked files as reported by git status. | def uncommitted_files
`git status`.scan(/^#(\t|\s{7})(\S.*)$/).map { |match| match.last.split.last }
end | [
"def untracked\n files = git \"ls-files --other --exclude-standard\"\n files.split(\"\\n\")\n end",
"def get_uncommitted_files\n\t\t\tlist = read_command_output( 'hg', 'status', '-n', '--color', 'never' )\n\t\t\tlist = list.split( /\\n/ )\n\n\t\t\ttrace \"Changed files: %p\" % [ list ]\n\t\t\treturn list\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Commit the given file with a message. The file has to be known to Git meaning that it has either to have been already committed in the past or freshly added to the index. Otherwise it will fail. | def commit(file, message)
git 'commit', '-m', message, file
end | [
"def commit(file, message)\n hg 'commit', '-m', message, file\n end",
"def commit(author, date, message, file = \"\")\r\n # Create message file (temporally)\r\n message = \"-\" if message == \"\"\r\n message_file = MESSAGE_FILE\r\n\r\n ec = Encoding::Converter.new(Encoding.find(\"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
this will check if the obj is locked with any user. | def locked?(obj)
RedisMutexer.config.redis.exists(key(obj))
end | [
"def locked?\n locked_by? && locked_at?\n end",
"def locked?() end",
"def i_dont_own?(object)\n if(current_user.present? and object.user.present? and object.user.id.present? and (current_user.id == object.user.id))\n false\n else\n true\n end\n end",
"def is_owner?(obj)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculate the sub_total as the SUM(line_item.line_amount). | def sub_total
total_cache(:sub_total) || sum_line_items(line_items, :line_amount)
end | [
"def sub_total\n @sub_total || line_items.inject(BigDecimal.new('0')) { | sum, line_item | sum + BigDecimal.new(line_item.line_amount.to_s) }\n end",
"def subtotal\n line_items.inject(BigDecimal.new(\"0\")) { |result, item| result += item.amount }\n end",
"def subtotal\n line_items.reduce(Big... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If a templating language other than ERB is specified, add the relevant gem to the Gemfile. | def add_view_language_gem
return if view_language == "erb"
add_gems %(gem "#{view_language}")
end | [
"def use_template_engine(template_engine, &blk)\n Merb.template_engine = template_engine\n\n if template_engine != :erb\n if template_engine.in?(:haml, :builder)\n template_engine_plugin = \"merb-#{template_engine}\"\n else\n template_engine_plugin = \"merb_#{template_engine}\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Run the Views generator to produce views | def generate_views
Views.new(cli: cli, app_path: app_path).generate
end | [
"def create_analysis_views\n puts \"====================\"\n puts \"creating analysis views for #{self.name}\"\n puts \"====================\"\n\n run_analysis_views\n\n puts \"> done\"\n puts \"====================\"\n end",
"def create_views\r\n generate(\"angular_views\", class_name.table... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
generates a fetch statistic image | def stats!
info "STATS"
task "generate chart" do
c = Chart::StatsPerCollection.new
@dbi.execute( File.read( sql_query(:chart) ) ).each{ |date,collection|
c.add_one(collection, Date.parse(date).day)
}
Chart.new(c).write File.join( @config['settings']['output'], '/chart.jpg' )
... | [
"def statistics_as_html\n title = \"Statistics on Image\"\n @builder ||= Builder::XmlMarkup.new(:indent => 2)\n @builder.declare! :DOCTYPE, :html\n @builder.html do\n @builder.head{ @builder.title title }\n @builder.body do\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
> compress [1, 1, 2, 3, 3, 3] => [1, 2, 3] | def compress(array)
array.uniq
end | [
"def list_compress(list, acc = [])\n return acc if list.empty?\n h, *t = list\n acc << h if acc.last != h\n list_compress(t, acc)\nend",
"def compress(data); end",
"def rangify(list, compress = false)\n last_item = nil\n\n list.sort.inject([]) do |ret, item|\n if last_item\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /admin/enrollments/new GET /admin/enrollments/new.xml | def new
@enrollment = Enrollment.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @enrollment }
end
end | [
"def new\n @client_enrollment = ClientEnrollment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @client_enrollment }\n end\n end",
"def new\n @entitlement = Entitlement.new\n\n respond_to do |format|\n format.html # new.html.erb\n for... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generate a searchable schema list in the output | def generate_schema_list
puts "GENERATE SCHEMA LIST"
# load all the features from the Registry
@items = Registry.all(:schema).sort { |a,b| a.name.downcase <=> b.name.downcase }
@list_title = "Schema List"
@list_type = "schema"
# optional: the specified stylesheet class
# when not specified it will... | [
"def schemas\n unless @schemas\n search_path = select_one(\"show search_path\")['search_path']\n @schemas = search_path.split(/,/).map { |p| quote(p.strip) }.join(',')\n end\n @schemas\n end",
"def schema\n schema = RiakJson::CollectionSchema.new\n self.attrib... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Remove a link from the website | def remove_link(link)
links.delete(link)
end | [
"def strip_links(html); end",
"def remove_link(link)\n raise Occi::Core::Errors::MandatoryArgumentError, 'Cannot remove a non-existent link' unless link\n\n link.source = nil\n link.source_kind = nil\n links.delete link\n end",
"def unlink!\n parse \n @tags.each do |... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Finds all links that contain the search string | def find_links(search)
links.select { |link| link.contains? search }
end | [
"def search_links(page,content)\n page.links_with( :text => Regexp.new(content, true))\n end",
"def find_links(search)\n website.find_links(search)\n end",
"def search_matching_links_to name\n\t\tanswer = nil\n\t\tif internet_available?\n\t\t\tanswer = WikiClient.ask name\n\t\t\tanswer.select! { |li... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Merge links based on the provided attribue to one link by combining the values. The first link will be updated and the obsolete links are deleted and will be returned | def merge_links_on(attribute, concat_string = ',')
links_group_by(attribute)
.select { |key, link_list| links.size > 1 }
.map do |key, link_list|
merge_attributes = Link::ATTRS - [attribute]
link_list.first
.update(Hash[extract_columns(link_lis... | [
"def links_duplicate_on(attribute, separator)\n links.map do |link|\n link.send(attribute).split(separator).collect do |value|\n link.dup.update(Hash[attribute, value])\n end\n end.flatten\n end",
"def merge_links\n website.merge_links_on(:url)\n end",
"def move_url_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Groups the links on the provided attribute. If no links array is provided the links from self are used | def links_group_by(attribute, linkz = links)
linkz.map { |link| { key: link.send(attribute), link: link } }
.group_by { |entry| entry[:key] }
.each { |key, link| link.map! { |l| l[:link] }}
end | [
"def merge_links_on(attribute, concat_string = ',')\n links_group_by(attribute)\n .select { |key, link_list| links.size > 1 }\n .map do |key, link_list| \n merge_attributes = Link::ATTRS - [attribute]\n link_list.first\n .update(Hash[extract_colum... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Groups the links on the provided attribute. If the attribute's value contains the provided separator, the value is split up and each of the values is used as group key | def links_group_by_separated(attribute, separator)
links_group_by(attribute, links_duplicate_on(attribute, separator))
end | [
"def links_duplicate_on(attribute, separator)\n links.map do |link|\n link.send(attribute).split(separator).collect do |value|\n link.dup.update(Hash[attribute, value])\n end\n end.flatten\n end",
"def links_group_by(attribute, linkz = links)\n linkz.map { |link| { k... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create multiple Links based on the attribute provided. The specified spearator will splitt the attribute value in distinct values and for each different value a Link will be created | def links_duplicate_on(attribute, separator)
links.map do |link|
link.send(attribute).split(separator).collect do |value|
link.dup.update(Hash[attribute, value])
end
end.flatten
end | [
"def merge_links_on(attribute, concat_string = ',')\n links_group_by(attribute)\n .select { |key, link_list| links.size > 1 }\n .map do |key, link_list| \n merge_attributes = Link::ATTRS - [attribute]\n link_list.first\n .update(Hash[extract_colum... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return an array of all link values as rows | def rows
links.map { |link| link.row }
end | [
"def links\n each_link.to_a\n end",
"def linkHashToQueryStringArray(links)\n if !links || !links.is_a?(Hash) then\n raise(StandardError,\"bad links value\")\n end\n\n strings = Array.new\n links.each do |table, key|\n if key.class == Array then\n key.each { |k| s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Mark that you want to use stdin and raise an exception if it's already been used. | def can_i_haz_stdin!
raise ArgumentError, "stdin (-) cannot be specified multiple times" if @stdin_used
@stdin_used = true
end | [
"def stdin!(stdin)\n @stdin = stdin\n self\n end",
"def feed_stdin(str)\n old_stdin = $stdin\n $stdin = StringIO.new str\n\n yield\nensure\n $stdin = old_stdin\nend",
"def stdin_pipe; end",
"def stdin\n @stdin_io || @stdin_spool\n end",
"def detect_and_set_stdin_discovery\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Determines if the ledger can be conciliated or nulled | def can_conciliate_or_null?
!(nuller_id.present? || approver_id.present?)
end | [
"def null_config?\n actual_config.base_currency.nil? || actual_config.currency_rates.nil?\n end",
"def minimal_charge_enabled?\n minimal_charge != 0\n end",
"def has_bridge?\r\n not @bridges.empty?\r\n end",
"def valid?\n return (self.battler != nil)\n end",
"def safe?(lbd, condition)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Verifico si el Medidor al que pertenece el estado, es de energia reactiva | def es_medidor_de_energia_reactiva
medidor_id = MedidorEstadoMedidor.where(estado_medidor_id: self.id).take.medidor_id
medidor = Medidor.find(medidor_id)
return medidor.tipo_medidor.codigo == 2
end | [
"def energized?\n @cur_energy > 0\n end",
"def inscrite?\n self.paiementsTotal == 0 and !self.enRegle?\n end",
"def revolution_per_meter? = unit == 'revolution-per-meter'",
"def is_ready_to_deliver?\n assert_female\n\n self.gestation >= self.species['attributes']['gestation_period'].to_i.mon... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Seteo el periodo "mes/anio" | def set_periodo
self.periodo = "#{self.fecha_medicion.month}/#{self.fecha_medicion.year}"
end | [
"def period=(value)\n @period = value\n end",
"def ultimoDia (mes, ano=7)\n fim_do_mes = { \"1\" => \"31\", \"01\" => \"31\", \"2\" => \"28\", \"02\" => \"28\", \"3\" => \"31\",\n \"03\" => \"31\", \"4\" => \"30\", \"04\" => \"30\", \... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Seteo el consumo promedio | def set_consumo_promedio
self.promedio = self.consumo_promedio
end | [
"def llenar_productos\n self.productos = self.clase.descripcion unless self.clase.nil?\n end",
"def envia_produto\n # Marca dia/hora do envio\n self.data_envio = Time.now.utc\n self.save(false)\n # Email para cliente\n self.notifica_envio_produto\n end",
"def preenche_parcelas_recorrencia\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculo el consumo para esa toma de estado | def consumo
estado_actual - estado_anterior
end | [
"def calculo \n self.minutos_reales = 5 * 480 #cantidad de OPERARIOS * Jornada de Trabajo(Turnos)\n self.costo_minuto = 89 #Costo Real por minuto\n self.otros_costos = 540 * 89 #Tiempo Total(Minutos) * Costo Real por Minutos\n self.costo_mano_obra = 420 * 5 * 89 # Jornada Minutos * Canti... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /first_semester_library_book_outlines/1 GET /first_semester_library_book_outlines/1.json | def show
@first_semester_library_book_outline = FirstSemesterLibraryBookOutline.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @first_semester_library_book_outline }
end
end | [
"def show\n @second_semester_library_book_outline = SecondSemesterLibraryBookOutline.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @second_semester_library_book_outline }\n end\n end",
"def new\n @first_semester_library_book_outline ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /first_semester_library_book_outlines/new GET /first_semester_library_book_outlines/new.json | def new
@first_semester_library_book_outline = FirstSemesterLibraryBookOutline.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @first_semester_library_book_outline }
end
end | [
"def new\n @second_semester_library_book_outline = SecondSemesterLibraryBookOutline.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @second_semester_library_book_outline }\n end\n end",
"def new\n @first_semester_course_outline = FirstSemesterCourseO... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /first_semester_library_book_outlines POST /first_semester_library_book_outlines.json | def create
@first_semester_library_book_outline = FirstSemesterLibraryBookOutline.new(params[:first_semester_library_book_outline])
respond_to do |format|
if @first_semester_library_book_outline.save
format.html { redirect_to ([:administrator, @first_semester_library_book_outline]), notice: 'Firs... | [
"def create\n @second_semester_library_book_outline = SecondSemesterLibraryBookOutline.new(params[:second_semester_library_book_outline])\n\n respond_to do |format|\n if @second_semester_library_book_outline.save\n format.html { redirect_to ([:administrator, @second_semester_library_book_outline])... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /first_semester_library_book_outlines/1 PUT /first_semester_library_book_outlines/1.json | def update
@first_semester_library_book_outline = FirstSemesterLibraryBookOutline.find(params[:id])
respond_to do |format|
if @first_semester_library_book_outline.update_attributes(params[:first_semester_library_book_outline])
format.html { redirect_to ([:administrator, @first_semester_library_bo... | [
"def update\n @second_semester_library_book_outline = SecondSemesterLibraryBookOutline.find(params[:id])\n\n respond_to do |format|\n if @second_semester_library_book_outline.update_attributes(params[:second_semester_library_book_outline])\n format.html { redirect_to ([:administrator, @second_seme... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /first_semester_library_book_outlines/1 DELETE /first_semester_library_book_outlines/1.json | def destroy
@first_semester_library_book_outline = FirstSemesterLibraryBookOutline.find(params[:id])
@first_semester_library_book_outline.destroy
respond_to do |format|
format.html { redirect_to administrator_first_semester_library_book_outlines_url }
format.json { head :no_content }
end
... | [
"def destroy\n @second_semester_library_book_outline = SecondSemesterLibraryBookOutline.find(params[:id])\n @second_semester_library_book_outline.destroy\n\n respond_to do |format|\n format.html { redirect_to administrator_second_semester_library_book_outlines_url }\n format.json { head :no_conte... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks whether +file+ is compliant with our cstyle guidelines using the `indent` utility. | def c_compliant?(file)
corrected = "#{file}_corrected"
status = system("indent #{file} -o #{corrected}")
return nil if status.nil?
return false unless FileUtils.compare_file(file, corrected)
return true
ensure
FileUtils.rm_f(corrected)
end | [
"def checkstyle(filename)\n cmd = [Dependency.find_by(name: 'cs-checkstyle').path, File.basename(filename)].join(' ')\n capture = Open3.capture3(cmd, chdir: File.dirname(filename))\n\n Capture.new(cmd, capture)\n end",
"def chk_format(config)\n skip = false\n config.each_line do |l... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get all the presentation ids from the grid view of the presentations and return an array of ids | def get_presentation_ids(base_url)
ids_arr=[]
get_page(base_url)
grid = @wait.until{@driver.find_element(:id,"presentation_grid")}
presentation_list = @driver.find_elements(:css, ".presentation_wrap")
presentation_list.each do |presentation|
presentation_id = presentation.attribute("id")
presentation... | [
"def division_ids(season)\n ids = Division.where(:season_id => season)\n @divs = Array.new\n ids.each do |p|\n @divs << p.id\n end\n end",
"def get_ids_optativas\n ids_array = Array.new\n self.optativas.each {|optativa| ids_array << optativa.get_id_optativa}\n\n ids_array\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Running tests with the ONLY_OS environment variable set limits the tested platforms to the specified values. Example: ONLY_OS=centos7x86_64,ubuntu14x86_64 | def only_test_os
if ENV.key?('ONLY_OS')
ENV['ONLY_OS'].split(',')
end
end | [
"def exclude_test_os\n if ENV.key?('EXCLUDE_OS')\n ENV['EXCLUDE_OS'].split(',')\n end\nend",
"def check_platform(atomic_test:)\n our_platform = case RbConfig::CONFIG['host_os']\n when /mswin|msys|mingw|cygwin|bccwin|wince|emc/\n 'windows'\n whe... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Running tests with the EXCLUDE_OS environment variable set limits the tested platforms to all but the specified values. Example: EXCLUDE_OS=centos7x86_64,ubuntu14x86_64 | def exclude_test_os
if ENV.key?('EXCLUDE_OS')
ENV['EXCLUDE_OS'].split(',')
end
end | [
"def only_test_os\n if ENV.key?('ONLY_OS')\n ENV['ONLY_OS'].split(',')\n end\nend",
"def platform_tests\n @tests.reject { |test| test.platform.nil? }\n end",
"def not_on(*architectures)\n architectures = architectures.map do |name|\n if name.respond_to?(:to_str)\n [name]\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Register a Let's Encrypt account This is required a private key to do this, and Let's Encrypt will use this private key to connect with domain and assign the owner who can renew and revoked. | def register(email)
account = client.new_account(contact: "mailto:#{email}", terms_of_service_agreed: true)
logger.info "Successfully registered private key with address #{email}"
account.kid # TODO: Save KID
true
end | [
"def key_register(id, encrypted_key)\n if auth_valid? and not encrypted_key.nil?\n auth_info[:key_chain][id] = encrypted_key\n end\n end",
"def finally_save_password\n KeyChain.add_generic_password( KEYCHAIN_ACCOUNT, KEYCHAIN_SERVICE, self.password )\n end",
"def create_account passphrase\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /normas/1 GET /normas/1.xml | def show
@norma = Norma.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @norma }
end
end | [
"def show\n @norm = Norm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @norm }\n end\n end",
"def xml(id)\n http.get(\"/nfse/#{id}/xml\") do |response|\n response.headers.fetch(\"Location\") { \"\" }\n end\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /normas/new GET /normas/new.xml | def new
@norma = Norma.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @norma }
end
end | [
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @norm = Norm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @norm }\n end\n end",
"def new\n @omat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /normas POST /normas.xml | def create
@norma = Norma.new(params[:norma])
respond_to do |format|
if @norma.save
format.html { redirect_to(@norma, :notice => 'Norma was successfully created.') }
format.xml { render :xml => @norma, :status => :created, :location => @norma }
else
format.html { render :ac... | [
"def create\n @norma = Norma.new(norma_params)\n\n respond_to do |format|\n if @norma.save\n format.html { redirect_to @norma, notice: 'Norma was successfully created.' }\n format.json { render :show, status: :created, location: @norma }\n else\n format.html { render :new }\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /normas/1 DELETE /normas/1.xml | def destroy
@norma = Norma.find(params[:id])
@norma.destroy
respond_to do |format|
format.html { redirect_to(normas_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @norm = Norm.find(params[:id])\n @norm.destroy\n\n respond_to do |format|\n format.html { redirect_to(norms_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @scrap_xml = ScrapXml.find(params[:id])\n @scrap_xml.destroy\n\n respond_to do |format|\n f... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Implementation of enter that calls transform for the traversed node. | def enter(node, depth)
transform(node)
end | [
"def enter(node, depth)\n method_name = \"enter_#{node.node_type}\"\n if respond_to?(method_name)\n send method_name, *[node, depth][0...method(method_name).arity]\n end\n end",
"def enter!\n @state_machine.current_state = self\n\n @entry_actions.each do |entry_action|\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Called to do the actual transformation of the source node into the target node. Delegates to transform_ if possible. The default implementation does nothing. | def transform(source)
method_name = "transform_#{source.node_type}"
if respond_to?(method_name)
send method_name, source
end
end | [
"def convert node, transform = nil\n transform ||= node.node_name\n # QUESTION is there a way we can control whether to use convert or send?\n (converter_for transform).convert node, transform\n end",
"def transform() end",
"def convert node, transform = nil, opts = nil\n (converter_for tra... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Copies the given node into the resulting tree. Includes all attributes and the schema if the given node has one. | def copy_node!(source)
child! source.node_type, source.attributes.merge({ __location: source })
if source.has_schema?
current.instance_variable_set(:@schema, source.instance_variable_get(:@schema))
end
end | [
"def copy_attributes\n record.parent = to.parent\n node.position = to.position\n node.depth = to.depth if tree.columns.depth?\n\n yield\n end",
"def copy_attrs_from(another_node)\n self.value = another_node.value\n self.left = another_node.left\n self.right = another_node... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /gene_names/1 GET /gene_names/1.json | def show
@gene_name = GeneName.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @gene_name }
end
end | [
"def gene_names\n gn # set @data['GN'] if it hasn't been already done\n if @data['GN'].first.class == Hash then\n @data['GN'].collect { |element| element[:name] }\n else\n @data['GN'].first\n end\n end",
"def show\n @gene = Gene.find(params[:id])\n\n respond_to do |format|\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /gene_names/new GET /gene_names/new.json | def new
@gene_name = GeneName.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @gene_name }
end
end | [
"def new\n @gene = Gene.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gene }\n end\n end",
"def create\n @gene_name = GeneName.new(params[:gene_name])\n\n respond_to do |format|\n if @gene_name.save\n format.html { redirect_to @gene... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /gene_names POST /gene_names.json | def create
@gene_name = GeneName.new(params[:gene_name])
respond_to do |format|
if @gene_name.save
format.html { redirect_to @gene_name, notice: 'Gene name was successfully created.' }
format.json { render json: @gene_name, status: :created, location: @gene_name }
else
forma... | [
"def gene_names\n gn # set @data['GN'] if it hasn't been already done\n if @data['GN'].first.class == Hash then\n @data['GN'].collect { |element| element[:name] }\n else\n @data['GN'].first\n end\n end",
"def create\n @gene = Gene.new(params[:gene])\n\n respond_to do |format|\n i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PUT /gene_names/1 PUT /gene_names/1.json | def update
@gene_name = GeneName.find(params[:id])
respond_to do |format|
if @gene_name.update_attributes(params[:gene_name])
format.html { redirect_to @gene_name, notice: 'Gene name was successfully updated.' }
format.json { head :no_content }
else
format.html { render acti... | [
"def update\n @gene = Gene.find(params[:id])\n\n respond_to do |format|\n if @gene.update_attributes(params[:gene])\n format.html { redirect_to @gene, notice: 'Gene was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /gene_names/1 DELETE /gene_names/1.json | def destroy
@gene_name = GeneName.find(params[:id])
@gene_name.destroy
respond_to do |format|
format.html { redirect_to gene_names_url }
format.json { head :no_content }
end
end | [
"def destroy\n @gene = Gene.find(params[:id])\n @gene.destroy\n\n respond_to do |format|\n format.html { redirect_to genes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gene.destroy\n respond_to do |format|\n format.html { redirect_to genes_url, notice: '... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method to rearrange facts returned from puppetdb so that the key for 'value' is the fact name instead of the literal string 'value' and deletes the entry for 'name' | def format_facts(array, factname)
array.each do |h|
h.store(factname, h.delete('value'))
h.delete('name')
end
end | [
"def remove_fact_from_list(remove)\n @facts['values'].delete(remove)\n end",
"def delete_facts\r\n @facts = {}\r\n end",
"def remove_unprocessed_thing_key_info(value)\n @children['unprocessed-thing-key-info'][:value].delete(value)\n end",
"def delete_value(value)\n key... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method to merge arrays of hashes on a common field | def merge_hasharray(array1, array2, commonfield)
xref = {}
array2.each { |hash| xref[hash[commonfield]] = hash }
array1.each do |hash|
next if xref[hash[commonfield]].empty?
xref[hash[commonfield]].each_pair do |kk, vv|
next if commonfield == kk
hash[kk] = vv
end
end
end | [
"def merge_2_array_of_hashes(a_arr, b_arr)\n merge_hash = a_hash = array_of_hashes_2_hash(a_arr) if a_arr\n merge_hash = b_hash = array_of_hashes_2_hash(b_arr) if b_arr\n merge_hash = a_hash.merge!(b_hash) if (a_arr and b_arr)\n merge_hash\nend",
"def merge(ary_1, ary_2)\r\n ary_2.uniq.each_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
method to make a hacky json inventory for Ansible | def hacky_json(nodes)
meta = {}
hosts = []
nodes.each do |node|
hosts.push(node['fqdn'])
meta[node['fqdn']] = { 'ansible_host' => node['ipaddress'] }
end
meta = { '_meta' => { 'hostvars' => meta } }
hosts = { 'all' => { 'hosts' => hosts } }
JSON.generate(hosts.merge(meta))
end | [
"def inventory\n render body: Cogy.bundle_config.to_yaml, content_type: \"application/x-yaml\"\n end",
"def create_packer_aws_json()\n install_service = $q_struct[\"type\"].value\n install_access = $q_struct[\"access_key\"].value\n install_secret = $q_struct[\"secret_key\"].value\n install_ami =... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
use the highest value found in our cache of avg_24_hours | def choose_suitable_avg_24_hours
expose_selected_values(:avg_24_hours).max
end | [
"def avg_h24_price\n cache_fetch(:avg_h24_price) do\n Trade.with_market(market_id).h24.yield_self do |t|\n total_volume = t.sum(:volume)\n if total_volume.zero?\n ZERO\n else\n t.sum('price * volume') / total_volume\n end\n end\n end\n end",
"def aver... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /brigade_memberships/1 GET /brigade_memberships/1.json | def show
brigade = Brigade.find(params[:brigade_id])
@brigade_membership = brigade.brigade_memberships.find(params[:id])
end | [
"def show\n @membership = current_account.memberships.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @membership }\n end\n end",
"def new\n @membership = current_account.memberships.new\n\n respond_to do |format|\n format.html... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /brigade_memberships POST /brigade_memberships.json | def create
brigade = Brigade.find(params[:brigade_id])
@brigade_membership = brigade.brigade_memberships.create(brigade_membership_params)
respond_to do |format|
if @brigade_membership.save
format.html { redirect_to brigade_brigade_memberships_url, notice: 'Brigade membership was successfully... | [
"def create\n logger.info \"Post parameters memberships: #{params}\"\n @membership = @group.memberships.create(user: @user, admin: params[:membership][:admin] )\n if @membership.save\n render json: @membership, status: :created, location: [@group, @membership]\n else\n render json: @membership... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /brigade_memberships/1 PATCH/PUT /brigade_memberships/1.json | def update
brigade = Brigade.find(params[:brigade_id])
@brigade_membership = brigade.brigade_memberships.find(params[:id])
respond_to do |format|
if @brigade_membership.update(brigade_membership_params)
format.html { redirect_to brigade_brigade_memberships_url, notice: 'Brigade membership was... | [
"def update\n @membership = @group.memberships.find(params[:id])\n if @membership.update_attributes(params[:membership])\n head :no_content\n else\n render json: @membership.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @membership.update(membership_params)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /brigade_memberships/1 DELETE /brigade_memberships/1.json | def destroy
brigade = Brigade.find(params[:brigade_id])
@brigade_membership = brigade.brigade_memberships.find(params[:id])
@brigade_membership.destroy
respond_to do |format|
format.html { redirect_to brigade_brigade_memberships_url, notice: 'Brigade membership was successfully destroyed.' }
e... | [
"def destroy\n @tribal_membership.destroy\n respond_to do |format|\n format.html { redirect_to tribal_memberships_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @membership.destroy\n head :no_content\n end",
"def destroy\n @membership.destroy\n\n head :no_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Builds the audit configuration as a hash | def build
{ audit: @config }
end | [
"def build_config_audit(eh)\n if controller_name == \"ops\" && @sb[:active_tab] == \"settings_server\"\n server = MiqServer.find(@sb[:selected_server_id])\n message = \"Server [#{server.name}] (#{server.id}) in Zone [#{server.my_zone}] VMDB config updated\"\n else\n message = \"VMDB config upda... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /keeps GET /keeps.json | def index
@keeps = current_user.keeps
end | [
"def index\n @keepers = current_user.keepers\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @keepers }\n end\n end",
"def destroy\n @keep.destroy\n respond_to do |format|\n format.html { redirect_to keeps_url, notice: 'Keep was successfully de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /keeps POST /keeps.json | def create
@keep = current_user.keeps.new(keep_params)
respond_to do |format|
if @keep.save
format.html { redirect_to @keep, notice: 'Keep was successfully created.' }
format.json { render :show, status: :created, location: @keep }
else
format.html { render :new }
fo... | [
"def destroy\n @keep.destroy\n respond_to do |format|\n format.html { redirect_to keeps_url, notice: 'Keep was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @keeps = current_user.keeps\n end",
"def destroy\n @keepmeposted.destroy\n respond... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /keeps/1 PATCH/PUT /keeps/1.json | def update
respond_to do |format|
if @keep.update(keep_params)
format.html { redirect_to @keep, notice: 'Keep was successfully updated.' }
format.json { render :show, status: :ok, location: @keep }
else
format.html { render :edit }
format.json { render json: @keep.errors,... | [
"def update\n if @bookkeeping.update(bookkeeping_params)\n head :no_content\n else\n render json: @bookkeeping.errors, status: :unprocessable_entity\n end\n end",
"def patch(path, params: {}, headers: {})\n request_json :patch, path, params, headers\n end",
"def patch *args\n make... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /keeps/1 DELETE /keeps/1.json | def destroy
@keep.destroy
respond_to do |format|
format.html { redirect_to keeps_url, notice: 'Keep was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @keeper = Keeper.find(params[:id])\n @keeper.destroy\n\n respond_to do |format|\n format.html { redirect_to keepers_url }\n form... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /admin/seasons POST /admin/seasons.json | def create
@admin_season = Season.new(admin_season_params)
respond_to do |format|
if @admin_season.save
format.html { redirect_to @admin_season, success: 'Season was successfully created.' }
format.json { render :show, status: :created, location: @admin_season }
else
format.... | [
"def create\n @season = Season.new(season_params)\n\n if @season.save\n render :show, status: :created\n else\n render json: @season.errors, status: :unprocessable_entity\n end\n end",
"def create\n @season = Season.new(season_params)\n\n if @season.save\n render :show, status: :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /admin/seasons/1 PATCH/PUT /admin/seasons/1.json | def update
respond_to do |format|
if @admin_season.update(admin_season_params)
format.html { redirect_to @admin_season, success: 'Season was successfully updated.' }
format.json { render :show, status: :ok, location: @admin_season }
else
format.html { render :edit }
forma... | [
"def update\n @admin_season_team = Admin::SeasonTeam.find(params[:id])\n\n respond_to do |format|\n if @admin_season_team.update_attributes(params[:admin_season_team])\n format.html { redirect_to @admin_season_team, notice: 'Season team was successfully updated.' }\n format.json { head :no_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /admin/seasons/1 DELETE /admin/seasons/1.json | def destroy
@admin_season.destroy
respond_to do |format|
format.html { redirect_to admin_seasons_url, success: 'Season was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @season.destroy\n respond_to do |format|\n format.html { redirect_to seasons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @season.destroy\n respond_to do |format|\n format.html { redirect_to serial_seasons_url }\n format.json { head :no_c... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Update the visibility of the work to match the correct state of the embargo, then clear the embargo date, etc. Saves the embargo and the work | def destroy
case work
when Valkyrie::Resource
embargo_manager = Hyrax::EmbargoManager.new(resource: work)
return if embargo_manager.embargo.embargo_release_date.blank?
embargo_manager.deactivate!
work.embargo = Hyrax.persister.save(resource: embargo_manager.embar... | [
"def update\n filter_docs_with_edit_access!\n copy_visibility = []\n copy_visibility = params[:embargoes].values.map { |h| h[:copy_visibility] } if params[:embargoes]\n resources = Hyrax.custom_queries.find_many_by_alternate_ids(alternate_ids: batch, use_valkyrie: Hyrax.config.use_valkyrie?)\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns all helper classes under the Hyde::Helpers module. | def get_helpers
Hyde::Helpers.constants.inject([Hyde::Helpers]) do |a, constant|
mod = Hyde::Helpers.const_get(constant)
a << mod if mod.is_a? Module
a
end
end | [
"def getHelpers\n @helpers ||= Buby::Implants::ExtensionHelpers.implant(_check_and_callback(:getHelpers))\n end",
"def get_helpers\n @helpers\n end",
"def helpers\n @helpers ||= begin\n helpers = Module.new\n AbstractController::Helpers.helper_modules_from_paths(helpers_paths).eac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get the class eav attributes | def class_eav_attributes
self.class.class_eav_attributes
end | [
"def class_attributes; end",
"def class_attributes\n @__class_attributes\n end",
"def getAttrs\n @attrs\n end",
"def attr_info; end",
"def eav_attributes\n @eav_attributes ||= eav_class.all(\n :conditions => { self_key => self.id }\n )\n end",
"def a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get all the eav attribute instances available for this model instance eg: if you model says 'has_eav :through => :post_attribute' these are all PostAttribute's | def eav_attributes
@eav_attributes ||= eav_class.all(
:conditions => { self_key => self.id }
)
end | [
"def eav_attributes_list # :nodoc:\n (\n self.instance_eav_attributes + self.class_eav_attributes.keys\n ).collect { |attribute| attribute.to_s }.uniq\n end",
"def class_eav_attributes\n self.class.class_eav_attributes\n end",
"def attributes\n query[ mod... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
save the list of eav_attribute back to the database | def save_eav_attributes # :nodoc:
eav_attributes.select { |a| a.changed? }.each do |a|
if a.new_record?
a.send( :write_attribute, self_key, self.id )
end
a.save!
end
end | [
"def save_save_list\n save_list.each do |obj|\n obj.save!\n end\n end",
"def save\n @data.map(&:save)\n end",
"def save_all\n RelaxDB.bulk_save self, *save_list\n end",
"def tag_and_save(tag_list)\n self.tag_list = tag_list\n self.save\n self.tag_list\n end",
... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
destroy eav_attributes from database | def destroy_eav_attributes # :nodoc:
eav_class.send :delete_all, "#{self_key} = #{self.id}"
end | [
"def destroy\n @image_attrib.destroy\n end",
"def destroy\n @attr_val = AttrVal.find(params[:id])\n @attr_val.destroy\n \n respond_to do |format|\n format.html { redirect_to databaseformalizer_attr_vals_url }\n format.json { head :no_content }\n end\n end",
"def destroy... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
override changed if any of the eav_attributes has changed, the object has changed. | def changed?
eav_attributes.each do |attribute|
return true if ( attribute.changed? || attribute.new_record? )
end
super
end | [
"def track_changed_attributes=(val)\n\t\t\t@track_changed_attributes = val\n\t\tend",
"def save_eav_attributes # :nodoc:\n eav_attributes.select { |a| a.changed? }.each do |a|\n if a.new_record?\n a.send( :write_attribute, self_key, self.id )\n end\n\n a.save... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
get a complete list of eav_attributes (class + instance) | def eav_attributes_list # :nodoc:
(
self.instance_eav_attributes + self.class_eav_attributes.keys
).collect { |attribute| attribute.to_s }.uniq
end | [
"def class_eav_attributes\n self.class.class_eav_attributes\n end",
"def eav_attributes\n @eav_attributes ||= eav_class.all(\n :conditions => { self_key => self.id }\n )\n end",
"def get_attributes(klass)\n return @attribute_store[klass] if @attribute_sto... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
cast an eav value to it's desired class | def cast_eav_value value, attribute # :nodoc:
attributes = self.class_eav_attributes.stringify_keys
return value unless attributes.keys.include?(attribute)
return value if attributes[attribute] == String # no need for casting
begin
# for core types [eg: Integer '12'... | [
"def cast_eav_value value, attribute # :nodoc:\n attributes = self.class_eav_attributes.stringify_keys\n return value unless attributes.keys.include?(attribute)\n return value if attributes[attribute] == String # no need for casting\n\n begin\n # for core types [eg: In... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Validate that the URIs I'm trying to connect belongs to the resource owner | def validate_owner(record, attribute, uris)
klass = Device
ids = find_ids(uris)
real = klass.in(id: ids).where(resource_owner_id: record.resource_owner_id)
expected = klass.in(id: ids)
not_owned_ids = expected.map(&:id) - real.map(&:id)
record.errors.add(attribute, "not owned with IDs #{... | [
"def validate\n if self.scheme != nil &&\n (self.host == nil || self.host == \"\") &&\n (self.path == nil || self.path == \"\")\n raise InvalidURIError,\n \"Absolute URI missing hierarchical segment.\"\n end\n if self.host == nil\n if self.specified_port != ni... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
process does all the heavy lifting adds any uncoded values discovered to the (global) uncoded_values_hash returns a hash with stats on coding | def process(uncoded_values_hash)
@uncoded = uncoded_values_hash
uncoded_encounters = find_uncoded_encounters()
uncoded_products = find_uncoded_products()
uncoded_problems = find_uncoded_problems()
uncoded_vital_results = find_uncoded_results("VitalSigns")
uncoded_test_r... | [
"def get_code_hash(code)\n code_hash = Hash.new(0)\n code.each do |key|\n if code_hash.has_key?(key)\n code_hash[key] = code_hash[key] + 1\n else\n code_hash[key] = 1\n end\n end\n code_hash\n end",
"def process_code(data)\n @codemap.each do |id... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get Ship The user is prompted about the type of ship they want to pilot The user then names their ship and is given a rundown of it | def get_ship(ship_class_arg = nil, ship_name_arg=nil)
unless ship_class_arg && ship_name_arg
printf "FIRST MATE: Captain #{self.name}, what kind of ship is this?\n"
while self.ship == nil
printf "-- Please choose a class of ship from the following options.\n"
puts "| " + Ship.subclasses.join(' | ') +... | [
"def get_new_ship\n print \"Please add a ship: \"\n next_ship = gets.chomp.split\n if next_ship.count != 3 \n puts \"Not a valid number of arguments\"\n get_new_ship\n else\n next_ship = map_ship_input(next_ship)\n if used_ship? next_ship\n puts \"You already... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /vicarages GET /vicarages.json | def index
@vicarages = Vicarage.all
end | [
"def index\n @voyages = Voyage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @voyages }\n end\n end",
"def index\n @voyages = Voyage.all\n end",
"def index\n @vacations = Vacation.all\n\n render json: @vacations\n end",
"def index\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /vicarages POST /vicarages.json | def create
@vicarage = Vicarage.new(vicarage_params)
respond_to do |format|
if @vicarage.save
format.html { redirect_to @vicarage, success: 'La Vicaría fue <strong>registrada</strong> exitosamente.' }
format.json { render :show, status: :created, location: @vicarage }
else
f... | [
"def create\n @voyage = Voyage.new(params[:voyage])\n\n respond_to do |format|\n if @voyage.save\n format.html { redirect_to @voyage, notice: 'Voyage was successfully created.' }\n format.json { render json: @voyage, status: :created, location: @voyage }\n else\n format.html { r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /vicarages/1 PATCH/PUT /vicarages/1.json | def update
respond_to do |format|
if @vicarage.update(vicarage_params)
format.html { redirect_to @vicarage, success: 'La Vicaría fue <strong>modificada</strong> exitosamente.' }
format.json { render :show, status: :ok, location: @vicarage }
else
format.html { render :edit }
... | [
"def update\n @voyage = Voyage.find(params[:id])\n\n respond_to do |format|\n if @voyage.update_attributes(params[:voyage])\n format.html { redirect_to @voyage, notice: 'Voyage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns true for resources that behave like an array | def array?
false
end | [
"def resourceable?(key)\n value_type = self.class.attributes[key.to_sym]\n value_type.is_a?(Array) || value_type.is_a?(Class)\n end",
"def array?\n true\n end",
"def returns_array?\n true\n end",
"def array?(item)\n item.is_a?(Array)\n end",
"def ref_items?\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Resources that don't include Fields or AssetFields return nil for fields | def fields
nil
end | [
"def resource_fields\n RAILS_DEFAULT_LOGGER.debug 'DEPRECIATION: resource_fields is depreciated, use resource_columns_for(:form)'\n @resource_fields ||= resource_class.respond_to?(:fields) ? resource_class.fields : resource_class.content_columns\n end",
"def simple_fields\n fields.reject { |fld| [\"Fiel... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the Environment ID | def environment_id
nil
end | [
"def environment_id\n @environment['id']\n end",
"def environment_id\n id\n end",
"def get_env_id(orgId)\n\n \t\t\tuserInfoPath = \"/accounts/api/organizations/#{orgId}/environments\"\n\n \t\t\trequest = Net::HTTP::Get.new(userInfoPath, authHeader)\n\n \t\t\tresponse = @http.request... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get default_locale from client | def default_locale
client.default_locale
end | [
"def default_locale\n evaluate_localization_option!(:default_locale)\n end",
"def default_locale\n return @default_locale\n end",
"def default_locale\n self.found_locale ||= find_locale\n end",
"def shop_locale\n BeyondApi::Session.new(api_url: current_shop.b... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Ensure inherited classes pick up coercions | def update_coercions!
return if @coercions_updated
if superclass.respond_to? :property_coercions
@property_coercions = superclass.property_coercions.dup.merge(@property_coercions || {})
end
if superclass.respond_to? :sys_coercions
@sys_coercions = superc... | [
"def strict_value_coercions; end",
"def inherited(subclass)\n super\n\n propagate_properties(subclass)\n propagate_connections(subclass)\n end",
"def inherited(subcls); subcls.send(:class_init) end",
"def upcasted?\n false\n end",
"def inherited(_sub)\n raise Error, \"ca... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetch the stack template | def stack_template_load(stack)
if(stack.persisted?)
result = request(
:endpoint => stack.custom.fetch(:manifest, stack.custom.get(:update, :manifest))
)
cache_template = stack.template = template_data_format(result[:body])
stack.custom = stack.cust... | [
"def get_template(template); end",
"def current_template\n template_nesting.last\n end",
"def cfn_template\n @_cfn_template ||= \\\n begin\n if stack_type\n send(\"cfn_template_#{stack_type}\")\n else\n cfn_template_guess || fail_task('cannot find te... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Convert value to YAML if not string | def yamlize(value)
unless(value.is_a?(String))
if(value.is_a?(Hash) && value.respond_to?(:to_hash))
value = value.to_hash
end
value.to_yaml(:header => true)
else
value
end
end | [
"def encode(value)\n value.to_yaml\n end",
"def parse_yaml_value val\n if val.empty?\n ''\n else\n begin\n ::SafeYAML.load %(--- #{val})\n rescue ::StandardError, ::SyntaxError\n val = val.gsub '\\'', '\\'\\'' if val.include? '\\''\n ::... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extract outputs from stack hash | def extract_outputs(stack_hash)
outputs = []
if(stack_hash[:outputs])
outputs += stack_hash[:outputs].map do |output|
Smash.new(:key => output[:name], :value => output[:finalValue])
end
end
stack_hash.fetch(:resources, []).each do |resource|
... | [
"def cf_outputs\n return @cf_outputs if defined? @cf_ouputs\n @cf_outputs = {}\n\n cf_stack.outputs.each do |out|\n @cf_outputs[out.key] = out.value\n end\n\n @cf_outputs\n end",
"def print_stack_output\n\t\t@stack.outputs[0].output_value\n\tend",
"def lookup_outputs(stack)\n client = ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
check if the collection accepts a given mime type; watch out for wildcards | def accept?(mime_type)
if mime_type =~ @@mime_re
p1, p2 = $1, $2
else
return false # WTF?
end
@accept.each do |pat|
pat = pat.to_s # working around REXML ticket 164
if pat =~ @@mime_re
if ($1 == p1 || $1 == "*") && ($2 == p2 || $2 == "*")
ret... | [
"def match_mime_type?(value, matcher); end",
"def validate_mime_type_inclusion(whitelist, message: nil)\n whitelist.any? { |mime_type| regex(mime_type) =~ get.mime_type.to_s } \\\n or add_error(:mime_type_inclusion, message, whitelist) && false\n end",
"def mime_type_allowed?\n ret... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Failing to get your bid is referred to as 'going set'. | def got_set
return self.bid != self.tricks
end | [
"def completed_bid\n completed_response.present? ? completed_response.bid : nil\n end",
"def bet_lost\n @bank -= @bet\n end",
"def broken_bikes\n bikes.select {|bike| bike.broken?}\n end",
"def not_confirmed_winning_bid\n current_bid if current_bid && current_bid.cents >= min_bid_cents\n end",... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
We can't find the affiliation the ussual way we have to improvise Given the afid, we search on every tag until we find the desired one | def search_affiliation(afid)
x=xml.at_xpath("//affiliation[@afid=\"#{afid}\"]")
if !x
raise "I can't find affiliation #{afid}"
else
name=x.xpath("organization").map { |e| e.text }.join(";")
city=process_path(xml, "//affiliation[@afid=\"#{afid}\"]/city-group")
... | [
"def lookup_affiliation_by_name(hash:)\n clean_name = AffiliationSelection::SearchService.name_without_alias(name: hash[:name]&.to_s)\n affiliation = Affiliation.search(term: clean_name).first\n exact_match?(rec: affiliation, name2: hash[:name]&.to_s) ? affiliation : nil\n end",
"def par... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Some affiliations doesn't have an id. We could create it hashing the name and the country on unidentified filliations on head tag The process only add the affiliation if name is not nil | def get_id_affiliation(name,city,country)
"NS:"+Digest::MD5.hexdigest("#{name}|#{city}|#{country}")
end | [
"def affiliation=(affil)\n affiliations.clear\n affiliations << affil\n end",
"def affiliation=(affil)\n affiliations.clear\n affiliations << affil\n end",
"def initialize_affiliation(hash:)\n return nil unless hash.present? && hash[:name].present?\n\n # If th... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Author groups gives us information about the authors groups as appears on the head. Could be useful to retrieve information about missing affilitations Authorgroups with authors duplicated are eliminated | def process_author_groups
author_groups_temp=xml.xpath("//bibrecord/head/author-group").map do |ag|
process_one_author_group(ag)
end
#authors_list= []
@author_groups=author_groups_temp
# @author_groups=[]
# author_groups_temp.each do |ag|
# @author_group... | [
"def authors\n return [] if @feed.channel.managingEditor.nil? && @feed.channel.dc_publishers.empty?\n [@feed.channel.managingEditor, ((@feed.channel.dc_publishers.empty?) ? nil : @feed.channel.dc_publishers.collect{|dcp| dcp.content})].flatten.uniq.compact.reject{|au| au == '' || au.match(/^\\s+$/)}\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /users/pending Pending means not approved or denied | def pending
@pending_users = User.where(isApproved:false).where(isDenied:false).paginate(:page => params[:pending_users_page], :per_page => 10)
end | [
"def pending\n @user = User.find(params[:id])\n end",
"def pending_users\n @pending_users = User.find(:all, :conditions => {:enabled => false, :activation_code => !nil})\n render :partial => 'pending_users'\n end",
"def pending\n tutor_requests = PendingTutorRequest\n .... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /users/approved Already approved but might need to promote to admin/deactivate | def approved
@approved_users = User.where(isApproved:true).where(isDenied:false).paginate(:page => params[:uapproved_users_page], :per_page => 10)
end | [
"def admin_approve_user\n @user.update(approved: true)\n redirect_to admin_path, notice: \"User Approved\"\n end",
"def admin_approve\n if current_user.can_approve(@user)\n @user.approve\n else\n flash[:danger] = \"You are not authorized to do that.\"\n end\n set_user\n set_users\n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /users/denied Already denied but might need to approve | def denied
@denied_users = User.where(isDenied:true).where(isApproved:false).paginate(:page => params[:denied_users_page], :per_page => 10)
end | [
"def hyves_access_denied\n access_denied\n end",
"def get_user_deny\n @user = get_user\n if !@user\n flash[:notice] = \"There was a problem finding your user information. Please try again.\"\n permission_denied \n end\n end",
"def access_denied\n end",
"de... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /users/inactive Already inactive but might need to activate | def inactive
@inactive_users = User.where(isActive:false).paginate(:page => params[:inactive_users_page], :per_page => 10)
end | [
"def retrieve_inactive_user_actions()\n start.uri('/api/user-action')\n .url_parameter('inactive', true)\n .get()\n .go()\n end",
"def retrieve_inactive_user_actions()\n start.uri('/api/user-action')\n .url_parameter('inactive', true)\n .get()\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the connectorServerName property value. The name of the server hosting the Exchange Connector. | def connector_server_name
return @connector_server_name
end | [
"def connector_server_name=(value)\n @connector_server_name = value\n end",
"def server_name\n return @server_name\n end",
"def server_name\n return @forwarded_server || @config[:ServerName]\n end",
"def exchange_server\n return @excha... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the connectorServerName property value. The name of the server hosting the Exchange Connector. | def connector_server_name=(value)
@connector_server_name = value
end | [
"def connector_server_name\n return @connector_server_name\n end",
"def exchange_server=(value)\n @exchange_server = value\n end",
"def server_name=(value)\n @server_name = value\n end",
"def set_server_name; self.name = domain; end... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the exchangeAlias property value. An alias assigned to the Exchange server | def exchange_alias
return @exchange_alias
end | [
"def exchange_alias=(value)\n @exchange_alias = value\n end",
"def alias_\n @alias_\n end",
"def account_alias\n # Do not execute IAM API call unless the -s/--show_account_alias flag is specified\n # (to prevent excess API calls *and* errors if IAM rights are not allowed)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.