idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
5,600 | def get_rsrc ( rsrc , format = :json ) validate_connected raise JSS :: InvalidDataError , 'format must be :json or :xml' unless %i[ json xml ] . include? format rsrc = URI . encode rsrc begin @last_http_response = @cnx [ rsrc ] . get ( accept : format ) rescue RestClient :: ExceptionWithResponse => e handle_http_error ... | disconnect Get an arbitrary JSS resource |
5,601 | def put_rsrc ( rsrc , xml ) validate_connected xml . gsub! ( / \r / , ' ' ) @last_http_response = @cnx [ rsrc ] . put ( xml , content_type : 'text/xml' ) rescue RestClient :: ExceptionWithResponse => e handle_http_error e end | Change an existing JSS resource |
5,602 | def post_rsrc ( rsrc , xml = '' ) validate_connected xml . gsub! ( / \r / , ' ' ) if xml @last_http_response = @cnx [ rsrc ] . post xml , content_type : 'text/xml' , accept : :json rescue RestClient :: ExceptionWithResponse => e handle_http_error e end | Create a new JSS resource |
5,603 | def delete_rsrc ( rsrc , xml = nil ) validate_connected raise MissingDataError , 'Missing :rsrc' if rsrc . nil? return delete_with_payload rsrc , xml if xml @last_http_response = @cnx [ rsrc ] . delete rescue RestClient :: ExceptionWithResponse => e handle_http_error e end | post_rsrc Delete a resource from the JSS |
5,604 | 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 raise JSS :: NoSuchItemError , 'No distribut... | 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 . |
5,605 | 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_distribution... | 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 |
5,606 | 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 Find the ids of the network segments that contain a given IP address . |
5,607 | 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 |
5,608 | def verify_basic_args ( args ) 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 for user '#{args[:user]}'" unless args... | Raise execeptions if we don t have essential data for the connection |
5,609 | def verify_server_version @connected = true begin @server = JSS :: Server . new get_rsrc ( 'jssuser' ) [ :user ] , self rescue RestClient :: Unauthorized raise JSS :: AuthenticationError , "Incorrect JSS username or password for '#{@user}@#{@server_host}:#{@port}'." end min_vers = JSS . parse_jss_version ( JSS :: MINIM... | Verify that we can connect with the args provided and that the server version is high enough for this version of ruby - jss . |
5,610 | def build_rest_url ( args ) @server_host = args [ :server ] @port = args [ :port ] . to_i if args [ :server_path ] @server_path = args [ :server_path ] . sub %r{ } , Regexp . last_match ( 1 ) @server_path << '/' end args [ :use_ssl ] = args [ :use_ssl ] != false || SSL_PORTS . include? ( @port ) @protocol = 'http' @pro... | Build the base URL for the API connection |
5,611 | def site = ( new_site ) return nil unless updatable? || creatable? 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_id ] return nil if new_name == @site_name raise JSS :: NoSuchItemError , "S... | cat assigned? Change the site of this object . Any of the NON_SITES values will unset the site |
5,612 | 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 ] @site_id = site_data [ :id ] end | Parse the site data from any incoming API data |
5,613 | 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_elem . add_element 'site' end site_e... | parse site Add the site to the XML for POSTing or PUTting to the API . |
5,614 | def associate ( computer ) if computer =~ / / 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}" unless JSS :: Computer ... | Associate this peripheral with a computer . |
5,615 | def check_field ( field , value ) @field_defs ||= JSS :: PeripheralType . fetch ( :name => @type , api : @api ) . fields . compact required_fields = @field_defs . map { | f | f [ :name ] } raise JSS :: InvalidDataError , "Peripherals of type '#{@type}' doesn't have a field '#{field}', they only have: #{required_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 . |
5,616 | 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 :: NoSuchItemError , "No Patch Title ma... | 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 |
5,617 | 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}." raise JSS :: NoSuc... | raise an exception if a given target version is not valid for this policy Otherwise return it |
5,618 | 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 | Update our local version data after the target_version is changed |
5,619 | 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 | Add this user to a site |
5,620 | 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 | Remove this user from a site |
5,621 | 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 | Does this network segment overlap with another? |
5,622 | 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 | Does this network segment include an address or another segment? Inclusion means the other is completely inside this one . |
5,623 | 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 | Does this network segment equal another? equality means the ranges are equal |
5,624 | 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 | set the override buildings option |
5,625 | 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 | set the department |
5,626 | 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 | set the override depts option |
5,627 | 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 | set the distribution_point |
5,628 | 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 | set the netboot_server |
5,629 | 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 | set the sw update server |
5,630 | 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 . last @need_to_update = true end | set a new starting and ending addr at the same time . |
5,631 | 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? @filename = n... | filename = Change the script s display name |
5,632 | def os_requirements = ( new_val ) new_val = [ ] if new_val . to_s . empty? case new_val when String new_val = JSS . expand_min_os ( new_val ) if new_val =~ / / when Array new_val . map! { | a | a =~ / / ? JSS . expand_min_os ( a ) : a } new_val . flatten! new_val . uniq! else raise JSS :: InvalidDataError , 'os_require... | name = Change the os_requirements |
5,633 | 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 | os_requirements = Change the priority of this script |
5,634 | def parameters = ( new_val ) return nil if new_val == @parameters new_val = { } if new_val . nil? || ( new_val == '' ) raise JSS :: InvalidDataError , ':parameters must be a Hash with keys :parameter4 thru :parameter11' unless new_val . is_a? ( Hash ) && ( ( new_val . keys & PARAMETER_KEYS ) == new_val . keys ) new_val... | notes = Replace all the script parameters at once . |
5,635 | 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 ) retur... | parameters = Change one of the stored parameters |
5,636 | 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 when Pathname new_val . read else raise JSS :: InvalidDataError , 'New code must be a String (path or code) or Pathname instance' end raise JSS :: InvalidDataError , "Scr... | Change the executable code of this script . |
5,637 | 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 JSS :: DistributionPoint . master_distribution_point . unmount if unmou... | upload Delete the filename from the master distribution point if it exists . |
5,638 | 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 ] op... | Run this script on the current machine using the jamf runScript command . |
5,639 | 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 . add_e... | Return the xml for creating or updating this script in the JSS |
5,640 | 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 | Replace the details of one specific field . |
5,641 | 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 . |
5,642 | 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 | Remove a field from the array of fields . |
5,643 | 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_T... | is a Hash of field data OK for use in the JSS? Return true or raise an exception |
5,644 | 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 | Remove a member by id or name |
5,645 | 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 .... | 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 . |
5,646 | 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 | Set email notifications on or off |
5,647 | 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 | Set web notifications on or off |
5,648 | def rest_xml doc = REXML :: Document . new 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' notifs . add_element ( 'web_notification' ... | Return the REST XML for this title with the current values for saving or updating . |
5,649 | 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' next if versions [ vers ] . package_id == :none pkg . add_elemen... | rest_xml add xml for any package changes to patch versions |
5,650 | 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 this t... | Raise an exception if object history is not available for this object |
5,651 | def validate_external_init_data hash_to_check = @init_data [ :general ] ? @init_data [ :general ] : @init_data combined_valid_keys = self . class :: REQUIRED_DATA_KEYS + self . class :: VALID_DATA_KEYS keys_ok = ( hash_to_check . keys & combined_valid_keys ) . count == combined_valid_keys . count unless keys_ok raise (... | If we were passed pre - lookedup API data validate it raising exceptions if not valid . |
5,652 | 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 ] raise JSS... | 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 . |
5,653 | def look_up_object_data ( args ) rsrc = if args [ :fetch_rsrc ] args [ :fetch_rsrc ] else rsrc_key , lookup_value = find_rsrc_keys ( args ) "#{self.class::RSRC_BASE}/#{rsrc_key}/#{lookup_value}" end args [ :rsrc_object_key ] ||= self . class :: RSRC_OBJECT_KEY raw_json = if defined? self . class :: USE_XML_WORKAROUND J... | Given initialization args perform an API lookup for an object . |
5,654 | 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 | Return a String with the XML Resource for submitting creation or changes to the JSS via the API via the Creatable or Updatable modules |
5,655 | 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 |
5,656 | def read ( file ) Pathname . new ( file ) . read . each_line do | line | next if line =~ / \s / line . strip =~ / \w \s \S / next unless $1 attr = $1 . to_sym setter = "#{attr}=" . to_sym value = $2 . strip if CONF_KEYS . keys . include? attr if value value = value . send ( CONF_KEYS [ attr ] ) end self . send ( setter... | Read in any prefs file |
5,657 | 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 | Set whether or not the VPP licenses should be assigned by device rather than by user |
5,658 | 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 | Insert an appropriate vpp element into the XML for sending changes to the JSS |
5,659 | 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 . |
5,660 | 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 . |
5,661 | 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 | Sorts the data by the currently set criteria and returns an array of profiling results . |
5,662 | 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 , total_time : :to_milliseconds , } , description : false ) ] . join ( "\n" ) end | Sorts the data by the currently set criteria and returns a pretty printed table as a string . |
5,663 | def asm ( str , arch : nil ) arch = Util . system_arch if arch . nil? compiler = Compiler . new ( arch ) str . lines . each { | l | compiler . process ( l ) } compiler . compile! . map ( & :asm ) . join end | Assembler of seccomp bpf . |
5,664 | def work ( argv ) 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 ) return show ( "SeccompTools Version #{SeccompTools::VERSION}" ) if preoption . include? ( '--version' ) return show (... | Main working method of CLI . |
5,665 | def disasm ( raw , arch : nil ) codes = to_bpf ( raw , arch ) contexts = Array . new ( codes . size ) { Set . new } contexts [ 0 ] . add ( Context . new ) dis = codes . zip ( contexts ) . map do | code , ctxs | ctxs . each do | ctx | code . branch ( ctx ) do | pc , c | contexts [ pc ] . add ( c ) unless pc >= contexts ... | Disassemble bpf codes . |
5,666 | 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 SeccompTools :: Instruction :: MISC when :ret then SeccompTools :: Instruc... | Corresponding instruction object . |
5,667 | def supported_archs @supported_archs ||= Dir . glob ( File . join ( __dir__ , 'consts' , '*.rb' ) ) . map { | f | File . basename ( f , '.rb' ) . to_sym } . sort end | Get currently supported architectures . |
5,668 | 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 | Wrapper color codes . |
5,669 | 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 | Set commands implemented in this core library . |
5,670 | 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 . |
5,671 | 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 . |
5,672 | def message_identification = ( value ) raise ArgumentError . new ( 'message_identification must be a string!' ) unless value . is_a? ( String ) regex = / \A \+ \? \/ \- \: \( \) \. \, \' \ \z / raise ArgumentError . new ( "message_identification does not match #{regex}!" ) unless value . match ( regex ) @message_ident... | Set unique identifer for the message |
5,673 | 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 | Returns the id of the batch to which the given transaction belongs Identified based upon the reference of the transaction |
5,674 | def follow ( * user_ids , & block ) query = TweetStream :: Arguments . new ( user_ids ) filter ( query . options . merge ( :follow => query ) , & block ) end | Returns public statuses from or in reply to a set of users . Mentions ( Hello |
5,675 | 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 | Make a call to the userstream api for currently authenticated user |
5,676 | 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 not support epoll or kqueue.' ) end EventMachine... | connect to twitter while starting a new EventMachine run loop |
5,677 | 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 invoke_call... | connect to twitter without starting a new EventMachine run loop |
5,678 | 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 elsif val . is_a? Hash val . each do | k , v | error... | Recurse through complex data structures . Return on first error . |
5,679 | 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 == 'testsuites' ? doc . no... | Parses multiple XML files which fills all the attributes will raise for errors |
5,680 | def report return if failures . nil? 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 ) message = "### Tests: \n\n" tests = ( failures + errors ) common_attribu... | Causes a build fail if there are test failures and outputs a markdown table of the results . |
5,681 | 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 | Generate csv output |
5,682 | def printable_fields raw_fields . map do | field | field . is_a? ( Array ) ? field . last : field end end | Uses the more printable names in |
5,683 | 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 raise Error , cmd_error_messag... | Command to be executed at |
5,684 | 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 / ) ) end... | List all files in current git directory excluding extensions in |
5,685 | def to_options ( options = { } ) options . merge ( wsHost : socket_options [ :host ] , wsPort : socket_options [ :port ] , cluster : "us-east-1" , disableStats : disable_stats ) end | Convert the configuration to a hash sutiable for Pusher JS options . |
5,686 | 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 | Emit an event to the connection . |
5,687 | 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 | Process an event . |
5,688 | 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 . |
5,689 | 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 . |
5,690 | 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 . |
5,691 | 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 . |
5,692 | 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 . |
5,693 | 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 . |
5,694 | def unknown ( message = nil , ex = nil , data = nil , & block ) args = block ? yield : [ message , ex , data ] append ( UNKNOWN , args ) end | Log any one or more of a message an exception and structured data as UNKNOWN . |
5,695 | 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 =~ step_definition . ... | Determines all normal and nested step calls and assigns them to the corresponding step definition . Does direct and fuzzy matching |
5,696 | 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 ) . gsub (... | Create a new changelog parser |
5,697 | 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 ) ) else raise ArgumentError . ... | POST json packed torrent add command . |
5,698 | 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 . debug ( 'got session id ' + id ) end... | Get transmission session id . |
5,699 | def merge_yaml! ( path , watch = true ) self . merge! ( YAML . load_file ( path ) ) rescue TypeError else watch_file ( path ) if watch && linux? end | Merge Config Hash with Hash from YAML file . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.