_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
30
4.3k
language
stringclasses
1 value
meta_information
dict
q19800
Mongoid.Tree.rearrange
train
def rearrange if self.parent_id self.parent_ids = parent.parent_ids + [self.parent_id]
ruby
{ "resource": "" }
q19801
CocoapodsMangle.Config.needs_update?
train
def needs_update? return true unless File.exist?(@context.xcconfig_path) xcconfig_hash = Xcodeproj::Config.new(File.new(@context.xcconfig_path)).to_hash needs_update = xcconfig_hash[MANGLED_SPECS_CHECKSUM_XCCONFIG_KEY]
ruby
{ "resource": "" }
q19802
CocoapodsMangle.Config.update_pod_xcconfigs_for_mangling!
train
def update_pod_xcconfigs_for_mangling! Pod::UI.message '- Updating Pod xcconfig files' do @context.pod_xcconfig_paths.each do
ruby
{ "resource": "" }
q19803
CocoapodsMangle.Config.update_pod_xcconfig_for_mangling!
train
def update_pod_xcconfig_for_mangling!(pod_xcconfig_path) mangle_xcconfig_include = "#include \"#{@context.xcconfig_path}\"\n" gcc_preprocessor_defs = File.readlines(pod_xcconfig_path).select { |line| line =~ /GCC_PREPROCESSOR_DEFINITIONS/ }.first gcc_preprocessor_defs.strip! xcconfig_contents ...
ruby
{ "resource": "" }
q19804
Motion::Project.CocoaPods.configure_project
train
def configure_project if (xcconfig = self.pods_xcconfig_hash) && ldflags = xcconfig['OTHER_LDFLAGS'] @config.resources_dirs << resources_dir.to_s frameworks = installed_frameworks[:pre_built] if frameworks @config.embedded_frameworks += frameworks @config.embedded_fram...
ruby
{ "resource": "" }
q19805
Motion::Project.CocoaPods.install!
train
def install!(update) FileUtils.rm_rf(resources_dir) pods_installer.update = update pods_installer.installation_options.integrate_targets
ruby
{ "resource": "" }
q19806
Motion::Project.CocoaPods.resources
train
def resources resources = [] script = Pathname.new(@config.project_dir) + SUPPORT_FILES + "Pods-#{TARGET_NAME}-resources.sh" return resources unless File.exist?(script) File.open(script) { |f| f.each_line do |line| if matched = line.match(/install_resource\s+(.*)/) ...
ruby
{ "resource": "" }
q19807
Laser.ActsAsStruct.acts_as_struct
train
def acts_as_struct(*members) include Comparable extend InheritedAttributes class_inheritable_array :current_members unless respond_to?(:current_members) self.current_members ||= [] self.current_members.concat members all_members = self.current_members # Only add new memb...
ruby
{ "resource": "" }
q19808
RGL.MutableGraph.cycles
train
def cycles g = self.clone self.inject([]) do |acc, v| acc
ruby
{ "resource": "" }
q19809
Laser.Analysis.parse
train
def parse(body = self.body) return PARSING_CACHE[body] if PARSING_CACHE[body] pairs = Analysis.analyze_inputs([[file,
ruby
{ "resource": "" }
q19810
Laser.Analysis.find_sexps
train
def find_sexps(type, tree = self.parse(self.body)) result = tree[0] == type ? [tree] : [] tree.each do |node|
ruby
{ "resource": "" }
q19811
RGL.Graph.strongly_connected_components
train
def strongly_connected_components raise NotDirectedError, "strong_components only works for directed graphs." unless directed?
ruby
{ "resource": "" }
q19812
RGL.Graph.each_edge
train
def each_edge (&block) if directed? each_vertex { |u| each_adjacent(u) { |v| yield u,v } }
ruby
{ "resource": "" }
q19813
Laser.Runner.handle_global_options
train
def handle_global_options(settings) if settings[:"line-length"] @using << Laser.LineLengthWarning(settings[:"line-length"]) end if (only_name = settings[:only]) @fix = @using = Warning.concrete_warnings.select do |w| classname = w.name && w.name.split('::').last (cl...
ruby
{ "resource": "" }
q19814
Laser.Runner.get_settings
train
def get_settings warning_opts = get_warning_options Trollop::options do banner 'LASER: Lexically- and Semantically-Enriched Ruby' opt :fix, 'Should errors be fixed in-line?', short: '-f' opt :display, 'Should errors be displayed?', short: '-b', default: true opt :'report-fixe...
ruby
{ "resource": "" }
q19815
Laser.Runner.get_warning_options
train
def get_warning_options all_options = Warning.all_warnings.inject({}) do |result, warning| options = warning.options options = [options] if options.any? && !options[0].is_a?(Array) options.each do |option|
ruby
{ "resource": "" }
q19816
Laser.Runner.print_modules
train
def print_modules Analysis::LaserModule.all_modules.map do |mod| result = [] result << if Analysis::LaserClass === mod && mod.superclass then "#{mod.path} < #{mod.superclass.path}"
ruby
{ "resource": "" }
q19817
Laser.Runner.convert_warning_list
train
def convert_warning_list(list) list.map do |list| case list when :all then Warning.all_warnings when :whitespace [ExtraBlankLinesWarning, ExtraWhitespaceWarning,
ruby
{ "resource": "" }
q19818
Laser.Runner.collect_warnings
train
def collect_warnings(files, scanner) full_list = files.map do |file| data = file == '(stdin)' ? STDIN.read : File.read(file) if scanner.settings[:fix] scanner.settings[:output_file] = scanner.settings[:stdin] ? STDOUT : File.open(file, 'w') end results = scanner.scan(data...
ruby
{ "resource": "" }
q19819
Laser.Runner.display_warnings
train
def display_warnings(warnings, settings) num_fixable = warnings.select { |warn| warn.fixable? }.size num_total = warnings.size results = "#{num_total} warnings found. #{num_fixable} are fixable." puts results puts '=' * results.size warnings.each do |warning|
ruby
{ "resource": "" }
q19820
RGL.GraphVisitor.attach_distance_map
train
def attach_distance_map (map = Hash.new(0)) @dist_map = map class << self def handle_tree_edge (u, v) super @dist_map[v] = @dist_map[u] + 1 end # Answer the
ruby
{ "resource": "" }
q19821
RGL.Graph.bfs_search_tree_from
train
def bfs_search_tree_from (v) require 'laser/third_party/rgl/adjacency' bfs = bfs_iterator(v) tree = DirectedAdjacencyGraph.new bfs.set_tree_edge_event_handler { |from, to|
ruby
{ "resource": "" }
q19822
RGL.Graph.depth_first_search
train
def depth_first_search (vis = DFSVisitor.new(self), &b) each_vertex do |u| unless vis.finished_vertex?(u)
ruby
{ "resource": "" }
q19823
RGL.Graph.depth_first_visit
train
def depth_first_visit (u, vis = DFSVisitor.new(self), &b) vis.color_map[u] = :GRAY vis.handle_examine_vertex(u) each_adjacent(u) { |v| vis.handle_examine_edge(u, v) if vis.follow_edge?(u, v) # (u,v) is a tree edge vis.handle_tree_edge(u, v) # also discovers...
ruby
{ "resource": "" }
q19824
Laser.Scanner.scan
train
def scan(text, filename='(none)') warnings = scan_for_file_warnings(text, filename) text = filter_fixable(warnings).inject(text) do |text, warning| warning.fix(text) end with_fixing_piped_to_output do text.split(/\n/).each_with_index do |line, number|
ruby
{ "resource": "" }
q19825
Laser.Scanner.process_line
train
def process_line(line, line_number, filename) warnings = all_warnings_for_line(line, line_number, filename) fix_input(warnings,
ruby
{ "resource": "" }
q19826
Laser.Scanner.fix_input
train
def fix_input(warnings, line, line_number, filename) fixable_warnings = filter_fixable warnings if fixable_warnings.size == 1 self.settings[:output_lines] << fixable_warnings.first.fix rescue line elsif fixable_warnings.size > 1
ruby
{ "resource": "" }
q19827
Laser.Scanner.all_warnings_for_line
train
def all_warnings_for_line(line, line_number, filename) new_warnings = check_for_indent_warnings!(line, filename) new_warnings.concat scan_for_line_warnings(line,
ruby
{ "resource": "" }
q19828
Laser.Scanner.check_for_indent_warnings!
train
def check_for_indent_warnings!(line, filename) return [] if line == "" indent_size = get_indent_size line if indent_size > current_indent self.indent_stack.push indent_size elsif indent_size < current_indent previous = self.indent_stack.pop if indent_size != current_inden...
ruby
{ "resource": "" }
q19829
Laser.Scanner.scan_for_line_warnings
train
def scan_for_line_warnings(line, filename) warnings = scan_for_warnings(using & LineWarning.all_warnings, line, filename)
ruby
{ "resource": "" }
q19830
Laser.LexicalAnalysis.lex
train
def lex(body = self.body, token_class = Token) return [] if body =~ /^#.*encoding.*/
ruby
{ "resource": "" }
q19831
Laser.LexicalAnalysis.find_token
train
def find_token(*args) body, list = _extract_token_search_args(args) # grr match comment with encoding in it lexed = lex(body) lexed.find.with_index do |tok, idx|
ruby
{ "resource": "" }
q19832
Laser.LexicalAnalysis.split_on_keyword
train
def split_on_keyword(*args) body, keywords = _extract_token_search_args(args) token = find_keyword(body,
ruby
{ "resource": "" }
q19833
Laser.LexicalAnalysis.split_on_token
train
def split_on_token(*args) body, tokens = _extract_token_search_args(args)
ruby
{ "resource": "" }
q19834
RGL.Graph.to_adjacency
train
def to_adjacency result = (directed? ? DirectedAdjacencyGraph : AdjacencyGraph).new
ruby
{ "resource": "" }
q19835
RGL.DirectedAdjacencyGraph.initialize_copy
train
def initialize_copy(orig) @vertex_dict = orig.instance_eval{@vertex_dict}.dup @vertex_dict.keys.each do |v| @vertex_dict[v] = @vertex_dict[v].dup end @predecessor_dict = orig.instance_eval{@predecessor_dict}.dup
ruby
{ "resource": "" }
q19836
RGL.DirectedAdjacencyGraph.edgelist_class=
train
def edgelist_class=(klass) @vertex_dict.keys.each do |v| @vertex_dict[v] = klass.new @vertex_dict[v].to_a end @predecessor_dict.keys.each do |v|
ruby
{ "resource": "" }
q19837
Laser.ModuleExtensions.opposite_method
train
def opposite_method(new_name, old_name) define_method new_name do |*args, &blk|
ruby
{ "resource": "" }
q19838
Laser.ModuleExtensions.attr_accessor_with_default
train
def attr_accessor_with_default(name, val) ivar_sym = "@#{name}" define_method name do unless instance_variable_defined?(ivar_sym)
ruby
{ "resource": "" }
q19839
Laser.ModuleExtensions.cattr_get_and_setter
train
def cattr_get_and_setter(*attrs) attrs.each do |attr| cattr_accessor attr singleton_class.instance_eval do alias_method "#{attr}_old_get".to_sym, attr define_method attr
ruby
{ "resource": "" }
q19840
RGL.Graph.dominance_frontier
train
def dominance_frontier(start_node = self.enter, dom_tree) vertices.inject(Hash.new { |h, k| h[k] = Set.new }) do |result, b| preds = b.real_predecessors if preds.size >= 2 preds.each do |p| b_dominator = dom_tree[b].successors.first break unless b_dominator
ruby
{ "resource": "" }
q19841
RGL.Graph.dominator_set_intersect
train
def dominator_set_intersect(b1, b2, doms) finger1, finger2 = b1, b2 while finger1.post_order_number != finger2.post_order_number finger1 = doms[finger1] while finger1.post_order_number < finger2.post_order_number
ruby
{ "resource": "" }
q19842
OodCore.Cluster.batch_connect_config
train
def batch_connect_config(template = nil) if template @batch_connect_config.fetch(template.to_sym,
ruby
{ "resource": "" }
q19843
OodCore.Cluster.batch_connect_template
train
def batch_connect_template(context = {}) context = context.to_h.symbolize_keys
ruby
{ "resource": "" }
q19844
OodCore.Cluster.custom_allow?
train
def custom_allow?(feature) allow? && !custom_config(feature).empty? &&
ruby
{ "resource": "" }
q19845
OodCore.Cluster.to_h
train
def to_h { id: id, metadata: metadata_config, login: login_config, job: job_config,
ruby
{ "resource": "" }
q19846
DRMAA.Session.run_bulk
train
def run_bulk(t, first, last, incr = 1) retry_until {
ruby
{ "resource": "" }
q19847
DRMAA.Session.wait_each
train
def wait_each(timeout = -1) if ! block_given? ary = Array.new end while true begin info = DRMAA.wait(ANY_JOB, timeout) rescue DRMAAInvalidJobError break ...
ruby
{ "resource": "" }
q19848
MetaWhere.Relation.predicate_visitor
train
def predicate_visitor join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(@klass, association_joins, custom_joins)
ruby
{ "resource": "" }
q19849
Sailthru.Client.schedule_blast_from_template
train
def schedule_blast_from_template(template, list, schedule_time, options={}) post = options ? options : {} post[:copy_template] = template post[:list]
ruby
{ "resource": "" }
q19850
Sailthru.Client.schedule_blast_from_blast
train
def schedule_blast_from_blast(blast_id, schedule_time, options={}) post = options ? options : {} post[:copy_blast] = blast_id #post[:name]
ruby
{ "resource": "" }
q19851
Sailthru.Client.update_blast
train
def update_blast(blast_id, name = nil, list = nil, schedule_time = nil, from_name = nil, from_email = nil, subject = nil, content_html = nil, content_text = nil, options = {}) data = options ? options : {} data[:blast_id] = blast_id if name != nil data[:name] = name end if list != ...
ruby
{ "resource": "" }
q19852
Sailthru.Client.stats_list
train
def stats_list(list = nil, date = nil) data = {} if list != nil data[:list] = list
ruby
{ "resource": "" }
q19853
Sailthru.Client.stats_blast
train
def stats_blast(blast_id = nil, start_date = nil, end_date = nil, options = {}) data = options if blast_id != nil data[:blast_id] = blast_id end if start_date != nil data[:start_date] = start_date end
ruby
{ "resource": "" }
q19854
Sailthru.Client.stats_send
train
def stats_send(template = nil, start_date = nil, end_date = nil, options = {}) data = options if template != nil data[:template] = template end if start_date != nil data[:start_date] = start_date end
ruby
{ "resource": "" }
q19855
Sailthru.Client.save_alert
train
def save_alert(email, type, template, _when = nil, options = {}) data = options data[:email] = email data[:type] = type data[:template] = template
ruby
{ "resource": "" }
q19856
Sailthru.Client.process_job
train
def process_job(job, options = {}, report_email = nil, postback_url = nil, binary_key = nil) data = options data['job'] = job
ruby
{ "resource": "" }
q19857
Sailthru.Client.process_import_job
train
def process_import_job(list, emails, report_email = nil, postback_url = nil, options = {}) data = options data['list'] = list data['emails']
ruby
{ "resource": "" }
q19858
Sailthru.Client.process_import_job_from_file
train
def process_import_job_from_file(list, file_path, report_email = nil, postback_url = nil, options = {}) data = options data['list'] = list
ruby
{ "resource": "" }
q19859
Sailthru.Client.process_update_job_from_file
train
def process_update_job_from_file(file_path, report_email = nil, postback_url = nil, options = {}) data = options data['file']
ruby
{ "resource": "" }
q19860
Sailthru.Client.process_purchase_import_job_from_file
train
def process_purchase_import_job_from_file(file_path, report_email = nil, postback_url = nil, options = {}) data = options data['file']
ruby
{ "resource": "" }
q19861
Sailthru.Client.process_snapshot_job
train
def process_snapshot_job(query = {}, report_email = nil, postback_url = nil, options = {}) data = options data['query']
ruby
{ "resource": "" }
q19862
Sailthru.Client.process_export_list_job
train
def process_export_list_job(list, report_email = nil, postback_url = nil, options = {}) data = options data['list'] = list
ruby
{ "resource": "" }
q19863
Sailthru.Client.get_user_by_key
train
def get_user_by_key(id, key, fields = {}) data = { 'id' => id, 'key' => key,
ruby
{ "resource": "" }
q19864
Sailthru.Client.get_trigger_by_template
train
def get_trigger_by_template(template, trigger_id = nil) data = {} data['template'] = template if
ruby
{ "resource": "" }
q19865
Sailthru.Client.post_template_trigger
train
def post_template_trigger(template, time, time_unit, event, zephyr) data = {} data['template'] = template data['time'] = time data['time_unit'] = time_unit
ruby
{ "resource": "" }
q19866
Sailthru.Client.post_event_trigger
train
def post_event_trigger(event, time, time_unit, zephyr) data = {} data['time'] = time data['time_unit'] = time_unit data['event'] =
ruby
{ "resource": "" }
q19867
Sailthru.Client.set_up_post_request
train
def set_up_post_request(uri, data, headers, binary_key = nil) if !binary_key.nil? binary_data = data[binary_key] if binary_data.is_a?(StringIO) data[binary_key] = UploadIO.new( binary_data, "text/plain", "local.path" ) else data[binary_key] = Uplo...
ruby
{ "resource": "" }
q19868
BaseCRM.TasksService.create
train
def create(task) validate_type!(task) attributes = sanitize(task) _, _, root
ruby
{ "resource": "" }
q19869
BaseCRM.TasksService.update
train
def update(task) validate_type!(task) params = extract_params!(task, :id) id = params[:id] attributes = sanitize(task) _,
ruby
{ "resource": "" }
q19870
BaseCRM.ContactsService.create
train
def create(contact) validate_type!(contact) attributes = sanitize(contact) _, _, root
ruby
{ "resource": "" }
q19871
BaseCRM.ContactsService.update
train
def update(contact) validate_type!(contact) params = extract_params!(contact, :id) id = params[:id] attributes = sanitize(contact)
ruby
{ "resource": "" }
q19872
BaseCRM.CallsService.create
train
def create(call) validate_type!(call) attributes = sanitize(call) _, _, root
ruby
{ "resource": "" }
q19873
BaseCRM.CallsService.update
train
def update(call) validate_type!(call) params = extract_params!(call, :id) id = params[:id] attributes = sanitize(call) _,
ruby
{ "resource": "" }
q19874
BaseCRM.AssociatedContactsService.where
train
def where(deal_id, options = {}) _, _, root = @client.get("/deals/#{deal_id}/associated_contacts",
ruby
{ "resource": "" }
q19875
BaseCRM.AssociatedContactsService.create
train
def create(deal_id, associated_contact) validate_type!(associated_contact) attributes = sanitize(associated_contact) _, _, root
ruby
{ "resource": "" }
q19876
BaseCRM.Sync.fetch
train
def fetch(&block) return unless block_given? # Set up a new synchronization session for given device's UUID session = @client.sync.start(@device_uuid) # Check if there is anything to synchronize return unless session && session.id # Drain the main queue unitl there is no more dat...
ruby
{ "resource": "" }
q19877
BaseCRM.SyncService.start
train
def start(device_uuid) validate_device!(device_uuid) status, _, root = @client.post("/sync/start",
ruby
{ "resource": "" }
q19878
BaseCRM.SyncService.fetch
train
def fetch(device_uuid, session_id, queue='main') validate_device!(device_uuid) raise ArgumentError, "session_id must not be nil nor empty" unless session_id && !session_id.strip.empty? raise ArgumentError, "queue name must not be nil nor empty"
ruby
{ "resource": "" }
q19879
BaseCRM.SyncService.ack
train
def ack(device_uuid, ack_keys) validate_device!(device_uuid) raise ArgumentError, "ack_keys must not be nil and an array" unless ack_keys && ack_keys.is_a?(Array)
ruby
{ "resource": "" }
q19880
BaseCRM.TagsService.create
train
def create(tag) validate_type!(tag) attributes = sanitize(tag) _, _, root
ruby
{ "resource": "" }
q19881
BaseCRM.TagsService.update
train
def update(tag) validate_type!(tag) params = extract_params!(tag, :id) id = params[:id] attributes = sanitize(tag) _,
ruby
{ "resource": "" }
q19882
BaseCRM.LossReasonsService.create
train
def create(loss_reason) validate_type!(loss_reason) attributes = sanitize(loss_reason) _, _, root
ruby
{ "resource": "" }
q19883
BaseCRM.LossReasonsService.update
train
def update(loss_reason) validate_type!(loss_reason) params = extract_params!(loss_reason, :id) id = params[:id] attributes = sanitize(loss_reason)
ruby
{ "resource": "" }
q19884
BaseCRM.NotesService.create
train
def create(note) validate_type!(note) attributes = sanitize(note) _, _, root
ruby
{ "resource": "" }
q19885
BaseCRM.NotesService.update
train
def update(note) validate_type!(note) params = extract_params!(note, :id) id = params[:id] attributes = sanitize(note) _,
ruby
{ "resource": "" }
q19886
BaseCRM.SourcesService.create
train
def create(source) validate_type!(source) attributes = sanitize(source) _, _, root
ruby
{ "resource": "" }
q19887
BaseCRM.OrdersService.create
train
def create(order) validate_type!(order) attributes = sanitize(order) _, _, root
ruby
{ "resource": "" }
q19888
BaseCRM.OrdersService.update
train
def update(order) validate_type!(order) params = extract_params!(order, :id) id = params[:id] attributes = sanitize(order) _,
ruby
{ "resource": "" }
q19889
BaseCRM.LeadsService.create
train
def create(lead) validate_type!(lead) attributes = sanitize(lead) _, _, root
ruby
{ "resource": "" }
q19890
BaseCRM.LeadsService.update
train
def update(lead) validate_type!(lead) params = extract_params!(lead, :id) id = params[:id] attributes = sanitize(lead) _,
ruby
{ "resource": "" }
q19891
BaseCRM.DealsService.create
train
def create(deal) validate_type!(deal) attributes = sanitize(deal) _, _, root
ruby
{ "resource": "" }
q19892
BaseCRM.DealsService.update
train
def update(deal) validate_type!(deal) params = extract_params!(deal, :id) id = params[:id] attributes = sanitize(deal) _,
ruby
{ "resource": "" }
q19893
BaseCRM.LineItemsService.where
train
def where(order_id, options = {}) _, _, root = @client.get("/orders/#{order_id}/line_items",
ruby
{ "resource": "" }
q19894
BaseCRM.LineItemsService.create
train
def create(order_id, line_item) validate_type!(line_item) attributes = sanitize(line_item) _, _, root
ruby
{ "resource": "" }
q19895
BaseCRM.LineItemsService.find
train
def find(order_id, id) _, _, root = @client.get("/orders/#{order_id}/line_items/#{id}")
ruby
{ "resource": "" }
q19896
BaseCRM.ProductsService.create
train
def create(product) validate_type!(product) attributes = sanitize(product) _, _, root
ruby
{ "resource": "" }
q19897
BaseCRM.ProductsService.update
train
def update(product) validate_type!(product) params = extract_params!(product, :id) id = params[:id] attributes = sanitize(product)
ruby
{ "resource": "" }
q19898
BaseCRM.DealUnqualifiedReasonsService.where
train
def where(options = {}) _, _, root = @client.get("/deal_unqualified_reasons", options) root[:items].map{
ruby
{ "resource": "" }
q19899
BaseCRM.DealUnqualifiedReasonsService.create
train
def create(deal_unqualified_reason) validate_type!(deal_unqualified_reason) attributes = sanitize(deal_unqualified_reason) _, _, root
ruby
{ "resource": "" }