idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
16,000 | def migrate ( direction ) return unless respond_to? ( direction ) case direction when :up then announce_migration "migrating" when :down then announce_migration "reverting" end time = Benchmark . measure { send ( direction ) } case direction when :up then announce_migration "migrated (%.4fs)" % time . real ; puts when ... | Execute this migration in the named direction . |
16,001 | def announce_migration ( message ) text = "#{name}: #{message}" length = [ 0 , 75 - text . length ] . max puts "== %s %s" % [ text , "=" * length ] end | Generates output labeled with name of migration and a line that goes up to 75 characters long in the terminal |
16,002 | def operation_history ( options = nil ) history = RecursiveOpenStruct . new ( send_request ( "/api/operation-history" , options ) . parsed_response ) history . operations = history . operations . map do | operation | RecursiveOpenStruct . new operation end history end | Returns operation history of a user s wallet |
16,003 | def operation_details ( operation_id ) request = send_request ( "/api/operation-details" , operation_id : operation_id ) RecursiveOpenStruct . new request . parsed_response end | Returns details of operation specified by operation_id |
16,004 | def incoming_transfer_accept ( operation_id , protection_code = nil ) uri = "/api/incoming-transfer-accept" if protection_code request_body = { operation_id : operation_id , protection_code : protection_code } else request_body = { operation_id : operation_id } end RecursiveOpenStruct . new send_request ( "/api/incomin... | Accepts incoming transfer with a protection code or deferred transfer |
16,005 | def api_execute ( path , method , options = { } ) params = options [ :params ] case method when :get req = build_http_request ( Net :: HTTP :: Get , path , params ) when :post req = build_http_request ( Net :: HTTP :: Post , path , nil , params ) when :put req = build_http_request ( Net :: HTTP :: Put , path , nil , pa... | This method sends api request to etcd server . |
16,006 | def process_http_request ( res ) case res when HTTP_SUCCESS Log . debug ( 'Http success' ) res when HTTP_CLIENT_ERROR fail Error . from_http_response ( res ) else Log . debug ( 'Http error' ) Log . debug ( res . body ) res . error! end end | need to have original request to process the response when it redirects |
16,007 | def list ( reverse = false ) requests = server . current_requests_full . reject do | request | local . merged? request . head . sha end source = local . source if requests . empty? puts "No pending requests for '#{source}'." else puts "Pending requests for '#{source}':" puts "ID Updated Comments Title" . pink ... | List all pending requests . |
16,008 | def show ( number , full = false ) request = server . get_request_by_number ( number ) option = full ? '' : '--stat ' diff = "diff --color=always #{option}HEAD...#{request.head.sha}" print_request_details request puts git_call ( diff ) print_request_discussions request end | Show details for a single request . |
16,009 | def browse ( number ) request = server . get_request_by_number ( number ) Launchy . open request . _links . html . href end | Open a browser window and review a specified request . |
16,010 | def checkout ( number , branch = true ) request = server . get_request_by_number ( number ) puts 'Checking out changes to your local repository.' puts 'To get back to your original state, just run:' puts puts ' git checkout master' . pink puts remote = local . remote_for_request ( request ) git_call "fetch #{remote}" ... | Checkout a specified request s changes to your local repository . |
16,011 | def approve ( number ) request = server . get_request_by_number ( number ) repo = server . source_repo comment = 'Reviewed and approved.' response = server . add_comment ( repo , request . number , comment ) if response [ :body ] == comment puts 'Successfully approved request.' else puts response [ :message ] end end | Add an approving comment to the request . |
16,012 | def merge ( number ) request = server . get_request_by_number ( number ) if request . head . repo message = "Accept request ##{request.number} " + "and merge changes into \"#{local.target}\"" command = "merge -m '#{message}' #{request.head.sha}" puts puts "Request title:" puts " #{request.title}" puts puts "Merge comm... | Accept a specified request by merging it into master . |
16,013 | def close ( number ) request = server . get_request_by_number ( number ) repo = server . source_repo server . close_issue ( repo , request . number ) unless server . request_exists? ( 'open' , request . number ) puts 'Successfully closed request.' end end | Close a specified request . |
16,014 | def create ( upstream = false ) original_branch , local_branch = prepare if local . uncommitted_changes? puts 'You have uncommitted changes.' puts 'Please stash or commit before creating the request.' return end if local . new_commits? ( upstream ) if server . request_exists_for_branch? ( upstream ) puts 'A pull reques... | Create a new request . |
16,015 | def print_repo_deleted ( request ) user = request . head . user . login url = request . patch_url puts "Sorry, #{user} deleted the source repository." puts "git-review doesn't support this." puts "Tell the contributor not to do this." puts puts "You can still manually patch your repo by running:" puts puts " curl #{ur... | someone deleted the source repo |
16,016 | def move_local_changes ( original_branch , feature_name ) feature_branch = create_feature_name ( feature_name ) git_call "checkout -b #{feature_branch}" if local . source_branch == feature_branch save_uncommitted_changes = local . uncommitted_changes? git_call ( 'stash' ) if save_uncommitted_changes git_call ( "checkou... | Move uncommitted changes from original_branch to a feature_branch . |
16,017 | def to_s ( ver = 0 , prefix = true ) return "#{name}=#{value}" if ver == 0 str = prefix ? "$Version=#{version};" : '' str << "#{name}=#{value};$Path=\"#{path}\"" str << ";$Domain=#{domain}" if domain . start_with? '.' str << ";$Port=\"#{ports.join ','}\"" if ports str end | Returns cookie in a format appropriate to send to a server . |
16,018 | def to_hash result = { name : @name , value : @value , domain : @domain , path : @path , created_at : @created_at } { expiry : @expiry , secure : ( true if @secure ) , http_only : ( true if @http_only ) , version : ( @version if version != 0 ) , comment : @comment , comment_url : @comment_url , discard : ( true if @dis... | Return a hash representation of the cookie . |
16,019 | def should_send? ( request_uri , script ) uri = CookieJar :: CookieValidation . to_uri request_uri path = if uri . path == '' '/' else uri . path end path_match = path . start_with? @path secure_match = ! ( @secure && uri . scheme == 'http' ) script_match = ! ( script && @http_only ) expiry_match = ! expired? ports_mat... | Determine if a cookie should be sent given a request URI along with other options . |
16,020 | def remotes_with_urls result = { } git_call ( 'remote -vv' ) . split ( "\n" ) . each do | line | entries = line . split ( "\t" ) remote = entries . first target_entry = entries . last . split ( ' ' ) direction = target_entry . last [ 1 .. - 2 ] . to_sym target_url = target_entry . first result [ remote ] ||= { } result... | Create a Hash with all remotes as keys and their urls as values . |
16,021 | def remotes_for_url ( remote_url ) result = remotes_with_urls . collect do | remote , urls | remote if urls . values . all? { | url | url == remote_url } end result . compact end | Collect all remotes for a given url . |
16,022 | def remote_for_request ( request ) repo_owner = request . head . repo . owner . login remote_url = server . remote_url_for ( repo_owner ) remotes = remotes_for_url ( remote_url ) if remotes . empty? remote = "review_#{repo_owner}" git_call ( "remote add #{remote} #{remote_url}" , debug_mode , true ) else remote = remot... | Find or create the correct remote for a fork with a given owner name . |
16,023 | def clean_remotes protected_remotes = remotes_for_branches remotes . each do | remote | if remote . index ( 'review_' ) == 0 && ! protected_remotes . include? ( remote ) git_call "remote remove #{remote}" end end end | Remove obsolete remotes with review prefix . |
16,024 | def remotes_for_branches remotes = git_call ( 'branch -lvv' ) . gsub ( '* ' , '' ) . split ( "\n" ) . map do | line | line . split ( ' ' ) [ 2 ] [ 1 .. - 2 ] . split ( '/' ) . first end remotes . uniq end | Find all remotes which are currently referenced by local branches . |
16,025 | def remote_for_branch ( branch_name ) git_call ( 'branch -lvv' ) . gsub ( '* ' , '' ) . split ( "\n" ) . each do | line | entries = line . split ( ' ' ) next unless entries . first == branch_name match = entries [ 2 ] . match ( %r( \[ \] ) ) return match [ 1 ] . split ( '/' ) . first if match end nil end | Finds the correct remote for a given branch name . |
16,026 | def clean_single ( number , force = false ) request = server . pull_request ( source_repo , number ) if request && request . state == 'closed' branch_name = request . head . ref if unmerged_commits? ( branch_name ) && ! force puts "Won't delete branches that contain unmerged commits." puts "Use '--force' to override." ... | clean a single request s obsolete branch |
16,027 | def clean_all ( review_branches - protected_branches ) . each do | branch_name | delete_branch ( branch_name ) unless unmerged_commits? ( branch_name , false ) end end | clean all obsolete branches |
16,028 | def target_repo ( upstream = false ) if upstream server . repository ( source_repo ) . parent . full_name else source_repo end end | if to send a pull request to upstream repo get the parent as target |
16,029 | def set_cookie2 ( request_uri , cookie_header_value ) cookie = Cookie . from_set_cookie2 request_uri , cookie_header_value add_cookie cookie end | Given a request URI and a literal Set - Cookie2 header value attempt to add the cookie to the cookie store . |
16,030 | def to_a result = [ ] @domains . values . each do | paths | paths . values . each do | cookies | cookies . values . inject result , :<< end end result end | Return an array of all cookie objects in the jar |
16,031 | def expire_cookies ( session = false ) @domains . delete_if do | _domain , paths | paths . delete_if do | _path , cookies | cookies . delete_if do | _cookie_name , cookie | cookie . expired? || ( session && cookie . session? ) end cookies . empty? end paths . empty? end end | Look through the jar for any cookies which have passed their expiration date or session cookies from a previous session |
16,032 | def get_cookies ( request_uri , opts = { } ) uri = to_uri request_uri hosts = Cookie . compute_search_domains uri return [ ] if hosts . nil? path = if uri . path == '' '/' else uri . path end results = [ ] hosts . each do | host | domain = find_domain host domain . each do | apath , cookies | next unless path . start_w... | Given a request URI return a sorted list of Cookie objects . Cookies will be in order per RFC 2965 - sorted by longest path length but otherwise unordered . |
16,033 | def get_cookie_header ( request_uri , opts = { } ) cookies = get_cookies request_uri , opts ver = [ [ ] , [ ] ] cookies . each do | cookie | ver [ cookie . version ] << cookie end if ver [ 1 ] . empty? cookies . map ( & :to_s ) . join ';' else result = '' unless ver [ 0 ] . empty? result << '$Version=0;' result << ver ... | Given a request URI return a string Cookie header . Cookies will be in order per RFC 2965 - sorted by longest path length but otherwise unordered . |
16,034 | def []= ( name , value ) memoized = true @memory . compute_if_absent ( name ) do memoized = false value end fail ArgumentError , "The method #{name} is already memoized" if memoized end | Store the value in memory |
16,035 | def attributes! ( object , * attrs ) attrs . each do | attr | method_missing attr , object . send ( attr ) end end | Adds a new JsonPair for each attribute in attrs by taking attr as key and value of that attribute in object . |
16,036 | def array! ( args ) __array args . each do | arg | @level += 1 yield arg @level -= 1 value = @stack . pop if ( JsonArray === value && value . values . length <= 1 ) value = value . values . first end @stack [ @level ] . add value end end | Creates array of json objects in current element from array passed to this method . Accepts block which yields each array element . |
16,037 | def error ( text = "" ) e = / \s \d \s \s / . match ( text ) || { } name = ( e [ 2 ] || "UnknownError" ) . titleize code = e [ 1 ] || - 1 error_class = name . gsub ( / \s / , "" ) if error_class == "NothingFound" [ ] else begin raise Semrush :: Exception . const_get ( error_class ) . new ( self , "#{name} (#{code})" ) ... | Format and raise an error |
16,038 | def each_ancestor ( * types , & block ) return to_enum ( __method__ , * types ) unless block_given? types . flatten! if types . empty? visit_ancestors ( & block ) else visit_ancestors_with_types ( types , & block ) end self end | Calls the given block for each ancestor node in the order from parent to root . If no block is given an Enumerator is returned . |
16,039 | def each_child_node ( * types ) return to_enum ( __method__ , * types ) unless block_given? types . flatten! children . each do | child | next unless child . is_a? ( Node ) yield child if types . empty? || types . include? ( child . type ) end self end | Calls the given block for each child node . If no block is given an Enumerator is returned . |
16,040 | def each_descendant ( * types , & block ) return to_enum ( __method__ , * types ) unless block_given? types . flatten! if types . empty? visit_descendants ( & block ) else visit_descendants_with_types ( types , & block ) end self end | Calls the given block for each descendant node with depth first order . If no block is given an Enumerator is returned . |
16,041 | def each_node ( * types , & block ) return to_enum ( __method__ , * types ) unless block_given? types . flatten! yield self if types . empty? || types . include? ( type ) if types . empty? visit_descendants ( & block ) else visit_descendants_with_types ( types , & block ) end self end | Calls the given block for the receiver and each descendant node with depth first order . If no block is given an Enumerator is returned . |
16,042 | def acts_as_avatarable ( options = { } ) options [ :styles ] ||= AvatarsForRails . avatarable_styles cattr_accessor :avatarable_options self . avatarable_options = options include AvatarsForRails :: Avatarable end | Adds an ActiveRecord model with support for avatars |
16,043 | def create_memoized_method name , method , freezer = @method_name , @original_method , @freezer @descendant . module_eval do define_method ( name ) do | & block | fail BlockNotAllowedError . new ( self . class , name ) if block memoized_method_cache . fetch ( name ) do freezer . call ( method . bind ( self ) . call ) e... | Create a new memoized method |
16,044 | def all summoner_id : result = perform_request api_url "champion-masteries/by-summoner/#{summoner_id}" result . map { | c | DynamicModel . new c } end | Get all champion mastery entries sorted by number of champion points descending |
16,045 | def all free_to_play : false result = perform_request api_url ( "champions" , "freeToPlay" => free_to_play ) result [ "champions" ] . map { | c | DynamicModel . new c } end | Retrieve all champions |
16,046 | def symbolize_key ( key ) return key unless key . respond_to? ( :split ) key . split ( ':' ) . last . underscore . to_sym end | Given a key convert to symbol removing XML namespace if any . |
16,047 | def symbolize_keys_deep ( hash ) return hash unless hash . is_a? ( Hash ) Hash [ hash . map do | key , value | if value . is_a? Array value = value . map { | element | symbolize_keys_deep ( element ) } elsif value . is_a? Hash value = symbolize_keys_deep ( value ) end [ symbolize_key ( key ) , value ] end ] end | Recursively transforms a hash |
16,048 | def to_s public_vars = instance_variables . reject do | var | INSTANCE_VARIABLE_LOG_BLACKLIST . include? var end public_vars . map! do | var | "#{var}=\"#{instance_variable_get(var)}\"" end public_vars = public_vars . join ( ' ' ) "<##{self.class}:#{object_id.to_s(8)} #{public_vars}>" end | Like Object . to_s except excludes BLACKLISTed instance vars |
16,049 | def create_tournament provider_id : , name : nil body = { "providerId" => provider_id , "name" => name } . delete_if do | k , v | v . nil? end perform_request api_url ( "tournaments" ) , :post , body end | Creates a tournament and returns its ID . |
16,050 | def create_codes tournament_id : , count : nil , allowed_participants : nil , map_type : "SUMMONERS_RIFT" , metadata : nil , team_size : 5 , pick_type : "TOURNAMENT_DRAFT" , spectator_type : "ALL" body = { "allowedSummonerIds" => allowed_participants , "mapType" => map_type , "metadata" => metadata , "pickType" => pick... | Create a tournament code for the given tournament . |
16,051 | def update_code tournament_code , allowed_participants : nil , map_type : nil , pick_type : nil , spectator_type : nil body = { "allowedSummonerIds" => allowed_participants , "mapType" => map_type , "pickType" => pick_type , "spectatorType" => spectator_type } . compact perform_request api_url ( "codes/#{tournament_cod... | Update the pick type map spectator type or allowed summoners for a code . |
16,052 | def all_lobby_events tournament_code : result = perform_request api_url "lobby-events/by-code/#{tournament_code}" result [ "eventList" ] . map { | e | DynamicModel . new e } end | Gets a list of lobby events by tournament code |
16,053 | def find_by_name name name = CGI . escape name . downcase . gsub ( / \s / , '' ) DynamicModel . new perform_request api_url "summoners/by-name/#{name}" end | Get a summoner by summoner name . |
16,054 | def apply Logger . set_name @name if @name Logger . set_verbosity @verbosity if @verbosity Logger . set_file @file if @file Logger . set_format @log_format if @log_format if @colours . is_a? Proc @colours . call else ColourThemes . send @colours . to_sym end end | Put the settings from this object in effect . |
16,055 | def api_url path , params = { } url = File . join File . join ( api_base_url , api_base_path ) , path "#{url}?#{api_query_string params}" end | Returns a full url for an API call |
16,056 | def clean_url ( url ) uri = URI . parse ( url ) uri . query = CGI . parse ( uri . query || '' ) . reject { | k | k == 'api_key' } . to_query uri . to_s end | Returns just a path from a full api url |
16,057 | def perform_request url , verb = :get , body = nil , options = { } options_id = options . inspect can_cache = [ :post , :put ] . include? ( verb ) ? false : cached? if can_cache && result = store . get ( "#{clean_url(url)}#{options_id}" ) return JSON . parse ( result ) end response = perform_rate_limited_request ( url ... | Calls the API via HTTParty and handles errors caching it if a cache is enabled and rate limiting it if a rate limiter is configured |
16,058 | def run Open3 . popen3 ( @cmd ) do | stdin , stdout , stderr , wait_thr | stdin . close stdout_buffer = "" stderr_buffer = "" streams = [ stdout , stderr ] while streams . length > 0 IO . select ( streams ) . flatten . compact . each do | io | if io . eof? streams . delete io next end stdout_buffer += io . readpartial ... | Execute the command and collect all the data from it . |
16,059 | def by_summoner_id summoner_id result = perform_request api_url "masteries/by-summoner/#{summoner_id}" result [ "pages" ] . map { | p | DynamicModel . new p } end | Get mastery pages for a given summoner ID |
16,060 | def define_writer! ( k , definition ) define_method ( "#{k}=" ) do | value | value = ensure_schema value , definition [ :schema ] instance_variable_set "@#{k}" , value self . changed_attributes ||= Set . new self . changed_attributes << k end end | Helper for dynamically defining writer method |
16,061 | def check_children ( child_schema , value ) return unless child_schema && value . present? if value . is_a? Array value . map ( & :errors ) . reject ( & :empty? ) else value . errors end end | Given a schema and a value which may be a single record or collection collect and return any errors . |
16,062 | def check_validation ( valid , value ) return unless valid && value passes_validation = begin valid . call ( value ) rescue StandardError false end passes_validation ? nil : 'is invalid' end | Checks that required field meets validation |
16,063 | def append! ( errors , attr , key , val ) return unless val . present? errors ||= { } errors [ attr ] ||= { } errors [ attr ] [ key ] = val end | Mutates errors adding in error messages scoped to the attribute and key |
16,064 | def to_hash serialized_attributes = attributes . dup self . class . expandable_attributes . each_pair . select do | attribute_name , expanded_class | if expanded_class === attributes [ attribute_name ] serialized_attributes [ attribute_name ] = serialized_attributes [ attribute_name ] . id end end serialized_attributes... | Attributes used for serialization |
16,065 | def update ( id , url = default_webhook_url ) params = { :url => url } Mailgun . submit :put , webhook_url ( id ) , params end | Updates an existing webhook |
16,066 | def update ( address , new_address , options = { } ) params = { :address => new_address } Mailgun . submit :put , list_url ( address ) , params . merge ( options ) end | Update a mailing list with a given address with an optional new address name or description |
16,067 | def encrypt ( data ) raise NoPublicKeyError , "Public key file: #{public_key_file}" unless public? encrypted_data = public_rsa . public_encrypt ( data ) [ encrypted_data ] . pack ( 'm' ) end | Creates a new cipher that uses an asymmetric encryption strategy . |
16,068 | def decrypt ( data ) raise NoPrivateKeyError , "Private key file: #{private_key_file}" unless private? decrypted_data = data . unpack ( 'm' ) [ 0 ] private_rsa . private_decrypt ( decrypted_data ) end | Decrypts the given data . If no private key file has been specified then a NoPrivateKeyError will be raised . |
16,069 | def private_rsa if password options = { :password => password } options [ :algorithm ] = algorithm if algorithm private_key = @private_key . decrypt ( :symmetric , options ) OpenSSL :: PKey :: RSA . new ( private_key ) else @private_rsa ||= OpenSSL :: PKey :: RSA . new ( @private_key ) end end | Retrieves the private RSA from the private key |
16,070 | def encrypt ( data ) Digest :: const_get ( algorithm . upcase ) . hexdigest ( build ( data , salt ) ) end | Returns the encrypted value of the data |
16,071 | def build ( data , salt ) if builder . is_a? ( Proc ) builder . call ( data , salt ) else builder . send ( :build , data , salt ) end end | Builds the value to hash based on the data being encrypted and the salt being used to seed the encryption algorithm |
16,072 | def check_request_auth ( timestamp , token , signature , offset = - 5 ) if offset != 0 offset = Time . now . to_i + offset * 60 return false if timestamp < offset end return signature == OpenSSL :: HMAC . hexdigest ( OpenSSL :: Digest :: Digest . new ( 'sha256' ) , Mailgun . api_key , '%s%s' % [ timestamp , token ] ) e... | check request auth |
16,073 | def json hash = { :started => @started , :finished => @finished , :results => @results , :type => @type } hash [ :world ] = world if world hash [ :hive_job_id ] = hive_job_id if hive_job_id JSON . pretty_generate ( hash ) end | Dump as json |
16,074 | def decrypt ( data ) cipher = build_cipher ( :decrypt ) cipher . update ( data . unpack ( 'm' ) [ 0 ] ) + cipher . final end | Creates a new cipher that uses a symmetric encryption strategy . |
16,075 | def encrypt ( data ) cipher = build_cipher ( :encrypt ) [ cipher . update ( data ) + cipher . final ] . pack ( 'm' ) end | Encrypts the current string using the current key and algorithm specified |
16,076 | def create ( domain , opts = { } ) opts = { name : domain } . merge ( opts ) Mailgun . submit :post , domain_url , opts end | Add domain to account |
16,077 | def index ( * coords ) s = coords . last coords . reverse [ 1 .. - 1 ] . each do | c | s = perm ( s ) + c end perm ( s ) end | A simple hashing |
16,078 | def add ( member_address , options = { } ) params = { :address => member_address } Mailgun . submit :post , list_member_url , params . merge ( options ) end | Adds a mailing list member with a given address NOTE Use create instead of add? |
16,079 | def update ( member_address , options = { } ) params = { :address => member_address } Mailgun . submit :put , list_member_url ( member_address ) , params . merge ( options ) end | Update a mailing list member with a given address |
16,080 | def cancel_pairing block_given? ? @o_dev [ I_DEVICE ] . CancelPairing ( & Proc . new ) : @o_dev [ I_DEVICE ] . CancelPairing ( ) true rescue DBus :: Error => e case e . name when E_DOES_NOT_EXIST then true when E_FAILED then false else raise ScriptError end end | This method can be used to cancel a pairing operation initiated by the Pair method . |
16,081 | def is_paired? @o_dev [ I_DEVICE ] [ 'Paired' ] rescue DBus :: Error => e case e . name when E_UNKNOWN_OBJECT raise StalledObject else raise ScriptError end end | Indicates if the remote device is paired |
16,082 | def trusted = ( val ) if ! [ true , false ] . include? ( val ) raise ArgumentError , "value must be a boolean" end @o_dev [ I_DEVICE ] [ 'Trusted' ] = val end | Indicates if the remote is seen as trusted . This setting can be changed by the application . |
16,083 | def blocked = ( val ) if ! [ true , false ] . include? ( val ) raise ArgumentError , "value must be a boolean" end @o_dev [ I_DEVICE ] [ 'Blocked' ] = val end | If set to true any incoming connections from the device will be immediately rejected . Any device drivers will also be removed and no new ones will be probed as long as the device is blocked |
16,084 | def refresh! _require_connection! max_wait ||= 1.5 @services = Hash [ @o_dev . subnodes . map { | p_srv | p_srv = [ @o_dev . path , p_srv ] . join '/' o_srv = BLUEZ . object ( p_srv ) o_srv . introspect srv = o_srv . GetAll ( I_GATT_SERVICE ) . first char = Hash [ o_srv . subnodes . map { | char | p_char = [ o_srv . pa... | Refresh list of services and characteristics |
16,085 | def action_bar ( show_action_bar , opts = { } ) @action_bar_options = ( { show : true , back : true , icon : false } ) . merge ( opts ) . merge ( { show : show_action_bar } ) end | Sets up the action bar for this screen . |
16,086 | def escape_object_for_js ( object , i = 0 ) if object . kind_of? Hash Hash . new . tap do | h | object . each do | k , v | h [ escape_object_for_js ( k , i + 1 ) ] = escape_object_for_js ( v , i + 1 ) end end elsif object . kind_of? Enumerable object . map do | elt | escape_object_for_js ( elt , i + 1 ) end elsif objec... | Recursively escape anything in a primitive array or hash in preparation for jsonifying it |
16,087 | def db_configuration ( opts ) return { } unless opts raise "ca_path for #{opts.inspect} cannot be determined from Rails root; please set it explicitly" unless ca_path config = { } [ :sslca , :sslcert , :sslkey , ] . each do | k | if value = opts [ k ] filepath = File . join ( ca_path , value ) raise "File #{filepath.in... | Returns a partial ActiveRecord configuration hash for the given SSL CA certificate . Checks to make sure the given filename actually exists and raises an error if it does not . |
16,088 | def db_config @db_config ||= begin raise "ENV['#{env_prefix}_DATABASE_URL'] expected but not found!" unless ENV [ "#{env_prefix}_DATABASE_URL" ] config = parse_db_uri ( ENV [ "#{env_prefix}_DATABASE_URL" ] ) if ENV [ "#{env_prefix}_DATABASE_CA" ] config . merge! ( db_configuration ( { :sslca => ENV [ "#{env_prefix}_DAT... | Returns an ActiveRecord configuration hash based on the environment variables . |
16,089 | def start_notify! ( service , characteristic ) char = _find_characteristic ( service , characteristic ) if char . flag? ( 'notify' ) char . notify! else raise OperationNotSupportedError . new ( "No notifications available for characteristic #{characteristic}" ) end end | Registers current device for notifications of the given _characteristic_ . Synonym for subscribe or activate . This step is required in order to later receive notifications . |
16,090 | def on_notification ( service , characteristic , raw : false , & callback ) _require_connection! char = _find_characteristic ( service , characteristic ) if char . flag? ( 'notify' ) char . on_change ( raw : raw ) { | val | callback . call ( val ) } elsif char . flag? ( 'encrypt-read' ) || char . flag? ( 'encrypt-authe... | Registers the callback to be invoked when a notification from the given _characteristic_ is received . |
16,091 | def get ( resource , params : { } , key : Steam . apikey ) params [ :key ] = key response = @conn . get resource , params JSON . parse ( response . body ) rescue JSON :: ParserError { error : '500 Internal Server Error' } end | overriding the get method of Faraday to make things simpler . |
16,092 | def bootstrap_tab_nav_tag ( title , linkto , active = false ) content_tag ( 'li' , link_to ( title , linkto , "data-toggle" : 'tab' ) , active ? { class : 'active' } : { } ) end | Creates a simple bootstrap tab navigation . |
16,093 | def bootstrap_list_badge_and_link_to ( type , count , name , path ) html = content_tag ( :div , bootstrap_badge_tag ( type , count ) , class : 'pull-right' ) + name bootstrap_list_link_to ( html , path ) end | Convenience wrapper for a bootstrap_list_link_to with badge |
16,094 | def bootstrap_progressbar_tag ( * args ) percentage = args [ 0 ] . to_i options = args [ 1 ] || { } options . stringify_keys! options [ 'title' ] ||= "#{percentage}%" classes = [ 'progress' ] classes << options . delete ( 'class' ) classes << 'progress-striped' type = options . delete ( 'type' ) . to_s type = " progres... | Creates a Boostrap progress bar . |
16,095 | def description_list_name_value_pair ( name , value , blank_value_placeholder = nil ) return unless value . present? || blank_value_placeholder . present? content_tag ( :dt , name ) + content_tag ( :dd , value || content_tag ( :span , blank_value_placeholder , class : 'text-muted' ) ) end | This helper produces a pair of HTML dt dd tags to display name and value pairs . If a blank_value_placeholder is not defined then the pair are not shown if the value is blank . Otherwise the placeholder is shown in the text - muted style . |
16,096 | def details_link ( path , options = { } ) return unless ndr_can? ( :read , path ) link_to_with_icon ( { icon : 'share-alt' , title : 'Details' , path : path } . merge ( options ) ) end | Creates a Boostrap Details link . |
16,097 | def edit_link ( path , options = { } ) return unless ndr_can? ( :edit , path ) path = edit_polymorphic_path ( path ) if path . is_a? ( ActiveRecord :: Base ) link_to_with_icon ( { icon : 'pencil' , title : 'Edit' , path : path } . merge ( options ) ) end | Creates a Boostrap Edit link . |
16,098 | def delete_link ( path , options = { } ) return unless ndr_can? ( :delete , path ) defaults = { icon : 'trash icon-white' , title : 'Delete' , path : path , class : 'btn btn-xs btn-danger' , method : :delete , 'data-confirm' : I18n . translate ( :' ' , locale : options [ :locale ] ) } link_to_with_icon ( defaults . mer... | Creates a Boostrap Delete link . |
16,099 | def link_to_with_icon ( options = { } ) options [ :class ] ||= 'btn btn-default btn-xs' icon = bootstrap_icon_tag ( options . delete ( :icon ) ) content = options . delete ( :text ) ? icon + ' ' + options [ :title ] : icon link_to content , options . delete ( :path ) , options end | Creates a Boostrap link with icon . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.