_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
66
10.5k
language
stringclasses
1 value
meta_information
dict
q12900
IceCube.Validations::FixedValue.validate_day_lock
train
def validate_day_lock(time, start_time) days_in_month = TimeUtil.days_in_month(time) date = Date.new(time.year, time.month, time.day) if value && value < 0 start = TimeUtil.day_of_month(value, date) month_overflow = days_in_month - TimeUtil.days_in_next_month(time) elsif value &...
ruby
{ "resource": "" }
q12901
IceCube.IcalBuilder.to_s
train
def to_s arr = [] if freq = @hash.delete('FREQ') arr << "FREQ=#{freq.join(',')}" end arr.concat(@hash.map do |key, value| if value.is_a?(Array) "#{key}=#{value.join(',')}" end end.compact) arr.join(';') end
ruby
{ "resource": "" }
q12902
IceCube.Validations::HourOfDay.hour_of_day
train
def hour_of_day(*hours) hours.flatten.each do |hour| unless hour.is_a?(Integer) raise ArgumentError, "expecting Integer value for hour, got #{hour.inspect}" end verify_alignment(hour, :hour, :hour_of_day) { |error| raise error } validations_for(:hour_of_day) << Validati...
ruby
{ "resource": "" }
q12903
IceCube.Schedule.add_recurrence_time
train
def add_recurrence_time(time) return if time.nil? rule = SingleOccurrenceRule.new(time) add_recurrence_rule rule time end
ruby
{ "resource": "" }
q12904
IceCube.Schedule.add_exception_time
train
def add_exception_time(time) return if time.nil? rule = SingleOccurrenceRule.new(time) add_exception_rule rule time end
ruby
{ "resource": "" }
q12905
IceCube.Schedule.remove_recurrence_time
train
def remove_recurrence_time(time) found = false @all_recurrence_rules.delete_if do |rule| found = true if rule.is_a?(SingleOccurrenceRule) && rule.time == time end time if found end
ruby
{ "resource": "" }
q12906
IceCube.Schedule.next_occurrences
train
def next_occurrences(num, from = nil, options = {}) from = TimeUtil.match_zone(from, start_time) || TimeUtil.now(start_time) enumerate_occurrences(from + 1, nil, options).take(num) end
ruby
{ "resource": "" }
q12907
IceCube.Schedule.previous_occurrence
train
def previous_occurrence(from) from = TimeUtil.match_zone(from, start_time) or raise ArgumentError, "Time required, got #{from.inspect}" return nil if from <= start_time enumerate_occurrences(start_time, from - 1).to_a.last end
ruby
{ "resource": "" }
q12908
IceCube.Schedule.previous_occurrences
train
def previous_occurrences(num, from) from = TimeUtil.match_zone(from, start_time) or raise ArgumentError, "Time required, got #{from.inspect}" return [] if from <= start_time a = enumerate_occurrences(start_time, from - 1).to_a a.size > num ? a[-1*num,a.size] : a end
ruby
{ "resource": "" }
q12909
IceCube.Schedule.occurs_between?
train
def occurs_between?(begin_time, closing_time, options = {}) enumerate_occurrences(begin_time, closing_time, options).next true rescue StopIteration false end
ruby
{ "resource": "" }
q12910
IceCube.Schedule.occurs_on?
train
def occurs_on?(date) date = TimeUtil.ensure_date(date) begin_time = TimeUtil.beginning_of_date(date, start_time) closing_time = TimeUtil.end_of_date(date, start_time) occurs_between?(begin_time, closing_time) end
ruby
{ "resource": "" }
q12911
IceCube.Schedule.occurring_at?
train
def occurring_at?(time) time = TimeUtil.match_zone(time, start_time) or raise ArgumentError, "Time required, got #{time.inspect}" if duration > 0 return false if exception_time?(time) occurs_between?(time - duration + 1, time) else occurs_at?(time) end end
ruby
{ "resource": "" }
q12912
IceCube.Schedule.conflicts_with?
train
def conflicts_with?(other_schedule, closing_time = nil) closing_time = TimeUtil.ensure_time(closing_time) unless terminating? || other_schedule.terminating? || closing_time raise ArgumentError, "One or both schedules must be terminating to use #conflicts_with?" end # Pick the terminating...
ruby
{ "resource": "" }
q12913
IceCube.Schedule.first
train
def first(n = nil) occurrences = enumerate_occurrences(start_time).take(n || 1) n.nil? ? occurrences.first : occurrences end
ruby
{ "resource": "" }
q12914
IceCube.Schedule.last
train
def last(n = nil) require_terminating_rules occurrences = enumerate_occurrences(start_time).to_a n.nil? ? occurrences.last : occurrences[-n..-1] end
ruby
{ "resource": "" }
q12915
IceCube.Schedule.to_ical
train
def to_ical(force_utc = false) pieces = [] pieces << "DTSTART#{IcalBuilder.ical_format(start_time, force_utc)}" pieces.concat recurrence_rules.map { |r| "RRULE:#{r.to_ical}" } pieces.concat exception_rules.map { |r| "EXRULE:#{r.to_ical}" } pieces.concat recurrence_times_without_start_time...
ruby
{ "resource": "" }
q12916
IceCube.Schedule.to_hash
train
def to_hash data = {} data[:start_time] = TimeUtil.serialize_time(start_time) data[:start_date] = data[:start_time] if IceCube.compatibility <= 11 data[:end_time] = TimeUtil.serialize_time(end_time) if end_time data[:rrules] = recurrence_rules.map(&:to_hash) if IceCube.compatibility ...
ruby
{ "resource": "" }
q12917
IceCube.Schedule.enumerate_occurrences
train
def enumerate_occurrences(opening_time, closing_time = nil, options = {}) opening_time = TimeUtil.match_zone(opening_time, start_time) closing_time = TimeUtil.match_zone(closing_time, start_time) opening_time += TimeUtil.subsec(start_time) - TimeUtil.subsec(opening_time) opening_time = start_tim...
ruby
{ "resource": "" }
q12918
IceCube.WeeklyRule.wday_offset
train
def wday_offset(step_time, start_time) return 0 if step_time == start_time wday_validations = other_interval_validations.select { |v| v.type == :wday } return 0 if wday_validations.none? days = step_time.to_date - start_time.to_date interval = base_interval_validation.validate(step_time,...
ruby
{ "resource": "" }
q12919
Trello.Client.find
train
def find(path, id, params = {}) response = get("/#{path.to_s.pluralize}/#{id}", params) trello_class = class_from_path(path) trello_class.parse response do |data| data.client = self end end
ruby
{ "resource": "" }
q12920
Trello.Client.find_many
train
def find_many(trello_class, path, params = {}) response = get(path, params) trello_class.parse_many response do |data| data.client = self end end
ruby
{ "resource": "" }
q12921
Trello.LabelName.update_fields
train
def update_fields(fields) attributes[:yellow] = fields['yellow'] || attributes[:yellow] attributes[:red] = fields['red'] || attributes[:red] attributes[:orange] = fields['orange'] || attributes[:orange] attributes[:green] = fields['green'] || attributes[:green] attributes[:purple] = field...
ruby
{ "resource": "" }
q12922
Trello.Webhook.save
train
def save # If we have an id, just update our fields. return update! if id from_response client.post("/webhooks", { description: description, idModel: id_model, callbackURL: callback_url }) end
ruby
{ "resource": "" }
q12923
Trello.Webhook.update!
train
def update! client.put("/webhooks/#{id}", { description: description, idModel: id_model, callbackURL: callback_url, active: active }) end
ruby
{ "resource": "" }
q12924
Trello.PluginDatum.update_fields
train
def update_fields(fields) attributes[:id] = fields['id'] || attributes[:id] attributes[:idPlugin] = fields['idPlugin'] || attributes[:idPlugin] attributes[:scope] = fields['scope'] || attributes[:scope] attributes[:value] = JSON.parse(fields['value']).presence if fields.has_key?(...
ruby
{ "resource": "" }
q12925
Trello.Card.update_fields
train
def update_fields(fields) attributes[:id] = fields[SYMBOL_TO_STRING[:id]] || attributes[:id] attributes[:short_id] = fields[SYMBOL_TO_STRING[:short_id]] || attributes[:short_id] attributes[:name] = fields[SYMBOL_TO_STRING[:name]] || fields[:name] || ...
ruby
{ "resource": "" }
q12926
Trello.Card.update!
train
def update! @previously_changed = changes # extract only new values to build payload payload = Hash[changes.map { |key, values| [SYMBOL_TO_STRING[key.to_sym].to_sym, values[1]] }] @changed_attributes.clear client.put("/cards/#{id}", payload) end
ruby
{ "resource": "" }
q12927
Trello.Card.move_to_list
train
def move_to_list(list) list_number = list.is_a?(String) ? list : list.id unless list_id == list_number client.put("/cards/#{id}/idList", { value: list_number }) end end
ruby
{ "resource": "" }
q12928
Trello.Card.move_to_list_on_any_board
train
def move_to_list_on_any_board(list_id) list = List.find(list_id) if board.id == list.board_id move_to_list(list_id) else move_to_board(Board.find(list.board_id), list) end end
ruby
{ "resource": "" }
q12929
Trello.Card.upvote
train
def upvote begin client.post("/cards/#{id}/membersVoted", { value: me.id }) rescue Trello::Error => e fail e unless e.message =~ /has already voted/i end self end
ruby
{ "resource": "" }
q12930
Trello.Card.remove_upvote
train
def remove_upvote begin client.delete("/cards/#{id}/membersVoted/#{me.id}") rescue Trello::Error => e fail e unless e.message =~ /has not voted/i end self end
ruby
{ "resource": "" }
q12931
Trello.Card.add_label
train
def add_label(label) unless label.valid? errors.add(:label, "is not valid.") return Trello.logger.warn "Label is not valid." unless label.valid? end client.post("/cards/#{id}/idLabels", {value: label.id}) end
ruby
{ "resource": "" }
q12932
Trello.Card.remove_label
train
def remove_label(label) unless label.valid? errors.add(:label, "is not valid.") return Trello.logger.warn "Label is not valid." unless label.valid? end client.delete("/cards/#{id}/idLabels/#{label.id}") end
ruby
{ "resource": "" }
q12933
Trello.Card.add_attachment
train
def add_attachment(attachment, name = '') # Is it a file object or a string (url)? if attachment.respond_to?(:path) && attachment.respond_to?(:read) client.post("/cards/#{id}/attachments", { file: attachment, name: name }) else client.post("/cards/#{id...
ruby
{ "resource": "" }
q12934
Trello.Card.attachments
train
def attachments attachments = Attachment.from_response client.get("/cards/#{id}/attachments") MultiAssociation.new(self, attachments).proxy end
ruby
{ "resource": "" }
q12935
Trello.Organization.boards
train
def boards boards = Board.from_response client.get("/organizations/#{id}/boards/all") MultiAssociation.new(self, boards).proxy end
ruby
{ "resource": "" }
q12936
Trello.Organization.members
train
def members(params = {}) members = Member.from_response client.get("/organizations/#{id}/members/all", params) MultiAssociation.new(self, members).proxy end
ruby
{ "resource": "" }
q12937
Trello.Comment.update_fields
train
def update_fields(fields) attributes[:action_id] = fields['id'] || attributes[:action_id] attributes[:text] = fields['data']['text'] || attributes[:text] attributes[:date] = Time.iso8601(fields['date']) if fields.has_key?('date') attributes[:member_creator_id...
ruby
{ "resource": "" }
q12938
Trello.Attachment.update_fields
train
def update_fields(fields) attributes[:name] = fields['name'] || attributes[:name] attributes[:id] = fields['id'] || attributes[:id] attributes[:pos] = fields['pos'] || attributes[:pos] attributes[:url] = fields['url'] || attributes[:url] attributes[:bytes] = fie...
ruby
{ "resource": "" }
q12939
Trello.CustomFieldItem.option_value
train
def option_value if option_id option_endpoint = "/customFields/#{custom_field_id}/options/#{option_id}" option = CustomFieldOption.from_response client.get(option_endpoint) option.value end end
ruby
{ "resource": "" }
q12940
Trello.Checklist.update_fields
train
def update_fields(fields) attributes[:id] = fields['id'] || attributes[:id] attributes[:name] = fields['name'] || fields[:name] || attributes[:name] attributes[:description] = fields['desc'] || attributes[:description] attributes[:closed] = fields['closed'] if fields.has_key?('closed') att...
ruby
{ "resource": "" }
q12941
Trello.Checklist.save
train
def save return update! if id from_response(client.post("/checklists", { name: name, idCard: card_id })) end
ruby
{ "resource": "" }
q12942
Trello.Checklist.members
train
def members members = member_ids.map do |member_id| Member.find(member_id) end MultiAssociation.new(self, members).proxy end
ruby
{ "resource": "" }
q12943
Trello.Checklist.add_item
train
def add_item(name, checked = false, position = 'bottom') client.post("/checklists/#{id}/checkItems", {name: name, checked: checked, pos: position}) end
ruby
{ "resource": "" }
q12944
Trello.HasActions.actions
train
def actions(options = {}) actions = Action.from_response client.get("#{request_prefix}/actions", { filter: :all }.merge(options)) MultiAssociation.new(self, actions).proxy end
ruby
{ "resource": "" }
q12945
Trello.CheckItemState.update_fields
train
def update_fields(fields) attributes[:id] = fields['id'] || attributes[:id] attributes[:state] = fields['state'] || attributes[:state] attributes[:item_id] = fields['idCheckItem'] || attributes[:item_id] self end
ruby
{ "resource": "" }
q12946
PragmaticSegmenter.Cleaner.clean
train
def clean return unless text remove_all_newlines replace_double_newlines replace_newlines replace_escaped_newlines @text.apply(HTML::All) replace_punctuation_in_brackets @text.apply(InlineFormattingRule) clean_quotations clean_table_of_contents check_f...
ruby
{ "resource": "" }
q12947
MessageBus.HTTPClient.subscribe
train
def subscribe(channel, last_message_id: nil, &callback) raise InvalidChannel unless channel.to_s.start_with?("/") raise MissingBlock unless block_given? last_message_id = -1 if last_message_id && !last_message_id.is_a?(Integer) @channels[channel] ||= Channel.new channel = @channels[chann...
ruby
{ "resource": "" }
q12948
MessageBus.HTTPClient.unsubscribe
train
def unsubscribe(channel, &callback) if callback @channels[channel].callbacks.delete(callback) remove_channel(channel) if @channels[channel].callbacks.empty? else remove_channel(channel) end stop if @channels.empty? @status end
ruby
{ "resource": "" }
q12949
AnyCable.RPCHandler.connect
train
def connect(request, _unused_call) logger.debug("RPC Connect: #{request.inspect}") socket = build_socket(env: rack_env(request)) connection = factory.call(socket) connection.handle_open if socket.closed? AnyCable::ConnectionResponse.new(status: AnyCable::Status::FAILURE) ...
ruby
{ "resource": "" }
q12950
AnyCable.RPCHandler.rack_env
train
def rack_env(request) uri = URI.parse(request.path) # Minimum required variables according to Rack Spec env = { "REQUEST_METHOD" => "GET", "SCRIPT_NAME" => "", "PATH_INFO" => uri.path, "QUERY_STRING" => uri.query, "SERVER_NAME" => uri.host, "SERVER_PORT...
ruby
{ "resource": "" }
q12951
AnyCable.Config.to_grpc_params
train
def to_grpc_params { pool_size: rpc_pool_size, max_waiting_requests: rpc_max_waiting_requests, poll_period: rpc_poll_period, pool_keep_alive: rpc_pool_keep_alive, server_args: rpc_server_args } end
ruby
{ "resource": "" }
q12952
AnyCable.Config.to_redis_params
train
def to_redis_params { url: redis_url }.tap do |params| next if redis_sentinels.nil? raise ArgumentError, "redis_sentinels must be an array; got #{redis_sentinels}" unless redis_sentinels.is_a?(Array) next if redis_sentinels.empty? params[:sentinels] = redis_sentinels.m...
ruby
{ "resource": "" }
q12953
AnyCable.Server.start
train
def start return if running? raise "Cannot re-start stopped server" if stopped? check_default_host logger.info "RPC server is starting..." @start_thread = Thread.new { grpc_server.run } grpc_server.wait_till_running logger.info "RPC server is listening on #{host}" end
ruby
{ "resource": "" }
q12954
Jekyll.TableOfContentsFilter.toc_only
train
def toc_only(html) Jekyll.logger.warn 'Deprecation: toc_only filter is deprecated and will be remove in jekyll-toc v1.0.', 'Use `{% toc %}` instead of `{{ content | toc_only }}`.' return '' unless toc_enabled? TableOfContents::Parser.new(html, toc_config).build_toc end
ruby
{ "resource": "" }
q12955
PhusionPassenger.Utils.generate_random_id
train
def generate_random_id(method) data = File.open("/dev/urandom", "rb") do |f| f.read(64) end case method when :base64 data = base64(data) data.gsub!("+", '') data.gsub!("/", '') data.gsub!(/==$/, '') return data when :hex return data.u...
ruby
{ "resource": "" }
q12956
PhusionPassenger.Utils.print_exception
train
def print_exception(current_location, exception, destination = nil) if !exception.is_a?(SystemExit) data = exception.backtrace_string(current_location) if defined?(DebugLogging) && self.is_a?(DebugLogging) error(data) else destination ||= STDERR destination.pu...
ruby
{ "resource": "" }
q12957
PhusionPassenger.Utils.create_thread_and_abort_on_exception
train
def create_thread_and_abort_on_exception(*args) Thread.new do Thread.current.abort_on_exception = true begin yield(*args) rescue SystemExit raise rescue Exception => e print_exception(nil, e) exit(1) end end end
ruby
{ "resource": "" }
q12958
PhusionPassenger.Utils.process_is_alive?
train
def process_is_alive?(pid) begin Process.kill(0, pid) return true rescue Errno::ESRCH return false rescue SystemCallError => e return true end end
ruby
{ "resource": "" }
q12959
PhusionPassenger.Utils.global_backtrace_report
train
def global_backtrace_report if Kernel.respond_to?(:caller_for_all_threads) all_thread_stacks = caller_for_all_threads elsif Thread.respond_to?(:list) && Thread.public_method_defined?(:backtrace) all_thread_stacks = {} Thread.list.each do |thread| all_thread_stacks[thread] =...
ruby
{ "resource": "" }
q12960
PhusionPassenger.NativeSupportLoader.current_user_name_or_id
train
def current_user_name_or_id require 'etc' if !defined?(Etc) begin user = Etc.getpwuid(Process.uid) rescue ArgumentError user = nil end if user return user.name else return "##{Process.uid}" end end
ruby
{ "resource": "" }
q12961
PhusionPassenger.LoaderSharedHelpers.maybe_make_path_relative_to_app_root
train
def maybe_make_path_relative_to_app_root(app_root, abs_path) if Dir.logical_pwd == app_root && File.dirname(abs_path) == app_root File.basename(abs_path) else abs_path end end
ruby
{ "resource": "" }
q12962
PhusionPassenger.LoaderSharedHelpers.before_handling_requests
train
def before_handling_requests(forked, options) if forked # Reseed pseudo-random number generator for security reasons. srand end if options["process_title"] && !options["process_title"].empty? $0 = options["process_title"] + ": " + options["app_group_name"] end # I...
ruby
{ "resource": "" }
q12963
PhusionPassenger.MessageChannel.read_hash
train
def read_hash buffer = new_buffer if !@io.read(HEADER_SIZE, buffer) return nil end while buffer.size < HEADER_SIZE tmp = @io.read(HEADER_SIZE - buffer.size) if tmp.empty? return nil else buffer << tmp end end chunk_size = b...
ruby
{ "resource": "" }
q12964
PhusionPassenger.MessageChannel.read_scalar
train
def read_scalar(buffer = new_buffer, max_size = nil) if !@io.read(4, buffer) return nil end while buffer.size < 4 tmp = @io.read(4 - buffer.size) if tmp.empty? return nil else buffer << tmp end end size = buffer.unpack(UINT32_PAC...
ruby
{ "resource": "" }
q12965
PhusionPassenger.RequestHandler.cleanup
train
def cleanup if @main_loop_thread @main_loop_thread_lock.synchronize do @graceful_termination_pipe[1].close rescue nil end @main_loop_thread.join end @server_sockets.each_value do |info| socket = info[:socket] type = get_socket_address_type(info[:addres...
ruby
{ "resource": "" }
q12966
PhusionPassenger.RequestHandler.main_loop
train
def main_loop debug("Entering request handler main loop") reset_signal_handlers begin @graceful_termination_pipe = IO.pipe @graceful_termination_pipe[0].close_on_exec! @graceful_termination_pipe[1].close_on_exec! @main_loop_thread_lock.synchronize do @main_lo...
ruby
{ "resource": "" }
q12967
PhusionPassenger.RequestHandler.reset_signal_handlers
train
def reset_signal_handlers Signal.list_trappable.each_key do |signal| begin prev_handler = trap(signal, DEFAULT) if prev_handler != DEFAULT @previous_signal_handlers[signal] = prev_handler end rescue ArgumentError # Signal cannot be trapped; ignor...
ruby
{ "resource": "" }
q12968
ActiveInteraction.Filter.default
train
def default(context = nil) raise NoDefaultError, name unless default? value = raw_default(context) raise InvalidValueError if value.is_a?(GroupedInput) cast(value, context) rescue InvalidNestedValueError => error raise InvalidDefaultError, "#{name}: #{value.inspect} (#{error})" r...
ruby
{ "resource": "" }
q12969
ActiveInteraction.ActiveRecordable.column_for_attribute
train
def column_for_attribute(name) filter = self.class.filters[name] FilterColumn.intern(filter.database_column_type) if filter end
ruby
{ "resource": "" }
q12970
Business.Calendar.add_business_days
train
def add_business_days(date, delta) date = roll_forward(date) delta.times do begin date += day_interval_for(date) end until business_day?(date) end date end
ruby
{ "resource": "" }
q12971
Business.Calendar.subtract_business_days
train
def subtract_business_days(date, delta) date = roll_backward(date) delta.times do begin date -= day_interval_for(date) end until business_day?(date) end date end
ruby
{ "resource": "" }
q12972
Business.Calendar.set_working_days
train
def set_working_days(working_days) @working_days = (working_days || default_working_days).map do |day| day.downcase.strip[0..2].tap do |normalised_day| raise "Invalid day #{day}" unless DAY_NAMES.include?(normalised_day) end end extra_working_dates_names = @extra_working_date...
ruby
{ "resource": "" }
q12973
Slanger.Channel.dispatch
train
def dispatch(message, channel) push(Oj.dump(message, mode: :compat)) unless channel =~ /\Aslanger:/ perform_client_webhook!(message) end
ruby
{ "resource": "" }
q12974
Slanger.Handler.onmessage
train
def onmessage(msg) msg = Oj.strict_load(msg) msg['data'] = Oj.strict_load(msg['data']) if msg['data'].is_a? String event = msg['event'].gsub(/\Apusher:/, 'pusher_') if event =~ /\Aclient-/ msg['socket_id'] = connection.socket_id Channel.send_client_message msg elsif resp...
ruby
{ "resource": "" }
q12975
Slanger.PresenceChannel.dispatch
train
def dispatch(message, channel) if channel =~ /\Aslanger:/ # Messages received from the Redis channel slanger:* carry info on # subscriptions. Update our subscribers accordingly. update_subscribers message else push Oj.dump(message, mode: :compat) end end
ruby
{ "resource": "" }
q12976
JsonApiClient.Schema.add
train
def add(name, options) @properties[name.to_sym] = Property.new(name.to_sym, options[:type], options[:default]) end
ruby
{ "resource": "" }
q12977
JsonApiClient.Connection.use
train
def use(middleware, *args, &block) return if faraday.builder.locked? faraday.builder.insert_before(Middleware::ParseJson, middleware, *args, &block) end
ruby
{ "resource": "" }
q12978
JsonApiClient.Resource.destroy
train
def destroy self.last_result_set = self.class.requestor.destroy(self) if last_result_set.has_errors? fill_errors false else mark_as_destroyed! self.relationships.last_result_set = nil _clear_cached_relationships _clear_belongs_to_params true ...
ruby
{ "resource": "" }
q12979
HTMLProofer.UrlValidator.new_url_query_values?
train
def new_url_query_values?(uri, paths_with_queries) queries = uri.query_values.keys.join('-') domain_path = extract_domain_path(uri) if paths_with_queries[domain_path].nil? paths_with_queries[domain_path] = [queries] true elsif !paths_with_queries[domain_path].include?(queries) ...
ruby
{ "resource": "" }
q12980
HTMLProofer.UrlValidator.external_link_checker
train
def external_link_checker(external_urls) external_urls = Hash[external_urls.sort] count = external_urls.length check_text = pluralize(count, 'external link', 'external links') @logger.log :info, "Checking #{check_text}..." # Route log from Typhoeus/Ethon to our own logger Ethon.log...
ruby
{ "resource": "" }
q12981
HTMLProofer.UrlValidator.check_hash_in_2xx_response
train
def check_hash_in_2xx_response(href, effective_url, response, filenames) return false if @options[:only_4xx] return false unless @options[:check_external_hash] return false unless (hash = hash?(href)) body_doc = create_nokogiri(response.body) unencoded_hash = Addressable::URI.unescape(ha...
ruby
{ "resource": "" }
q12982
HTMLProofer.Runner.check_files
train
def check_files @external_urls = {} process_files.each do |item| @external_urls.merge!(item[:external_urls]) @failures.concat(item[:failures]) end # TODO: lazy. if we're checking only external links, # we'll just trash all the failed tests. really, we should # just ...
ruby
{ "resource": "" }
q12983
HTMLProofer.Runner.process_files
train
def process_files if @options[:parallel].empty? files.map { |path| check_path(path) } else Parallel.map(files, @options[:parallel]) { |path| check_path(path) } end end
ruby
{ "resource": "" }
q12984
Yt.Request.set_request_body!
train
def set_request_body!(request) case @request_format when :json then request.body = (camelize_keys! @body).to_json when :form then request.set_form_data @body when :file then request.body_stream = @body end if @body end
ruby
{ "resource": "" }
q12985
Yt.Request.parse_response!
train
def parse_response! response.body = case @response_format when :xml then Hash.from_xml response.body when :json then JSON response.body end if response.body end
ruby
{ "resource": "" }
q12986
Yt.Request.server_errors
train
def server_errors [ OpenSSL::SSL::SSLError, Errno::ETIMEDOUT, Errno::EHOSTUNREACH, Errno::ENETUNREACH, Errno::ECONNRESET, Net::OpenTimeout, SocketError, Net::HTTPServerError ] + extra_server_errors end
ruby
{ "resource": "" }
q12987
Byebug.PryProcessor.perform
train
def perform(action, options = {}) return unless %i[ backtrace down finish frame next step up ].include?(action) send("perform_#{action}", options) end
ruby
{ "resource": "" }
q12988
Byebug.PryProcessor.resume_pry
train
def resume_pry new_binding = frame._binding run do if defined?(@pry) && @pry @pry.repl(new_binding) else @pry = Pry.start_without_pry_byebug(new_binding) end end end
ruby
{ "resource": "" }
q12989
Haml.Engine.render
train
def render(scope = Object.new, locals = {}, &block) parent = scope.instance_variable_defined?(:@haml_buffer) ? scope.instance_variable_get(:@haml_buffer) : nil buffer = Haml::Buffer.new(parent, @options.for_buffer) if scope.is_a?(Binding) scope_object = eval("self", scope) scope = sco...
ruby
{ "resource": "" }
q12990
Haml.Engine.render_proc
train
def render_proc(scope = Object.new, *local_names) if scope.is_a?(Binding) scope_object = eval("self", scope) else scope_object = scope scope = scope_object.instance_eval{binding} end begin str = @temple_engine.precompiled_with_ambles(local_names) eval( ...
ruby
{ "resource": "" }
q12991
Haml.Engine.def_method
train
def def_method(object, name, *local_names) method = object.is_a?(Module) ? :module_eval : :instance_eval object.send(method, "def #{name}(_haml_locals = {}); #{@temple_engine.precompiled_with_ambles(local_names)}; end", @options.filename, @options.line) end
ruby
{ "resource": "" }
q12992
Haml.AttributeCompiler.compile_attribute_values
train
def compile_attribute_values(values) if values.map(&:key).uniq.size == 1 compile_attribute(values.first.key, values) else runtime_build(values) end end
ruby
{ "resource": "" }
q12993
Haml.AttributeCompiler.static_build
train
def static_build(values) hash_content = values.group_by(&:key).map do |key, values_for_key| "#{frozen_string(key)} => #{merged_value(key, values_for_key)}" end.join(', ') arguments = [@is_html, @attr_wrapper, @escape_attrs, @hyphenate_data_attrs] code = "::Haml::AttributeBuilder.build_a...
ruby
{ "resource": "" }
q12994
Haml.AttributeCompiler.compile_attribute
train
def compile_attribute(key, values) if values.all? { |v| Temple::StaticAnalyzer.static?(v.to_literal) } return static_build(values) end case key when 'id', 'class' compile_id_or_class_attribute(key, values) else compile_common_attribute(key, values) end en...
ruby
{ "resource": "" }
q12995
Haml.Util.parse_haml_magic_comment
train
def parse_haml_magic_comment(str) scanner = StringScanner.new(str.dup.force_encoding(Encoding::ASCII_8BIT)) bom = scanner.scan(/\xEF\xBB\xBF/n) return bom unless scanner.scan(/-\s*#\s*/n) if coding = try_parse_haml_emacs_magic_comment(scanner) return bom, coding end return b...
ruby
{ "resource": "" }
q12996
Haml.Buffer.rstrip!
train
def rstrip! if capture_position.nil? buffer.rstrip! return end buffer << buffer.slice!(capture_position..-1).rstrip end
ruby
{ "resource": "" }
q12997
Haml.Helpers.preserve
train
def preserve(input = nil, &block) return preserve(capture_haml(&block)) if block s = input.to_s.chomp("\n") s.gsub!(/\n/, '&#x000A;') s.delete!("\r") s end
ruby
{ "resource": "" }
q12998
Haml.Helpers.capture_haml
train
def capture_haml(*args, &block) buffer = eval('if defined? _hamlout then _hamlout else nil end', block.binding) || haml_buffer with_haml_buffer(buffer) do position = haml_buffer.buffer.length haml_buffer.capture_position = position value = block.call(*args) captured = haml_...
ruby
{ "resource": "" }
q12999
Haml.Helpers.haml_internal_concat
train
def haml_internal_concat(text = "", newline = true, indent = true) if haml_buffer.tabulation == 0 haml_buffer.buffer << "#{text}#{"\n" if newline}" else haml_buffer.buffer << %[#{haml_indent if indent}#{text.to_s.gsub("\n", "\n#{haml_indent}")}#{"\n" if newline}] end end
ruby
{ "resource": "" }