repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
PixarAnimationStudios/ruby-jss | lib/jss/api_connection.rb | JSS.APIConnection.get_rsrc | def get_rsrc(rsrc, format = :json)
# puts object_id
validate_connected
raise JSS::InvalidDataError, 'format must be :json or :xml' unless %i[json xml].include? format
# TODO: fix what rubocop is complaining about in the line below.
# (I doubt we want to CGI.escape the whole resource)
... | ruby | def get_rsrc(rsrc, format = :json)
# puts object_id
validate_connected
raise JSS::InvalidDataError, 'format must be :json or :xml' unless %i[json xml].include? format
# TODO: fix what rubocop is complaining about in the line below.
# (I doubt we want to CGI.escape the whole resource)
... | [
"def",
"get_rsrc",
"(",
"rsrc",
",",
"format",
"=",
":json",
")",
"# puts object_id",
"validate_connected",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'format must be :json or :xml'",
"unless",
"%i[",
"json",
"xml",
"]",
".",
"include?",
"format",
"# TODO: fix ... | disconnect
Get an arbitrary JSS resource
The first argument is the resource to get (the part of the API url
after the 'JSSResource/' )
By default we get the data in JSON, and parse it
into a ruby data structure (arrays, hashes, strings, etc)
with symbolized Hash keys.
@param rsrc[String] the resource to get
... | [
"disconnect",
"Get",
"an",
"arbitrary",
"JSS",
"resource"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L525-L542 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_connection.rb | JSS.APIConnection.put_rsrc | def put_rsrc(rsrc, xml)
validate_connected
# convert CRs & to
xml.gsub!(/\r/, ' ')
# send the data
@last_http_response = @cnx[rsrc].put(xml, content_type: 'text/xml')
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end | ruby | def put_rsrc(rsrc, xml)
validate_connected
# convert CRs & to
xml.gsub!(/\r/, ' ')
# send the data
@last_http_response = @cnx[rsrc].put(xml, content_type: 'text/xml')
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end | [
"def",
"put_rsrc",
"(",
"rsrc",
",",
"xml",
")",
"validate_connected",
"# convert CRs & to ",
"xml",
".",
"gsub!",
"(",
"/",
"\\r",
"/",
",",
"' '",
")",
"# send the data",
"@last_http_response",
"=",
"@cnx",
"[",
"rsrc",
"]",
".",
"put",
"(",
"xml"... | Change an existing JSS resource
@param rsrc[String] the API resource being changed, the URL part after 'JSSResource/'
@param xml[String] the xml specifying the changes.
@return [String] the xml response from the server. | [
"Change",
"an",
"existing",
"JSS",
"resource"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L552-L562 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_connection.rb | JSS.APIConnection.post_rsrc | def post_rsrc(rsrc, xml = '')
validate_connected
# convert CRs & to
xml.gsub!(/\r/, ' ') if xml
# send the data
@last_http_response = @cnx[rsrc].post xml, content_type: 'text/xml', accept: :json
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end | ruby | def post_rsrc(rsrc, xml = '')
validate_connected
# convert CRs & to
xml.gsub!(/\r/, ' ') if xml
# send the data
@last_http_response = @cnx[rsrc].post xml, content_type: 'text/xml', accept: :json
rescue RestClient::ExceptionWithResponse => e
handle_http_error e
end | [
"def",
"post_rsrc",
"(",
"rsrc",
",",
"xml",
"=",
"''",
")",
"validate_connected",
"# convert CRs & to ",
"xml",
".",
"gsub!",
"(",
"/",
"\\r",
"/",
",",
"' '",
")",
"if",
"xml",
"# send the data",
"@last_http_response",
"=",
"@cnx",
"[",
"rsrc",
"]... | Create a new JSS resource
@param rsrc[String] the API resource being created, the URL part after 'JSSResource/'
@param xml[String] the xml specifying the new object.
@return [String] the xml response from the server. | [
"Create",
"a",
"new",
"JSS",
"resource"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L572-L582 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_connection.rb | JSS.APIConnection.delete_rsrc | def delete_rsrc(rsrc, xml = nil)
validate_connected
raise MissingDataError, 'Missing :rsrc' if rsrc.nil?
# payload?
return delete_with_payload rsrc, xml if xml
# delete the resource
@last_http_response = @cnx[rsrc].delete
rescue RestClient::ExceptionWithResponse => e
hand... | ruby | def delete_rsrc(rsrc, xml = nil)
validate_connected
raise MissingDataError, 'Missing :rsrc' if rsrc.nil?
# payload?
return delete_with_payload rsrc, xml if xml
# delete the resource
@last_http_response = @cnx[rsrc].delete
rescue RestClient::ExceptionWithResponse => e
hand... | [
"def",
"delete_rsrc",
"(",
"rsrc",
",",
"xml",
"=",
"nil",
")",
"validate_connected",
"raise",
"MissingDataError",
",",
"'Missing :rsrc'",
"if",
"rsrc",
".",
"nil?",
"# payload?",
"return",
"delete_with_payload",
"rsrc",
",",
"xml",
"if",
"xml",
"# delete the reso... | post_rsrc
Delete a resource from the JSS
@param rsrc[String] the resource to create, the URL part after 'JSSResource/'
@return [String] the xml response from the server. | [
"post_rsrc",
"Delete",
"a",
"resource",
"from",
"the",
"JSS"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L590-L601 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_connection.rb | JSS.APIConnection.master_distribution_point | def master_distribution_point(refresh = false)
@master_distribution_point = nil if refresh
return @master_distribution_point if @master_distribution_point
all_dps = JSS::DistributionPoint.all refresh, api: self
@master_distribution_point =
case all_dps.size
when 0
rai... | ruby | def master_distribution_point(refresh = false)
@master_distribution_point = nil if refresh
return @master_distribution_point if @master_distribution_point
all_dps = JSS::DistributionPoint.all refresh, api: self
@master_distribution_point =
case all_dps.size
when 0
rai... | [
"def",
"master_distribution_point",
"(",
"refresh",
"=",
"false",
")",
"@master_distribution_point",
"=",
"nil",
"if",
"refresh",
"return",
"@master_distribution_point",
"if",
"@master_distribution_point",
"all_dps",
"=",
"JSS",
"::",
"DistributionPoint",
".",
"all",
"r... | Get the DistributionPoint instance for the master
distribution point in the JSS. If there's only one
in the JSS, return it even if not marked as master.
@param refresh[Boolean] re-read from the API?
@return [JSS::DistributionPoint] | [
"Get",
"the",
"DistributionPoint",
"instance",
"for",
"the",
"master",
"distribution",
"point",
"in",
"the",
"JSS",
".",
"If",
"there",
"s",
"only",
"one",
"in",
"the",
"JSS",
"return",
"it",
"even",
"if",
"not",
"marked",
"as",
"master",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L831-L846 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_connection.rb | JSS.APIConnection.my_distribution_point | def my_distribution_point(refresh = false)
@my_distribution_point = nil if refresh
return @my_distribution_point if @my_distribution_point
my_net_seg = my_network_segments[0]
@my_distribution_point = JSS::NetworkSegment.fetch(id: my_net_seg, api: self).distribution_point if my_net_seg
@my... | ruby | def my_distribution_point(refresh = false)
@my_distribution_point = nil if refresh
return @my_distribution_point if @my_distribution_point
my_net_seg = my_network_segments[0]
@my_distribution_point = JSS::NetworkSegment.fetch(id: my_net_seg, api: self).distribution_point if my_net_seg
@my... | [
"def",
"my_distribution_point",
"(",
"refresh",
"=",
"false",
")",
"@my_distribution_point",
"=",
"nil",
"if",
"refresh",
"return",
"@my_distribution_point",
"if",
"@my_distribution_point",
"my_net_seg",
"=",
"my_network_segments",
"[",
"0",
"]",
"@my_distribution_point",... | Get the DistributionPoint instance for the machine running
this code, based on its IP address. If none is defined for this IP address,
use the result of master_distribution_point
@param refresh[Boolean] should the distribution point be re-queried?
@return [JSS::DistributionPoint] | [
"Get",
"the",
"DistributionPoint",
"instance",
"for",
"the",
"machine",
"running",
"this",
"code",
"based",
"on",
"its",
"IP",
"address",
".",
"If",
"none",
"is",
"defined",
"for",
"this",
"IP",
"address",
"use",
"the",
"result",
"of",
"master_distribution_poi... | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L856-L864 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_connection.rb | JSS.APIConnection.network_segments_for_ip | def network_segments_for_ip(ip)
ok_ip = IPAddr.new(ip)
matches = []
network_ranges.each { |id, subnet| matches << id if subnet.include?(ok_ip) }
matches
end | ruby | def network_segments_for_ip(ip)
ok_ip = IPAddr.new(ip)
matches = []
network_ranges.each { |id, subnet| matches << id if subnet.include?(ok_ip) }
matches
end | [
"def",
"network_segments_for_ip",
"(",
"ip",
")",
"ok_ip",
"=",
"IPAddr",
".",
"new",
"(",
"ip",
")",
"matches",
"=",
"[",
"]",
"network_ranges",
".",
"each",
"{",
"|",
"id",
",",
"subnet",
"|",
"matches",
"<<",
"id",
"if",
"subnet",
".",
"include?",
... | def network_segments
Find the ids of the network segments that contain a given IP address.
Even tho IPAddr.include? will take a String or an IPAddr
I convert the ip to an IPAddr so that an exception will be raised if
the ip isn't a valid ip.
@param ip[String, IPAddr] the IP address to locate
@param refresh[Boo... | [
"def",
"network_segments",
"Find",
"the",
"ids",
"of",
"the",
"network",
"segments",
"that",
"contain",
"a",
"given",
"IP",
"address",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L899-L904 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_connection.rb | JSS.APIConnection.send_mobiledevice_mdm_command | def send_mobiledevice_mdm_command(targets, command, data = {})
JSS::MobileDevice.send_mdm_command(targets, command, opts: data, api: self)
end | ruby | def send_mobiledevice_mdm_command(targets, command, data = {})
JSS::MobileDevice.send_mdm_command(targets, command, opts: data, api: self)
end | [
"def",
"send_mobiledevice_mdm_command",
"(",
"targets",
",",
"command",
",",
"data",
"=",
"{",
"}",
")",
"JSS",
"::",
"MobileDevice",
".",
"send_mdm_command",
"(",
"targets",
",",
"command",
",",
"opts",
":",
"data",
",",
"api",
":",
"self",
")",
"end"
] | Send an MDM command to one or more mobile devices managed by
this JSS
see {JSS::MobileDevice.send_mdm_command}
@deprecated Please use JSS::MobileDevice.send_mdm_command or its
convenience methods. @see JSS::MDM | [
"Send",
"an",
"MDM",
"command",
"to",
"one",
"or",
"more",
"mobile",
"devices",
"managed",
"by",
"this",
"JSS"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L922-L924 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_connection.rb | JSS.APIConnection.verify_basic_args | def verify_basic_args(args)
# must have server, user, and pw
raise JSS::MissingDataError, 'No JSS :server specified, or in configuration.' unless args[:server]
raise JSS::MissingDataError, 'No JSS :user specified, or in configuration.' unless args[:user]
raise JSS::MissingDataError, "Missing :pw... | ruby | def verify_basic_args(args)
# must have server, user, and pw
raise JSS::MissingDataError, 'No JSS :server specified, or in configuration.' unless args[:server]
raise JSS::MissingDataError, 'No JSS :user specified, or in configuration.' unless args[:user]
raise JSS::MissingDataError, "Missing :pw... | [
"def",
"verify_basic_args",
"(",
"args",
")",
"# must have server, user, and pw",
"raise",
"JSS",
"::",
"MissingDataError",
",",
"'No JSS :server specified, or in configuration.'",
"unless",
"args",
"[",
":server",
"]",
"raise",
"JSS",
"::",
"MissingDataError",
",",
"'No ... | Raise execeptions if we don't have essential data for the connection
@param args[Hash] The args for #connect
@return [void] | [
"Raise",
"execeptions",
"if",
"we",
"don",
"t",
"have",
"essential",
"data",
"for",
"the",
"connection"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L1024-L1029 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_connection.rb | JSS.APIConnection.verify_server_version | def verify_server_version
@connected = true
# the jssuser resource is readable by anyone with a JSS acct
# regardless of their permissions.
# However, it's marked as 'deprecated'. Hopefully jamf will
# keep this basic level of info available for basic authentication
# and JSS versio... | ruby | def verify_server_version
@connected = true
# the jssuser resource is readable by anyone with a JSS acct
# regardless of their permissions.
# However, it's marked as 'deprecated'. Hopefully jamf will
# keep this basic level of info available for basic authentication
# and JSS versio... | [
"def",
"verify_server_version",
"@connected",
"=",
"true",
"# the jssuser resource is readable by anyone with a JSS acct",
"# regardless of their permissions.",
"# However, it's marked as 'deprecated'. Hopefully jamf will",
"# keep this basic level of info available for basic authentication",
"# a... | Verify that we can connect with the args provided, and that
the server version is high enough for this version of ruby-jss.
This makes the first API GET call and will raise an exception if things
are wrong, like failed authentication. Will also raise an exception
if the JSS version is too low
(see also JSS::Serve... | [
"Verify",
"that",
"we",
"can",
"connect",
"with",
"the",
"args",
"provided",
"and",
"that",
"the",
"server",
"version",
"is",
"high",
"enough",
"for",
"this",
"version",
"of",
"ruby",
"-",
"jss",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L1041-L1061 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_connection.rb | JSS.APIConnection.build_rest_url | def build_rest_url(args)
@server_host = args[:server]
@port = args[:port].to_i
if args[:server_path]
# remove leading & trailing slashes in serverpath if any
@server_path = args[:server_path].sub %r{^/*(.*?)/*$}, Regexp.last_match(1)
# re-add single trailing slash
@ser... | ruby | def build_rest_url(args)
@server_host = args[:server]
@port = args[:port].to_i
if args[:server_path]
# remove leading & trailing slashes in serverpath if any
@server_path = args[:server_path].sub %r{^/*(.*?)/*$}, Regexp.last_match(1)
# re-add single trailing slash
@ser... | [
"def",
"build_rest_url",
"(",
"args",
")",
"@server_host",
"=",
"args",
"[",
":server",
"]",
"@port",
"=",
"args",
"[",
":port",
"]",
".",
"to_i",
"if",
"args",
"[",
":server_path",
"]",
"# remove leading & trailing slashes in serverpath if any",
"@server_path",
"... | Build the base URL for the API connection
@param args[Hash] The args for #connect
@return [String] The URI encoded URL | [
"Build",
"the",
"base",
"URL",
"for",
"the",
"API",
"connection"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_connection.rb#L1069-L1090 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/sitable.rb | JSS.Sitable.site= | def site=(new_site)
return nil unless updatable? || creatable?
# unset the site? Use nil or an empty string
if NON_SITES.include? new_site
unset_site
return
end
new_id = JSS::Site.valid_id new_site, api: @api
new_name = JSS::Site.map_all_ids_to(:name, api: @api)[new... | ruby | def site=(new_site)
return nil unless updatable? || creatable?
# unset the site? Use nil or an empty string
if NON_SITES.include? new_site
unset_site
return
end
new_id = JSS::Site.valid_id new_site, api: @api
new_name = JSS::Site.map_all_ids_to(:name, api: @api)[new... | [
"def",
"site",
"=",
"(",
"new_site",
")",
"return",
"nil",
"unless",
"updatable?",
"||",
"creatable?",
"# unset the site? Use nil or an empty string",
"if",
"NON_SITES",
".",
"include?",
"new_site",
"unset_site",
"return",
"end",
"new_id",
"=",
"JSS",
"::",
"Site",
... | cat assigned?
Change the site of this object.
Any of the NON_SITES values will
unset the site
@param new_site[Integer, String] The new site
@return [void] | [
"cat",
"assigned?",
"Change",
"the",
"site",
"of",
"this",
"object",
".",
"Any",
"of",
"the",
"NON_SITES",
"values",
"will",
"unset",
"the",
"site"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/sitable.rb#L120-L139 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/sitable.rb | JSS.Sitable.parse_site | def parse_site
site_data =
if self.class::SITE_SUBSET == :top
@init_data[:site]
elsif @init_data[self.class::SITE_SUBSET]
@init_data[self.class::SITE_SUBSET][:site]
end
site_data ||= { name: NO_SITE_NAME, id: NO_SITE_ID }
@site_name = site_data[:name]
... | ruby | def parse_site
site_data =
if self.class::SITE_SUBSET == :top
@init_data[:site]
elsif @init_data[self.class::SITE_SUBSET]
@init_data[self.class::SITE_SUBSET][:site]
end
site_data ||= { name: NO_SITE_NAME, id: NO_SITE_ID }
@site_name = site_data[:name]
... | [
"def",
"parse_site",
"site_data",
"=",
"if",
"self",
".",
"class",
"::",
"SITE_SUBSET",
"==",
":top",
"@init_data",
"[",
":site",
"]",
"elsif",
"@init_data",
"[",
"self",
".",
"class",
"::",
"SITE_SUBSET",
"]",
"@init_data",
"[",
"self",
".",
"class",
"::"... | Parse the site data from any incoming API data
@return [void] | [
"Parse",
"the",
"site",
"data",
"from",
"any",
"incoming",
"API",
"data"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/sitable.rb#L161-L172 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/sitable.rb | JSS.Sitable.add_site_to_xml | def add_site_to_xml(xmldoc)
root = xmldoc.root
site_elem =
if self.class::SITE_SUBSET == :top
root.add_element 'site'
else
parent_elem = root.elements[self.class::SITE_SUBSET.to_s]
parent_elem ||= root.add_element(self.class::SITE_SUBSET.to_s)
parent_e... | ruby | def add_site_to_xml(xmldoc)
root = xmldoc.root
site_elem =
if self.class::SITE_SUBSET == :top
root.add_element 'site'
else
parent_elem = root.elements[self.class::SITE_SUBSET.to_s]
parent_elem ||= root.add_element(self.class::SITE_SUBSET.to_s)
parent_e... | [
"def",
"add_site_to_xml",
"(",
"xmldoc",
")",
"root",
"=",
"xmldoc",
".",
"root",
"site_elem",
"=",
"if",
"self",
".",
"class",
"::",
"SITE_SUBSET",
"==",
":top",
"root",
".",
"add_element",
"'site'",
"else",
"parent_elem",
"=",
"root",
".",
"elements",
"[... | parse site
Add the site to the XML for POSTing or PUTting to the API.
@param xmldoc[REXML::Document] The in-construction XML document
@return [void] | [
"parse",
"site",
"Add",
"the",
"site",
"to",
"the",
"XML",
"for",
"POSTing",
"or",
"PUTting",
"to",
"the",
"API",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/sitable.rb#L180-L191 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/peripheral.rb | JSS.Peripheral.associate | def associate(computer)
if computer =~ /^d+$/
raise JSS::NoSuchItemError, "No computer in the JSS with id #{computer}" unless JSS::Computer.all_ids(api: @api).include? computer
@computer_id = computer
else
raise JSS::NoSuchItemError, "No computer in the JSS with name #{computer}" unl... | ruby | def associate(computer)
if computer =~ /^d+$/
raise JSS::NoSuchItemError, "No computer in the JSS with id #{computer}" unless JSS::Computer.all_ids(api: @api).include? computer
@computer_id = computer
else
raise JSS::NoSuchItemError, "No computer in the JSS with name #{computer}" unl... | [
"def",
"associate",
"(",
"computer",
")",
"if",
"computer",
"=~",
"/",
"/",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"\"No computer in the JSS with id #{computer}\"",
"unless",
"JSS",
"::",
"Computer",
".",
"all_ids",
"(",
"api",
":",
"@api",
")",
".",
"i... | Associate this peripheral with a computer.
@param computer[String,Integer] the name or id of a computer in the JSS
@return [void] | [
"Associate",
"this",
"peripheral",
"with",
"a",
"computer",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/peripheral.rb#L233-L242 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/peripheral.rb | JSS.Peripheral.check_field | def check_field(field, value)
### get the field defs for this PeriphType, omitting the leading nil
@field_defs ||= JSS::PeripheralType.fetch(:name => @type, api: @api).fields.compact
### we must have the right number of fields, and they must have the same names
### as the definition
requi... | ruby | def check_field(field, value)
### get the field defs for this PeriphType, omitting the leading nil
@field_defs ||= JSS::PeripheralType.fetch(:name => @type, api: @api).fields.compact
### we must have the right number of fields, and they must have the same names
### as the definition
requi... | [
"def",
"check_field",
"(",
"field",
",",
"value",
")",
"### get the field defs for this PeriphType, omitting the leading nil",
"@field_defs",
"||=",
"JSS",
"::",
"PeripheralType",
".",
"fetch",
"(",
":name",
"=>",
"@type",
",",
"api",
":",
"@api",
")",
".",
"fields"... | check a field, the field name must match those defined in
the appropriate peripheral type.
If a field is a menu field, the value must also be one of those defined
in the periph type.
Raise an exception if wrong. | [
"check",
"a",
"field",
"the",
"field",
"name",
"must",
"match",
"those",
"defined",
"in",
"the",
"appropriate",
"peripheral",
"type",
".",
"If",
"a",
"field",
"is",
"a",
"menu",
"field",
"the",
"value",
"must",
"also",
"be",
"one",
"of",
"those",
"define... | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/peripheral.rb#L270-L286 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/patch_policy.rb | JSS.PatchPolicy.validate_patch_title | def validate_patch_title(a_title)
if a_title.is_a? JSS::PatchTitle
@patch_title = a_title
return a_title.id
end
raise JSS::MissingDataError, ':patch_title is required' unless a_title
title_id = JSS::PatchTitle.valid_id a_title
return title_id if title_id
raise JSS::No... | ruby | def validate_patch_title(a_title)
if a_title.is_a? JSS::PatchTitle
@patch_title = a_title
return a_title.id
end
raise JSS::MissingDataError, ':patch_title is required' unless a_title
title_id = JSS::PatchTitle.valid_id a_title
return title_id if title_id
raise JSS::No... | [
"def",
"validate_patch_title",
"(",
"a_title",
")",
"if",
"a_title",
".",
"is_a?",
"JSS",
"::",
"PatchTitle",
"@patch_title",
"=",
"a_title",
"return",
"a_title",
".",
"id",
"end",
"raise",
"JSS",
"::",
"MissingDataError",
",",
"':patch_title is required'",
"unles... | raise an error if the patch title we're trying to use isn't available in
the jss. If handed a PatchTitle instance, we assume it came from the JSS
@param new_title[String,Integer,JSS::PatchTitle] the title to validate
@return [Integer] the id of the valid title | [
"raise",
"an",
"error",
"if",
"the",
"patch",
"title",
"we",
"re",
"trying",
"to",
"use",
"isn",
"t",
"available",
"in",
"the",
"jss",
".",
"If",
"handed",
"a",
"PatchTitle",
"instance",
"we",
"assume",
"it",
"came",
"from",
"the",
"JSS"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/patch_policy.rb#L543-L552 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/patch_policy.rb | JSS.PatchPolicy.validate_target_version | def validate_target_version(tgt_vers)
raise JSS::MissingDataError, "target_version can't be nil" unless tgt_vers
JSS::Validate.non_empty_string tgt_vers
unless patch_title(:refresh).versions.key? tgt_vers
errmsg = "Version '#{tgt_vers}' does not exist for title: #{patch_title_name}."
... | ruby | def validate_target_version(tgt_vers)
raise JSS::MissingDataError, "target_version can't be nil" unless tgt_vers
JSS::Validate.non_empty_string tgt_vers
unless patch_title(:refresh).versions.key? tgt_vers
errmsg = "Version '#{tgt_vers}' does not exist for title: #{patch_title_name}."
... | [
"def",
"validate_target_version",
"(",
"tgt_vers",
")",
"raise",
"JSS",
"::",
"MissingDataError",
",",
"\"target_version can't be nil\"",
"unless",
"tgt_vers",
"JSS",
"::",
"Validate",
".",
"non_empty_string",
"tgt_vers",
"unless",
"patch_title",
"(",
":refresh",
")",
... | raise an exception if a given target version is not valid for this policy
Otherwise return it | [
"raise",
"an",
"exception",
"if",
"a",
"given",
"target",
"version",
"is",
"not",
"valid",
"for",
"this",
"policy",
"Otherwise",
"return",
"it"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/patch_policy.rb#L557-L571 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/patch_policy.rb | JSS.PatchPolicy.refetch_version_info | def refetch_version_info
tmp = self.class.fetch id: id
@release_date = tmp.release_date
@incremental_update = tmp.incremental_update
@reboot = tmp.reboot
@minimum_os = tmp.minimum_os
@kill_apps = tmp.kill_apps
end | ruby | def refetch_version_info
tmp = self.class.fetch id: id
@release_date = tmp.release_date
@incremental_update = tmp.incremental_update
@reboot = tmp.reboot
@minimum_os = tmp.minimum_os
@kill_apps = tmp.kill_apps
end | [
"def",
"refetch_version_info",
"tmp",
"=",
"self",
".",
"class",
".",
"fetch",
"id",
":",
"id",
"@release_date",
"=",
"tmp",
".",
"release_date",
"@incremental_update",
"=",
"tmp",
".",
"incremental_update",
"@reboot",
"=",
"tmp",
".",
"reboot",
"@minimum_os",
... | Update our local version data after the target_version is changed | [
"Update",
"our",
"local",
"version",
"data",
"after",
"the",
"target_version",
"is",
"changed"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/patch_policy.rb#L579-L586 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/user.rb | JSS.User.add_site | def add_site (site)
return nil if @sites.map{|s| s[:name]}.include? site
raise JSS::InvalidDataError, "No site in the JSS named #{site}" unless JSS::Site.all_names(api: @api).include? site
@sites << {:name => site}
@need_to_update = true
end | ruby | def add_site (site)
return nil if @sites.map{|s| s[:name]}.include? site
raise JSS::InvalidDataError, "No site in the JSS named #{site}" unless JSS::Site.all_names(api: @api).include? site
@sites << {:name => site}
@need_to_update = true
end | [
"def",
"add_site",
"(",
"site",
")",
"return",
"nil",
"if",
"@sites",
".",
"map",
"{",
"|",
"s",
"|",
"s",
"[",
":name",
"]",
"}",
".",
"include?",
"site",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"No site in the JSS named #{site}\"",
"unless",
"JS... | Add this user to a site
@param site[String] the name of the site
@return [void] | [
"Add",
"this",
"user",
"to",
"a",
"site"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/user.rb#L233-L238 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/user.rb | JSS.User.remove_site | def remove_site (site)
return nil unless @sites.map{|s| s[:name]}.include? site
@sites.reject!{|s| s[:name] == site}
@need_to_update = true
end | ruby | def remove_site (site)
return nil unless @sites.map{|s| s[:name]}.include? site
@sites.reject!{|s| s[:name] == site}
@need_to_update = true
end | [
"def",
"remove_site",
"(",
"site",
")",
"return",
"nil",
"unless",
"@sites",
".",
"map",
"{",
"|",
"s",
"|",
"s",
"[",
":name",
"]",
"}",
".",
"include?",
"site",
"@sites",
".",
"reject!",
"{",
"|",
"s",
"|",
"s",
"[",
":name",
"]",
"==",
"site",... | Remove this user from a site
@param site[String] the name of the site
@return [void] | [
"Remove",
"this",
"user",
"from",
"a",
"site"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/user.rb#L247-L251 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/network_segment.rb | JSS.NetworkSegment.overlap? | def overlap?(other_segment)
raise TypeError, 'Argument must be a JSS::NetworkSegment' unless \
other_segment.is_a? JSS::NetworkSegment
other_range = other_segment.range
range.include?(other_range.begin) || range.include?(other_range.end)
end | ruby | def overlap?(other_segment)
raise TypeError, 'Argument must be a JSS::NetworkSegment' unless \
other_segment.is_a? JSS::NetworkSegment
other_range = other_segment.range
range.include?(other_range.begin) || range.include?(other_range.end)
end | [
"def",
"overlap?",
"(",
"other_segment",
")",
"raise",
"TypeError",
",",
"'Argument must be a JSS::NetworkSegment'",
"unless",
"other_segment",
".",
"is_a?",
"JSS",
"::",
"NetworkSegment",
"other_range",
"=",
"other_segment",
".",
"range",
"range",
".",
"include?",
"(... | Does this network segment overlap with another?
@param other_segment[JSS::NetworkSegment] the other segment to check
@return [Boolean] Does the other segment overlap this one? | [
"Does",
"this",
"network",
"segment",
"overlap",
"with",
"another?"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/network_segment.rb#L304-L309 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/network_segment.rb | JSS.NetworkSegment.include? | def include?(thing)
if thing.is_a? JSS::NetworkSegment
@starting_address <= thing.range.begin && @ending_address >= thing.range.end
else
thing = IPAddr.new thing.to_s
range.include? thing
end
end | ruby | def include?(thing)
if thing.is_a? JSS::NetworkSegment
@starting_address <= thing.range.begin && @ending_address >= thing.range.end
else
thing = IPAddr.new thing.to_s
range.include? thing
end
end | [
"def",
"include?",
"(",
"thing",
")",
"if",
"thing",
".",
"is_a?",
"JSS",
"::",
"NetworkSegment",
"@starting_address",
"<=",
"thing",
".",
"range",
".",
"begin",
"&&",
"@ending_address",
">=",
"thing",
".",
"range",
".",
"end",
"else",
"thing",
"=",
"IPAdd... | Does this network segment include an address or another segment?
Inclusion means the other is completely inside this one.
@param thing[JSS::NetworkSegment, String, IPAddr] the other thing to check
@return [Boolean] Does this segment include the other? | [
"Does",
"this",
"network",
"segment",
"include",
"an",
"address",
"or",
"another",
"segment?",
"Inclusion",
"means",
"the",
"other",
"is",
"completely",
"inside",
"this",
"one",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/network_segment.rb#L318-L325 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/network_segment.rb | JSS.NetworkSegment.building= | def building=(newval)
new = JSS::Building.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No building matching '#{newval}'" unless new
@building = new[:name]
@need_to_update = true
end | ruby | def building=(newval)
new = JSS::Building.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No building matching '#{newval}'" unless new
@building = new[:name]
@need_to_update = true
end | [
"def",
"building",
"=",
"(",
"newval",
")",
"new",
"=",
"JSS",
"::",
"Building",
".",
"all",
".",
"select",
"{",
"|",
"b",
"|",
"(",
"b",
"[",
":id",
"]",
"==",
"newval",
")",
"||",
"(",
"b",
"[",
":name",
"]",
"==",
"newval",
")",
"}",
"[",
... | Does this network segment equal another?
equality means the ranges are equal
@param other_segment[JSS::NetworkSegment] the other segment to check
@return [Boolean] Does this segment include the other?
Set the building
@param newval[String, Integer] the new building by name or id, must be in the JSS
@return [... | [
"Does",
"this",
"network",
"segment",
"equal",
"another?",
"equality",
"means",
"the",
"ranges",
"are",
"equal"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/network_segment.rb#L346-L351 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/network_segment.rb | JSS.NetworkSegment.override_buildings= | def override_buildings=(newval)
raise JSS::InvalidDataError, 'New value must be boolean true or false' unless JSS::TRUE_FALSE.include? newval
@override_buildings = newval
@need_to_update = true
end | ruby | def override_buildings=(newval)
raise JSS::InvalidDataError, 'New value must be boolean true or false' unless JSS::TRUE_FALSE.include? newval
@override_buildings = newval
@need_to_update = true
end | [
"def",
"override_buildings",
"=",
"(",
"newval",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'New value must be boolean true or false'",
"unless",
"JSS",
"::",
"TRUE_FALSE",
".",
"include?",
"newval",
"@override_buildings",
"=",
"newval",
"@need_to_update",
"="... | set the override buildings option
@param newval[Boolean] the new override buildings option
@return [void] | [
"set",
"the",
"override",
"buildings",
"option"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/network_segment.rb#L359-L363 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/network_segment.rb | JSS.NetworkSegment.department= | def department=(newval)
new = JSS::Department.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No department matching '#{newval}' in the JSS" unless new
@department = new[:name]
@need_to_update = true
end | ruby | def department=(newval)
new = JSS::Department.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No department matching '#{newval}' in the JSS" unless new
@department = new[:name]
@need_to_update = true
end | [
"def",
"department",
"=",
"(",
"newval",
")",
"new",
"=",
"JSS",
"::",
"Department",
".",
"all",
".",
"select",
"{",
"|",
"b",
"|",
"(",
"b",
"[",
":id",
"]",
"==",
"newval",
")",
"||",
"(",
"b",
"[",
":name",
"]",
"==",
"newval",
")",
"}",
"... | set the department
@param newval[String, Integer] the new dept by name or id, must be in the JSS
@return [void] | [
"set",
"the",
"department"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/network_segment.rb#L371-L376 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/network_segment.rb | JSS.NetworkSegment.override_departments= | def override_departments=(newval)
raise JSS::InvalidDataError, 'New value must be boolean true or false' unless JSS::TRUE_FALSE.include? newval
@override_departments = newval
@need_to_update = true
end | ruby | def override_departments=(newval)
raise JSS::InvalidDataError, 'New value must be boolean true or false' unless JSS::TRUE_FALSE.include? newval
@override_departments = newval
@need_to_update = true
end | [
"def",
"override_departments",
"=",
"(",
"newval",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'New value must be boolean true or false'",
"unless",
"JSS",
"::",
"TRUE_FALSE",
".",
"include?",
"newval",
"@override_departments",
"=",
"newval",
"@need_to_update",
... | set the override depts option
@param newval[Boolean] the new setting
@return [void] | [
"set",
"the",
"override",
"depts",
"option"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/network_segment.rb#L385-L389 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/network_segment.rb | JSS.NetworkSegment.distribution_point= | def distribution_point=(newval)
new = JSS::DistributionPoint.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No distribution_point matching '#{newval}' in the JSS" unless new
@distribution_point = new[:name]
@need_to_update = true
end | ruby | def distribution_point=(newval)
new = JSS::DistributionPoint.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No distribution_point matching '#{newval}' in the JSS" unless new
@distribution_point = new[:name]
@need_to_update = true
end | [
"def",
"distribution_point",
"=",
"(",
"newval",
")",
"new",
"=",
"JSS",
"::",
"DistributionPoint",
".",
"all",
".",
"select",
"{",
"|",
"b",
"|",
"(",
"b",
"[",
":id",
"]",
"==",
"newval",
")",
"||",
"(",
"b",
"[",
":name",
"]",
"==",
"newval",
... | set the distribution_point
@param newval[String, Integer] the new dist. point by name or id, must be in the JSS
@return [void] | [
"set",
"the",
"distribution_point"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/network_segment.rb#L397-L402 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/network_segment.rb | JSS.NetworkSegment.netboot_server= | def netboot_server=(newval)
new = JSS::NetbootServer.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No netboot_server matching '#{newval}' in the JSS" unless new
@netboot_server = new[:name]
@need_to_update = true
end | ruby | def netboot_server=(newval)
new = JSS::NetbootServer.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No netboot_server matching '#{newval}' in the JSS" unless new
@netboot_server = new[:name]
@need_to_update = true
end | [
"def",
"netboot_server",
"=",
"(",
"newval",
")",
"new",
"=",
"JSS",
"::",
"NetbootServer",
".",
"all",
".",
"select",
"{",
"|",
"b",
"|",
"(",
"b",
"[",
":id",
"]",
"==",
"newval",
")",
"||",
"(",
"b",
"[",
":name",
"]",
"==",
"newval",
")",
"... | set the netboot_server
@param newval[String, Integer] the new netboot server by name or id, must be in the JSS
@return [void] | [
"set",
"the",
"netboot_server"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/network_segment.rb#L410-L415 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/network_segment.rb | JSS.NetworkSegment.swu_server= | def swu_server=(newval)
new = JSS::SoftwareUpdateServer.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No swu_server matching '#{newval}' in the JSS" unless new
@swu_server = new[:name]
@need_to_update = true
end | ruby | def swu_server=(newval)
new = JSS::SoftwareUpdateServer.all.select { |b| (b[:id] == newval) || (b[:name] == newval) }[0]
raise JSS::MissingDataError, "No swu_server matching '#{newval}' in the JSS" unless new
@swu_server = new[:name]
@need_to_update = true
end | [
"def",
"swu_server",
"=",
"(",
"newval",
")",
"new",
"=",
"JSS",
"::",
"SoftwareUpdateServer",
".",
"all",
".",
"select",
"{",
"|",
"b",
"|",
"(",
"b",
"[",
":id",
"]",
"==",
"newval",
")",
"||",
"(",
"b",
"[",
":name",
"]",
"==",
"newval",
")",
... | set the sw update server
@param newval[String, Integer] the new server by name or id, must be in the JSS
@return [void] | [
"set",
"the",
"sw",
"update",
"server"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/network_segment.rb#L423-L428 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/network_segment.rb | JSS.NetworkSegment.set_ip_range | def set_ip_range(starting_address: nil, ending_address: nil, mask: nil, cidr: nil)
range = self.class.ip_range(
starting_address: starting_address,
ending_address: ending_address,
mask: mask,
cidr: cidr
)
@starting_address = range.first
@ending_address = range.las... | ruby | def set_ip_range(starting_address: nil, ending_address: nil, mask: nil, cidr: nil)
range = self.class.ip_range(
starting_address: starting_address,
ending_address: ending_address,
mask: mask,
cidr: cidr
)
@starting_address = range.first
@ending_address = range.las... | [
"def",
"set_ip_range",
"(",
"starting_address",
":",
"nil",
",",
"ending_address",
":",
"nil",
",",
"mask",
":",
"nil",
",",
"cidr",
":",
"nil",
")",
"range",
"=",
"self",
".",
"class",
".",
"ip_range",
"(",
"starting_address",
":",
"starting_address",
","... | set a new starting and ending addr at the same time.
@see_also NetworkSegment.ip_range for how to specify the starting
and ending addresses.
@param starting_address[String] The starting address, possibly masked
@param ending_address[String] The ending address
@param mask[String] The subnet mask to apply to the... | [
"set",
"a",
"new",
"starting",
"and",
"ending",
"addr",
"at",
"the",
"same",
"time",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/network_segment.rb#L485-L495 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/script.rb | JSS.Script.name= | def name=(new_val)
return nil if new_val == @name
new_val = nil if new_val == ''
raise JSS::MissingDataError, "Name can't be empty" unless new_val
raise JSS::AlreadyExistsError, "A #{RSRC_OBJECT_KEY} already exists with the name '#{args[:name]}'" if JSS.send(LIST_METHOD).values.include?
#... | ruby | def name=(new_val)
return nil if new_val == @name
new_val = nil if new_val == ''
raise JSS::MissingDataError, "Name can't be empty" unless new_val
raise JSS::AlreadyExistsError, "A #{RSRC_OBJECT_KEY} already exists with the name '#{args[:name]}'" if JSS.send(LIST_METHOD).values.include?
#... | [
"def",
"name",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"new_val",
"==",
"@name",
"new_val",
"=",
"nil",
"if",
"new_val",
"==",
"''",
"raise",
"JSS",
"::",
"MissingDataError",
",",
"\"Name can't be empty\"",
"unless",
"new_val",
"raise",
"JSS",
"::",... | filename=
Change the script's display name
If the filename is the same as the name, the filename will be changed also
@param new_val[String] the new display name
@return [void] | [
"filename",
"=",
"Change",
"the",
"script",
"s",
"display",
"name"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/script.rb#L178-L191 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/script.rb | JSS.Script.os_requirements= | def os_requirements=(new_val)
### nil should be an empty array
new_val = [] if new_val.to_s.empty?
### if any value starts with >=, expand it
case new_val
when String
new_val = JSS.expand_min_os(new_val) if new_val =~ /^>=/
when Array
new_val.map! { |a| a =~ /^>=/ ? ... | ruby | def os_requirements=(new_val)
### nil should be an empty array
new_val = [] if new_val.to_s.empty?
### if any value starts with >=, expand it
case new_val
when String
new_val = JSS.expand_min_os(new_val) if new_val =~ /^>=/
when Array
new_val.map! { |a| a =~ /^>=/ ? ... | [
"def",
"os_requirements",
"=",
"(",
"new_val",
")",
"### nil should be an empty array",
"new_val",
"=",
"[",
"]",
"if",
"new_val",
".",
"to_s",
".",
"empty?",
"### if any value starts with >=, expand it",
"case",
"new_val",
"when",
"String",
"new_val",
"=",
"JSS",
"... | name=
Change the os_requirements
Minumum OS's can be specified as a string using the notation ">=10.6.7"
See the {JSS.expand_min_os} method for details.
@param new_val[String, Array<String>] the new os requirements as a comma-separted String or an Array of Strings
@return [void]
@example String value
myscr... | [
"name",
"=",
"Change",
"the",
"os_requirements"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/script.rb#L212-L231 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/script.rb | JSS.Script.priority= | def priority=(new_val)
return nil if new_val == @priority
new_val = DEFAULT_PRIORITY if new_val.nil? || (new_val == '')
raise JSS::InvalidDataError, ":priority must be one of: #{PRIORITIES.join ', '}" unless PRIORITIES.include? new_val
@priority = new_val
@need_to_update = true
end | ruby | def priority=(new_val)
return nil if new_val == @priority
new_val = DEFAULT_PRIORITY if new_val.nil? || (new_val == '')
raise JSS::InvalidDataError, ":priority must be one of: #{PRIORITIES.join ', '}" unless PRIORITIES.include? new_val
@priority = new_val
@need_to_update = true
end | [
"def",
"priority",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"new_val",
"==",
"@priority",
"new_val",
"=",
"DEFAULT_PRIORITY",
"if",
"new_val",
".",
"nil?",
"||",
"(",
"new_val",
"==",
"''",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\":pr... | os_requirements=
Change the priority of this script
@param new_val[Integer] the new priority, which must be one of {PRIORITIES}
@return [void] | [
"os_requirements",
"=",
"Change",
"the",
"priority",
"of",
"this",
"script"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/script.rb#L239-L245 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/script.rb | JSS.Script.parameters= | def parameters=(new_val)
return nil if new_val == @parameters
new_val = {} if new_val.nil? || (new_val == '')
### check the values
raise JSS::InvalidDataError, ':parameters must be a Hash with keys :parameter4 thru :parameter11' unless \
new_val.is_a?(Hash) && ((new_val.keys & PARAMETER... | ruby | def parameters=(new_val)
return nil if new_val == @parameters
new_val = {} if new_val.nil? || (new_val == '')
### check the values
raise JSS::InvalidDataError, ':parameters must be a Hash with keys :parameter4 thru :parameter11' unless \
new_val.is_a?(Hash) && ((new_val.keys & PARAMETER... | [
"def",
"parameters",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"new_val",
"==",
"@parameters",
"new_val",
"=",
"{",
"}",
"if",
"new_val",
".",
"nil?",
"||",
"(",
"new_val",
"==",
"''",
")",
"### check the values",
"raise",
"JSS",
"::",
"InvalidDataE... | notes=
Replace all the script parameters at once.
This will replace the entire set with the hash provided.
@param new_val[Hash] the Hash keys must exist in {PARAMETER_KEYS}
@return [void] | [
"notes",
"=",
"Replace",
"all",
"the",
"script",
"parameters",
"at",
"once",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/script.rb#L283-L296 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/script.rb | JSS.Script.set_parameter | def set_parameter(param_num, new_val)
raise JSS::NoSuchItemError, 'Parameter numbers must be from 4-11' unless (4..11).cover? param_num
pkey = "parameter#{param_num}".to_sym
raise JSS::InvalidDataError, 'parameter values must be strings or nil' unless new_val.nil? || new_val.is_a?(String)
return... | ruby | def set_parameter(param_num, new_val)
raise JSS::NoSuchItemError, 'Parameter numbers must be from 4-11' unless (4..11).cover? param_num
pkey = "parameter#{param_num}".to_sym
raise JSS::InvalidDataError, 'parameter values must be strings or nil' unless new_val.nil? || new_val.is_a?(String)
return... | [
"def",
"set_parameter",
"(",
"param_num",
",",
"new_val",
")",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"'Parameter numbers must be from 4-11'",
"unless",
"(",
"4",
"..",
"11",
")",
".",
"cover?",
"param_num",
"pkey",
"=",
"\"parameter#{param_num}\"",
".",
"t... | parameters=
Change one of the stored parameters
@param param_num[Integer] which param are we setting? must be 4..11
@param new_val[String] the new value for the parameter
@return [void] | [
"parameters",
"=",
"Change",
"one",
"of",
"the",
"stored",
"parameters"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/script.rb#L306-L313 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/script.rb | JSS.Script.script_contents= | def script_contents=(new_val)
new_code = case new_val
when String
if new_val.start_with? '/'
Pathname.new(new_val).read
else
new_val
end # if
when Pathname
new_va... | ruby | def script_contents=(new_val)
new_code = case new_val
when String
if new_val.start_with? '/'
Pathname.new(new_val).read
else
new_val
end # if
when Pathname
new_va... | [
"def",
"script_contents",
"=",
"(",
"new_val",
")",
"new_code",
"=",
"case",
"new_val",
"when",
"String",
"if",
"new_val",
".",
"start_with?",
"'/'",
"Pathname",
".",
"new",
"(",
"new_val",
")",
".",
"read",
"else",
"new_val",
"end",
"# if",
"when",
"Pathn... | Change the executable code of this script.
If the arg is a Pathname instance, or a String starting with "/"
Then the arg is assumed to be a file from which to read the code.
Otherwise it should be a String with the code itself, and it must start with '#!"
After doing this, use {#create} or {#update} to write it ... | [
"Change",
"the",
"executable",
"code",
"of",
"this",
"script",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/script.rb#L329-L347 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/script.rb | JSS.Script.delete_master_file | def delete_master_file(rw_pw, unmount = true)
file = JSS::DistributionPoint.master_distribution_point.mount(rw_pw, :rw) + "#{DIST_POINT_SCRIPTS_FOLDER}/#{@filename}"
if file.exist?
file.delete
did_it = true
else
did_it = false
end # if exists
JSS::DistributionPoint.... | ruby | def delete_master_file(rw_pw, unmount = true)
file = JSS::DistributionPoint.master_distribution_point.mount(rw_pw, :rw) + "#{DIST_POINT_SCRIPTS_FOLDER}/#{@filename}"
if file.exist?
file.delete
did_it = true
else
did_it = false
end # if exists
JSS::DistributionPoint.... | [
"def",
"delete_master_file",
"(",
"rw_pw",
",",
"unmount",
"=",
"true",
")",
"file",
"=",
"JSS",
"::",
"DistributionPoint",
".",
"master_distribution_point",
".",
"mount",
"(",
"rw_pw",
",",
":rw",
")",
"+",
"\"#{DIST_POINT_SCRIPTS_FOLDER}/#{@filename}\"",
"if",
"... | upload
Delete the filename from the master distribution point, if it exists.
If you'll be uploading several files you can specify unmount as false, and do it manually when all
are finished.
@param rw_pw[String] the password for the read/write account on the master Distribution Point
@param unmount[Boolean] whet... | [
"upload",
"Delete",
"the",
"filename",
"from",
"the",
"master",
"distribution",
"point",
"if",
"it",
"exists",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/script.rb#L384-L394 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/script.rb | JSS.Script.run | def run(opts = {})
opts[:target] ||= '/'
opts[:p1] ||= @parameters[:parameter4]
opts[:p2] ||= @parameters[:parameter5]
opts[:p3] ||= @parameters[:parameter6]
opts[:p4] ||= @parameters[:parameter7]
opts[:p5] ||= @parameters[:parameter8]
opts[:p6] ||= @parameters[:parameter9]
... | ruby | def run(opts = {})
opts[:target] ||= '/'
opts[:p1] ||= @parameters[:parameter4]
opts[:p2] ||= @parameters[:parameter5]
opts[:p3] ||= @parameters[:parameter6]
opts[:p4] ||= @parameters[:parameter7]
opts[:p5] ||= @parameters[:parameter8]
opts[:p6] ||= @parameters[:parameter9]
... | [
"def",
"run",
"(",
"opts",
"=",
"{",
"}",
")",
"opts",
"[",
":target",
"]",
"||=",
"'/'",
"opts",
"[",
":p1",
"]",
"||=",
"@parameters",
"[",
":parameter4",
"]",
"opts",
"[",
":p2",
"]",
"||=",
"@parameters",
"[",
":parameter5",
"]",
"opts",
"[",
"... | Run this script on the current machine using the "jamf runScript" command.
If the script code is available in the {#script_contents} attribute, then that
code is saved to a tmp file, and executed. Otherwise, the script is assumed
to be stored on the distribution point.
If the dist. point has http downloads enable... | [
"Run",
"this",
"script",
"on",
"the",
"current",
"machine",
"using",
"the",
"jamf",
"runScript",
"command",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/script.rb#L450-L547 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/script.rb | JSS.Script.rest_xml | def rest_xml
doc = REXML::Document.new
scpt = doc.add_element 'script'
scpt.add_element('filename').text = @filename
scpt.add_element('id').text = @id
scpt.add_element('info').text = @info
scpt.add_element('name').text = @name
scpt.add_element('notes').text = @notes
scpt... | ruby | def rest_xml
doc = REXML::Document.new
scpt = doc.add_element 'script'
scpt.add_element('filename').text = @filename
scpt.add_element('id').text = @id
scpt.add_element('info').text = @info
scpt.add_element('name').text = @name
scpt.add_element('notes').text = @notes
scpt... | [
"def",
"rest_xml",
"doc",
"=",
"REXML",
"::",
"Document",
".",
"new",
"scpt",
"=",
"doc",
".",
"add_element",
"'script'",
"scpt",
".",
"add_element",
"(",
"'filename'",
")",
".",
"text",
"=",
"@filename",
"scpt",
".",
"add_element",
"(",
"'id'",
")",
"."... | Return the xml for creating or updating this script in the JSS | [
"Return",
"the",
"xml",
"for",
"creating",
"or",
"updating",
"this",
"script",
"in",
"the",
"JSS"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/script.rb#L564-L587 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/peripheral_type.rb | JSS.PeripheralType.set_field | def set_field(order, field = {})
raise JSS::NoSuchItemError, "No field with number '#{order}'. Use #append_field, #prepend_field, or #insert_field" unless @fields[order]
field_ok? field
@fields[order] = field
@need_to_update = true
end | ruby | def set_field(order, field = {})
raise JSS::NoSuchItemError, "No field with number '#{order}'. Use #append_field, #prepend_field, or #insert_field" unless @fields[order]
field_ok? field
@fields[order] = field
@need_to_update = true
end | [
"def",
"set_field",
"(",
"order",
",",
"field",
"=",
"{",
"}",
")",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"\"No field with number '#{order}'. Use #append_field, #prepend_field, or #insert_field\"",
"unless",
"@fields",
"[",
"order",
"]",
"field_ok?",
"field",
"@... | Replace the details of one specific field.
The order must already exist. Otherwise use
{#append_field}, {#prepend_field}, or {#insert_field}
@param order[Integer] which field are we replacing?
@param field[Hash] the new field data
@return [void] | [
"Replace",
"the",
"details",
"of",
"one",
"specific",
"field",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/peripheral_type.rb#L172-L177 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/peripheral_type.rb | JSS.PeripheralType.insert_field | def insert_field(order,field = {})
field_ok? field
@fields.insert((order -1), field)
order_fields
@need_to_update = true
end | ruby | def insert_field(order,field = {})
field_ok? field
@fields.insert((order -1), field)
order_fields
@need_to_update = true
end | [
"def",
"insert_field",
"(",
"order",
",",
"field",
"=",
"{",
"}",
")",
"field_ok?",
"field",
"@fields",
".",
"insert",
"(",
"(",
"order",
"-",
"1",
")",
",",
"field",
")",
"order_fields",
"@need_to_update",
"=",
"true",
"end"
] | Add a new field to the middle of the fields Array.
@param order[Integer] where does the new field go?
@param field[Hash] the new field data
@return [void] | [
"Add",
"a",
"new",
"field",
"to",
"the",
"middle",
"of",
"the",
"fields",
"Array",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/peripheral_type.rb#L216-L221 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/peripheral_type.rb | JSS.PeripheralType.delete_field | def delete_field(order)
if @fields[order]
raise JSS::MissingDataError, "Fields can't be empty" if @fields.count == 1
@fields.delete_at index
order_fields
@need_to_update = true
end
end | ruby | def delete_field(order)
if @fields[order]
raise JSS::MissingDataError, "Fields can't be empty" if @fields.count == 1
@fields.delete_at index
order_fields
@need_to_update = true
end
end | [
"def",
"delete_field",
"(",
"order",
")",
"if",
"@fields",
"[",
"order",
"]",
"raise",
"JSS",
"::",
"MissingDataError",
",",
"\"Fields can't be empty\"",
"if",
"@fields",
".",
"count",
"==",
"1",
"@fields",
".",
"delete_at",
"index",
"order_fields",
"@need_to_up... | Remove a field from the array of fields.
@param order[Integer] which field to remove?
@return [void] | [
"Remove",
"a",
"field",
"from",
"the",
"array",
"of",
"fields",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/peripheral_type.rb#L230-L237 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/peripheral_type.rb | JSS.PeripheralType.field_ok? | def field_ok?(field)
raise JSS::InvalidDataError, "Field elements must be hashes with :name, :type, and possibly :choices" unless field.kind_of? Hash
raise JSS::InvalidDataError, "Fields require names" if field[:name].to_s.empty?
raise JSS::InvalidDataError, "Fields :type must be one of: :#{FIELD_TYPE... | ruby | def field_ok?(field)
raise JSS::InvalidDataError, "Field elements must be hashes with :name, :type, and possibly :choices" unless field.kind_of? Hash
raise JSS::InvalidDataError, "Fields require names" if field[:name].to_s.empty?
raise JSS::InvalidDataError, "Fields :type must be one of: :#{FIELD_TYPE... | [
"def",
"field_ok?",
"(",
"field",
")",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"Field elements must be hashes with :name, :type, and possibly :choices\"",
"unless",
"field",
".",
"kind_of?",
"Hash",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"\"Fields require n... | is a Hash of field data OK for use in the JSS?
Return true or raise an exception | [
"is",
"a",
"Hash",
"of",
"field",
"data",
"OK",
"for",
"use",
"in",
"the",
"JSS?",
"Return",
"true",
"or",
"raise",
"an",
"exception"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/peripheral_type.rb#L250-L263 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/group.rb | JSS.Group.remove_member | def remove_member(mem)
raise InvalidDataError, "Smart group members can't be changed." if @is_smart
raise InvalidDataError, "Can't remove nil" if mem.nil?
removed = @members.reject! { |mm| [mm[:id], mm[:name], mm[:username]].include? mem }
@need_to_update = true if removed
end | ruby | def remove_member(mem)
raise InvalidDataError, "Smart group members can't be changed." if @is_smart
raise InvalidDataError, "Can't remove nil" if mem.nil?
removed = @members.reject! { |mm| [mm[:id], mm[:name], mm[:username]].include? mem }
@need_to_update = true if removed
end | [
"def",
"remove_member",
"(",
"mem",
")",
"raise",
"InvalidDataError",
",",
"\"Smart group members can't be changed.\"",
"if",
"@is_smart",
"raise",
"InvalidDataError",
",",
"\"Can't remove nil\"",
"if",
"mem",
".",
"nil?",
"removed",
"=",
"@members",
".",
"reject!",
"... | Remove a member by id, or name
@param m[Integer,String] the id or name of the member to remove
@return [void] | [
"Remove",
"a",
"member",
"by",
"id",
"or",
"name"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/group.rb#L339-L344 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/group.rb | JSS.Group.check_member | def check_member(m)
potential_members = self.class::MEMBER_CLASS.map_all_ids_to(:name, api: @api)
if m.to_s =~ /^\d+$/
return { id: m.to_i, name: potential_members[m] } if potential_members.key?(m.to_i)
else
return { name: m, id: potential_members.invert[m] } if potential_members.value... | ruby | def check_member(m)
potential_members = self.class::MEMBER_CLASS.map_all_ids_to(:name, api: @api)
if m.to_s =~ /^\d+$/
return { id: m.to_i, name: potential_members[m] } if potential_members.key?(m.to_i)
else
return { name: m, id: potential_members.invert[m] } if potential_members.value... | [
"def",
"check_member",
"(",
"m",
")",
"potential_members",
"=",
"self",
".",
"class",
"::",
"MEMBER_CLASS",
".",
"map_all_ids_to",
"(",
":name",
",",
"api",
":",
"@api",
")",
"if",
"m",
".",
"to_s",
"=~",
"/",
"\\d",
"/",
"return",
"{",
"id",
":",
"m... | Check that a potential group member is valid in the JSS.
Arg must be an id or name.
An exception is raised if the device doesn't exist.
@return [Hash{:id=>Integer,:name=>String}] the valid id and name | [
"Check",
"that",
"a",
"potential",
"group",
"member",
"is",
"valid",
"in",
"the",
"JSS",
".",
"Arg",
"must",
"be",
"an",
"id",
"or",
"name",
".",
"An",
"exception",
"is",
"raised",
"if",
"the",
"device",
"doesn",
"t",
"exist",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/group.rb#L403-L411 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/patch_title.rb | JSS.PatchTitle.email_notification= | def email_notification=(new_setting)
return if email_notification == new_setting
raise JSS::InvalidDataError, 'New Setting must be boolean true or false' unless JSS::TRUE_FALSE.include? @email_notification = new_setting
@need_to_update = true
end | ruby | def email_notification=(new_setting)
return if email_notification == new_setting
raise JSS::InvalidDataError, 'New Setting must be boolean true or false' unless JSS::TRUE_FALSE.include? @email_notification = new_setting
@need_to_update = true
end | [
"def",
"email_notification",
"=",
"(",
"new_setting",
")",
"return",
"if",
"email_notification",
"==",
"new_setting",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'New Setting must be boolean true or false'",
"unless",
"JSS",
"::",
"TRUE_FALSE",
".",
"include?",
"@em... | Set email notifications on or off
@param new_setting[Boolean] Should email notifications be on or off?
@return [void] | [
"Set",
"email",
"notifications",
"on",
"or",
"off"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/patch_title.rb#L428-L432 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/patch_title.rb | JSS.PatchTitle.web_notification= | def web_notification=(new_setting)
return if web_notification == new_setting
raise JSS::InvalidDataError, 'New Setting must be boolean true or false' unless JSS::TRUE_FALSE.include? @web_notification = new_setting
@need_to_update = true
end | ruby | def web_notification=(new_setting)
return if web_notification == new_setting
raise JSS::InvalidDataError, 'New Setting must be boolean true or false' unless JSS::TRUE_FALSE.include? @web_notification = new_setting
@need_to_update = true
end | [
"def",
"web_notification",
"=",
"(",
"new_setting",
")",
"return",
"if",
"web_notification",
"==",
"new_setting",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'New Setting must be boolean true or false'",
"unless",
"JSS",
"::",
"TRUE_FALSE",
".",
"include?",
"@web_no... | Set web notifications on or off
@param new_setting[Boolean] Should email notifications be on or off?
@return [void] | [
"Set",
"web",
"notifications",
"on",
"or",
"off"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/patch_title.rb#L440-L444 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/patch_title.rb | JSS.PatchTitle.rest_xml | def rest_xml
doc = REXML::Document.new # JSS::APIConnection::XML_HEADER
obj = doc.add_element RSRC_OBJECT_KEY.to_s
obj.add_element('name').text = name
obj.add_element('name_id').text = name_id
obj.add_element('source_id').text = source_id
notifs = obj.add_element 'notifications'
... | ruby | def rest_xml
doc = REXML::Document.new # JSS::APIConnection::XML_HEADER
obj = doc.add_element RSRC_OBJECT_KEY.to_s
obj.add_element('name').text = name
obj.add_element('name_id').text = name_id
obj.add_element('source_id').text = source_id
notifs = obj.add_element 'notifications'
... | [
"def",
"rest_xml",
"doc",
"=",
"REXML",
"::",
"Document",
".",
"new",
"# JSS::APIConnection::XML_HEADER",
"obj",
"=",
"doc",
".",
"add_element",
"RSRC_OBJECT_KEY",
".",
"to_s",
"obj",
".",
"add_element",
"(",
"'name'",
")",
".",
"text",
"=",
"name",
"obj",
"... | Return the REST XML for this title, with the current values,
for saving or updating. | [
"Return",
"the",
"REST",
"XML",
"for",
"this",
"title",
"with",
"the",
"current",
"values",
"for",
"saving",
"or",
"updating",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/patch_title.rb#L495-L513 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/patch_title.rb | JSS.PatchTitle.add_changed_pkg_xml | def add_changed_pkg_xml(obj)
versions_elem = obj.add_element 'versions'
@changed_pkgs.each do |vers|
velem = versions_elem.add_element 'version'
velem.add_element('software_version').text = vers.to_s
pkg = velem.add_element 'package'
# leave am empty package element to remove... | ruby | def add_changed_pkg_xml(obj)
versions_elem = obj.add_element 'versions'
@changed_pkgs.each do |vers|
velem = versions_elem.add_element 'version'
velem.add_element('software_version').text = vers.to_s
pkg = velem.add_element 'package'
# leave am empty package element to remove... | [
"def",
"add_changed_pkg_xml",
"(",
"obj",
")",
"versions_elem",
"=",
"obj",
".",
"add_element",
"'versions'",
"@changed_pkgs",
".",
"each",
"do",
"|",
"vers",
"|",
"velem",
"=",
"versions_elem",
".",
"add_element",
"'version'",
"velem",
".",
"add_element",
"(",
... | rest_xml
add xml for any package changes to patch versions | [
"rest_xml",
"add",
"xml",
"for",
"any",
"package",
"changes",
"to",
"patch",
"versions"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/patch_title.rb#L516-L526 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object.rb | JSS.APIObject.validate_object_history_available | def validate_object_history_available
raise JSS::NoSuchItemError, 'Object not yet created' unless @id && @in_jss
raise JSS::InvalidConnectionError, 'Not connected to MySQL' unless JSS::DB_CNX.connected?
raise JSS::UnsupportedError, "Object History access is not supported for #{self.class} objects at... | ruby | def validate_object_history_available
raise JSS::NoSuchItemError, 'Object not yet created' unless @id && @in_jss
raise JSS::InvalidConnectionError, 'Not connected to MySQL' unless JSS::DB_CNX.connected?
raise JSS::UnsupportedError, "Object History access is not supported for #{self.class} objects at... | [
"def",
"validate_object_history_available",
"raise",
"JSS",
"::",
"NoSuchItemError",
",",
"'Object not yet created'",
"unless",
"@id",
"&&",
"@in_jss",
"raise",
"JSS",
"::",
"InvalidConnectionError",
",",
"'Not connected to MySQL'",
"unless",
"JSS",
"::",
"DB_CNX",
".",
... | Raise an exception if object history is not
available for this object
@return [void] | [
"Raise",
"an",
"exception",
"if",
"object",
"history",
"is",
"not",
"available",
"for",
"this",
"object"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object.rb#L887-L893 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object.rb | JSS.APIObject.validate_external_init_data | def validate_external_init_data
# data must include all they keys in REQUIRED_DATA_KEYS + VALID_DATA_KEYS
# in either the main hash keys or the :general sub-hash, if it exists
hash_to_check = @init_data[:general] ? @init_data[:general] : @init_data
combined_valid_keys = self.class::REQUIRED_DATA... | ruby | def validate_external_init_data
# data must include all they keys in REQUIRED_DATA_KEYS + VALID_DATA_KEYS
# in either the main hash keys or the :general sub-hash, if it exists
hash_to_check = @init_data[:general] ? @init_data[:general] : @init_data
combined_valid_keys = self.class::REQUIRED_DATA... | [
"def",
"validate_external_init_data",
"# data must include all they keys in REQUIRED_DATA_KEYS + VALID_DATA_KEYS",
"# in either the main hash keys or the :general sub-hash, if it exists",
"hash_to_check",
"=",
"@init_data",
"[",
":general",
"]",
"?",
"@init_data",
"[",
":general",
"]",
... | If we were passed pre-lookedup API data, validate it,
raising exceptions if not valid.
DEPRECATED: pre-lookedup data is never used
and support for it will be going away.
TODO: delete this and all defined VALID_DATA_KEYS
@return [void] | [
"If",
"we",
"were",
"passed",
"pre",
"-",
"lookedup",
"API",
"data",
"validate",
"it",
"raising",
"exceptions",
"if",
"not",
"valid",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object.rb#L905-L920 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object.rb | JSS.APIObject.validate_init_for_creation | def validate_init_for_creation(args)
raise JSS::UnsupportedError, "Creating #{self.class::RSRC_LIST_KEY} isn't yet supported. Please use other Casper workflows." unless creatable?
raise JSS::MissingDataError, "You must provide a :name to create a #{self.class::RSRC_OBJECT_KEY}." unless args[:name]
r... | ruby | def validate_init_for_creation(args)
raise JSS::UnsupportedError, "Creating #{self.class::RSRC_LIST_KEY} isn't yet supported. Please use other Casper workflows." unless creatable?
raise JSS::MissingDataError, "You must provide a :name to create a #{self.class::RSRC_OBJECT_KEY}." unless args[:name]
r... | [
"def",
"validate_init_for_creation",
"(",
"args",
")",
"raise",
"JSS",
"::",
"UnsupportedError",
",",
"\"Creating #{self.class::RSRC_LIST_KEY} isn't yet supported. Please use other Casper workflows.\"",
"unless",
"creatable?",
"raise",
"JSS",
"::",
"MissingDataError",
",",
"\"You... | validate_init_data
If we're making a new object in the JSS, make sure we were given
valid data to do so, raise exceptions otherwise.
NOTE: some subclasses may do further validation.
TODO: support for objects that can have duplicate names.
@param args[Hash] The args passed to #initialize
@return [void] | [
"validate_init_data",
"If",
"we",
"re",
"making",
"a",
"new",
"object",
"in",
"the",
"JSS",
"make",
"sure",
"we",
"were",
"given",
"valid",
"data",
"to",
"do",
"so",
"raise",
"exceptions",
"otherwise",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object.rb#L933-L939 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object.rb | JSS.APIObject.look_up_object_data | def look_up_object_data(args)
rsrc =
if args[:fetch_rsrc]
args[:fetch_rsrc]
else
# what lookup key are we using?
# TODO: simplify this, see the notes at #find_rsrc_keys
rsrc_key, lookup_value = find_rsrc_keys(args)
"#{self.class::RSRC_BASE}/#{rsrc_... | ruby | def look_up_object_data(args)
rsrc =
if args[:fetch_rsrc]
args[:fetch_rsrc]
else
# what lookup key are we using?
# TODO: simplify this, see the notes at #find_rsrc_keys
rsrc_key, lookup_value = find_rsrc_keys(args)
"#{self.class::RSRC_BASE}/#{rsrc_... | [
"def",
"look_up_object_data",
"(",
"args",
")",
"rsrc",
"=",
"if",
"args",
"[",
":fetch_rsrc",
"]",
"args",
"[",
":fetch_rsrc",
"]",
"else",
"# what lookup key are we using?",
"# TODO: simplify this, see the notes at #find_rsrc_keys",
"rsrc_key",
",",
"lookup_value",
"=",... | Given initialization args, perform an API lookup for an object.
@param args[Hash] The args passed to #initialize
@return [Hash] The parsed JSON data for the object from the API | [
"Given",
"initialization",
"args",
"perform",
"an",
"API",
"lookup",
"for",
"an",
"object",
"."
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object.rb#L947-L973 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object.rb | JSS.APIObject.rest_xml | def rest_xml
doc = REXML::Document.new JSS::APIConnection::XML_HEADER
tmpl = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
tmpl.add_element('name').text = @name
doc.to_s
end | ruby | def rest_xml
doc = REXML::Document.new JSS::APIConnection::XML_HEADER
tmpl = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
tmpl.add_element('name').text = @name
doc.to_s
end | [
"def",
"rest_xml",
"doc",
"=",
"REXML",
"::",
"Document",
".",
"new",
"JSS",
"::",
"APIConnection",
"::",
"XML_HEADER",
"tmpl",
"=",
"doc",
".",
"add_element",
"self",
".",
"class",
"::",
"RSRC_OBJECT_KEY",
".",
"to_s",
"tmpl",
".",
"add_element",
"(",
"'n... | Return a String with the XML Resource
for submitting creation or changes to the JSS via
the API via the Creatable or Updatable modules
Most classes will redefine this method. | [
"Return",
"a",
"String",
"with",
"the",
"XML",
"Resource",
"for",
"submitting",
"creation",
"or",
"changes",
"to",
"the",
"JSS",
"via",
"the",
"API",
"via",
"the",
"Creatable",
"or",
"Updatable",
"modules"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object.rb#L1160-L1165 | train |
PixarAnimationStudios/ruby-jss | lib/jss/configuration.rb | JSS.Configuration.reload | def reload(file = nil)
clear_all
if file
read file
return true
end
read_global
read_user
return true
end | ruby | def reload(file = nil)
clear_all
if file
read file
return true
end
read_global
read_user
return true
end | [
"def",
"reload",
"(",
"file",
"=",
"nil",
")",
"clear_all",
"if",
"file",
"read",
"file",
"return",
"true",
"end",
"read_global",
"read_user",
"return",
"true",
"end"
] | Clear the settings and reload the prefs files, or another file if provided
@param file[String,Pathname] a non-standard prefs file to load
@return [void] | [
"Clear",
"the",
"settings",
"and",
"reload",
"the",
"prefs",
"files",
"or",
"another",
"file",
"if",
"provided"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/configuration.rb#L212-L221 | train |
PixarAnimationStudios/ruby-jss | lib/jss/configuration.rb | JSS.Configuration.read | def read(file)
Pathname.new(file).read.each_line do |line|
# skip blank lines and those starting with #
next if line =~ /^\s*(#|$)/
line.strip =~ /^(\w+?):\s*(\S.*)$/
next unless $1
attr = $1.to_sym
setter = "#{attr}=".to_sym
value = $2.strip... | ruby | def read(file)
Pathname.new(file).read.each_line do |line|
# skip blank lines and those starting with #
next if line =~ /^\s*(#|$)/
line.strip =~ /^(\w+?):\s*(\S.*)$/
next unless $1
attr = $1.to_sym
setter = "#{attr}=".to_sym
value = $2.strip... | [
"def",
"read",
"(",
"file",
")",
"Pathname",
".",
"new",
"(",
"file",
")",
".",
"read",
".",
"each_line",
"do",
"|",
"line",
"|",
"# skip blank lines and those starting with #",
"next",
"if",
"line",
"=~",
"/",
"\\s",
"/",
"line",
".",
"strip",
"=~",
"/"... | Read in any prefs file
@param file[String,Pathname] the file to read
@return [void] | [
"Read",
"in",
"any",
"prefs",
"file"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/configuration.rb#L291-L312 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/vppable.rb | JSS.VPPable.assign_vpp_device_based_licenses= | def assign_vpp_device_based_licenses=(new_val)
return nil if new_val == @assign_vpp_device_based_licenses
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@assign_vpp_device_based_licenses = new_val
@need_to_update = true
end | ruby | def assign_vpp_device_based_licenses=(new_val)
return nil if new_val == @assign_vpp_device_based_licenses
raise JSS::InvalidDataError, 'New value must be true or false' unless new_val.jss_boolean?
@assign_vpp_device_based_licenses = new_val
@need_to_update = true
end | [
"def",
"assign_vpp_device_based_licenses",
"=",
"(",
"new_val",
")",
"return",
"nil",
"if",
"new_val",
"==",
"@assign_vpp_device_based_licenses",
"raise",
"JSS",
"::",
"InvalidDataError",
",",
"'New value must be true or false'",
"unless",
"new_val",
".",
"jss_boolean?",
... | Set whether or not the VPP licenses should be assigned
by device rather than by user
@param new_val[Boolean] The new value
@return [void] | [
"Set",
"whether",
"or",
"not",
"the",
"VPP",
"licenses",
"should",
"be",
"assigned",
"by",
"device",
"rather",
"than",
"by",
"user"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/vppable.rb#L77-L82 | train |
PixarAnimationStudios/ruby-jss | lib/jss/api_object/vppable.rb | JSS.VPPable.add_vpp_xml | def add_vpp_xml(xdoc)
doc_root = xdoc.root
vpp = doc_root.add_element 'vpp'
vpp.add_element('assign_vpp_device_based_licenses').text = @assign_vpp_device_based_licenses
end | ruby | def add_vpp_xml(xdoc)
doc_root = xdoc.root
vpp = doc_root.add_element 'vpp'
vpp.add_element('assign_vpp_device_based_licenses').text = @assign_vpp_device_based_licenses
end | [
"def",
"add_vpp_xml",
"(",
"xdoc",
")",
"doc_root",
"=",
"xdoc",
".",
"root",
"vpp",
"=",
"doc_root",
".",
"add_element",
"'vpp'",
"vpp",
".",
"add_element",
"(",
"'assign_vpp_device_based_licenses'",
")",
".",
"text",
"=",
"@assign_vpp_device_based_licenses",
"en... | Insert an appropriate vpp element into the XML for sending changes
to the JSS
@param xdoc[REXML::Document] The XML document to work with
@return [void] | [
"Insert",
"an",
"appropriate",
"vpp",
"element",
"into",
"the",
"XML",
"for",
"sending",
"changes",
"to",
"the",
"JSS"
] | 4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9 | https://github.com/PixarAnimationStudios/ruby-jss/blob/4ab645bfaec8b2edb1ea146bfc2b10f0d62edee9/lib/jss/api_object/vppable.rb#L109-L113 | train |
elct9620/rails-letsencrypt | app/models/concerns/lets_encrypt/certificate_verifiable.rb | LetsEncrypt.CertificateVerifiable.verify | def verify
create_order
start_challenge
wait_verify_status
check_verify_status
rescue Acme::Client::Error => e
retry_on_verify_error(e)
end | ruby | def verify
create_order
start_challenge
wait_verify_status
check_verify_status
rescue Acme::Client::Error => e
retry_on_verify_error(e)
end | [
"def",
"verify",
"create_order",
"start_challenge",
"wait_verify_status",
"check_verify_status",
"rescue",
"Acme",
"::",
"Client",
"::",
"Error",
"=>",
"e",
"retry_on_verify_error",
"(",
"e",
")",
"end"
] | Returns true if verify domain is succeed. | [
"Returns",
"true",
"if",
"verify",
"domain",
"is",
"succeed",
"."
] | 25aa4685320bca4f871fa7e573e10693bc2a2dc3 | https://github.com/elct9620/rails-letsencrypt/blob/25aa4685320bca4f871fa7e573e10693bc2a2dc3/app/models/concerns/lets_encrypt/certificate_verifiable.rb#L9-L16 | train |
weppos/whois-parser | lib/whois/safe_record.rb | Whois.SafeRecord.properties | def properties
hash = {}
Parser::PROPERTIES.each do |property|
hash[property] = __send__(property)
end
hash
end | ruby | def properties
hash = {}
Parser::PROPERTIES.each do |property|
hash[property] = __send__(property)
end
hash
end | [
"def",
"properties",
"hash",
"=",
"{",
"}",
"Parser",
"::",
"PROPERTIES",
".",
"each",
"do",
"|",
"property",
"|",
"hash",
"[",
"property",
"]",
"=",
"__send__",
"(",
"property",
")",
"end",
"hash",
"end"
] | Returns a Hash containing all supported properties for this record
along with corresponding values.
@return [{ Symbol => Object }] | [
"Returns",
"a",
"Hash",
"containing",
"all",
"supported",
"properties",
"for",
"this",
"record",
"along",
"with",
"corresponding",
"values",
"."
] | 9db810d187a97175c3b28edd100c4edd07d683f2 | https://github.com/weppos/whois-parser/blob/9db810d187a97175c3b28edd100c4edd07d683f2/lib/whois/safe_record.rb#L83-L89 | train |
change/method_profiler | lib/method_profiler/report.rb | MethodProfiler.Report.to_a | def to_a
if @order == :ascending
@data.sort { |a, b| a[@sort_by] <=> b[@sort_by] }
else
@data.sort { |a, b| b[@sort_by] <=> a[@sort_by] }
end
end | ruby | def to_a
if @order == :ascending
@data.sort { |a, b| a[@sort_by] <=> b[@sort_by] }
else
@data.sort { |a, b| b[@sort_by] <=> a[@sort_by] }
end
end | [
"def",
"to_a",
"if",
"@order",
"==",
":ascending",
"@data",
".",
"sort",
"{",
"|",
"a",
",",
"b",
"|",
"a",
"[",
"@sort_by",
"]",
"<=>",
"b",
"[",
"@sort_by",
"]",
"}",
"else",
"@data",
".",
"sort",
"{",
"|",
"a",
",",
"b",
"|",
"b",
"[",
"@s... | Sorts the data by the currently set criteria and returns an array of profiling results.
@return [Array] An array of profiling results. | [
"Sorts",
"the",
"data",
"by",
"the",
"currently",
"set",
"criteria",
"and",
"returns",
"an",
"array",
"of",
"profiling",
"results",
"."
] | f2ddb631675211b5d52136e0c3f50ca42728c713 | https://github.com/change/method_profiler/blob/f2ddb631675211b5d52136e0c3f50ca42728c713/lib/method_profiler/report.rb#L66-L72 | train |
change/method_profiler | lib/method_profiler/report.rb | MethodProfiler.Report.to_s | def to_s
[
"MethodProfiler results for: #{@name}",
Hirb::Helpers::Table.render(
to_a,
headers: HEADERS.dup,
fields: FIELDS.dup,
filters: {
min: :to_milliseconds,
max: :to_milliseconds,
average: :to_milliseconds,
... | ruby | def to_s
[
"MethodProfiler results for: #{@name}",
Hirb::Helpers::Table.render(
to_a,
headers: HEADERS.dup,
fields: FIELDS.dup,
filters: {
min: :to_milliseconds,
max: :to_milliseconds,
average: :to_milliseconds,
... | [
"def",
"to_s",
"[",
"\"MethodProfiler results for: #{@name}\"",
",",
"Hirb",
"::",
"Helpers",
"::",
"Table",
".",
"render",
"(",
"to_a",
",",
"headers",
":",
"HEADERS",
".",
"dup",
",",
"fields",
":",
"FIELDS",
".",
"dup",
",",
"filters",
":",
"{",
"min",
... | Sorts the data by the currently set criteria and returns a pretty printed table as a string.
@return [String] A table of profiling results. | [
"Sorts",
"the",
"data",
"by",
"the",
"currently",
"set",
"criteria",
"and",
"returns",
"a",
"pretty",
"printed",
"table",
"as",
"a",
"string",
"."
] | f2ddb631675211b5d52136e0c3f50ca42728c713 | https://github.com/change/method_profiler/blob/f2ddb631675211b5d52136e0c3f50ca42728c713/lib/method_profiler/report.rb#L78-L94 | train |
david942j/seccomp-tools | lib/seccomp-tools/asm/asm.rb | SeccompTools.Asm.asm | def asm(str, arch: nil)
arch = Util.system_arch if arch.nil? # TODO: show warning
compiler = Compiler.new(arch)
str.lines.each { |l| compiler.process(l) }
compiler.compile!.map(&:asm).join
end | ruby | def asm(str, arch: nil)
arch = Util.system_arch if arch.nil? # TODO: show warning
compiler = Compiler.new(arch)
str.lines.each { |l| compiler.process(l) }
compiler.compile!.map(&:asm).join
end | [
"def",
"asm",
"(",
"str",
",",
"arch",
":",
"nil",
")",
"arch",
"=",
"Util",
".",
"system_arch",
"if",
"arch",
".",
"nil?",
"# TODO: show warning",
"compiler",
"=",
"Compiler",
".",
"new",
"(",
"arch",
")",
"str",
".",
"lines",
".",
"each",
"{",
"|",... | Assembler of seccomp bpf.
@param [String] str
@return [String]
Raw bpf bytes.
@example
asm(<<EOS)
# lines start with '#' are comments
A = sys_number # here's a comment, too
A >= 0x40000000 ? dead : next # 'next' is a keyword, denote the next instruction
A == read ? ok : next ... | [
"Assembler",
"of",
"seccomp",
"bpf",
"."
] | 8dfc288a28eab2d683d1a4cc0fed405d75dc5595 | https://github.com/david942j/seccomp-tools/blob/8dfc288a28eab2d683d1a4cc0fed405d75dc5595/lib/seccomp-tools/asm/asm.rb#L27-L32 | train |
david942j/seccomp-tools | lib/seccomp-tools/cli/cli.rb | SeccompTools.CLI.work | def work(argv)
# all -h equivalent to --help
argv = argv.map { |a| a == '-h' ? '--help' : a }
idx = argv.index { |c| !c.start_with?('-') }
preoption = idx.nil? ? argv.shift(argv.size) : argv.shift(idx)
# handle --version or --help or nothing
return show("SeccompTools Version #{Secco... | ruby | def work(argv)
# all -h equivalent to --help
argv = argv.map { |a| a == '-h' ? '--help' : a }
idx = argv.index { |c| !c.start_with?('-') }
preoption = idx.nil? ? argv.shift(argv.size) : argv.shift(idx)
# handle --version or --help or nothing
return show("SeccompTools Version #{Secco... | [
"def",
"work",
"(",
"argv",
")",
"# all -h equivalent to --help",
"argv",
"=",
"argv",
".",
"map",
"{",
"|",
"a",
"|",
"a",
"==",
"'-h'",
"?",
"'--help'",
":",
"a",
"}",
"idx",
"=",
"argv",
".",
"index",
"{",
"|",
"c",
"|",
"!",
"c",
".",
"start_... | Main working method of CLI.
@param [Array<String>] argv
Command line arguments.
@return [void]
@example
work(%w[--help])
#=> # usage message
work(%w[--version])
#=> # version message | [
"Main",
"working",
"method",
"of",
"CLI",
"."
] | 8dfc288a28eab2d683d1a4cc0fed405d75dc5595 | https://github.com/david942j/seccomp-tools/blob/8dfc288a28eab2d683d1a4cc0fed405d75dc5595/lib/seccomp-tools/cli/cli.rb#L40-L56 | train |
david942j/seccomp-tools | lib/seccomp-tools/disasm/disasm.rb | SeccompTools.Disasm.disasm | def disasm(raw, arch: nil)
codes = to_bpf(raw, arch)
contexts = Array.new(codes.size) { Set.new }
contexts[0].add(Context.new)
# all we care is if A is exactly one of data[*]
dis = codes.zip(contexts).map do |code, ctxs|
ctxs.each do |ctx|
code.branch(ctx) do |pc, c|
... | ruby | def disasm(raw, arch: nil)
codes = to_bpf(raw, arch)
contexts = Array.new(codes.size) { Set.new }
contexts[0].add(Context.new)
# all we care is if A is exactly one of data[*]
dis = codes.zip(contexts).map do |code, ctxs|
ctxs.each do |ctx|
code.branch(ctx) do |pc, c|
... | [
"def",
"disasm",
"(",
"raw",
",",
"arch",
":",
"nil",
")",
"codes",
"=",
"to_bpf",
"(",
"raw",
",",
"arch",
")",
"contexts",
"=",
"Array",
".",
"new",
"(",
"codes",
".",
"size",
")",
"{",
"Set",
".",
"new",
"}",
"contexts",
"[",
"0",
"]",
".",
... | Disassemble bpf codes.
@param [String] raw
The raw bpf bytes.
@param [Symbol] arch
Architecture. | [
"Disassemble",
"bpf",
"codes",
"."
] | 8dfc288a28eab2d683d1a4cc0fed405d75dc5595 | https://github.com/david942j/seccomp-tools/blob/8dfc288a28eab2d683d1a4cc0fed405d75dc5595/lib/seccomp-tools/disasm/disasm.rb#L17-L35 | train |
david942j/seccomp-tools | lib/seccomp-tools/bpf.rb | SeccompTools.BPF.inst | def inst
@inst ||= case command
when :alu then SeccompTools::Instruction::ALU
when :jmp then SeccompTools::Instruction::JMP
when :ld then SeccompTools::Instruction::LD
when :ldx then SeccompTools::Instruction::LDX
when :misc then... | ruby | def inst
@inst ||= case command
when :alu then SeccompTools::Instruction::ALU
when :jmp then SeccompTools::Instruction::JMP
when :ld then SeccompTools::Instruction::LD
when :ldx then SeccompTools::Instruction::LDX
when :misc then... | [
"def",
"inst",
"@inst",
"||=",
"case",
"command",
"when",
":alu",
"then",
"SeccompTools",
"::",
"Instruction",
"::",
"ALU",
"when",
":jmp",
"then",
"SeccompTools",
"::",
"Instruction",
"::",
"JMP",
"when",
":ld",
"then",
"SeccompTools",
"::",
"Instruction",
":... | Corresponding instruction object.
@return [SeccompTools::Instruction::Base] | [
"Corresponding",
"instruction",
"object",
"."
] | 8dfc288a28eab2d683d1a4cc0fed405d75dc5595 | https://github.com/david942j/seccomp-tools/blob/8dfc288a28eab2d683d1a4cc0fed405d75dc5595/lib/seccomp-tools/bpf.rb#L91-L102 | train |
david942j/seccomp-tools | lib/seccomp-tools/util.rb | SeccompTools.Util.supported_archs | def supported_archs
@supported_archs ||= Dir.glob(File.join(__dir__, 'consts', '*.rb'))
.map { |f| File.basename(f, '.rb').to_sym }
.sort
end | ruby | def supported_archs
@supported_archs ||= Dir.glob(File.join(__dir__, 'consts', '*.rb'))
.map { |f| File.basename(f, '.rb').to_sym }
.sort
end | [
"def",
"supported_archs",
"@supported_archs",
"||=",
"Dir",
".",
"glob",
"(",
"File",
".",
"join",
"(",
"__dir__",
",",
"'consts'",
",",
"'*.rb'",
")",
")",
".",
"map",
"{",
"|",
"f",
"|",
"File",
".",
"basename",
"(",
"f",
",",
"'.rb'",
")",
".",
... | Get currently supported architectures.
@return [Array<Symbol>]
Architectures. | [
"Get",
"currently",
"supported",
"architectures",
"."
] | 8dfc288a28eab2d683d1a4cc0fed405d75dc5595 | https://github.com/david942j/seccomp-tools/blob/8dfc288a28eab2d683d1a4cc0fed405d75dc5595/lib/seccomp-tools/util.rb#L9-L13 | train |
david942j/seccomp-tools | lib/seccomp-tools/util.rb | SeccompTools.Util.colorize | def colorize(s, t: nil)
s = s.to_s
return s unless colorize_enabled?
cc = COLOR_CODE
color = cc[t]
"#{color}#{s.sub(cc[:esc_m], cc[:esc_m] + color)}#{cc[:esc_m]}"
end | ruby | def colorize(s, t: nil)
s = s.to_s
return s unless colorize_enabled?
cc = COLOR_CODE
color = cc[t]
"#{color}#{s.sub(cc[:esc_m], cc[:esc_m] + color)}#{cc[:esc_m]}"
end | [
"def",
"colorize",
"(",
"s",
",",
"t",
":",
"nil",
")",
"s",
"=",
"s",
".",
"to_s",
"return",
"s",
"unless",
"colorize_enabled?",
"cc",
"=",
"COLOR_CODE",
"color",
"=",
"cc",
"[",
"t",
"]",
"\"#{color}#{s.sub(cc[:esc_m], cc[:esc_m] + color)}#{cc[:esc_m]}\"",
"... | Wrapper color codes.
@param [String] s
Contents to wrapper.
@param [Symbol?] t
Specific which kind of color to use, valid symbols are defined in {Util.COLOR_CODE}.
@return [String]
Wrapper with color codes. | [
"Wrapper",
"color",
"codes",
"."
] | 8dfc288a28eab2d683d1a4cc0fed405d75dc5595 | https://github.com/david942j/seccomp-tools/blob/8dfc288a28eab2d683d1a4cc0fed405d75dc5595/lib/seccomp-tools/util.rb#L57-L64 | train |
appium/ruby_lib_core | script/commands.rb | Script.CommandsChecker.get_mjsonwp_routes | def get_mjsonwp_routes(to_path = './mjsonwp_routes.js')
uri = URI 'https://raw.githubusercontent.com/appium/appium-base-driver/master/lib/protocol/routes.js?raw=1'
result = Net::HTTP.get uri
File.delete to_path if File.exist? to_path
File.write to_path, result
to_path
end | ruby | def get_mjsonwp_routes(to_path = './mjsonwp_routes.js')
uri = URI 'https://raw.githubusercontent.com/appium/appium-base-driver/master/lib/protocol/routes.js?raw=1'
result = Net::HTTP.get uri
File.delete to_path if File.exist? to_path
File.write to_path, result
to_path
end | [
"def",
"get_mjsonwp_routes",
"(",
"to_path",
"=",
"'./mjsonwp_routes.js'",
")",
"uri",
"=",
"URI",
"'https://raw.githubusercontent.com/appium/appium-base-driver/master/lib/protocol/routes.js?raw=1'",
"result",
"=",
"Net",
"::",
"HTTP",
".",
"get",
"uri",
"File",
".",
"delet... | Set commands implemented in this core library.
- implemented_mjsonwp_commands: All commands include ::Selenium::WebDriver::Remote::OSS::Bridge::COMMANDS
- implemented_w3c_commands: All commands include ::Selenium::WebDriver::Remote::W3C::Bridge::COMMANDS
- implemented_core_commands: All commands except for selen... | [
"Set",
"commands",
"implemented",
"in",
"this",
"core",
"library",
"."
] | 2d8a8f3433f6774a1cc2d76028269ca006ca5273 | https://github.com/appium/ruby_lib_core/blob/2d8a8f3433f6774a1cc2d76028269ca006ca5273/script/commands.rb#L49-L56 | train |
appium/ruby_lib_core | script/commands.rb | Script.CommandsChecker.diff_except_for_webdriver | def diff_except_for_webdriver
result = compare_commands(@spec_commands, @implemented_core_commands)
white_list.each { |v| result.delete v }
result
end | ruby | def diff_except_for_webdriver
result = compare_commands(@spec_commands, @implemented_core_commands)
white_list.each { |v| result.delete v }
result
end | [
"def",
"diff_except_for_webdriver",
"result",
"=",
"compare_commands",
"(",
"@spec_commands",
",",
"@implemented_core_commands",
")",
"white_list",
".",
"each",
"{",
"|",
"v",
"|",
"result",
".",
"delete",
"v",
"}",
"result",
"end"
] | Commands, only this core library, which haven't been implemented in ruby core library yet.
@return [Hash] | [
"Commands",
"only",
"this",
"core",
"library",
"which",
"haven",
"t",
"been",
"implemented",
"in",
"ruby",
"core",
"library",
"yet",
"."
] | 2d8a8f3433f6774a1cc2d76028269ca006ca5273 | https://github.com/appium/ruby_lib_core/blob/2d8a8f3433f6774a1cc2d76028269ca006ca5273/script/commands.rb#L108-L112 | train |
basecamp/name_of_person | lib/name_of_person/assignable_name.rb | NameOfPerson.AssignableName.name= | def name=(name)
full_name = NameOfPerson::PersonName.full(name)
self.first_name, self.last_name = full_name&.first, full_name&.last
end | ruby | def name=(name)
full_name = NameOfPerson::PersonName.full(name)
self.first_name, self.last_name = full_name&.first, full_name&.last
end | [
"def",
"name",
"=",
"(",
"name",
")",
"full_name",
"=",
"NameOfPerson",
"::",
"PersonName",
".",
"full",
"(",
"name",
")",
"self",
".",
"first_name",
",",
"self",
".",
"last_name",
"=",
"full_name",
"&.",
"first",
",",
"full_name",
"&.",
"last",
"end"
] | Assigns first_name and last_name attributes as extracted from a supplied full name. | [
"Assigns",
"first_name",
"and",
"last_name",
"attributes",
"as",
"extracted",
"from",
"a",
"supplied",
"full",
"name",
"."
] | 16978debe3d6391739bfef7da5b4df487f44ccda | https://github.com/basecamp/name_of_person/blob/16978debe3d6391739bfef7da5b4df487f44ccda/lib/name_of_person/assignable_name.rb#L6-L9 | train |
salesking/sepa_king | lib/sepa_king/message.rb | SEPA.Message.message_identification= | def message_identification=(value)
raise ArgumentError.new('message_identification must be a string!') unless value.is_a?(String)
regex = /\A([A-Za-z0-9]|[\+|\?|\/|\-|\:|\(|\)|\.|\,|\'|\ ]){1,35}\z/
raise ArgumentError.new("message_identification does not match #{regex}!") unless value.match(regex)
... | ruby | def message_identification=(value)
raise ArgumentError.new('message_identification must be a string!') unless value.is_a?(String)
regex = /\A([A-Za-z0-9]|[\+|\?|\/|\-|\:|\(|\)|\.|\,|\'|\ ]){1,35}\z/
raise ArgumentError.new("message_identification does not match #{regex}!") unless value.match(regex)
... | [
"def",
"message_identification",
"=",
"(",
"value",
")",
"raise",
"ArgumentError",
".",
"new",
"(",
"'message_identification must be a string!'",
")",
"unless",
"value",
".",
"is_a?",
"(",
"String",
")",
"regex",
"=",
"/",
"\\A",
"\\+",
"\\?",
"\\/",
"\\-",
"\... | Set unique identifer for the message | [
"Set",
"unique",
"identifer",
"for",
"the",
"message"
] | bfe6a633c3a4b6077ece313414d790eca5375681 | https://github.com/salesking/sepa_king/blob/bfe6a633c3a4b6077ece313414d790eca5375681/lib/sepa_king/message.rb#L73-L80 | train |
salesking/sepa_king | lib/sepa_king/message.rb | SEPA.Message.batch_id | def batch_id(transaction_reference)
grouped_transactions.each do |group, transactions|
if transactions.select { |transaction| transaction.reference == transaction_reference }.any?
return payment_information_identification(group)
end
end
end | ruby | def batch_id(transaction_reference)
grouped_transactions.each do |group, transactions|
if transactions.select { |transaction| transaction.reference == transaction_reference }.any?
return payment_information_identification(group)
end
end
end | [
"def",
"batch_id",
"(",
"transaction_reference",
")",
"grouped_transactions",
".",
"each",
"do",
"|",
"group",
",",
"transactions",
"|",
"if",
"transactions",
".",
"select",
"{",
"|",
"transaction",
"|",
"transaction",
".",
"reference",
"==",
"transaction_referenc... | Returns the id of the batch to which the given transaction belongs
Identified based upon the reference of the transaction | [
"Returns",
"the",
"id",
"of",
"the",
"batch",
"to",
"which",
"the",
"given",
"transaction",
"belongs",
"Identified",
"based",
"upon",
"the",
"reference",
"of",
"the",
"transaction"
] | bfe6a633c3a4b6077ece313414d790eca5375681 | https://github.com/salesking/sepa_king/blob/bfe6a633c3a4b6077ece313414d790eca5375681/lib/sepa_king/message.rb#L105-L111 | train |
tweetstream/tweetstream | lib/tweetstream/client.rb | TweetStream.Client.follow | def follow(*user_ids, &block)
query = TweetStream::Arguments.new(user_ids)
filter(query.options.merge(:follow => query), &block)
end | ruby | def follow(*user_ids, &block)
query = TweetStream::Arguments.new(user_ids)
filter(query.options.merge(:follow => query), &block)
end | [
"def",
"follow",
"(",
"*",
"user_ids",
",",
"&",
"block",
")",
"query",
"=",
"TweetStream",
"::",
"Arguments",
".",
"new",
"(",
"user_ids",
")",
"filter",
"(",
"query",
".",
"options",
".",
"merge",
"(",
":follow",
"=>",
"query",
")",
",",
"block",
"... | Returns public statuses from or in reply to a set of users. Mentions
("Hello @user!") and implicit replies ("@user Hello!" created without
pressing the reply "swoosh") are not matched. Requires integer user
IDs, not screen names. Query parameters may be passed as the last argument. | [
"Returns",
"public",
"statuses",
"from",
"or",
"in",
"reply",
"to",
"a",
"set",
"of",
"users",
".",
"Mentions",
"(",
"Hello"
] | 27c5f411627dc30ce1268923fc9b408652f98050 | https://github.com/tweetstream/tweetstream/blob/27c5f411627dc30ce1268923fc9b408652f98050/lib/tweetstream/client.rb#L113-L116 | train |
tweetstream/tweetstream | lib/tweetstream/client.rb | TweetStream.Client.userstream | def userstream(query_params = {}, &block)
stream_params = {:host => 'userstream.twitter.com'}
query_params.merge!(:extra_stream_parameters => stream_params)
start('/1.1/user.json', query_params, &block)
end | ruby | def userstream(query_params = {}, &block)
stream_params = {:host => 'userstream.twitter.com'}
query_params.merge!(:extra_stream_parameters => stream_params)
start('/1.1/user.json', query_params, &block)
end | [
"def",
"userstream",
"(",
"query_params",
"=",
"{",
"}",
",",
"&",
"block",
")",
"stream_params",
"=",
"{",
":host",
"=>",
"'userstream.twitter.com'",
"}",
"query_params",
".",
"merge!",
"(",
":extra_stream_parameters",
"=>",
"stream_params",
")",
"start",
"(",
... | Make a call to the userstream api for currently authenticated user | [
"Make",
"a",
"call",
"to",
"the",
"userstream",
"api",
"for",
"currently",
"authenticated",
"user"
] | 27c5f411627dc30ce1268923fc9b408652f98050 | https://github.com/tweetstream/tweetstream/blob/27c5f411627dc30ce1268923fc9b408652f98050/lib/tweetstream/client.rb#L141-L145 | train |
tweetstream/tweetstream | lib/tweetstream/client.rb | TweetStream.Client.start | def start(path, query_parameters = {}, &block)
if EventMachine.reactor_running?
connect(path, query_parameters, &block)
else
if EventMachine.epoll?
EventMachine.epoll
elsif EventMachine.kqueue?
EventMachine.kqueue
else
Kernel.warn('Your OS does n... | ruby | def start(path, query_parameters = {}, &block)
if EventMachine.reactor_running?
connect(path, query_parameters, &block)
else
if EventMachine.epoll?
EventMachine.epoll
elsif EventMachine.kqueue?
EventMachine.kqueue
else
Kernel.warn('Your OS does n... | [
"def",
"start",
"(",
"path",
",",
"query_parameters",
"=",
"{",
"}",
",",
"&",
"block",
")",
"if",
"EventMachine",
".",
"reactor_running?",
"connect",
"(",
"path",
",",
"query_parameters",
",",
"block",
")",
"else",
"if",
"EventMachine",
".",
"epoll?",
"Ev... | connect to twitter while starting a new EventMachine run loop | [
"connect",
"to",
"twitter",
"while",
"starting",
"a",
"new",
"EventMachine",
"run",
"loop"
] | 27c5f411627dc30ce1268923fc9b408652f98050 | https://github.com/tweetstream/tweetstream/blob/27c5f411627dc30ce1268923fc9b408652f98050/lib/tweetstream/client.rb#L413-L429 | train |
tweetstream/tweetstream | lib/tweetstream/client.rb | TweetStream.Client.connect | def connect(path, options = {}, &block)
stream_parameters, callbacks = connection_options(path, options)
@stream = EM::Twitter::Client.connect(stream_parameters)
@stream.each do |item|
begin
hash = MultiJson.decode(item, :symbolize_keys => true)
rescue MultiJson::DecodeError... | ruby | def connect(path, options = {}, &block)
stream_parameters, callbacks = connection_options(path, options)
@stream = EM::Twitter::Client.connect(stream_parameters)
@stream.each do |item|
begin
hash = MultiJson.decode(item, :symbolize_keys => true)
rescue MultiJson::DecodeError... | [
"def",
"connect",
"(",
"path",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"stream_parameters",
",",
"callbacks",
"=",
"connection_options",
"(",
"path",
",",
"options",
")",
"@stream",
"=",
"EM",
"::",
"Twitter",
"::",
"Client",
".",
"connect... | connect to twitter without starting a new EventMachine run loop | [
"connect",
"to",
"twitter",
"without",
"starting",
"a",
"new",
"EventMachine",
"run",
"loop"
] | 27c5f411627dc30ce1268923fc9b408652f98050 | https://github.com/tweetstream/tweetstream/blob/27c5f411627dc30ce1268923fc9b408652f98050/lib/tweetstream/client.rb#L432-L475 | train |
voxpupuli/puppet-syntax | lib/puppet-syntax/hiera.rb | PuppetSyntax.Hiera.check_eyaml_data | def check_eyaml_data(name, val)
error = nil
if val.is_a? String
err = check_eyaml_blob(val)
error = "Key #{name} #{err}" if err
elsif val.is_a? Array
val.each_with_index do |v, idx|
error = check_eyaml_data("#{name}[#{idx}]", v)
break if error
end
... | ruby | def check_eyaml_data(name, val)
error = nil
if val.is_a? String
err = check_eyaml_blob(val)
error = "Key #{name} #{err}" if err
elsif val.is_a? Array
val.each_with_index do |v, idx|
error = check_eyaml_data("#{name}[#{idx}]", v)
break if error
end
... | [
"def",
"check_eyaml_data",
"(",
"name",
",",
"val",
")",
"error",
"=",
"nil",
"if",
"val",
".",
"is_a?",
"String",
"err",
"=",
"check_eyaml_blob",
"(",
"val",
")",
"error",
"=",
"\"Key #{name} #{err}\"",
"if",
"err",
"elsif",
"val",
".",
"is_a?",
"Array",
... | Recurse through complex data structures. Return on first error. | [
"Recurse",
"through",
"complex",
"data",
"structures",
".",
"Return",
"on",
"first",
"error",
"."
] | eb1592218739119a2f9307b3e33b7e1f1df59a7c | https://github.com/voxpupuli/puppet-syntax/blob/eb1592218739119a2f9307b3e33b7e1f1df59a7c/lib/puppet-syntax/hiera.rb#L25-L42 | train |
orta/danger-junit | lib/junit/plugin.rb | Danger.DangerJunit.parse_files | def parse_files(*files)
require 'ox'
@tests = []
failed_tests = []
Array(files).flatten.each do |file|
raise "No JUnit file was found at #{file}" unless File.exist? file
xml_string = File.read(file)
doc = Ox.parse(xml_string)
suite_root = doc.nodes.first.value ... | ruby | def parse_files(*files)
require 'ox'
@tests = []
failed_tests = []
Array(files).flatten.each do |file|
raise "No JUnit file was found at #{file}" unless File.exist? file
xml_string = File.read(file)
doc = Ox.parse(xml_string)
suite_root = doc.nodes.first.value ... | [
"def",
"parse_files",
"(",
"*",
"files",
")",
"require",
"'ox'",
"@tests",
"=",
"[",
"]",
"failed_tests",
"=",
"[",
"]",
"Array",
"(",
"files",
")",
".",
"flatten",
".",
"each",
"do",
"|",
"file",
"|",
"raise",
"\"No JUnit file was found at #{file}\"",
"un... | Parses multiple XML files, which fills all the attributes,
will `raise` for errors
@return [void] | [
"Parses",
"multiple",
"XML",
"files",
"which",
"fills",
"all",
"the",
"attributes",
"will",
"raise",
"for",
"errors"
] | 32fc5d2c026604a0880a3901783628dab06e4877 | https://github.com/orta/danger-junit/blob/32fc5d2c026604a0880a3901783628dab06e4877/lib/junit/plugin.rb#L105-L145 | train |
orta/danger-junit | lib/junit/plugin.rb | Danger.DangerJunit.report | def report
return if failures.nil? # because danger calls `report` before loading a file
warn("Skipped #{skipped.count} tests.") if show_skipped_tests && skipped.count > 0
unless failures.empty? && errors.empty?
fail('Tests have failed, see below for more information.', sticky: false)
... | ruby | def report
return if failures.nil? # because danger calls `report` before loading a file
warn("Skipped #{skipped.count} tests.") if show_skipped_tests && skipped.count > 0
unless failures.empty? && errors.empty?
fail('Tests have failed, see below for more information.', sticky: false)
... | [
"def",
"report",
"return",
"if",
"failures",
".",
"nil?",
"# because danger calls `report` before loading a file",
"warn",
"(",
"\"Skipped #{skipped.count} tests.\"",
")",
"if",
"show_skipped_tests",
"&&",
"skipped",
".",
"count",
">",
"0",
"unless",
"failures",
".",
"e... | Causes a build fail if there are test failures,
and outputs a markdown table of the results.
@return [void] | [
"Causes",
"a",
"build",
"fail",
"if",
"there",
"are",
"test",
"failures",
"and",
"outputs",
"a",
"markdown",
"table",
"of",
"the",
"results",
"."
] | 32fc5d2c026604a0880a3901783628dab06e4877 | https://github.com/orta/danger-junit/blob/32fc5d2c026604a0880a3901783628dab06e4877/lib/junit/plugin.rb#L151-L184 | train |
oleander/git-fame-rb | lib/git_fame/base.rb | GitFame.Base.to_csv | def to_csv
CSV.generate do |csv|
csv << fields
authors.each do |author|
csv << fields.map do |f|
author.send(f)
end
end
end
end | ruby | def to_csv
CSV.generate do |csv|
csv << fields
authors.each do |author|
csv << fields.map do |f|
author.send(f)
end
end
end
end | [
"def",
"to_csv",
"CSV",
".",
"generate",
"do",
"|",
"csv",
"|",
"csv",
"<<",
"fields",
"authors",
".",
"each",
"do",
"|",
"author",
"|",
"csv",
"<<",
"fields",
".",
"map",
"do",
"|",
"f",
"|",
"author",
".",
"send",
"(",
"f",
")",
"end",
"end",
... | Generate csv output | [
"Generate",
"csv",
"output"
] | d0f17660bc26d18e27fd86952a84c4a6164689ec | https://github.com/oleander/git-fame-rb/blob/d0f17660bc26d18e27fd86952a84c4a6164689ec/lib/git_fame/base.rb#L121-L130 | train |
oleander/git-fame-rb | lib/git_fame/base.rb | GitFame.Base.printable_fields | def printable_fields
raw_fields.map do |field|
field.is_a?(Array) ? field.last : field
end
end | ruby | def printable_fields
raw_fields.map do |field|
field.is_a?(Array) ? field.last : field
end
end | [
"def",
"printable_fields",
"raw_fields",
".",
"map",
"do",
"|",
"field",
"|",
"field",
".",
"is_a?",
"(",
"Array",
")",
"?",
"field",
".",
"last",
":",
"field",
"end",
"end"
] | Uses the more printable names in @visible_fields | [
"Uses",
"the",
"more",
"printable",
"names",
"in"
] | d0f17660bc26d18e27fd86952a84c4a6164689ec | https://github.com/oleander/git-fame-rb/blob/d0f17660bc26d18e27fd86952a84c4a6164689ec/lib/git_fame/base.rb#L260-L264 | train |
oleander/git-fame-rb | lib/git_fame/base.rb | GitFame.Base.execute | def execute(command, silent = false, &block)
result = run_with_timeout(command)
if result.success? or silent
warn command if @verbose
return result unless block
return block.call(result)
end
raise Error, cmd_error_message(command, result.data)
rescue Errno::ENOENT
... | ruby | def execute(command, silent = false, &block)
result = run_with_timeout(command)
if result.success? or silent
warn command if @verbose
return result unless block
return block.call(result)
end
raise Error, cmd_error_message(command, result.data)
rescue Errno::ENOENT
... | [
"def",
"execute",
"(",
"command",
",",
"silent",
"=",
"false",
",",
"&",
"block",
")",
"result",
"=",
"run_with_timeout",
"(",
"command",
")",
"if",
"result",
".",
"success?",
"or",
"silent",
"warn",
"command",
"if",
"@verbose",
"return",
"result",
"unless... | Command to be executed at @repository
@silent = true wont raise an error on exit code =! 0 | [
"Command",
"to",
"be",
"executed",
"at"
] | d0f17660bc26d18e27fd86952a84c4a6164689ec | https://github.com/oleander/git-fame-rb/blob/d0f17660bc26d18e27fd86952a84c4a6164689ec/lib/git_fame/base.rb#L313-L323 | train |
oleander/git-fame-rb | lib/git_fame/base.rb | GitFame.Base.current_files | def current_files
if commit_range.is_range?
execute("git #{git_directory_params} -c diff.renames=0 -c diff.renameLimit=1000 diff -M -C -c --name-only --ignore-submodules=all --diff-filter=AM #{encoding_opt} #{default_params} #{commit_range.to_s}") do |result|
filter_files(result.to_s.split(/\n/)... | ruby | def current_files
if commit_range.is_range?
execute("git #{git_directory_params} -c diff.renames=0 -c diff.renameLimit=1000 diff -M -C -c --name-only --ignore-submodules=all --diff-filter=AM #{encoding_opt} #{default_params} #{commit_range.to_s}") do |result|
filter_files(result.to_s.split(/\n/)... | [
"def",
"current_files",
"if",
"commit_range",
".",
"is_range?",
"execute",
"(",
"\"git #{git_directory_params} -c diff.renames=0 -c diff.renameLimit=1000 diff -M -C -c --name-only --ignore-submodules=all --diff-filter=AM #{encoding_opt} #{default_params} #{commit_range.to_s}\"",
")",
"do",
"|"... | List all files in current git directory, excluding
extensions in @extensions defined by the user | [
"List",
"all",
"files",
"in",
"current",
"git",
"directory",
"excluding",
"extensions",
"in"
] | d0f17660bc26d18e27fd86952a84c4a6164689ec | https://github.com/oleander/git-fame-rb/blob/d0f17660bc26d18e27fd86952a84c4a6164689ec/lib/git_fame/base.rb#L380-L391 | train |
tristandunn/pusher-fake | lib/pusher-fake/configuration.rb | PusherFake.Configuration.to_options | def to_options(options = {})
options.merge(
wsHost: socket_options[:host],
wsPort: socket_options[:port],
cluster: "us-east-1",
disableStats: disable_stats
)
end | ruby | def to_options(options = {})
options.merge(
wsHost: socket_options[:host],
wsPort: socket_options[:port],
cluster: "us-east-1",
disableStats: disable_stats
)
end | [
"def",
"to_options",
"(",
"options",
"=",
"{",
"}",
")",
"options",
".",
"merge",
"(",
"wsHost",
":",
"socket_options",
"[",
":host",
"]",
",",
"wsPort",
":",
"socket_options",
"[",
":port",
"]",
",",
"cluster",
":",
"\"us-east-1\"",
",",
"disableStats",
... | Convert the configuration to a hash sutiable for Pusher JS options.
@param [Hash] options Custom options for Pusher client. | [
"Convert",
"the",
"configuration",
"to",
"a",
"hash",
"sutiable",
"for",
"Pusher",
"JS",
"options",
"."
] | 7bd5df7253c0bff4b39f0e4eac9891ba6a1735c4 | https://github.com/tristandunn/pusher-fake/blob/7bd5df7253c0bff4b39f0e4eac9891ba6a1735c4/lib/pusher-fake/configuration.rb#L63-L70 | train |
tristandunn/pusher-fake | lib/pusher-fake/connection.rb | PusherFake.Connection.emit | def emit(event, data = {}, channel = nil)
message = { event: event, data: MultiJson.dump(data) }
message[:channel] = channel if channel
PusherFake.log("SEND #{id}: #{message}")
socket.send(MultiJson.dump(message))
end | ruby | def emit(event, data = {}, channel = nil)
message = { event: event, data: MultiJson.dump(data) }
message[:channel] = channel if channel
PusherFake.log("SEND #{id}: #{message}")
socket.send(MultiJson.dump(message))
end | [
"def",
"emit",
"(",
"event",
",",
"data",
"=",
"{",
"}",
",",
"channel",
"=",
"nil",
")",
"message",
"=",
"{",
"event",
":",
"event",
",",
"data",
":",
"MultiJson",
".",
"dump",
"(",
"data",
")",
"}",
"message",
"[",
":channel",
"]",
"=",
"channe... | Emit an event to the connection.
@param [String] event The event name.
@param [Hash] data The event data.
@param [String] channel The channel name. | [
"Emit",
"an",
"event",
"to",
"the",
"connection",
"."
] | 7bd5df7253c0bff4b39f0e4eac9891ba6a1735c4 | https://github.com/tristandunn/pusher-fake/blob/7bd5df7253c0bff4b39f0e4eac9891ba6a1735c4/lib/pusher-fake/connection.rb#L32-L39 | train |
tristandunn/pusher-fake | lib/pusher-fake/connection.rb | PusherFake.Connection.process | def process(data)
message = MultiJson.load(data, symbolize_keys: true)
event = message[:event]
PusherFake.log("RECV #{id}: #{message}")
if event.start_with?(CLIENT_EVENT_PREFIX)
process_trigger(event, message)
else
process_event(event, message)
end
end | ruby | def process(data)
message = MultiJson.load(data, symbolize_keys: true)
event = message[:event]
PusherFake.log("RECV #{id}: #{message}")
if event.start_with?(CLIENT_EVENT_PREFIX)
process_trigger(event, message)
else
process_event(event, message)
end
end | [
"def",
"process",
"(",
"data",
")",
"message",
"=",
"MultiJson",
".",
"load",
"(",
"data",
",",
"symbolize_keys",
":",
"true",
")",
"event",
"=",
"message",
"[",
":event",
"]",
"PusherFake",
".",
"log",
"(",
"\"RECV #{id}: #{message}\"",
")",
"if",
"event"... | Process an event.
@param [String] data The event data as JSON. | [
"Process",
"an",
"event",
"."
] | 7bd5df7253c0bff4b39f0e4eac9891ba6a1735c4 | https://github.com/tristandunn/pusher-fake/blob/7bd5df7253c0bff4b39f0e4eac9891ba6a1735c4/lib/pusher-fake/connection.rb#L50-L61 | train |
tilfin/ougai | lib/ougai/logging.rb | Ougai.Logging.trace | def trace(message = nil, ex = nil, data = nil, &block)
log(TRACE, message, ex, data, block)
end | ruby | def trace(message = nil, ex = nil, data = nil, &block)
log(TRACE, message, ex, data, block)
end | [
"def",
"trace",
"(",
"message",
"=",
"nil",
",",
"ex",
"=",
"nil",
",",
"data",
"=",
"nil",
",",
"&",
"block",
")",
"log",
"(",
"TRACE",
",",
"message",
",",
"ex",
",",
"data",
",",
"block",
")",
"end"
] | Log any one or more of a message, an exception and structured data as TRACE.
@return [Boolean] true
@see Logging#debug | [
"Log",
"any",
"one",
"or",
"more",
"of",
"a",
"message",
"an",
"exception",
"and",
"structured",
"data",
"as",
"TRACE",
"."
] | 884d8cfebcb9fb4abc3e71571a7f7b132966b561 | https://github.com/tilfin/ougai/blob/884d8cfebcb9fb4abc3e71571a7f7b132966b561/lib/ougai/logging.rb#L24-L26 | train |
tilfin/ougai | lib/ougai/logging.rb | Ougai.Logging.debug | def debug(message = nil, ex = nil, data = nil, &block)
log(DEBUG, message, ex, data, block)
end | ruby | def debug(message = nil, ex = nil, data = nil, &block)
log(DEBUG, message, ex, data, block)
end | [
"def",
"debug",
"(",
"message",
"=",
"nil",
",",
"ex",
"=",
"nil",
",",
"data",
"=",
"nil",
",",
"&",
"block",
")",
"log",
"(",
"DEBUG",
",",
"message",
",",
"ex",
",",
"data",
",",
"block",
")",
"end"
] | Log any one or more of a message, an exception and structured data as DEBUG.
If the block is given for delay evaluation, it returns them as an array or the one of them as a value.
@param message [String] The message to log. Use default_message if not specified.
@param ex [Exception] The exception or the error
@para... | [
"Log",
"any",
"one",
"or",
"more",
"of",
"a",
"message",
"an",
"exception",
"and",
"structured",
"data",
"as",
"DEBUG",
".",
"If",
"the",
"block",
"is",
"given",
"for",
"delay",
"evaluation",
"it",
"returns",
"them",
"as",
"an",
"array",
"or",
"the",
"... | 884d8cfebcb9fb4abc3e71571a7f7b132966b561 | https://github.com/tilfin/ougai/blob/884d8cfebcb9fb4abc3e71571a7f7b132966b561/lib/ougai/logging.rb#L35-L37 | train |
tilfin/ougai | lib/ougai/logging.rb | Ougai.Logging.info | def info(message = nil, ex = nil, data = nil, &block)
log(INFO, message, ex, data, block)
end | ruby | def info(message = nil, ex = nil, data = nil, &block)
log(INFO, message, ex, data, block)
end | [
"def",
"info",
"(",
"message",
"=",
"nil",
",",
"ex",
"=",
"nil",
",",
"data",
"=",
"nil",
",",
"&",
"block",
")",
"log",
"(",
"INFO",
",",
"message",
",",
"ex",
",",
"data",
",",
"block",
")",
"end"
] | Log any one or more of a message, an exception and structured data as INFO.
@return [Boolean] true
@see Logging#debug | [
"Log",
"any",
"one",
"or",
"more",
"of",
"a",
"message",
"an",
"exception",
"and",
"structured",
"data",
"as",
"INFO",
"."
] | 884d8cfebcb9fb4abc3e71571a7f7b132966b561 | https://github.com/tilfin/ougai/blob/884d8cfebcb9fb4abc3e71571a7f7b132966b561/lib/ougai/logging.rb#L42-L44 | train |
tilfin/ougai | lib/ougai/logging.rb | Ougai.Logging.warn | def warn(message = nil, ex = nil, data = nil, &block)
log(WARN, message, ex, data, block)
end | ruby | def warn(message = nil, ex = nil, data = nil, &block)
log(WARN, message, ex, data, block)
end | [
"def",
"warn",
"(",
"message",
"=",
"nil",
",",
"ex",
"=",
"nil",
",",
"data",
"=",
"nil",
",",
"&",
"block",
")",
"log",
"(",
"WARN",
",",
"message",
",",
"ex",
",",
"data",
",",
"block",
")",
"end"
] | Log any one or more of a message, an exception and structured data as WARN.
@return [Boolean] true
@see Logging#debug | [
"Log",
"any",
"one",
"or",
"more",
"of",
"a",
"message",
"an",
"exception",
"and",
"structured",
"data",
"as",
"WARN",
"."
] | 884d8cfebcb9fb4abc3e71571a7f7b132966b561 | https://github.com/tilfin/ougai/blob/884d8cfebcb9fb4abc3e71571a7f7b132966b561/lib/ougai/logging.rb#L49-L51 | train |
tilfin/ougai | lib/ougai/logging.rb | Ougai.Logging.error | def error(message = nil, ex = nil, data = nil, &block)
log(ERROR, message, ex, data, block)
end | ruby | def error(message = nil, ex = nil, data = nil, &block)
log(ERROR, message, ex, data, block)
end | [
"def",
"error",
"(",
"message",
"=",
"nil",
",",
"ex",
"=",
"nil",
",",
"data",
"=",
"nil",
",",
"&",
"block",
")",
"log",
"(",
"ERROR",
",",
"message",
",",
"ex",
",",
"data",
",",
"block",
")",
"end"
] | Log any one or more of a message, an exception and structured data as ERROR.
@return [Boolean] true
@see Logging#debug | [
"Log",
"any",
"one",
"or",
"more",
"of",
"a",
"message",
"an",
"exception",
"and",
"structured",
"data",
"as",
"ERROR",
"."
] | 884d8cfebcb9fb4abc3e71571a7f7b132966b561 | https://github.com/tilfin/ougai/blob/884d8cfebcb9fb4abc3e71571a7f7b132966b561/lib/ougai/logging.rb#L56-L58 | train |
tilfin/ougai | lib/ougai/logging.rb | Ougai.Logging.fatal | def fatal(message = nil, ex = nil, data = nil, &block)
log(FATAL, message, ex, data, block)
end | ruby | def fatal(message = nil, ex = nil, data = nil, &block)
log(FATAL, message, ex, data, block)
end | [
"def",
"fatal",
"(",
"message",
"=",
"nil",
",",
"ex",
"=",
"nil",
",",
"data",
"=",
"nil",
",",
"&",
"block",
")",
"log",
"(",
"FATAL",
",",
"message",
",",
"ex",
",",
"data",
",",
"block",
")",
"end"
] | Log any one or more of a message, an exception and structured data as FATAL.
@return [Boolean] true
@see Logging#debug | [
"Log",
"any",
"one",
"or",
"more",
"of",
"a",
"message",
"an",
"exception",
"and",
"structured",
"data",
"as",
"FATAL",
"."
] | 884d8cfebcb9fb4abc3e71571a7f7b132966b561 | https://github.com/tilfin/ougai/blob/884d8cfebcb9fb4abc3e71571a7f7b132966b561/lib/ougai/logging.rb#L63-L65 | train |
tilfin/ougai | lib/ougai/logging.rb | Ougai.Logging.unknown | def unknown(message = nil, ex = nil, data = nil, &block)
args = block ? yield : [message, ex, data]
append(UNKNOWN, args)
end | ruby | def unknown(message = nil, ex = nil, data = nil, &block)
args = block ? yield : [message, ex, data]
append(UNKNOWN, args)
end | [
"def",
"unknown",
"(",
"message",
"=",
"nil",
",",
"ex",
"=",
"nil",
",",
"data",
"=",
"nil",
",",
"&",
"block",
")",
"args",
"=",
"block",
"?",
"yield",
":",
"[",
"message",
",",
"ex",
",",
"data",
"]",
"append",
"(",
"UNKNOWN",
",",
"args",
"... | Log any one or more of a message, an exception and structured data as UNKNOWN.
@return [Boolean] true
@see Logging#debug | [
"Log",
"any",
"one",
"or",
"more",
"of",
"a",
"message",
"an",
"exception",
"and",
"structured",
"data",
"as",
"UNKNOWN",
"."
] | 884d8cfebcb9fb4abc3e71571a7f7b132966b561 | https://github.com/tilfin/ougai/blob/884d8cfebcb9fb4abc3e71571a7f7b132966b561/lib/ougai/logging.rb#L70-L73 | train |
r-cochran/cuke_sniffer | lib/cuke_sniffer/cli.rb | CukeSniffer.CLI.catalog_step_calls | def catalog_step_calls
puts "\nCataloging Step Calls: "
steps = CukeSniffer::CukeSnifferHelper.get_all_steps(@features, @step_definitions)
steps_map = build_steps_map(steps)
@step_definitions.each do |step_definition|
print '.'
calls = steps_map.find_all {|step, location| step =~... | ruby | def catalog_step_calls
puts "\nCataloging Step Calls: "
steps = CukeSniffer::CukeSnifferHelper.get_all_steps(@features, @step_definitions)
steps_map = build_steps_map(steps)
@step_definitions.each do |step_definition|
print '.'
calls = steps_map.find_all {|step, location| step =~... | [
"def",
"catalog_step_calls",
"puts",
"\"\\nCataloging Step Calls: \"",
"steps",
"=",
"CukeSniffer",
"::",
"CukeSnifferHelper",
".",
"get_all_steps",
"(",
"@features",
",",
"@step_definitions",
")",
"steps_map",
"=",
"build_steps_map",
"(",
"steps",
")",
"@step_definitions... | Determines all normal and nested step calls and assigns them to the corresponding step definition.
Does direct and fuzzy matching | [
"Determines",
"all",
"normal",
"and",
"nested",
"step",
"calls",
"and",
"assigns",
"them",
"to",
"the",
"corresponding",
"step",
"definition",
".",
"Does",
"direct",
"and",
"fuzzy",
"matching"
] | a4fa217c3074b6a172c9be4833d9d5099dc5c317 | https://github.com/r-cochran/cuke_sniffer/blob/a4fa217c3074b6a172c9be4833d9d5099dc5c317/lib/cuke_sniffer/cli.rb#L171-L184 | train |
tech-angels/vandamme | lib/vandamme/parser.rb | Vandamme.Parser.parse | def parse
@changelog.scan(@version_header_exp) do |match|
version_content = $~.post_match
changelog_scanner = StringScanner.new(version_content)
changelog_scanner.scan_until(@version_header_exp)
@changelog_hash[match[@match_group]] = (changelog_scanner.pre_match || version_content)... | ruby | def parse
@changelog.scan(@version_header_exp) do |match|
version_content = $~.post_match
changelog_scanner = StringScanner.new(version_content)
changelog_scanner.scan_until(@version_header_exp)
@changelog_hash[match[@match_group]] = (changelog_scanner.pre_match || version_content)... | [
"def",
"parse",
"@changelog",
".",
"scan",
"(",
"@version_header_exp",
")",
"do",
"|",
"match",
"|",
"version_content",
"=",
"$~",
".",
"post_match",
"changelog_scanner",
"=",
"StringScanner",
".",
"new",
"(",
"version_content",
")",
"changelog_scanner",
".",
"s... | Create a new changelog parser
Options:
* +changelog+:: Changelog content as a +String+.
* +version_header_exp+ (optional):: regexp to match the starting line of version.
Defaults to /^#{0,3} ?([\w\d\.-]+\.[\w\d\.-]+[a-zA-Z0-9])(?: \/ (\w+ \d{1,2}(?:st|nd|rd|th)?,\s\d{4}|\d{4}-\d{2}-\d{2}|\w+))?\n?[=-]*/
See h... | [
"Create",
"a",
"new",
"changelog",
"parser"
] | 9bc3c0651713b24530aed1eb0f4fd9be18eabcc5 | https://github.com/tech-angels/vandamme/blob/9bc3c0651713b24530aed1eb0f4fd9be18eabcc5/lib/vandamme/parser.rb#L35-L43 | train |
nning/transmission-rss | lib/transmission-rss/client.rb | TransmissionRSS.Client.add_torrent | def add_torrent(file, type = :url, options = {})
arguments = set_arguments_from_options(options)
case type
when :url
file = URI.encode(file) if URI.decode(file) == file
arguments.filename = file
when :file
arguments.metainfo = Base64.encode64(File.read(file))
... | ruby | def add_torrent(file, type = :url, options = {})
arguments = set_arguments_from_options(options)
case type
when :url
file = URI.encode(file) if URI.decode(file) == file
arguments.filename = file
when :file
arguments.metainfo = Base64.encode64(File.read(file))
... | [
"def",
"add_torrent",
"(",
"file",
",",
"type",
"=",
":url",
",",
"options",
"=",
"{",
"}",
")",
"arguments",
"=",
"set_arguments_from_options",
"(",
"options",
")",
"case",
"type",
"when",
":url",
"file",
"=",
"URI",
".",
"encode",
"(",
"file",
")",
"... | POST json packed torrent add command. | [
"POST",
"json",
"packed",
"torrent",
"add",
"command",
"."
] | 07baaf149d9e129e98b4cb496d808a528a59bc5b | https://github.com/nning/transmission-rss/blob/07baaf149d9e129e98b4cb496d808a528a59bc5b/lib/transmission-rss/client.rb#L46-L74 | train |
nning/transmission-rss | lib/transmission-rss/client.rb | TransmissionRSS.Client.get_session_id | def get_session_id
get = Net::HTTP::Get.new(@rpc_path)
add_basic_auth(get)
response = request(get)
id = response.header['x-transmission-session-id']
if id.nil?
@log.debug("could not obtain session id (#{response.code}, " +
"#{response.class})")
else
@log... | ruby | def get_session_id
get = Net::HTTP::Get.new(@rpc_path)
add_basic_auth(get)
response = request(get)
id = response.header['x-transmission-session-id']
if id.nil?
@log.debug("could not obtain session id (#{response.code}, " +
"#{response.class})")
else
@log... | [
"def",
"get_session_id",
"get",
"=",
"Net",
"::",
"HTTP",
"::",
"Get",
".",
"new",
"(",
"@rpc_path",
")",
"add_basic_auth",
"(",
"get",
")",
"response",
"=",
"request",
"(",
"get",
")",
"id",
"=",
"response",
".",
"header",
"[",
"'x-transmission-session-id... | Get transmission session id. | [
"Get",
"transmission",
"session",
"id",
"."
] | 07baaf149d9e129e98b4cb496d808a528a59bc5b | https://github.com/nning/transmission-rss/blob/07baaf149d9e129e98b4cb496d808a528a59bc5b/lib/transmission-rss/client.rb#L85-L102 | train |
nning/transmission-rss | lib/transmission-rss/config.rb | TransmissionRSS.Config.merge_yaml! | def merge_yaml!(path, watch = true)
self.merge!(YAML.load_file(path))
rescue TypeError
# If YAML loading fails, .load_file returns `false`.
else
watch_file(path) if watch && linux?
end | ruby | def merge_yaml!(path, watch = true)
self.merge!(YAML.load_file(path))
rescue TypeError
# If YAML loading fails, .load_file returns `false`.
else
watch_file(path) if watch && linux?
end | [
"def",
"merge_yaml!",
"(",
"path",
",",
"watch",
"=",
"true",
")",
"self",
".",
"merge!",
"(",
"YAML",
".",
"load_file",
"(",
"path",
")",
")",
"rescue",
"TypeError",
"# If YAML loading fails, .load_file returns `false`.",
"else",
"watch_file",
"(",
"path",
")",... | Merge Config Hash with Hash from YAML file. | [
"Merge",
"Config",
"Hash",
"with",
"Hash",
"from",
"YAML",
"file",
"."
] | 07baaf149d9e129e98b4cb496d808a528a59bc5b | https://github.com/nning/transmission-rss/blob/07baaf149d9e129e98b4cb496d808a528a59bc5b/lib/transmission-rss/config.rb#L72-L78 | train |
Subsets and Splits
SQL Console for semeru/code-text-ruby
Retrieves 20,000 non-null code samples labeled as Ruby, providing a basic overview of the dataset but without deeper analysis.