Dataset Viewer
Auto-converted to Parquet Duplicate
repository_name
stringlengths
7
56
func_path_in_repository
stringlengths
10
101
func_name
stringlengths
12
78
language
stringclasses
1 value
func_code_string
stringlengths
74
11.9k
func_documentation_string
stringlengths
3
8.03k
split_name
stringclasses
1 value
func_code_url
stringlengths
98
213
enclosing_scope
stringlengths
42
98.2k
wied03/opal-factory_girl
opal/opal/active_support/inflector/methods.rb
ActiveSupport.Inflector.titleize
ruby
def titleize(word) # negative lookbehind doesn't work in Firefox / Safari # humanize(underscore(word)).gsub(/\b(?<!['’`])[a-z]/) { |match| match.capitalize } humanized = humanize(underscore(word)) humanized.reverse.gsub(/[a-z](?!['’`])\b/) { |match| match.capitalize }.reverse end
Capitalizes all the words and replaces some characters in the string to create a nicer looking title. +titleize+ is meant for creating pretty output. It is not used in the Rails internals. +titleize+ is also aliased as +titlecase+. titleize('man from the boondocks') # => "Man From The Boondocks" titleize('...
train
https://github.com/wied03/opal-factory_girl/blob/697114a8c63f4cba38b84d27d1f7b823c8d0bb38/opal/opal/active_support/inflector/methods.rb#L160-L165
module Inflector extend self # Returns the plural form of the word in the string. # # If passed an optional +locale+ parameter, the word will be # pluralized using rules defined for that language. By default, # this parameter is set to <tt>:en</tt>. # # pluralize('post') ...
bitbucket-rest-api/bitbucket
lib/bitbucket_rest_api/teams.rb
BitBucket.Teams.followers
ruby
def followers(team_name) response = get_request("/2.0/teams/#{team_name.to_s}/followers") return response["values"] unless block_given? response["values"].each { |el| yield el } end
List followers of the provided team = Examples bitbucket = BitBucket.new :oauth_token => '...', :oauth_secret => '...' bitbucket.teams.followers(:team_name_here) bitbucket.teams.followers(:team_name_here) { |follower| ... }
train
https://github.com/bitbucket-rest-api/bitbucket/blob/e03b6935104d59b3d9a922474c3dc210a5ef76d2/lib/bitbucket_rest_api/teams.rb#L54-L58
class Teams < API extend AutoloadHelper def initialize(options = { }) super(options) end # List teams for the authenticated user where the user has the provided role # Roles are :admin, :contributor, :member # # = Examples # bitbucket = BitBucket.new :oauth_token => '...', :o...
senchalabs/jsduck
lib/jsduck/news.rb
JsDuck.News.filter_new_members
ruby
def filter_new_members(cls) members = cls.all_local_members.find_all do |m| visible?(m) && (m[:new] || new_params?(m)) end members = discard_accessors(members) members.sort! {|a, b| a[:name] <=> b[:name] } end
Returns all members of a class that have been marked as new, or have parameters marked as new.
train
https://github.com/senchalabs/jsduck/blob/febef5558ecd05da25f5c260365acc3afd0cafd8/lib/jsduck/news.rb#L68-L74
class News # Creates News object from relations data when --import option # specified. def self.create(relations, doc_formatter, opts) if opts.import.length > 0 News.new(relations, doc_formatter) else Util::NullObject.new(:to_html => "") end end # Generates list ...
rossf7/elasticrawl
lib/elasticrawl/config.rb
Elasticrawl.Config.load_config
ruby
def load_config(config_file) if dir_exists? begin config_file = File.join(config_dir, "#{config_file}.yml") config = YAML::load(File.open(config_file)) rescue StandardError => e raise FileAccessError, e.message end else raise ConfigDirMissingErr...
Loads a YAML configuration file.
train
https://github.com/rossf7/elasticrawl/blob/db70bb6819c86805869f389daf1920f3acc87cef/lib/elasticrawl/config.rb#L57-L69
class Config CONFIG_DIR = '.elasticrawl' DATABASE_FILE = 'elasticrawl.sqlite3' TEMPLATES_DIR = '../../templates' TEMPLATE_FILES = ['aws.yml', 'cluster.yml', 'jobs.yml'] attr_reader :access_key_id attr_reader :secret_access_key # Sets the AWS access credentials needed for the S3 and EMR A...
tarcieri/cool.io
lib/cool.io/meta.rb
Coolio.Meta.watcher_delegate
ruby
def watcher_delegate(proxy_var) %w{attach attached? detach enable disable}.each do |method| module_eval <<-EOD def #{method}(*args) if defined? #{proxy_var} and #{proxy_var} #{proxy_var}.#{method}(*args) return self end super ...
Use an alternate watcher with the attach/detach/enable/disable methods if it is presently assigned. This is useful if you are waiting for an event to occur before the current watcher can be used in earnest, such as making an outgoing TCP connection.
train
https://github.com/tarcieri/cool.io/blob/0fd3fd1d8e8d81e24f79f809979367abc3f52b92/lib/cool.io/meta.rb#L13-L26
module Meta # Use an alternate watcher with the attach/detach/enable/disable methods # if it is presently assigned. This is useful if you are waiting for # an event to occur before the current watcher can be used in earnest, # such as making an outgoing TCP connection. # Define callbacks whose ...
dennisreimann/masq
app/controllers/masq/server_controller.rb
Masq.ServerController.decide
ruby
def decide @site = current_account.sites.find_or_initialize_by_url(checkid_request.trust_root) @site.persona = current_account.personas.find(params[:persona_id] || :first) if sreg_request || ax_store_request || ax_fetch_request end
Displays the decision page on that the user can confirm the request and choose which data should be transfered to the relying party.
train
https://github.com/dennisreimann/masq/blob/bc6b6d84fe06811b9de19e7863c53c6bfad201fe/app/controllers/masq/server_controller.rb#L64-L67
class ServerController < BaseController # CSRF-protection must be skipped, because incoming # OpenID requests lack an authenticity token skip_before_filter :verify_authenticity_token # Error handling rescue_from OpenID::Server::ProtocolError, :with => :render_openid_error # Actions other than ...
arvicco/win_gui
old_code/lib/win_gui/def_api.rb
WinGui.DefApi.def_api
ruby
def def_api(function, params, returns, options={}, &define_block) name, aliases = generate_names(function, options) boolean = options[:boolean] zeronil = options[:zeronil] proto = params.respond_to?(:join) ? params.join : params # Convert params into prototype string api = Win32::API.new(f...
Defines new method wrappers for Windows API function call: - Defines method with original (CamelCase) API function name and original signature (matches MSDN description) - Defines method with snake_case name (converted from CamelCase function name) with enhanced API signature When the defined wrapper metho...
train
https://github.com/arvicco/win_gui/blob/a3a4c18db2391144fcb535e4be2f0fb47e9dcec7/old_code/lib/win_gui/def_api.rb#L36-L56
module DefApi # DLL to use with API decarations by default ('user32') DEFAULT_DLL = 'user32' ## # Defines new method wrappers for Windows API function call: # - Defines method with original (CamelCase) API function name and original signature (matches MSDN description) # - Defines method ...
sup-heliotrope/sup
lib/sup/index.rb
Redwood.Index.parse_query
ruby
def parse_query s query = {} subs = HookManager.run("custom-search", :subs => s) || s begin subs = SearchManager.expand subs rescue SearchManager::ExpansionError => e raise ParseError, e.message end subs = subs.gsub(/\b(to|from):(\S+)\b/) do field, value = $1, $2 email_f...
parse a query string from the user. returns a query object that can be passed to any index method with a 'query' argument. raises a ParseError if something went wrong.
train
https://github.com/sup-heliotrope/sup/blob/36f95462e3014c354c577d63a78ba030c4b84474/lib/sup/index.rb#L405-L548
class Index include InteractiveLock INDEX_VERSION = '4' ## dates are converted to integers for xapian, and are used for document ids, ## so we must ensure they're reasonably valid. this typically only affect ## spam. MIN_DATE = Time.at 0 MAX_DATE = Time.at(2**31-1) HookManager.register "custom-search...
rmagick/rmagick
lib/rmagick_internal.rb
Magick.ImageList.method_missing
ruby
def method_missing(meth_id, *args, &block) if @scene @images[@scene].send(meth_id, *args, &block) else super end rescue NoMethodError Kernel.raise NoMethodError, "undefined method `#{meth_id.id2name}' for #{self.class}" rescue Exception $ERROR_POSITION.delete_if { |...
The ImageList class supports the Magick::Image class methods by simply sending the method to the current image. If the method isn't explicitly supported, send it to the current image in the array. If there are no images, send it up the line. Catch a NameError and emit a useful message.
train
https://github.com/rmagick/rmagick/blob/ef6688ed9d76bf123c2ea1a483eff8635051adb7/lib/rmagick_internal.rb#L1603-L1614
class ImageList include Comparable include Enumerable attr_reader :scene private def get_current @images[@scene].__id__ rescue StandardError nil end protected def is_an_image(obj) Kernel.raise ArgumentError, "Magick::Image required (#{obj.class} given)" unless...
documentcloud/jammit
lib/jammit/helper.rb
Jammit.Helper.tags_with_options
ruby
def tags_with_options(packages, options) packages.dup.map {|package| yield package }.flatten.map {|package| stylesheet_link_tag package, options }.join("\n") end
Generate the stylesheet tags for a batch of packages, with options, by yielding each package to a block.
train
https://github.com/documentcloud/jammit/blob/dc866f1ac3eb069d65215599c451db39d66119a7/lib/jammit/helper.rb#L76-L82
module Helper DATA_URI_START = "<!--[if (!IE)|(gte IE 8)]><!-->" unless defined?(DATA_URI_START) DATA_URI_END = "<!--<![endif]-->" unless defined?(DATA_URI_END) MHTML_START = "<!--[if lte IE 7]>" unless defined?(MHTML_START) MHTML_END = "<![endif]-->" ...
quixoten/queue_to_the_future
lib/queue_to_the_future/job.rb
QueueToTheFuture.Job.method_missing
ruby
def method_missing(*args, &block) Thread.pass until defined?(@result) case @result when Exception def self.method_missing(*args, &block); raise @result; end else def self.method_missing(*args, &block); @result.send(*args, &block); end end self.method_mis...
Allows the job to behave as the return value of the block. Accessing any method on the job will cause code to block until the job is completed.
train
https://github.com/quixoten/queue_to_the_future/blob/dd8260fa165ee42b95e6d76bc665fdf68339dfd6/lib/queue_to_the_future/job.rb#L34-L45
class Job instance_methods.each { |meth| undef_method(meth) unless %w(__send__ __id__ object_id inspect).include?(meth.to_s) } # Creates a job and schedules it by calling {Coordinator#schedule}. # # @param [List] *args The list of arguments to pass to the given block # @param [Proc] &block Th...
simplymadeapps/simple_scheduler
lib/simple_scheduler/task.rb
SimpleScheduler.Task.future_run_times
ruby
def future_run_times future_run_times = existing_run_times.dup last_run_time = future_run_times.last || at - frequency last_run_time = last_run_time.in_time_zone(time_zone) # Ensure there are at least two future jobs scheduled and that the queue ahead time is filled while future_run_times...
Returns an array Time objects for future run times based on the current time and the given minutes to look ahead. @return [Array<Time>] rubocop:disable Metrics/AbcSize
train
https://github.com/simplymadeapps/simple_scheduler/blob/4d186042507c1397ee79a5e8fe929cc14008c026/lib/simple_scheduler/task.rb#L67-L82
class Task attr_reader :job_class, :params DEFAULT_QUEUE_AHEAD_MINUTES = 360 # Initializes a task by parsing the params so the task can be queued in the future. # @param params [Hash] # @option params [String] :class The class of the Active Job or Sidekiq Worker # @option params [String] :ev...
SamSaffron/message_bus
lib/message_bus/http_client.rb
MessageBus.HTTPClient.start
ruby
def start @mutex.synchronize do return if started? @status = STARTED thread = Thread.new do begin while started? unless @channels.empty? poll @stats.success += 1 @stats.failed = 0 end ...
@param base_url [String] Base URL of the message_bus server to connect to @param enable_long_polling [Boolean] Enable long polling @param enable_chunked_encoding [Boolean] Enable chunk encoding @param min_poll_interval [Float, Integer] Min poll interval when long polling in seconds @param max_poll_interval [Float, ...
train
https://github.com/SamSaffron/message_bus/blob/90fba639eb5d332ca8e87fd35f1d603a5743076d/lib/message_bus/http_client.rb#L96-L127
class HTTPClient class InvalidChannel < StandardError; end class MissingBlock < StandardError; end attr_reader :channels, :stats attr_accessor :enable_long_polling, :status, :enable_chunked_encoding, :min_poll_interval, ...
bitbucket-rest-api/bitbucket
lib/bitbucket_rest_api/issues/components.rb
BitBucket.Issues::Components.get
ruby
def get(user_name, repo_name, component_id, params={}) _update_user_repo_params(user_name, repo_name) _validate_user_repo_params(user, repo) unless user? && repo? _validate_presence_of component_id normalize! params get_request("/1.0/repositories/#{user}/#{repo.downcase}/issues/components...
Get a single component = Examples bitbucket = BitBucket.new bitbucket.issues.components.find 'user-name', 'repo-name', 'component-id'
train
https://github.com/bitbucket-rest-api/bitbucket/blob/e03b6935104d59b3d9a922474c3dc210a5ef76d2/lib/bitbucket_rest_api/issues/components.rb#L36-L43
class Issues::Components < API VALID_COMPONENT_INPUTS = %w[ name ].freeze # Creates new Issues::Components API def initialize(options = {}) super(options) end # List all components for a repository # # = Examples # bitbucket = BitBucket.new :user => 'user-name', :repo => 'repo...
cookpad/rrrspec
rrrspec-client/lib/rrrspec/redis_models.rb
RRRSpec.Task.add_trial
ruby
def add_trial(trial) RRRSpec.redis.rpush(RRRSpec.make_key(key, 'trial'), trial.key) end
Public: Add a trial of the task.
train
https://github.com/cookpad/rrrspec/blob/a5bde2b062ce68b1e32b8caddf194389c2ce28b0/rrrspec-client/lib/rrrspec/redis_models.rb#L640-L643
class Task attr_reader :key def initialize(task_key) @key = task_key end def self.create(taskset, estimate_sec, spec_file) task_key = RRRSpec.make_key(taskset.key, 'task', spec_file) RRRSpec.redis.hmset( task_key, 'taskset', taskset.key, 'estimate_sec', esti...
ImpressCMS/vagrant-impressbox
lib/vagrant-impressbox/provisioner.rb
Impressbox.Provisioner.xaml_config
ruby
def xaml_config require_relative File.join('objects', 'config_file') file = detect_file(config.file) @machine.ui.info "\t" + I18n.t('config.loaded_from_file', file: file) Impressbox::Objects::ConfigFile.new file end
Loads xaml config @return [::Impressbox::Objects::ConfigFile]
train
https://github.com/ImpressCMS/vagrant-impressbox/blob/78dcd119a15ea6fbfd1f28c1e78f1cbf371bc6a2/lib/vagrant-impressbox/provisioner.rb#L81-L86
class Provisioner < Vagrant.plugin('2', :provisioner) # Stores loaded ConfigFile instance # #@return [::Impressbox::Objects::ConfigFile,nil] @@__loaded_config = nil # Object with loaded config from file # #@return [::Impressbox::Objects::ConfigFile,nil] def self.loaded_config @...
grpc/grpc
src/ruby/lib/grpc/generic/client_stub.rb
GRPC.ClientStub.request_response
ruby
def request_response(method, req, marshal, unmarshal, deadline: nil, return_op: false, parent: nil, credentials: nil, metadata: {}) c = new_active_call(method, marshal, unmarshal, ...
Creates a new ClientStub. Minimally, a stub is created with the just the host of the gRPC service it wishes to access, e.g., my_stub = ClientStub.new(example.host.com:50505, :this_channel_is_insecure) If a channel_override argument is passed, it will be used as the underlying chann...
train
https://github.com/grpc/grpc/blob/f3937f0e55227a4ef3a23f895d3b204a947610f8/src/ruby/lib/grpc/generic/client_stub.rb#L148-L181
class ClientStub include Core::StatusCodes include Core::TimeConsts # Default timeout is infinity. DEFAULT_TIMEOUT = INFINITE_FUTURE # setup_channel is used by #initialize to constuct a channel from its # arguments. def self.setup_channel(alt_chan, host, creds, channel_args = {}) u...
CocoaPods/Xcodeproj
lib/xcodeproj/workspace.rb
Xcodeproj.Workspace.save_as
ruby
def save_as(path) FileUtils.mkdir_p(path) File.open(File.join(path, 'contents.xcworkspacedata'), 'w') do |out| out << to_s end end
Saves the workspace at the given `xcworkspace` path. @param [String] path the path where to save the project. @return [void]
train
https://github.com/CocoaPods/Xcodeproj/blob/3be1684437a6f8e69c7836ad4c85a2b78663272f/lib/xcodeproj/workspace.rb#L179-L184
class Workspace # @return [REXML::Document] the parsed XML model for the workspace contents attr_reader :document # @return [Hash<String => String>] a mapping from scheme name to project full path # containing the scheme attr_reader :schemes # @return [Array<FileReference>] the paths...
End of preview. Expand in Data Studio

Dataset Card for "temp_dataset"

More Information needed

Downloads last month
3