idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
23,900 | def replace_nil_binds ( sql , args ) nils = [ ] args . each_with_index { | value , i | nils << i if value . nil? } unless nils . empty? then logger . debug { "SQL executor working around RDBI bug by eliminating the nil arguments #{nils.to_series} for the SQL:\n#{sql}..." } raise ArgumentError . new ( "RDBI work-around ... | Replaces nil arguments with a + NULL + literal in the given SQL . |
23,901 | def current_reading ( doc ) reading = { } xpath = "//table/caption[@class='titleDataHeader'][" xpath += "contains(text(),'Conditions')" xpath += " and " xpath += "not(contains(text(),'Solar Radiation'))" xpath += "]" source_updated_at = reading_timestamp ( doc , xpath ) reading [ :source_updated_at ] = source_updated_a... | Reding from the Conditions at .. as of .. table |
23,902 | def facts logger . debug "get complete data of all VMs in all datacenters: begin" result = Hash [ vm_mos_to_h ( @vcenter . vms ) . map do | h | [ h [ 'name' ] , Hash [ h . map { | k , v | [ k . tr ( '.' , '_' ) , v ] } ] ] end ] logger . debug "get complete data of all VMs in all datacenters: end" result end | get all vms and their facts as hash with vm . name as key |
23,903 | def traverse ( node = nil , & block ) return self . to_enum unless block_given? node_stack = [ node || self ] until node_stack . empty? current = node_stack . shift if current yield current node_stack = node_stack . insert ( 0 , * current . nodes ) if current . respond_to? ( :nodes ) end end node || self if block_given... | pre - order traverse through this node and all of its descendants |
23,904 | def method_missing ( sym , * args , & block ) if ( data && data [ sym ] ) data [ sym ] else super ( sym , * args , & block ) end end | If method is missing try to pass through to underlying data hash . |
23,905 | def validate! logger . debug "Starting validation for #{description}" raise NotFound . new path unless File . exists? path raise NonDirectory . new path unless File . directory? path raise MissingBinary . new vagrant unless File . exists? vagrant raise MissingBinary . new vagrant unless File . executable? vagrant logge... | Initialize an instance for a particular directory |
23,906 | def version logger . info "Determining Vagrant version for #{description}" output = execute! ( "--version" ) . stdout Derelict :: Parser :: Version . new ( output ) . version end | Determines the version of this Vagrant instance |
23,907 | def execute ( subcommand , * arguments , & block ) options = arguments . last . is_a? ( Hash ) ? arguments . pop : Hash . new command = command ( subcommand , * arguments ) command = "sudo -- #{command}" if options . delete ( :sudo ) logger . debug "Executing #{command} using #{description}" Executer . execute command ... | Executes a Vagrant subcommand using this instance |
23,908 | def command ( subcommand , * arguments ) args = [ vagrant , subcommand . to_s , arguments ] . flatten args . map { | a | Shellwords . escape a } . join ( ' ' ) . tap do | command | logger . debug "Generated command '#{command}' from " + "subcommand '#{subcommand.to_s}' with arguments " + arguments . inspect end end | Constructs the command to execute a Vagrant subcommand |
23,909 | def call! ( env ) status , headers , body = @app . call ( env ) if error = env [ 'deas.error' ] error_body = Body . new ( error ) headers [ 'Content-Length' ] = error_body . size . to_s headers [ 'Content-Type' ] = error_body . mime_type . to_s body = [ error_body . content ] end [ status , headers , body ] end | The real Rack call interface . |
23,910 | def sign_in begin sign_in_res = RestClient . get ( Endpoints :: SIGN_IN ) rescue RestClient :: ExceptionWithResponse => error fail HelpDeskAPI :: Exceptions . SignInError , "Error contacting #{Endpoints::SIGN_IN}: #{error}" end page = Nokogiri :: HTML ( sign_in_res ) HelpDeskAPI :: Authentication . authenticity_token =... | Authenicate user and set cookies . This will be called automatically on endpoint request . |
23,911 | def copy_in_bytes bytes , len data_buffer = LibC . malloc len data_buffer . write_string bytes , len LibXS . xs_msg_init_data @pointer , data_buffer , len , LibC :: Free , nil end | Makes a copy of + len + bytes from the ruby string + bytes + . Library handles deallocation of the native memory buffer . |
23,912 | def check @definition . namespaces . each do | ( namespace , ns ) | ns . items . each do | key , _ | lookup ( namespace , key ) end end end | check items have a value . Will raise Undefined error if a required item has no value . |
23,913 | def check_opts ( constraints , opts ) opts ||= { } opts . each { | k , v | raise "opt not permitted: #{k.inspect}" if ! constraints . has_key? ( k ) } Hash [ constraints . map do | k , constraint | if opts . has_key? ( k ) v = opts [ k ] if constraint . is_a? ( Array ) raise "unknown value for opt #{k.inspect}: #{v.ins... | simple option checking with value constraints and sub - hash checking |
23,914 | def max4 ( a , b , c , d ) x = a >= b ? a : b y = c >= d ? c : d ( x >= y ) ? x : y end | Returns the max of 4 integers |
23,915 | def get_complex ( path ) client ( path ) . get_complex ( service_name ( path ) , section_name ( path ) , graph_name ( path ) ) . tap do | graph | graph [ 'base_uri' ] = client ( path ) . base_uri graph [ 'path' ] = path end end | Get a complex graph |
23,916 | def delete_complex ( path ) client ( path ) . delete_complex ( service_name ( path ) , section_name ( path ) , graph_name ( path ) ) end | Delete a complex graph |
23,917 | def certificate_create ( global_options , options ) result = Excon . post ( "#{global_options[:fenton_server_url]}/certificates.json" , body : certificate_json ( options ) , headers : { 'Content-Type' => 'application/json' } ) write_client_certificate ( public_key_cert_location ( options [ :public_key ] ) , JSON . pars... | Sends a post request with json from the command line certificate |
23,918 | def set_relations ( context , relation ) @contexts ||= { } @contexts [ relation ] ||= [ ] @media_relation_set ||= [ ] if @contexts [ relation ] . include? ( context ) raise Exception . new ( "You should NOT use same context identifier for several has_one or has_many relation to media" ) end @contexts [ relation ] << co... | set_relations add relation on medium if not exists Also check if a class has a duplicate context |
23,919 | def method_missing meth , * args , & block meth_s = meth . to_s if @method && meth_s =~ API_REGEX if meth_s . end_with? ( '!' ) self [ meth_s [ 0 ... - 1 ] ] . ! ( args [ 0 ] || { } ) else self [ meth_s ] end else super end end | this is where the fun begins ... |
23,920 | def save ( path ) unless path . kind_of? String raise ArgumentError , 'save expects a string path' end Xcellus :: _save ( @handle , path ) end | Saves the current modifications to the provided path . |
23,921 | def changelog_modified? ( * changelogs ) changelogs = config . changelogs if changelogs . nil? || changelogs . empty? changelogs . any? { | changelog | git . modified_files . include? ( changelog ) } end | Check if any changelog were modified . When the helper receives nothing changelogs defined by the config are used . |
23,922 | def has_app_changes? ( * sources ) sources = config . sources if sources . nil? || sources . empty? sources . any? do | source | pattern = Samsao :: Regexp . from_matcher ( source , when_string_pattern_prefix_with : '^' ) modified_file? ( pattern ) end end | Return true if any source files are in the git modified files list . |
23,923 | def truncate ( input , max = 30 ) return input if input . nil? || input . length <= max input [ 0 .. max - 1 ] . gsub ( / \s \w \s / , '...' ) end | Truncate the string received . |
23,924 | def resolve @leaf ||= begin ref = self loop do break ref unless ref . target . kind_of? MultiGit :: Ref ref = ref . target end end end | Resolves symbolic references and returns the final reference . |
23,925 | def commit ( options = { } , & block ) resolve . update ( options . fetch ( :lock , :optimistic ) ) do | current | Commit :: Builder . new ( current , & block ) end return reload end | Shorthand method to directly create a commit and update the given ref . |
23,926 | def set_session_current_user ( user ) self . current_user = user if session [ :authpwn_suid ] token = Tokens :: SessionUid . with_code ( session [ :authpwn_suid ] ) . first if token if token . user == user token . touch return user else token . destroy end end end if user session [ :authpwn_suid ] = Tokens :: SessionUi... | Sets up the session so that it will authenticate the given user . |
23,927 | def authenticate_using_session return if current_user session_uid = session [ :authpwn_suid ] user = session_uid && Tokens :: SessionUid . authenticate ( session_uid ) self . current_user = user if user && ! user . instance_of? ( Symbol ) end | The before_action that implements authenticates_using_session . |
23,928 | def del tkar_id tkaroid = @objects [ tkar_id ] if tkaroid if @follow_id == tkar_id follow nil end delete tkaroid . tag @objects . delete tkar_id @changed . delete tkar_id get_objects_by_layer ( tkaroid . layer ) . delete tkaroid end end | Not delete ! That already exists in tk . |
23,929 | def add path , kwargs = { } remove_files = kwargs . arg :remove_files , false cmd = 'aptly repo add' cmd += ' -remove-files' if remove_files cmd += " #{@name.quote} #{path}" Aptly :: runcmd cmd end | Add debian packages to a repo |
23,930 | def import from_mirror , kwargs = { } deps = kwargs . arg :deps , false packages = kwargs . arg :packages , [ ] if packages . length == 0 raise AptlyError . new '1 or more packages are required' end cmd = 'aptly repo import' cmd += ' -with-deps' if deps cmd += " #{from_mirror.quote} #{@name.quote}" packages . each { | ... | Imports package resources from existing mirrors |
23,931 | def copy from_repo , to_repo , kwargs = { } deps = kwargs . arg :deps , false packages = kwargs . arg :packages , [ ] if packages . length == 0 raise AptlyError . new '1 or more packages are required' end cmd = 'aptly repo copy' cmd += ' -with-deps' if deps cmd += " #{from_repo.quote} #{to_repo.quote}" packages . each ... | Copy package resources from one repository to another |
23,932 | def login ( code = nil ) @client = Google :: APIClient . new @client . authorization . client_id = c ( 'client_id' ) @client . authorization . client_secret = c ( 'client_secret' ) @client . authorization . scope = @scope @client . authorization . redirect_uri = c ( 'redirect_uri' ) @api = @client . discovered_api ( @n... | Classic oauth 2 login |
23,933 | def login_by_line ( server = 'http://localhost/oauth2callback' , port = 0 ) begin require "launchy" rescue raise GoogleApi :: RequireError , "You don't have launchy gem. Firt install it: gem install launchy." end require "socket" require "uri" uri = URI ( server ) webserver = TCPServer . new ( uri . host , port ) uri .... | Automaticaly open autorization url a waiting for callback . Launchy gem is required |
23,934 | def add_namespace ( image , path ) namespace path . to_sym do | _args | require 'rspec/core/rake_task' :: RSpec :: Core :: RakeTask . new ( :spec ) do | task | task . pattern = "#{path}/spec/*_spec.rb" end docker_image = Vtasks :: Docker :: Image . new ( image , path , args ) lint_image ( path ) desc 'Build and tag doc... | def define_tasks Image namespace |
23,935 | def dockerfiles @dockerfiles = Dir . glob ( '*' ) . select do | dir | File . directory? ( dir ) && File . exist? ( "#{dir}/Dockerfile" ) end end | List all folders containing Dockerfiles |
23,936 | def list_images desc 'List all Docker images' task :list do info dockerfiles . map { | image | File . basename ( image ) } end end | List all images |
23,937 | def html_options_for_form ( url_for_options , options ) options . stringify_keys . tap do | html_options | html_options [ "enctype" ] = "multipart/form-data" if html_options . delete ( "multipart" ) html_options [ "action" ] = forward_return_hook ( url_for ( url_for_options ) ) html_options [ "accept-charset" ] = "UTF-... | This method overrides the rails built in form helper s action setting code to inject a return path |
23,938 | def deploy! ( app , settings = [ ] ) @beanstalk . update_environment ( { version_label : app . version , environment_name : self . name , option_settings : settings } ) end | Assuming the provided app has already been uploaded update this environment to the app s version Optionally pass in a bunch of settings to override |
23,939 | def create! ( archive , stack , cnames , settings = [ ] ) params = { application_name : archive . app_name , version_label : archive . version , environment_name : self . name , solution_stack_name : stack , option_settings : settings } cnames . each do | c | if dns_available ( c ) params [ :cname_prefix ] = c break el... | Assuming the archive has already been uploaded create a new environment with the app deployed onto the provided stack . Attempts to use the first available cname in the cnames array . |
23,940 | def fix_utf8 ( s = nil ) s = self if s . nil? if String . method_defined? ( :scrub ) return s . scrub { | bytes | '<' + bytes . unpack ( 'H*' ) [ 0 ] + '>' } else return DR :: Encoding . to_utf8 ( s ) end end | if a mostly utf8 has some mixed in latin1 characters replace the invalid characters |
23,941 | def to_utf8! ( s = nil , from : nil ) s = self if s . nil? from = s . encoding if from . nil? return s . encode! ( 'UTF-8' , from , :invalid => :replace , :undef => :replace , :fallback => Proc . new { | bytes | '<' + bytes . unpack ( 'H*' ) [ 0 ] + '>' } ) end | assume ruby > = 1 . 9 here |
23,942 | def __mock_dispatch_spy @stub . __mock_disps . values . flatten . each do | disp | next unless __mock_defis . key? ( disp . msg ) defis = __mock_defis [ disp . msg ] if idx = __mock_find_checked_difi ( defis , disp . args , :index ) __mock_disps_push ( defis . delete_at ( idx ) ) elsif defis . empty? __mock_failed ( di... | spies don t leave any track simulate dispatching before passing to mock to verify |
23,943 | def check_non_single_commit_feature ( level = :fail ) commit_count = git . commits . size message = "Your feature branch should have a single commit but found #{commit_count}, squash them together!" report ( level , message ) if feature_branch? && commit_count > 1 end | Check if a feature branch have more than one commit . |
23,944 | def check_feature_jira_issue_number ( level = :fail ) return if samsao . trivial_change? || ! samsao . feature_branch? return report ( :fail , 'Your Danger config is missing a `jira_project_key` value.' ) unless jira_project_key? message = 'The PR title must starts with JIRA issue number between square brackets' " (i.e... | Check if a feature branch contains a single JIRA issue number matching the jira project key . |
23,945 | def check_fix_jira_issue_number ( level = :warn ) return if samsao . trivial_change? || ! samsao . fix_branch? return report ( :fail , 'Your Danger config is missing a `jira_project_key` value.' ) unless jira_project_key? git . commits . each do | commit | check_commit_contains_jira_issue_number ( commit , level ) end ... | Check if all fix branch commit s message contains any JIRA issue number matching the jira project key . |
23,946 | def check_acceptance_criteria ( level = :warn ) return unless samsao . feature_branch? message = 'The PR description should have the acceptance criteria in the body.' report ( level , message ) if ( / /i =~ github . pr_body ) . nil? end | Check if it s a feature branch and if the PR body contains acceptance criteria . |
23,947 | def check_label_pr ( level = :fail ) message = 'The PR should have at least one label added to it.' report ( level , message ) if github . pr_labels . nil? || github . pr_labels . empty? end | Check if the PR has at least one label added to it . |
23,948 | def report ( level , content ) case level when :warn warn content when :fail fail content when :message message content else raise "Report level '#{level}' is invalid." end end | Send report to danger depending on the level . |
23,949 | def check_commit_contains_jira_issue_number ( commit , type ) commit_id = "#{shorten_sha(commit.sha)} ('#{truncate(commit.message)}')" jira_project_key = config . jira_project_key message = "The commit message #{commit_id} should contain JIRA issue number" " between square brackets (i.e. [#{jira_project_key}-XXX]), mul... | Check if the commit s message contains any JIRA issue number matching the jira project key . |
23,950 | def wait config . ui . logger . debug { "wait" } pid , status = ( Process . wait2 ( @pid ) rescue nil ) if ! pid . nil? && ! status . nil? data = ( Marshal . load ( Base64 . decode64 ( @parent_reader . read . to_s ) ) rescue nil ) config . ui . logger . debug { "read(#{data.inspect})" } ! data . nil? and @result = data... | Wait for the background process to finish . |
23,951 | def extract_columns ( rows , header ) columns = [ ] header . each do | h | columns << rows . map do | r | r . send ( h ) end end columns end | Extracts the columns to display in the table based on the header column names |
23,952 | def max_column_widths ( columns , header , opts = { } ) row_column_widths = columns . map do | c | c . reduce ( 0 ) { | m , v | [ m , v . nil? ? 0 : v . length ] . max } end header_column_widths = header . map { | h | h . length } row_column_widths = header_column_widths if row_column_widths . empty? widths = row_colum... | Determines max column widths for each column based on the data and header columns . |
23,953 | def print_horizontal_line ( line , separator , widths ) puts widths . map { | width | line * width } . join ( separator ) end | Prints a horizontal line below the header |
23,954 | def print_table ( columns , formatter ) columns . transpose . each { | row | puts sprintf ( formatter , * row ) } end | Prints columns in a table format |
23,955 | def all ( path , options = { } , & block ) all = [ ] list_type , list_item = get_list_types ( path ) result = request ( 'GET' , path , options ) raise RequestError . new result . status if result . status_code != 200 or result . parsed [ list_type ] . nil? total = result . parsed [ list_type ] [ 'totalItems' ] . to_i i... | get ALL records at path by paging through record set can pass block to act on each page of results |
23,956 | def post_blob_url ( url ) raise ArgumentError . new ( "Invalid blob URL #{url}" ) unless URI . parse ( url ) . scheme =~ / / request 'POST' , "blobs" , { query : { "blobUri" => url } , } end | create blob record by external url |
23,957 | def to_object ( record , attribute_map , stringify_keys = false ) attributes = { } attribute_map . each do | map | map = map . inject ( { } ) { | memo , ( k , v ) | memo [ k . to_s ] = v ; memo } if stringify_keys if map [ "with" ] as = deep_find ( record , map [ "key" ] , map [ "nested_key" ] ) values = [ ] if as . is... | parsed record and map to get restructured object |
23,958 | def topic if @topic @topic else connected do fiber = Fiber . current callbacks = { } [ 331 , 332 , 403 , 442 ] . each do | numeric | callbacks [ numeric ] = @thaum . on ( numeric ) do | event_data | topic = event_data [ :params ] . match ( ':(.*)' ) . captures . first fiber . resume topic end end raw "TOPIC #{@name}" @... | Experimental no tests so far . |
23,959 | def search! query , operations = [ ] , & block result = @agent_page . search query result = operations . reduce ( result ) do | tmp , op | tmp . __send__ op end if result yield result if block_given? result end | at returns the first one only but search returns all |
23,960 | def get_output ( file ) file_dir = File . dirname ( file ) file_name = File . basename ( file ) . split ( '.' ) [ 0 .. - 2 ] . join ( '.' ) file_name = "#{file_name}.js" if file_name . match ( "\.js" ) . nil? file_dir = file_dir . gsub ( Regexp . new ( "#{@options[:input]}(\/){0,1}" ) , '' ) if @options [ :input ] file... | Get the file path to output the html based on the file being built . The output path is relative to where guard is being run . |
23,961 | def slice ( ** options ) defaults = { lower : nil , upper : nil , exclusive : false , lex : @lex } self . class :: Slice . new ( self , ** defaults . merge ( options ) ) end | Returns a slice or partial selection of the set . |
23,962 | def to_enum ( match : '*' , count : 10 , with_scores : false ) enumerator = self . connection . zscan_each ( @key , match : match , count : count ) return enumerator if with_scores return Enumerator . new do | yielder | loop do item , = enumerator . next yielder << item end end end | Use redis - rb zscan_each method to iterate over particular keys |
23,963 | def delete ( key , timeout = 2000 ) result_raw = @conn . call ( :delete , [ key , timeout ] ) result = @conn . class . process_result_delete ( result_raw ) @lastDeleteResult = result [ :results ] if result [ :success ] == true return result [ :ok ] elsif result [ :success ] == :timeout raise TimeoutError . new ( result... | Create a new object using the given connection . Tries to delete the value at the given key . |
23,964 | def prettify ( blocks ) docs_blocks , code_blocks = blocks rendered_html = self . class . renderer . render ( docs_blocks . join ( "\n\n##### DIVIDER\n\n" ) ) rendered_html = ' ' if rendered_html == '' docs_html = rendered_html . split ( / \n \/ \n /m ) docs_html . zip ( code_blocks ) end | Take the result of split and apply Markdown formatting to comments |
23,965 | def method_missing ( method , * args ) if method . to_s =~ / \w \? / v = self . class . find_by_symbol ( $1 ) raise NameError unless v other = v . to_sym self . class . class_eval { define_method ( method ) { self . to_sym == other } } return self . to_sym == other end super end | Allow to test for a specific role or similar like Role . accountant? |
23,966 | def flush_cache Rails . cache . delete ( [ self . class . name , symbol_was . to_s ] ) Rails . cache . delete ( [ self . class . name , id ] ) end | Flushes cache if record is saved |
23,967 | def find_blob ( blob_name , current_tree = root_tree , & block ) blob = current_tree [ blob_name ] if blob blob = repository . lookup ( blob [ :oid ] ) if ! block_given? || yield ( blob ) return blob end end current_tree . each_tree do | sub_tree | blob = find_blob ( blob_name , repository . lookup ( sub_tree [ :oid ] ... | Recursively searches for the blob identified by blob_name in all subdirectories in the repository . A blob is usually either a file or a directory . |
23,968 | def conditions_hash_validations conditions . each do | comparator , mappings | errors . add ( :conditions , "can't use undefined comparators" ) unless Scram :: DSL :: Definitions :: COMPARATORS . keys . include? comparator . to_sym errors . add ( :conditions , "comparators must have values of type Hash" ) unless mappin... | Validates that the conditions Hash follows an expected format |
23,969 | def register_data_path ( path ) path = File . expand_path ( path ) DataPaths . register ( path ) data_paths << path unless data_paths . include? ( path ) return path end | Registers a path as a data directory . |
23,970 | def unregister_data_path ( path ) path = File . expand_path ( path ) self . data_paths . delete ( path ) return DataPaths . unregister! ( path ) end | Unregisters any matching data directories . |
23,971 | def unregister_data_paths data_paths . each { | path | DataPaths . unregister! ( path ) } data_paths . clear return true end | Unregisters all previously registered data directories . |
23,972 | def reinit_with ( coder ) @attributes_cache = { } dirty = @changed_attributes . keys attributes = self . class . initialize_attributes ( coder [ 'attributes' ] . except ( * dirty ) ) @attributes . update ( attributes ) @changed_attributes . update ( coder [ 'attributes' ] . slice ( * dirty ) ) @changed_attributes . del... | Reinitialize an Identity Map model object from + coder + . + coder + must contain the attributes necessary for initializing an empty model object . |
23,973 | def sso require "discourse_mountable_sso/single_sign_on" sso = DiscourseMountableSso :: SingleSignOn . parse ( ( ( session [ :discourse_mountable_sso ] || { } ) . delete ( :query_string ) . presence || request . query_string ) , @config . secret ) discourse_data = send @config . discourse_data_method discourse_data . e... | ensures user must login |
23,974 | def followers ( count = 10 ) count = 0 if count . is_a? ( Symbol ) && count == :all query = "SELECT * FROM meme.followers(#{count}) WHERE owner_guid='#{self.guid}'" parse = Request . parse ( query ) if parse results = parse [ 'query' ] [ 'results' ] results . nil? ? nil : results [ 'meme' ] . map { | m | Info . new ( m... | Return user followers |
23,975 | def posts ( quantity = 0 ) query = "SELECT * FROM meme.posts(#{quantity}) WHERE owner_guid='#{self.guid}';" parse = Request . parse ( query ) if parse results = parse [ 'query' ] [ 'results' ] results . nil? ? nil : results [ 'post' ] . map { | m | Post . new ( m ) } else parse . error! end end | Retrieves all posts of an user |
23,976 | def add_links_from_file ( file ) File . foreach ( file ) do | line | next if line . chomp . empty? url , name , description , tag = line . chomp . split ( ';' ) website . add_link ( Link . new ( url , { name : name , description : description , tag : tag } ) ) end end | Reads arguments from a CSV file and creates links accordingly . The links are added to the websie |
23,977 | def export ( format ) message = "to_#{format.downcase}" if website . respond_to? message website . send ( message ) else raise "cannot export to #{format}" end end | Export links to specified format |
23,978 | def update_links_from_file ( file ) File . foreach ( file ) do | line | next if line . chomp . empty? url , name , description , tag = line . chomp . split ( ';' ) website . find_links ( url ) . first . update ( { name : name , description : description , tag : tag } ) end end | Updates links read from a file |
23,979 | def remove_links ( urls ) urls . map { | url | list_links ( { url : url } ) } . flatten . compact . each do | link | website . remove_link ( link ) end end | Deletes one or more links from the website . Returns the deleted links . Expects the links provided in an array |
23,980 | def remove_links_from_file ( file ) urls = File . foreach ( file ) . map { | url | url . chomp unless url . empty? } remove_links ( urls ) end | Deletes links based on URLs that are provided in a file . Each URL has to be in one line |
23,981 | def save_website ( directory ) File . open ( yaml_file ( directory , website . title ) , 'w' ) do | f | YAML . dump ( website , f ) end end | Saves the website to the specified directory with the downcased name of the website and the extension website . The website is save as YAML |
23,982 | def delete_website ( directory ) if File . exists? yaml_file ( directory , website . title ) FileUtils . rm ( yaml_file ( directory , website . title ) ) end end | Deletes the website if it already exists |
23,983 | def parse ( data = nil ) data ||= @raw_data css_out = [ ] data . strip_side_space! . strip_space! data . split ( '}' ) . each_with_index do | assignments , index | tags , styles = assignments . split ( '{' ) . map { | a | a . strip_side_space! } unless styles . blank? tags . strip_selector_space! tags . gsub! ( / \. / ... | returns a hash of all CSS data passed |
23,984 | def load_enviroment ( file = nil ) file ||= "." if File . directory? ( file ) && File . exists? ( File . expand_path ( "#{file}/config/environment.rb" ) ) require 'rails' require File . expand_path ( "#{file}/config/environment.rb" ) if defined? ( :: Rails ) && :: Rails . respond_to? ( :application ) :: Rails . applica... | Loads the environment from the given configuration file . |
23,985 | def each_element ( e_node_type = nil , & block ) @children . each do | c | if c . kind_of? MDElement if ( not e_node_type ) || ( e_node_type == c . node_type ) block . call c end c . each_element ( e_node_type , & block ) end end end | Yields to each element of specified node_type All elements if e_node_type is nil . |
23,986 | def replace_each_string ( & block ) for c in @children if c . kind_of? MDElement c . replace_each_string ( & block ) end end processed = [ ] until @children . empty? c = @children . shift if c . kind_of? String result = block . call ( c ) [ * result ] . each do | e | processed << e end else processed << c end end @chil... | Apply passed block to each String in the hierarchy . |
23,987 | def and_before_calling_original self . and_wrap_original do | m , * args , & block | yield * args m . call ( * args , & block ) end end | Will call the given block with all the actual arguments every time the method is called |
23,988 | def and_after_calling_original self . and_wrap_original do | m , * args , & block | result = m . call ( * args , & block ) yield result result end end | Will call the given block with it s result every time the method returns |
23,989 | def acts_as_integer_infinitable ( fields , options = { } ) options [ :infinity_value ] = - 1 unless options . key? :infinity_value fields . each do | field | define_method ( "#{field}=" ) do | value | int_value = value == Float :: INFINITY ? options [ :infinity_value ] : value write_attribute ( field , int_value ) end ... | Allows the fields to store an Infinity value . |
23,990 | def query ( template_or_hql , * path ) String === template_or_hql ? query_hql ( template_or_hql ) : query_template ( template_or_hql , path ) end | Creates a new PersistenceService with the specified application service name and options . |
23,991 | def query_hql ( hql ) logger . debug { "Building HQLCriteria..." } criteria = HQLCriteria . new ( hql ) target = hql [ / \s \S /i , 1 ] raise DatabaseError . new ( "HQL does not contain a FROM clause: #{hql}" ) unless target logger . debug { "Submitting search on target class #{target} with the following HQL:\n #{hql}... | Dispatches the given HQL to the application service . |
23,992 | def query_association_post_caCORE_v4 ( obj , attribute ) assn = obj . class . association ( attribute ) begin result = dispatch { | svc | svc . association ( obj , assn ) } rescue Exception => e logger . error ( "Error fetching association #{obj} - #{e}" ) raise end end | Returns an array of domain objects associated with obj through the specified attribute . This method uses the + caCORE + v . 4 + getAssociation application service method . |
23,993 | def run_partially ( paths ) return if paths . empty? displayed_paths = paths . map { | path | smart_path ( path ) } UI . info "Inspecting Yarddocs: #{displayed_paths.join(' ')}" inspect_with_yardstick ( path : paths ) end | Runs yardstick on a partial set of paths passed in by guard |
23,994 | def inspect_with_yardstick ( yardstick_options = { } ) config = :: Yardstick :: Config . coerce ( yardstick_config ( yardstick_options ) ) measurements = :: Yardstick . measure ( config ) measurements . puts rescue StandardError => error UI . error 'The following exception occurred while running ' "guard-yardstick: #{e... | Runs yardstick and outputs results to STDOUT |
23,995 | def yardstick_config ( extra_options = { } ) return options unless options [ :config ] yardstick_options = YAML . load_file ( options [ :config ] ) yardstick_options . merge ( extra_options ) end | Merge further options with yardstick config file . |
23,996 | def domain_error! ( first , * args ) first = [ first ] + args unless args . empty? raise TypeError , "Can't convert `#{first.inspect}` into #{self}" , caller end | Raises a type error for args . |
23,997 | def login_url options email = options . delete ( :email ) or raise ArgumentError . new ( "No :email passed for user" ) user_identifier = options . delete ( :user_identifier ) or raise ArgumentError . new ( "No :user_identifier passed for user" ) authenticated_parameters = build_authenticated_parameters ( email , user_i... | Used to build the authenticated parameters for logging in an end - user on checkd . in via a redirect . |
23,998 | def call url = URI ( api_url ) http = Net :: HTTP . new ( url . host , url . port ) http . use_ssl = true http . verify_mode = OpenSSL :: SSL :: VERIFY_NONE url . query = URI . encode_www_form ( @params ) if @params request = Net :: HTTP :: Get . new ( url ) request [ 'key' ] = ENV [ 'MESER_ONGKIR_API_KEY' ] http . req... | Creating new object |
23,999 | def method_missing ( sym , * args , & block ) matchers = natural_language . keywords [ 'matchers' ] be_word = matchers [ 'be' ] if matchers sym = be_to_english ( sym , be_word ) return Matchers :: BePredicate . new ( sym , * args , & block ) if be_predicate? ( sym ) return Matchers :: Has . new ( sym , * args , & block... | Method Missing that returns Predicate for the respective sym word Search the translate be word in the languages . yml for the rspec - i18n try to comunicate with the Rspec |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.