_id
stringlengths
2
6
title
stringlengths
9
130
partition
stringclasses
3 values
text
stringlengths
30
4.3k
language
stringclasses
1 value
meta_information
dict
q6200
PureCDB.Reader.values
train
def values(key) h = hash(key) hoff = @hashes[(h % 256)*2] hlen = @hashes[(h % 256)*2 + 1] return [] if hlen == 0 off = (h / 256) % hlen vals = [] # FIXME: Is this potentially an infinite loop (if full)? # Easy to avoid by exiting if off reaches the same value twice.
ruby
{ "resource": "" }
q6201
NCore.ActiveModel.errors_for_actionpack
train
def errors_for_actionpack e0 = ::ActiveModel::Errors.new(self)
ruby
{ "resource": "" }
q6202
Gearbox.AdHocProperties.add_property
train
def add_property(accessor, predicate, object) new_property =
ruby
{ "resource": "" }
q6203
DataMapper::Adapters.BugzillaAdapter.update
train
def update(attributes, collection) each_resource_with_edit_url(collection) do |resource, edit_url| put_updated_resource(edit_url,
ruby
{ "resource": "" }
q6204
Squash.Symbolicator.architectures
train
def architectures architectures = Hash.new stdin, stdout, stderr = Open3.popen3('dwarfdump', '-u', @dsym) stdout.each_line do |line| if
ruby
{ "resource": "" }
q6205
Detroit.Email.announce
train
def announce apply_environment unless @approved mailopts = self.mailopts if mailto.empty? report "No recipents given." else if trial? subject = mailopts['subject'] mailto = mailopts['to'].flatten.join(", ") report "email '#{subject}' to #{mailto}"...
ruby
{ "resource": "" }
q6206
Detroit.Email.message
train
def message @message ||= ( path = Dir[file].first if file if path project.announcement(File.new(file)) else
ruby
{ "resource": "" }
q6207
Detroit.Email.apply_environment
train
def apply_environment return if noenv @server ||= ENV['EMAIL_SERVER'] @from ||= ENV['EMAIL_FROM'] || ENV['EMAIL_ACCOUNT'] @account ||= ENV['EMAIL_ACCOUNT'] || ENV['EMAIL_FROM'] @password ||= ENV['EMAIL_PASSWORD']
ruby
{ "resource": "" }
q6208
Bebox.Provision.apply
train
def apply started_at = DateTime.now.to_s # Check if a Puppetfile is neccesary for use/not use librarian-puppet check_puppetfile_content # Copy static modules that are not downloaded by librarian-puppet copy_static_modules
ruby
{ "resource": "" }
q6209
Bebox.Provision.create_step_checkpoint
train
def create_step_checkpoint(started_at) self.node.started_at = started_at self.node.finished_at = DateTime.now.to_s Bebox::Environment.create_checkpoint_directories(project_root,
ruby
{ "resource": "" }
q6210
Yargi.VertexSet.in_edges
train
def in_edges(filter=nil, &block) r = self.collect {|v| v.in_edges(filter, &block) }
ruby
{ "resource": "" }
q6211
Yargi.VertexSet.in_adjacent
train
def in_adjacent(filter=nil, &block) r = self.collect {|v| v.in_adjacent(filter, &block) }
ruby
{ "resource": "" }
q6212
Yargi.VertexSet.adjacent
train
def adjacent(filter=nil, &block) (in_adjacent(filter,
ruby
{ "resource": "" }
q6213
Houdah.Job.config
train
def config @parsed_config ||= Nokogiri::XML(config_xml).xpath("//property").inject({}) { |props, xprop|
ruby
{ "resource": "" }
q6214
BetterSqs.Client.push
train
def push(queue_name, message_body) sqs.send_message(queue_url:
ruby
{ "resource": "" }
q6215
BetterSqs.Client.reserve
train
def reserve(queue_name) resp = sqs.receive_message(queue_url: url_for_queue(queue_name), max_number_of_messages: 1) return nil unless resp.messages.any? Message.new
ruby
{ "resource": "" }
q6216
BetterSqs.Client.delete
train
def delete(message) sqs.delete_message queue_url:
ruby
{ "resource": "" }
q6217
BetterSqs.Client.defer_retry
train
def defer_retry(message) sqs.change_message_visibility queue_url: url_for_queue(message.queue), receipt_handle: message.receipt_handle,
ruby
{ "resource": "" }
q6218
Pushfile.Resize.resize!
train
def resize! begin image = MiniMagick::Image.open(@file.path) image.resize("#{@width}x#{@height}") rescue # Pass on
ruby
{ "resource": "" }
q6219
Pushfile.Resize.thumbnail!
train
def thumbnail! begin image = MiniMagick::Image.open(@file.path) image.resize("#{Pushfile.settings[:images][:thumb][:width]}x") rescue @thumb = nil else t = @name.split('.');
ruby
{ "resource": "" }
q6220
Hornetseye.Lambda.element
train
def element(i) unless i.matched? unless (0 ... shape.last).member? i raise "Index must be in 0 ... #{shape.last} (was #{i})" end i = INT.new i end
ruby
{ "resource": "" }
q6221
ConfluenceReporter.Reporter.report_event
train
def report_event(name, parrent_page_id=nil, space=nil) page = find_page_by_name(name, parrent_page_id) if page append_to_page(page["id"], parrent_page_id) else
ruby
{ "resource": "" }
q6222
ConfluenceReporter.Reporter.create_page
train
def create_page(title, space, parrent_page_id=nil) params = { 'type' => 'page', 'title' => title, 'space' => {'key' => space}, 'body' => { 'storage' => { 'value' => ("#{ @body_message.to_json.gsub("&&", "&&")...
ruby
{ "resource": "" }
q6223
Aims.Atom.constrained?
train
def constrained? if self.constrain if self.constrain == true true elsif self.constrain.is_a? String true
ruby
{ "resource": "" }
q6224
Aims.Atom.distance_to
train
def distance_to(atom) Math.sqrt((self.x - atom.x)**2 + (self.y -
ruby
{ "resource": "" }
q6225
Aims.Atom.displace
train
def displace(x,y,z) Atom.new(self.x+x, self.y+y, self.z+z,
ruby
{ "resource": "" }
q6226
Aims.Atom.displace!
train
def displace!(x,y,z) self.x += x self.y
ruby
{ "resource": "" }
q6227
Aims.Atom.format_geometry_in
train
def format_geometry_in line = "atom %16.6f %16.6f %16.6f %s" % [self.x, self.y, self.z, self.species] if self.constrain if self.constrain == true line << "\nconstrain_relaxation .true." elsif self.constrain.is_a? String
ruby
{ "resource": "" }
q6228
Trooper.Runner.build_commands
train
def build_commands(strategy_name, type, action_name) action = Arsenal.actions[action_name] if action options = action.options case type when :prerequisite commands = action.prerequisite_call config Trooper.logger.action "Prerequisite: #{action.description}" ...
ruby
{ "resource": "" }
q6229
Trooper.Runner.hosts
train
def hosts @hosts ||= begin r, h, u = [], (config[:hosts] rescue nil), (config[:user] rescue nil)
ruby
{ "resource": "" }
q6230
Trooper.Runner.runner_execute!
train
def runner_execute!(host, commands, options = {}) result = host.execute commands, options if result && result[1] == :stdout
ruby
{ "resource": "" }
q6231
Gvis.DataTable.add_row
train
def add_row(row) size = row.size raise ArgumentError.new("Given a row of data with #{size}
ruby
{ "resource": "" }
q6232
Gvis.DataTable.add_rows
train
def add_rows(rows) sizes = rows.collect {|r| r.size }.uniq expected_size = @table_columns.size errors = sizes.select {|s| s != expected_size } raise ArgumentError.new("Given a row of data with #{errors.to_sentence}
ruby
{ "resource": "" }
q6233
Gvis.DataTable.format_data
train
def format_data formatted_rows = [] @data.each do |row| values = [] row.each_with_index do |entry,index| values << Gvis::DataCell.new(entry, @column_types.to_a[index][1]).to_js end
ruby
{ "resource": "" }
q6234
Gvis.DataTable.register_column
train
def register_column(type, name) type = type.to_s.downcase raise ArgumentError.new("invalid column type #{type}, permitted types are #{COLUMN_TYPES.join(',
ruby
{ "resource": "" }
q6235
Taaze.TaazeCollections.extract_books
train
def extract_books booklist = [] if @doc.count != 0 @doc.each do |book_data| book = {} book['title'] = book_data['titleMain'] book['book_url'] = BOOK_URL + book_data['prodId']
ruby
{ "resource": "" }
q6236
SiteMapper.Crawler.collect_urls
train
def collect_urls @fetch_queue << @crawl_url.resolved_base_url until @fetch_queue.empty? || @processed.length >= @options[:max_requests] url = @fetch_queue.pop yield(url) page_urls_for(url) end result = @processed + @fetch_queue Logger.log "Crawling finished:" ...
ruby
{ "resource": "" }
q6237
Liner.Hashable.liner
train
def liner liner_keys.inject({}) { |h,k| h[k] =
ruby
{ "resource": "" }
q6238
Pith.Output.build
train
def build return false if @generated logger.info("--> #{path}") @dependencies = Set.new file.parent.mkpath if input.template?
ruby
{ "resource": "" }
q6239
Yargi.Digraph.each_vertex
train
def each_vertex(filter=nil, &block) if filter.nil? @vertices.each &block else
ruby
{ "resource": "" }
q6240
Yargi.Digraph.remove_vertices
train
def remove_vertices(*vertices) vertices = to_vertices(*vertices).sort{|v1,v2| v2<=>v1} vertices.each do |vertex| remove_edges(vertex.in_edges+vertex.out_edges) @vertices.delete_at(vertex.index)
ruby
{ "resource": "" }
q6241
Yargi.Digraph.each_edge
train
def each_edge(filter=nil, &block) if filter.nil? @edges.each &block else
ruby
{ "resource": "" }
q6242
Yargi.Digraph.remove_edges
train
def remove_edges(*edges) edges = to_edges(edges).sort{|e1,e2| e2<=>e1} edges.each do |edge| edge.source.remove_out_edge(edge) edge.target.remove_in_edge(edge) @edges.delete_at(edge.index)
ruby
{ "resource": "" }
q6243
Yargi.Digraph.to_dot
train
def to_dot(buffer='') buffer << "digraph G {\n" buffer << " graph[#{to_dot_attributes(self.to_h(true))}]\n" each_vertex do |v| buffer << "
ruby
{ "resource": "" }
q6244
Yargi.Digraph.to_dot_attributes
train
def to_dot_attributes(hash) # TODO: fix uncompatible key names # TODO: some values must be encoded (backquoting and the like) buffer = "" hash.each_pair do |k,v| buffer << " " unless buffer.empty? v = case v when Array if v.all?{|elm| Array===elm and elm.len...
ruby
{ "resource": "" }
q6245
Yargi.Digraph.check_sanity
train
def check_sanity @vertices.each_with_index do |v,i| raise "Removed vertex in vertex list" unless v.index==i v.in_edges.each do |ine| raise "Removed edge in vertex incoming edges" if ine.index<0 raise "Vertex and edge don't agree on target" unless ine.target==v end ...
ruby
{ "resource": "" }
q6246
Yargi.Digraph.to_vertices
train
def to_vertices(*args) selected = args.collect do |arg| case arg when Integer [@vertices[arg]] when VertexSet arg when Array arg.collect{|v| to_vertices(v)}.flatten.uniq when Digraph::Vertex
ruby
{ "resource": "" }
q6247
Yargi.Digraph.to_edges
train
def to_edges(*args) selected = args.collect do |arg| case arg when Integer [@edges[arg]] when EdgeSet arg when Array arg.collect{|v| to_edges(v)}.flatten.uniq when Digraph::Edge
ruby
{ "resource": "" }
q6248
Yargi.Digraph.apply_arg_conventions
train
def apply_arg_conventions(element, args) args.each do |arg| case arg when Module element.tag(arg) when Hash element.add_marks(arg) else
ruby
{ "resource": "" }
q6249
Curtain.HTMLHelpers.content_tag
train
def content_tag(name, content=nil, attrs={}, &body) if content.is_a?(Hash) attrs = content content = nil end if block_given? content = capture(&body) end tag
ruby
{ "resource": "" }
q6250
BarkestCore.ApplicationHelper.render_alert
train
def render_alert(type, message) if type.to_s.index('safe_') type = type.to_s[5..-1] message = message.to_s.html_safe end type = type.to_sym type = :info if type == :notice type = :danger if type == :alert return nil unless [:info, :success, :danger, :warning].inclu...
ruby
{ "resource": "" }
q6251
ActionKitApi.EventCampaign.create_event
train
def create_event(*args) raise "EventCampaign needs to be saved before Event creation" if self.id.nil?
ruby
{ "resource": "" }
q6252
ActionKitApi.EventCampaign.public_search
train
def public_search(*args) (args[0]).merge!(:campaign_id => self.id) results = ActionKitApi.connection.call("Event.public_search",
ruby
{ "resource": "" }
q6253
EncryptedStore.CryptoHash.encrypt
train
def encrypt(dek, salt, iter_mag=10) return nil if empty? raise Errors::InvalidSaltSize, 'too long' if salt.bytes.length > 255 key, iv = _keyiv_gen(dek, salt, iter_mag) encryptor = OpenSSL::Cipher::AES256.new(:CBC).encrypt encryptor.key = key encryptor.iv = iv data_packet
ruby
{ "resource": "" }
q6254
Incline.UserManager.authenticate
train
def authenticate(email, password, client_ip) return nil unless Incline::EmailValidator.valid?(email) email = email.downcase # If an engine is registered for the email domain, then use it. engine = get_auth_engine(email) if engine return engine.authenticate(email, password, client_...
ruby
{ "resource": "" }
q6255
Incline.UserManager.begin_external_authentication
train
def begin_external_authentication(request) # We don't have an email domain to work from. # Instead, we'll call each engine's authenticate_external method. # If one of them returns a
ruby
{ "resource": "" }
q6256
Incline.UserManager.register_auth_engine
train
def register_auth_engine(engine, *domains) unless engine.nil? unless engine.is_a?(::Incline::AuthEngineBase) raise ArgumentError, "The 'engine' parameter must be an instance of an auth engine or a class defining an auth engine." unless engine.is_a?(::Class) engine = engine.new(@options...
ruby
{ "resource": "" }
q6257
Generators.ControllerGeneratorBase.copy_view_files
train
def copy_view_files #do NOT change the name of this method # it must be overriding an existing one in a parent class base_path = File.join("app/views", class_path, file_name) #binding.pry empty_directory base_path @actions = actions.nil? || actions.empty? ? %w(index new ...
ruby
{ "resource": "" }
q6258
Footing.Hash.to_h
train
def to_h copied_object.each_with_object({}) do |pair, memo| value = pair.last if value.is_a?(Footing::Hash) memo[pair.first] = value.to_h elsif value.is_a?(::Array) memo[pair.first] = value.map do |val| if val.is_a?(Footing::Hash)
ruby
{ "resource": "" }
q6259
Smarteru.Client.request
train
def request(operation, data) opts = { method: :post, url: api_url, payload: { 'Package' => body(operation, data) }, content_type: :xml, verify_ssl: verify_ssl, ssl_ca_file: ssl_ca_file } response = RestClient::Request.execute(opts)
ruby
{ "resource": "" }
q6260
Smarteru.Client.body_parameters
train
def body_parameters(parameters) parameters_xml = '' parameters.each_pair do |k, v| key = parameter_key(k) val = case v when Hash body_parameters(v) when Array v.map { |i| body_parameters(i) }.join('') when nil
ruby
{ "resource": "" }
q6261
Smarteru.Client.parameter_key
train
def parameter_key(term) string = term.to_s string = string.sub(/^[a-z\d]*/) { $&.capitalize }
ruby
{ "resource": "" }
q6262
Aims.ZincBlende.get_bulk
train
def get_bulk b = 0.25*self.lattice_const a1 = Atom.new(0, 0, 0, self.cation) a2 = Atom.new(b, b, b, self.anion) v1 = Vector[0.5, 0.5, 0.0]*self.lattice_const v2 = Vector[0.5, 0.0, 0.5]*self.lattice_const v3 = Vector[0.0, 0.5, 0.5]*self.lattice_const zb = Geometry.new([a1...
ruby
{ "resource": "" }
q6263
Aims.ZincBlende.fill_volume
train
def fill_volume(volume) # First fill a cube that bounds the volume max = volume.max_point min = volume.min_point dx = max[0] - min[0] dy = max[1] - min[1] dz = max[2] - min[2] bulk = get_bulk # This inverse matrix gives the number of repetition...
ruby
{ "resource": "" }
q6264
Aims.ZincBlende.get_001_surface
train
def get_001_surface(monolayers, vacuum, constrain_layers = 0) anion = Atom.new(0,0,0,self.cation) cation = Atom.new(0.25*self.lattice_const, 0.25*self.lattice_const, 0.25*self.lattice_const, self.anion) v1 = Vector[0.5, 0.5, 0]*self.lattice_const v2 = Vector[-0.5,0.5,0]*self.lattice_const ...
ruby
{ "resource": "" }
q6265
Aims.ZincBlende.get_111_surface
train
def get_111_surface(dir, monolayers, vacuum, constrain_layers = 0) if dir == "A" top_atom = self.anion bot_atom = self.cation elsif dir == "B" top_atom = self.cation bot_atom = self.anion else raise "Direction must be either A or B" end # The...
ruby
{ "resource": "" }
q6266
Aims.ZincBlende.get_112_surface
train
def get_112_surface(monolayers, vacuum=0, constrain_layers = 0) atom1 = Atom.new(0,0,0,self.cation) atom2 = Atom.new(self.lattice_const*sqrt(3)/2, 0, 0, self.anion) v1 = Vector[sqrt(3), 0, 0]*self.lattice_const v2 = Vector[0, sqrt(2)/2, 0]*self.lattice_const v3 = Vector[1/sqrt(3), 1...
ruby
{ "resource": "" }
q6267
Aims.ZincBlende.get_110_surface
train
def get_110_surface(monolayers, vacuum=0, constrain_layers = 0) # The atoms on a FCC atom1 = Atom.new(0,0,0,self.cation) atom2 = Atom.new(self.lattice_const*1/(2*sqrt(2)), self.lattice_const*0.25, 0.0, self.anion) # The lattice Vectors v1 = Vector[1/sqrt(2), 0.0, 0.0]*self.lattice_const...
ruby
{ "resource": "" }
q6268
Jinx.Collection.to_compact_hash_with_index
train
def to_compact_hash_with_index hash = {} self.each_with_index do |item, index| next if item.nil? value = yield(item, index)
ruby
{ "resource": "" }
q6269
Jinx.Collection.partial_sort!
train
def partial_sort! unless block_given? then return partial_sort! { |item1, item2| item1 <=> item2 } end # The comparison hash h = Hash.new { |h, k| h[k] = Hash.new } sort! do |a, b| # * If a and b are comparable, then use the comparison result. # * Otherwise, if there is a member ...
ruby
{ "resource": "" }
q6270
Jinx.Inversible.set_inverse
train
def set_inverse(other, writer, inv_writer)
ruby
{ "resource": "" }
q6271
Jinx.Inversible.set_inversible_noncollection_attribute
train
def set_inversible_noncollection_attribute(newval, accessors, inverse_writer) rdr, wtr = accessors # the previous value oldval = send(rdr) # bail if no change return newval if newval.equal?(oldval) # clear the previous inverse logger.debug { "Moving #{qp} from #{oldval.qp} to ...
ruby
{ "resource": "" }
q6272
Jinx.Inversible.add_to_inverse_collection
train
def add_to_inverse_collection(newval, accessors, inverse) rdr, wtr = accessors # the current inverse oldval = send(rdr) # no-op if no change return newval if newval == oldval # delete self from the current inverse reference collection if oldval then coll = oldval.send(...
ruby
{ "resource": "" }
q6273
Garcon.Pathref.expand_pathseg
train
def expand_pathseg(handle) return handle unless handle.is_a?(Symbol) pathsegs = ROOT_PATHS[handle] or raise ArgumentError, "Don't know how to expand path reference
ruby
{ "resource": "" }
q6274
Garcon.MutexCountDownLatch.wait
train
def wait(timeout = nil) @mutex.synchronize do remaining = Condition::Result.new(timeout) while @count > 0 && remaining.can_wait?
ruby
{ "resource": "" }
q6275
ModelSchema.SchemaError.dump_extra_diffs
train
def dump_extra_diffs(field) extra_diffs = diffs_by_field_type(field, TYPE_EXTRA) if extra_diffs.length > 0 header = "Table #{@table_name} has extra #{field}:\n" diff_str = extra_diffs.map do |diff|
ruby
{ "resource": "" }
q6276
ModelSchema.SchemaError.dump_missing_diffs
train
def dump_missing_diffs(field) missing_diffs = diffs_by_field_type(field, TYPE_MISSING) if missing_diffs.length > 0 header = "Table #{@table_name} is missing #{field}:\n" diff_str = missing_diffs.map do |diff|
ruby
{ "resource": "" }
q6277
ModelSchema.SchemaError.dump_mismatch_diffs
train
def dump_mismatch_diffs(field) mismatch_diffs = diffs_by_field_type(field, TYPE_MISMATCH) if mismatch_diffs.length > 0 header = "Table #{@table_name} has mismatched #{field}:\n" diff_str = mismatch_diffs.map do |diff| "actual: #{dump_single(field, diff[:db_generator], diff[:db_...
ruby
{ "resource": "" }
q6278
ModelSchema.SchemaError.to_s
train
def to_s parts = FIELDS.flat_map do |field| [dump_extra_diffs(field), dump_missing_diffs(field), dump_mismatch_diffs(field)] end [ "Table #{@table_name} does not match the expected schema.\n\n", parts.compact.join("\n"),
ruby
{ "resource": "" }
q6279
Jinx.Visitor.filter
train
def filter raise ArgumentError.new("A filter block is not given to the visitor filter method") unless block_given?
ruby
{ "resource": "" }
q6280
Jinx.Visitor.node_children
train
def node_children(node) children = @navigator.call(node) return Array::EMPTY_ARRAY if children.nil?
ruby
{ "resource": "" }
q6281
Jinx.Visitor.visit_root
train
def visit_root(node, &operator) clear # Exclude cycles if the prune cycles flag is set. @exclude.merge!(cyclic_nodes(node)) if @prune_cycle_flag # Visit the root node.
ruby
{ "resource": "" }
q6282
Jinx.Visitor.cyclic_nodes
train
def cyclic_nodes(root) copts = @options.reject { |k, v| k == :prune_cycle } cyclic = Set.new cycler = Visitor.new(copts) do |parent| children = @navigator.call(parent) # Look for a cycle back to the child. children.each do |child|
ruby
{ "resource": "" }
q6283
RichUnits.Numeric.duration
train
def duration(part = nil, klass = Duration) if [:years, :months, :weeks, :days, :hours, :minutes, :seconds].include? part klass.new(part
ruby
{ "resource": "" }
q6284
RichUnits.Duration.seconds
train
def seconds(part = nil) # Table mapping h = {:weeks => WEEK, :days => DAY, :hours => HOUR, :minutes => MINUTE}
ruby
{ "resource": "" }
q6285
RichUnits.Duration.to_s
train
def to_s str = '' each do |part, time| # Skip any zero times. next if time.zero? # Concatenate the part of the time and the time itself. str << "#{time} #{time == 1
ruby
{ "resource": "" }
q6286
MMETools.Config.dump
train
def dump(filename) File.open(filename,'w') do |f|
ruby
{ "resource": "" }
q6287
ReindeerETL::Sources.MultiSource.each
train
def each rows = [] all_keys = Set.new @sources.each_with_index do |source, source_idx| first_row = false source.each do |row| unless row.keys.include? @key raise ReindeerETL::Errors::RecordInvalid.new("Path#1 missing key: #{@key}") end if sour...
ruby
{ "resource": "" }
q6288
LogCabin.SetCollection.find
train
def find(name) cache(name) { @children.find { |x|
ruby
{ "resource": "" }
q6289
OffTheGrid.User.add
train
def add Tempfile.open do |tmpfile| tmpfile.puts render(Templates::User::ERB) tmpfile.flush system("qconf
ruby
{ "resource": "" }
q6290
Undecided.Decider.decide
train
def decide(rule, values, strict = true) rule = rule.clone values = values.clone error unless Undecided::Evaluator.valid?(rule, values, strict)
ruby
{ "resource": "" }
q6291
XMSensu.XMClient.get_default_properties
train
def get_default_properties(event) client = event['client'] check = event['check'] { server_name: client['name'], server_ip: client['address'], subscriptions: client['subscriptions'].join(';'), environment: client['environment'],
ruby
{ "resource": "" }
q6292
Garcon.SecretBag.data_bag_config_for
train
def data_bag_config_for(environment, source) data_bag_item = encrypted_data_bag_for(environment, DATA_BAG) if data_bag_item.has_key?(source) data_bag_item[source]
ruby
{ "resource": "" }
q6293
Garcon.SecretBag.encrypted_data_bag_for
train
def encrypted_data_bag_for(environment, data_bag) @encrypted_data_bags = {} unless @encrypted_data_bags if encrypted_data_bags[data_bag] return get_from_data_bags_cache(data_bag) else data_bag_item = encrypted_data_bag_item(data_bag,
ruby
{ "resource": "" }
q6294
AttachmentMagic.ClassMethods.copy_to_temp_file
train
def copy_to_temp_file(file, temp_base_name) Tempfile.new(temp_base_name, AttachmentMagic.tempfile_path).tap do |tmp|
ruby
{ "resource": "" }
q6295
AttachmentMagic.ClassMethods.write_to_temp_file
train
def write_to_temp_file(data, temp_base_name) Tempfile.new(temp_base_name, AttachmentMagic.tempfile_path).tap do |tmp|
ruby
{ "resource": "" }
q6296
AttachmentMagic.InstanceMethods.uploaded_data=
train
def uploaded_data=(file_data) if file_data.respond_to?(:content_type) return nil if file_data.size == 0 self.content_type = detect_mimetype(file_data) self.filename = file_data.original_filename if respond_to?(:filename) else return nil if file_data.blank? || file_data['s...
ruby
{ "resource": "" }
q6297
AttachmentMagic.InstanceMethods.attachment_attributes_valid?
train
def attachment_attributes_valid? [:size, :content_type].each do |attr_name| enum = attachment_options[attr_name]
ruby
{ "resource": "" }
q6298
ActionCommand.PrettyPrintLogAction.execute_internal
train
def execute_internal(_result) item = LogMessage.new parser = LogParser.new(@source, @sequence) sequences = {} # keep track of sequences, and when you complete one, then print out the # entire thing at once. while parser.next(item) if item.kind?(ActionCommand::LOG_KIND_COMMAN...
ruby
{ "resource": "" }
q6299
Mutter.Mutterer.load
train
def load styles styles += '.yml' unless styles =~ /\.ya?ml$/ styles = File.join(File.dirname(__FILE__), "styles", styles) unless File.exist? styles YAML.load_file(styles).inject({}) do |h, (key, value)|
ruby
{ "resource": "" }