_id
stringlengths 2
6
| title
stringlengths 9
130
| partition
stringclasses 3
values | text
stringlengths 30
4.3k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q1000 | Sweetify.SweetAlert.sweetalert | train | def sweetalert(text, title = '', opts = {})
opts = {
showConfirmButton: false,
timer: 2000,
allowOutsideClick: true,
confirmButtonText: 'OK'
}.merge(opts)
opts[:text] = text
opts[:title] = title
if opts[:button]
opts[:showConfirmButton] = true
opts[:confirmButtonText] = opts[:button] if opts[:button].is_a?(String)
opts.delete(:button)
end
| ruby | {
"resource": ""
} |
q1001 | Sweetify.SweetAlert.flash_config | train | def flash_config(opts)
if opts[:title].blank?
opts[:title] = | ruby | {
"resource": ""
} |
q1002 | Exchanger.Element.to_xml | train | def to_xml(options = {})
doc = Nokogiri::XML::Document.new
root = doc.create_element(tag_name)
self.class.keys.each do |name|
value = read_attribute(name)
next if value.blank?
root[name.to_s.camelize] = value
end
self.class.elements.each do |name, field|
next if options[:only] && !options[:only].include?(name)
next if field.options[:readonly]
value = read_attribute(name) | ruby | {
"resource": ""
} |
q1003 | Middleware.Builder.insert | train | def insert(index, middleware, *args, &block)
index = self.index(index) unless index.is_a?(Integer)
raise "no such | ruby | {
"resource": ""
} |
q1004 | Middleware.Builder.replace | train | def replace(index, middleware, *args, &block)
if index.is_a?(Integer)
delete(index)
insert(index, middleware, *args, &block)
else
| ruby | {
"resource": ""
} |
q1005 | Exchanger.Persistence.reload | train | def reload
if new_record?
false
else
reloaded_element = self.class.find(self.id)
@attributes | ruby | {
"resource": ""
} |
q1006 | Exchanger.Field.to_xml | train | def to_xml(value, options = {})
if value.is_a?(Exchanger::Element)
value.tag_name = tag_name
value.to_xml(options)
else
doc = Nokogiri::XML::Document.new
root = doc.create_element(tag_name)
case value
when Array
| ruby | {
"resource": ""
} |
q1007 | Exchanger.Field.value_from_xml | train | def value_from_xml(node)
if type.respond_to?(:new_from_xml)
type.new_from_xml(node)
elsif type.is_a?(Array)
node.children.map do |sub_node|
sub_field.value_from_xml(sub_node)
end
elsif type == Boolean
node.text == "true"
| ruby | {
"resource": ""
} |
q1008 | Exchanger.Dirty.reset_attribute! | train | def reset_attribute!(name)
value = attribute_was(name)
if value
@attributes[name] = value
| ruby | {
"resource": ""
} |
q1009 | Exchanger.Dirty.accessed | train | def accessed(name, value)
@accessed ||= {}
@accessed[name] = value.dup if (value.is_a?(Array) | ruby | {
"resource": ""
} |
q1010 | Exchanger.Dirty.modifications | train | def modifications
@accessed.each_pair do |field, value|
current = @attributes[field]
if current != value || (current.is_a?(Array) &&
current.any? { |v| v.respond_to?(:changed?) && | ruby | {
"resource": ""
} |
q1011 | Exchanger.Dirty.modify | train | def modify(name, old_value, new_value)
@attributes[name] = new_value
if @modifications && (old_value != new_value) | ruby | {
"resource": ""
} |
q1012 | Exchanger.Attributes.method_missing | train | def method_missing(name, *args)
attr = name.to_s.sub("=", "")
return super unless attributes.has_key?(attr)
| ruby | {
"resource": ""
} |
q1013 | Exchanger.Client.request | train | def request(post_body, headers)
response = @client.post(endpoint, post_body, headers)
return { :status | ruby | {
"resource": ""
} |
q1014 | Adauth.Connection.bind | train | def bind
conn = Net::LDAP.new :host => @config[:server],
:port => @config[:port],
:base => @config[:base]
if @config[:encryption]
conn.encryption @config[:encryption]
end
raise "Anonymous Bind is disabled" if @config[:password] == "" && !(@config[:anonymous_bind])
conn.auth "#{@config[:username]}@#{@config[:domain]}", @config[:password]
begin
Timeout::timeout(10){
if conn.bind
return conn
else
raise 'Query User Rejected'
| ruby | {
"resource": ""
} |
q1015 | Nextcloud.Api.request | train | def request(method, path, params = nil, body = nil, depth = nil, destination = nil, raw = false)
response = Net::HTTP.start(@url.host, @url.port,
use_ssl: @url.scheme == "https") do |http|
req = Kernel.const_get("Net::HTTP::#{method.capitalize}").new(@url.request_uri + path)
req["OCS-APIRequest"] = true
req.basic_auth @username, @password
req["Content-Type"] = "application/x-www-form-urlencoded"
req["Depth"] = 0 if depth
req["Destination"] | ruby | {
"resource": ""
} |
q1016 | Nextcloud.Helpers.parse_with_meta | train | def parse_with_meta(doc, xpath)
groups = []
doc.xpath(xpath).each do |prop|
groups << prop.text
end
meta = get_meta(doc) | ruby | {
"resource": ""
} |
q1017 | Nextcloud.Helpers.get_meta | train | def get_meta(doc)
meta = doc.xpath("//meta/*").each_with_object({}) do |node, meta|
| ruby | {
"resource": ""
} |
q1018 | Nextcloud.Helpers.doc_to_hash | train | def doc_to_hash(doc, xpath = "/")
h = | ruby | {
"resource": ""
} |
q1019 | Nextcloud.Helpers.add_meta | train | def add_meta(doc, obj)
meta = get_meta(doc)
| ruby | {
"resource": ""
} |
q1020 | Nextcloud.Helpers.parse_dav_response | train | def parse_dav_response(doc)
doc.remove_namespaces!
if doc.at_xpath("//error")
{
exception: doc.xpath("//exception").text,
message: doc.xpath("//message").text
}
elsif doc.at_xpath("//status")
| ruby | {
"resource": ""
} |
q1021 | Nextcloud.Helpers.has_dav_errors | train | def has_dav_errors(doc)
doc.remove_namespaces!
if doc.at_xpath("//error")
{
exception: doc.xpath("//exception").text,
| ruby | {
"resource": ""
} |
q1022 | Adauth.AdObject.handle_field | train | def handle_field(field)
case field
when Symbol then return return_symbol_value(field)
| ruby | {
"resource": ""
} |
q1023 | Adauth.AdObject.cn_groups_nested | train | def cn_groups_nested
@cn_groups_nested = cn_groups
cn_groups.each do |group|
ado = Adauth::AdObjects::Group.where('name', group).first
if ado
groups = convert_to_objects ado.cn_groups
groups.each do | ruby | {
"resource": ""
} |
q1024 | Adauth.AdObject.ous | train | def ous
unless @ous
@ous = []
@ldap_object.dn.split(/,/).each do |entry|
| ruby | {
"resource": ""
} |
q1025 | Adauth.AdObject.modify | train | def modify(operations)
Adauth.logger.info(self.class.inspect) { "Attempting modify operation" }
unless Adauth.connection.modify :dn => @ldap_object.dn, :operations => operations
Adauth.logger.fatal(self.class.inspect) { "Modify Operation Failed! Code: | ruby | {
"resource": ""
} |
q1026 | Adauth.AdObject.members | train | def members
unless @members
@members = []
[Adauth::AdObjects::Computer, Adauth::AdObjects::OU, Adauth::AdObjects::User, Adauth::AdObjects::Group].each do |object|
object.all.each do |entity|
| ruby | {
"resource": ""
} |
q1027 | WDM.SpecSupport.run_and_collect_multiple_changes | train | def run_and_collect_multiple_changes(monitor, times, directory, *flags, &block)
watch_and_run(monitor, | ruby | {
"resource": ""
} |
q1028 | WDM.SpecSupport.run | train | def run(monitor, directory, *flags, &block)
result = watch_and_run(monitor, 1, false, directory, *flags, &block)
| ruby | {
"resource": ""
} |
q1029 | WDM.SpecSupport.run_with_fixture | train | def run_with_fixture(monitor, *flags, &block)
fixture do |f|
| ruby | {
"resource": ""
} |
q1030 | WDM.SpecSupport.run_recursively_and_collect_multiple_changes | train | def run_recursively_and_collect_multiple_changes(monitor, times, directory, | ruby | {
"resource": ""
} |
q1031 | WDM.SpecSupport.run_recursively | train | def run_recursively(monitor, directory, *flags, &block)
result = watch_and_run(monitor, 1, true, directory, *flags, &block)
| ruby | {
"resource": ""
} |
q1032 | WDM.SpecSupport.run_recursively_with_fixture | train | def run_recursively_with_fixture(monitor, *flags, &block)
| ruby | {
"resource": ""
} |
q1033 | WDM.SpecSupport.watch_and_run | train | def watch_and_run(monitor, times, recursively, directory, *flags)
result = OpenStruct.new(directory: directory, changes: [])
i = 0
result.changes[i] = OpenStruct.new(called: false)
can_return = false
callback = Proc.new do |change|
next if can_return
result.changes[i].called = true;
result.changes[i].change = change
i += 1
if i < times
result.changes[i] = OpenStruct.new(called: false)
else
can_return = true
end
end
if recursively
monitor.watch_recursively(directory, *flags, &callback)
else
monitor.watch(directory, *flags, &callback)
| ruby | {
"resource": ""
} |
q1034 | WDM.SpecSupport.fixture | train | def fixture
pwd = FileUtils.pwd
path = File.expand_path(File.join(pwd, "spec/.fixtures/#{rand(99999)}"))
FileUtils.mkdir_p(path)
FileUtils.cd(path)
| ruby | {
"resource": ""
} |
q1035 | PryTheme.RGB.to_term | train | def to_term(color_model = 256)
term = case color_model
when 256 then PryTheme::RGB::TABLE.index(@value)
when 16 then PryTheme::RGB::SYSTEM.index(@value)
when 8 then PryTheme::RGB::LINUX.index(@value)
else raise ArgumentError,
| ruby | {
"resource": ""
} |
q1036 | PryTheme.RGB.validate_array | train | def validate_array(ary)
correct_size = ary.size.equal?(3)
correct_vals = ary.all?{ |val| val.is_a?(Integer) && val.between?(0, 255) }
return true if correct_size && correct_vals
| ruby | {
"resource": ""
} |
q1037 | PryTheme.RGB.nearest_term_256 | train | def nearest_term_256(byte)
for i in 0..4
lower, upper = BYTEPOINTS_256[i], BYTEPOINTS_256[i + 1]
next unless byte.between?(lower, upper)
distance_from_lower = (lower - byte).abs
| ruby | {
"resource": ""
} |
q1038 | PryTheme.RGB.find_among_term_colors | train | def find_among_term_colors(term, color_model)
rgb = @value.map { |byte| nearest_term_256(byte) }
term | ruby | {
"resource": ""
} |
q1039 | PryTheme.RGB.approximate | train | def approximate(term, color_model)
needs_approximation = (term > color_model - 1)
if needs_approximation
case color_model
| ruby | {
"resource": ""
} |
q1040 | Sinatra.SwaggerExposer.endpoint_parameter | train | def endpoint_parameter(name, description, how_to_pass, required, type, params = {})
parameters = settings.swagger_current_endpoint_parameters
check_if_not_duplicate(name, parameters, 'Parameter')
parameters[name] = Sinatra::SwaggerExposer::Configuration::SwaggerEndpointParameter.new(
| ruby | {
"resource": ""
} |
q1041 | Sinatra.SwaggerExposer.endpoint | train | def endpoint(params)
params.each_pair do |param_name, param_value|
case param_name
when :summary
endpoint_summary param_value
when :description
endpoint_description param_value
when :tags
endpoint_tags *param_value
when :produces
endpoint_produces *param_value
when :path
endpoint_path param_value
when :parameters
param_value.each do |param, args_param|
endpoint_parameter param, *args_param
| ruby | {
"resource": ""
} |
q1042 | Sinatra.SwaggerExposer.response_header | train | def response_header(name, type, description)
settings.swagger_response_headers.add_r | ruby | {
"resource": ""
} |
q1043 | Sinatra.SwaggerExposer.endpoint_response | train | def endpoint_response(code, type = nil, description = nil, headers = [])
responses = settings.swagger_current_endpoint_responses
check_if_not_duplicate(code, responses, 'Response')
responses[code] = Sinatra::SwaggerExposer::Configuration::SwaggerEndpointResponse.new(
| ruby | {
"resource": ""
} |
q1044 | Sinatra.SwaggerExposer.route | train | def route(verb, path, options = {}, &block)
no_swagger = options[:no_swagger]
options.delete(:no_swagger)
if (verb == 'HEAD') || no_swagger
super(verb, path, options, &block)
else
request_processor = create_request_processor(verb.downcase, path, options)
super(verb, path, options) do |*params|
response = catch(:halt) do
request_processor.run(self, params, &block)
end
if settings.result_validation
begin
# Inspired from Sinatra#invoke
if (Fixnum === response) or (String === response)
response = [response]
end
| ruby | {
"resource": ""
} |
q1045 | Sinatra.SwaggerExposer.create_request_processor | train | def create_request_processor(type, path, opts)
current_endpoint_info = settings.swagger_current_endpoint_info
current_endpoint_parameters = settings.swagger_current_endpoint_parameters
current_endpoint_responses = settings.swagger_current_endpoint_responses
endpoint = Sinatra::SwaggerExposer::Configuration::SwaggerEndpoint.new(
type,
| ruby | {
"resource": ""
} |
q1046 | Sinatra.SwaggerExposer.check_if_not_duplicate | train | def check_if_not_duplicate(key, values, name)
if values.key? key
raise SwaggerInvalidException.new("#{name} already | ruby | {
"resource": ""
} |
q1047 | PryTheme.HEX.validate_value | train | def validate_value(value)
unless value.is_a?(String)
raise TypeError, "can't convert #{ value.class } into PryTheme::HEX"
end
if value !~ PryTheme::HEX::PATTERN | ruby | {
"resource": ""
} |
q1048 | PryTheme.WhenStartedHook.recreate_user_themes_from_default_ones | train | def recreate_user_themes_from_default_ones
FileUtils.mkdir_p(USER_THEMES_DIR) unless File.exist?(USER_THEMES_DIR)
default_themes = Dir.entries(DEF_THEMES_DIR) - %w(. ..)
| ruby | {
"resource": ""
} |
q1049 | Bond.Rc.files | train | def files(input)
(::Readline::FILENAME_COMPLETION_PROC.call(input) || []).map {|f|
| ruby | {
"resource": ""
} |
q1050 | Bond.Rc.objects_of | train | def objects_of(klass)
object = []
ObjectSpace.each_object(klass) | ruby | {
"resource": ""
} |
q1051 | Bond.Mission.call_search | train | def call_search(search, input, list)
Rc.send("#{search}_search", input || '', list)
rescue
message = $!.is_a?(NoMethodError) && !Rc.respond_to?("#{search}_search") ?
"Completion search '#{search}' doesn't exist." :
| ruby | {
"resource": ""
} |
q1052 | Bond.Mission.call_action | train | def call_action(input)
@action.respond_to?(:call) ? @action.call(input) : Rc.send(@action, input)
rescue StandardError, SyntaxError
message = $!.is_a?(NoMethodError) && !@action.respond_to?(:call) &&
!Rc.respond_to?(@action) ? "Completion action '#{@action}' doesn't exist." | ruby | {
"resource": ""
} |
q1053 | MagicCloud.Spriter.ensure_position | train | def ensure_position(rect)
# no place in current row -> go to next row
if cur_x + rect.width > canvas.width
@cur_x = 0
@cur_y += row_height
@row_height = 0
end
| ruby | {
"resource": ""
} |
q1054 | NBayes.Data.remove_token_from_category | train | def remove_token_from_category(category, token)
cat_data(category)[:tokens][token] -= 1
delete_token_from_category(category, token) if cat_data(category)[:tokens][token] < 1
| ruby | {
"resource": ""
} |
q1055 | NBayes.Base.load | train | def load(yml)
if yml.nil?
nbayes = NBayes::Base.new
elsif yml[0..2] == "---"
nbayes = self.class.from_yml(yml)
| ruby | {
"resource": ""
} |
q1056 | Bond.Agent.complete | train | def complete(options={}, &block)
if (mission = create_mission(options, &block)).is_a?(Mission)
mission.place.is_a?(Integer) ? @missions.insert(mission.place - 1, | ruby | {
"resource": ""
} |
q1057 | Bond.Agent.recomplete | train | def recomplete(options={}, &block)
if (mission = create_mission(options, &block)).is_a?(Mission)
if (existing_mission = @missions.find {|e| e.name == mission.name })
@missions[@missions.index(existing_mission)] = mission
| ruby | {
"resource": ""
} |
q1058 | Bond.Agent.spy | train | def spy(input)
if (mission = find_mission(input))
puts mission.match_message, "Possible completions: #{mission.execute.inspect}",
"Matches for #{mission.condition.inspect} are #{mission.matched.to_a.inspect}"
else
puts "Doesn't match a completion."
end
rescue FailedMissionError => | ruby | {
"resource": ""
} |
q1059 | Bond.M.debrief | train | def debrief(options={})
config.merge! options
config[:readline] ||= default_readline
if !config[:readline].is_a?(Module) &&
Bond.const_defined?(config[:readline].to_s.capitalize)
config[:readline] = Bond.const_get(config[:readline].to_s.capitalize)
end | ruby | {
"resource": ""
} |
q1060 | Bond.M.find_gem_file | train | def find_gem_file(rubygem, file)
begin gem(rubygem); rescue Exception; end
(dir = | ruby | {
"resource": ""
} |
q1061 | Bond.M.load_file | train | def load_file(file)
Rc.module_eval File.read(file)
rescue Exception => e
$stderr.puts | ruby | {
"resource": ""
} |
q1062 | Bond.M.load_dir | train | def load_dir(base_dir)
if File.exist?(dir = File.join(base_dir, 'completions'))
| ruby | {
"resource": ""
} |
q1063 | Bond.M.home | train | def home
['HOME', 'USERPROFILE'].each {|e| return ENV[e] if ENV[e] }
return "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}" if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
| ruby | {
"resource": ""
} |
q1064 | NessusREST.Client.user_add | train | def user_add(username, password, permissions, type)
payload = {
:username => username,
:password => password, | ruby | {
"resource": ""
} |
q1065 | NessusREST.Client.user_chpasswd | train | def user_chpasswd(user_id, password)
payload = {
:password => password,
:json => 1
}
res = | ruby | {
"resource": ""
} |
q1066 | NessusREST.Client.http_delete | train | def http_delete(opts={})
ret=http_delete_low(opts)
if ret.is_a?(Hash) and ret.has_key?('error') | ruby | {
"resource": ""
} |
q1067 | NessusREST.Client.http_get | train | def http_get(opts={})
raw_content = opts[:raw_content] || false
ret=http_get_low(opts)
if !raw_content then
if ret.is_a?(Hash) and ret.has_key?('error') and ret['error']=='Invalid Credentials' then
authdefault
| ruby | {
"resource": ""
} |
q1068 | NessusREST.Client.http_post | train | def http_post(opts={})
if opts.has_key?(:authenticationmethod) then
# i know authzmethod = opts.delete(:authorizationmethod) is short, but not readable
authzmethod = opts[:authenticationmethod]
| ruby | {
"resource": ""
} |
q1069 | NessusREST.Client.parse_json | train | def parse_json(body)
buf = {}
begin
buf = JSON.parse(body)
| ruby | {
"resource": ""
} |
q1070 | OAuth2Client.UrlHelper.build_url | train | def build_url(uri, opts={})
path = opts[:path] || ''
query = opts[:params] || {}
fragment = opts[:fragment] || {}
url = Addressable::URI.parse uri
url.path = path
| ruby | {
"resource": ""
} |
q1071 | OAuth2Client.UrlHelper.generate_urlsafe_key | train | def generate_urlsafe_key(size=48)
seed = Time.now.to_i
size = size - seed.to_s.length
Base64.encode64("#{ | ruby | {
"resource": ""
} |
q1072 | OAuth2Client.UrlHelper.to_query | train | def to_query(params)
unless params.is_a?(Hash)
raise "Expected Hash but got #{params.class.name}"
| ruby | {
"resource": ""
} |
q1073 | OData.Entity.[] | train | def [](property_name)
if get_property(property_name).is_a?(::OData::ComplexType)
get_property(property_name)
else
get_property(property_name).value
| ruby | {
"resource": ""
} |
q1074 | OData.Entity.[]= | train | def []=(property_name, value)
properties[property_name.to_s].value = | ruby | {
"resource": ""
} |
q1075 | OData.Entity.to_xml | train | def to_xml
builder = Nokogiri::XML::Builder.new do |xml|
xml.entry('xmlns' => 'http://www.w3.org/2005/Atom',
'xmlns:data' => 'http://schemas.microsoft.com/ado/2007/08/dataservices',
'xmlns:metadata' => 'http://schemas.microsoft.com/ado/2007/08/dataservices/metadata',
'xmlns:georss' => 'http://www.georss.org/georss',
'xmlns:gml' => 'http://www.opengis.net/gml',
'xml:base' => 'http://services.odata.org/OData/OData.svc/') do
xml.category(term: "#{namespace}.#{type}",
scheme: | ruby | {
"resource": ""
} |
q1076 | OData.ServiceRegistry.add | train | def add(service)
initialize_instance_variables
@services << service if service.is_a?(OData::Service) && !@services.include?(service) | ruby | {
"resource": ""
} |
q1077 | OData.Service.entity_sets | train | def entity_sets
@entity_sets ||= Hash[metadata.xpath('//EntityContainer/EntitySet').collect {|entity|
[
| ruby | {
"resource": ""
} |
q1078 | OData.Service.associations | train | def associations
@associations ||= Hash[metadata.xpath('//Association').collect do |association_definition|
[
| ruby | {
"resource": ""
} |
q1079 | OData.Service.execute | train | def execute(url_chunk, additional_options = {})
request = ::Typhoeus::Request.new(
URI.escape("#{service_url}/#{url_chunk}"),
options[:typhoeus].merge({ method: :get
| ruby | {
"resource": ""
} |
q1080 | OData.Service.find_node | train | def find_node(results, node_name)
document = ::Nokogiri::XML(results.body)
document.remove_namespaces!
| ruby | {
"resource": ""
} |
q1081 | OData.Service.find_entities | train | def find_entities(results)
document = ::Nokogiri::XML(results.body)
| ruby | {
"resource": ""
} |
q1082 | OData.Service.get_title_property_name | train | def get_title_property_name(entity_name)
node = metadata.xpath("//EntityType[@Name='#{ | ruby | {
"resource": ""
} |
q1083 | OData.Service.properties_for_entity | train | def properties_for_entity(entity_name)
type_definition = metadata.xpath("//EntityType[@Name='#{entity_name}']").first
raise ArgumentError, "Unknown EntityType: #{entity_name}" if type_definition.nil?
properties_to_return = {}
type_definition.xpath('./Property').each do |property_xml| | ruby | {
"resource": ""
} |
q1084 | OData.Service.properties_for_complex_type | train | def properties_for_complex_type(type_name)
type_definition = metadata.xpath("//ComplexType[@Name='#{type_name}']").first
raise ArgumentError, "Unknown ComplexType: #{type_name}" if type_definition.nil?
properties_to_return = {}
type_definition.xpath('./Property').each do |property_xml| | ruby | {
"resource": ""
} |
q1085 | OData.EntitySet.each | train | def each(&block)
per_page = @each_batch_size
page = 0
loop do
entities = get_paginated_entities(per_page, page)
| ruby | {
"resource": ""
} |
q1086 | OData.EntitySet.first | train | def first(count = 1)
query = OData::Query.new(self).limit(count)
result = service.execute(query)
entities = service.find_entities(result)
res = count | ruby | {
"resource": ""
} |
q1087 | OData.EntitySet.[] | train | def [](key)
entity = new_entity
key_property = entity.get_property(entity.primary_key)
key_property.value = key
result = service.execute("#{name}(#{key_property.url_value})")
| ruby | {
"resource": ""
} |
q1088 | NumbersInWords.NumberGroup.groups | train | def groups size
#1234567 => %w(765 432 1)
@array = in_groups_of(@number.to_s.reverse.split(""), size)
#%w(765 432 1) => %w(1 432 765)
@array.reverse!
#%w(1 432 765) => [1, 234, 567]
@array.map! {|group| group.reverse.join("").to_i}
@array.reverse! # put in ascending order of power of ten
power = 0 | ruby | {
"resource": ""
} |
q1089 | OData.Query.[] | train | def [](property)
property_instance = @entity_set.new_entity.get_property(property)
| ruby | {
"resource": ""
} |
q1090 | OData.Query.execute | train | def execute
response = entity_set.service.execute(self.to_s)
| ruby | {
"resource": ""
} |
q1091 | Retrospec::Puppet::Generators.ProviderGenerator.template_dir | train | def template_dir
external_templates = File.expand_path(File.join(config_data[:template_dir], 'providers', 'provider_template.rb.retrospec.erb'))
if File.exist?(external_templates)
File.join(config_data[:template_dir], 'providers')
| ruby | {
"resource": ""
} |
q1092 | Retrospec::Puppet::Generators.ProviderGenerator.type_file | train | def type_file(p_type = provider_type)
if TypeGenerator::CORE_TYPES.include?(p_type)
type_file = "puppet/type/#{p_type}.rb"
else
| ruby | {
"resource": ""
} |
q1093 | Utilities.PuppetModule.create_tmp_module_path | train | def create_tmp_module_path(module_path)
fail 'ModulePathNotFound' unless module_path
path = File.join(tmp_modules_dir, module_dir_name)
unless File.exist?(path) # only create if it doesn't already exist
# | ruby | {
"resource": ""
} |
q1094 | Utilities.PuppetModule.tmp_modules_dir | train | def tmp_modules_dir
if @tmp_modules_dir.nil? || !File.exist?(@tmp_modules_dir)
tmp_path = File.expand_path(File.join(temporary_environment_path, 'modules'))
| ruby | {
"resource": ""
} |
q1095 | Utilities.PuppetModule.request | train | def request(key, method)
instance = ::Puppet::Indirector::Indirection.instance(:resource_type)
indirection_name = 'test'
@request | ruby | {
"resource": ""
} |
q1096 | Stemcell.Launcher.render_template | train | def render_template(opts={})
template_file_path = File.expand_path(TEMPLATE_PATH, __FILE__)
template_file = File.read(template_file_path)
erb_template = ERB.new(template_file)
last_bootstrap_line = LAST_BOOTSTRAP_LINE
generated_template | ruby | {
"resource": ""
} |
q1097 | Stemcell.Launcher.get_vpc_security_group_ids | train | def get_vpc_security_group_ids(vpc_id, group_names)
group_map = {}
@log.info "resolving security groups #{group_names} in #{vpc_id}"
vpc = AWS::EC2::VPC.new(vpc_id, :ec2_endpoint => "ec2.#{@region}.amazonaws.com")
vpc.security_groups.each do |sg|
next if sg.vpc_id != vpc_id
group_map[sg.name] = sg.group_id
end
| ruby | {
"resource": ""
} |
q1098 | Rubyipmi.BaseCommand.runcmd | train | def runcmd
@success = false
@success = run
logger.debug(@lastcall.inspect) unless @lastcall.nil? if logger
| ruby | {
"resource": ""
} |
q1099 | Rubyipmi.BaseCommand.find_fix | train | def find_fix(result)
return unless result
# The errorcode code hash contains the fix
begin
fix = ErrorCodes.search(result)
@options.merge_notify!(fix)
rescue
| ruby | {
"resource": ""
} |