idx
int64
0
24.9k
question
stringlengths
68
4.14k
target
stringlengths
9
749
14,500
def login raise SocketError , "Socket must be opened before logging in" if ! @socket or @socket . closed? xml = new_epp_request xml . root << command = Node . new ( "command" ) command << login = Node . new ( "login" ) login << Node . new ( "clID" , tag ) login << Node . new ( "pw" , password ) login << options = Node ...
Sends a standard login request to the EPP server .
14,501
def logout raise SocketError , "Socket must be opened before logging out" if ! @socket or @socket . closed? xml = new_epp_request xml . root << command = Node . new ( "command" ) command << login = Node . new ( "logout" ) command << Node . new ( "clTRID" , UUIDTools :: UUID . timestamp_create . to_s ) response = Hprico...
Sends a standard logout request to the EPP server .
14,502
def find_category ( category_name , options = { } ) categories = self . categories if categories . is_a? ( Array ) categories . detect { | c | c [ 'name' ] == category_name } else raise "Could not retrieve categories: #{categories}" end end
Find category by name
14,503
def find_forum ( category_name , forum_name , options = { } ) category = self . find_category ( category_name , options ) if category self . forums . detect { | f | f [ 'category_id' ] == category [ 'id' ] && f [ 'name' ] == forum_name } end end
Find forum by name knowing the category name
14,504
def find_or_create_forum ( category_name , forum_name , options = { } ) category = self . find_or_create_category ( category_name , options ) if category self . forums . detect { | f | f [ 'category_id' ] == category [ 'id' ] && f [ 'name' ] == forum_name } || post_forum ( category [ 'id' ] , forum_name ) end end
Given a category name find a forum by name . Create the category and forum either doesn t exist .
14,505
def find_topic ( category_name , forum_name , topic_title , options = { } ) forum = self . find_forum ( category_name , forum_name , options ) if forum self . topics ( forum [ 'id' ] , options ) . detect { | t | t [ 'title' ] == topic_title } end end
Find topic by name knowing the forum name and category name
14,506
def post_forum ( category_id , forum_name , options = { } ) self . post ( '/forums.json' , options . merge ( :body => { :forum => { :name => forum_name , :category_id => category_id } } . to_json ) ) [ 'forum' ] end
Create a forum in the given category id
14,507
def post_topic ( forum_id , title , body , options = { } ) self . post ( "/topics.json" , options . merge ( :body => { :topic => { :forum_id => forum_id , :title => title , :body => body } } . to_json ) ) [ 'topic' ] end
Create a topic in the given forum id
14,508
def responsive_image_tag ( piece , options = { } , breakpoints ) srcset = generate_srcset ( piece ) sizes = generate_sizes ( piece , breakpoints ) if piece . image . attachment . exists? ( computed_style ( piece , 'x2000' ) ) image_tag ( piece . image . url ( default_style ( piece , breakpoints ) ) , options . merge ( ...
Returns the actual image_tag
14,509
def assert test , msg = nil msg ||= "Failed assertion, no message given." unless test then msg = msg . call if Proc === msg raise RWebSpec :: Assertion , msg end true end
own assert method
14,510
def assert_link_present_with_text ( link_text ) @web_browser . links . each { | link | return if link . text . include? ( link_text ) } fail ( "can't find the link containing text: #{link_text}" ) end
Assert a link containing specified text in the page
14,511
def assert_radio_option_not_present ( radio_group , radio_option ) @web_browser . radios . each { | radio | the_element_name = element_name ( radio ) if ( the_element_name == radio_group ) then perform_assertion { assert ( ! ( radio_option == element_value ( radio ) ) , "unexpected radio option: " + radio_option + " fo...
radio radio_group is the name field radio options value field
14,512
def yield_connection response = begin resource = @connection_pool . resource yield resource ensure resource . close if resource end if @convert_objects convert ( response ) else response end end
Construct a new JedisRb Pool .
14,513
def convert ( value ) case value when java . util . List then value . to_a when java . util . Set then value . to_set when java . util . Map then value . to_hash else value end end
Convert Java return values to their ruby equivalents .
14,514
def create ( hash , sources , parameters , start , end_time = nil ) params = { :hash => hash , :sources => sources , :parameters => parameters , :start => start } requires params params . merge! ( :end => end_time ) unless end_time . nil? DataSift . request ( :POST , 'preview/create' , @config , params ) end
Create a new Historics Preview
14,515
def connect! @connection = HTTParty . post ( File . join ( url , "rest/user/login" ) , body : credentials_hash ) @cookies [ 'Cookie' ] = @connection . headers [ 'set-cookie' ] @connection . code end
Makes a login call and sets the Cookie headers
14,516
def url ( style = :original , * args ) if style . to_sym == :original original_url ( * args ) else named_url ( style , * args ) end end
Prefix with an underscore to use base Asset styles
14,517
def log_step ( id , step , context , options , error = nil ) return unless Hero . logger if error Hero . logger . error "HERO #{id.to_s.ljust(6)} #{formula_name} -> #{step.first} Context: #{context.inspect} Options: #{options.inspect} Error: #{error.message}" else Hero . logger . info "HERO #{id.to_s.ljust(6)} #{formul...
Logs a step to the registered Hero . logger .
14,518
def create ( service : , type : , subscription_id : , name : , parameters : ) DataSift . request ( :POST , "pylon/#{service}/task" , @config , { type : type , subscription_id : subscription_id , name : name , parameters : parameters } ) end
Creates a Task ; this call requires use of an identity API key
14,519
def list ( service : , type : 'analysis' , ** opts ) params = { } params [ :per_page ] = opts [ :per_page ] if opts . key? ( :per_page ) params [ :page ] = opts [ :page ] if opts . key? ( :page ) params [ :status ] = opts [ :status ] if opts . key? ( :status ) DataSift . request ( :GET , "pylon/#{service}/task/#{type}"...
Gets a list of all current Tasks on the service . This call may be accessed using either a main or identity - level API key .
14,520
def update ( cluster ) deployed = primary_deployment ( cluster ) Ecs . update_service ( cluster . name , name , register ( deployed ) ) name end
Register this task definition with ECS and update the corresponding service .
14,521
def scale ( cluster , count ) Ecs . update_service_desired_count ( cluster . name , name , count ) name end
Set the number of running copies of a service we want to have .
14,522
def run ( cluster , started_by : nil , ** args ) overrides_json = json_generator . generate_override_json ( ** args ) info = Ecs . run_task ( cluster . name , register , started_by : started_by , overrides_json : overrides_json ) info . fetch ( "tasks" ) [ 0 ] . fetch ( "taskArn" ) end
Run this task definition as a one - shot ECS task with the specified overrides .
14,523
def evaluate ( scope , locals , & block ) binding . pry template = data . dup template . gsub! ( / / , '\\"' ) template . gsub! ( / \r \n / , '\\n' ) template . gsub! ( / \t / , '\\t' ) return 'console.log(1223);' end
Generates Javascript code from a HandlebarsJS template . The SC template name is derived from the lowercase logical asset path by replacing non - alphanum characheters by underscores .
14,524
def moving_average ( average_specifier ) if average_specifier . kind_of? ( Array ) avg = MovingAverage . weighted ( average_specifier ) elsif average_specifier . kind_of? ( Integer ) avg = MovingAverage . simple ( average_specifier ) else raise ArgumentError . new ( "Unknown weights" ) end avg . calculate ( self ) end
Returns a moving average for this array given either a number of terms or a list of weights .
14,525
def calculate ( array ) return [ ] if @span > array . length array . each_cons ( @span ) . map do | window | window . zip ( weights ) . map { | ( a , b ) | a * b } . inject ( & :+ ) end end
Creates a new MovingAverage given a list of weights .
14,526
def check_weights raise ArgumentError . new ( "Weights should be an odd list" ) unless @span . odd? sum = weights . inject ( & :+ ) if sum < 0.999999 || sum > 1.000001 raise ArgumentError . new ( "Weights must sum to 1" ) end end
Error checking for weights
14,527
def purge_request ( params , * titles ) params [ :action ] = 'purge' params [ :titles ] = titles . join ( '|' ) post ( params ) [ 'purge' ] . inject ( { } ) do | result , hash | title = hash [ 'title' ] result [ title ] = hash . key? ( 'purged' ) && ! hash . key? ( 'missing' ) warn "Invalid purge (#{title}) #{hash['inv...
Sends a purge API request and handles the return value and warnings .
14,528
def reset self . user_agent = DEFAULT_USER_AGENT self . server_url = DEFAULT_SERVER_URL self . chef_version = DEFAULT_CHEF_VERSION self . client_name = DEFAULT_CLIENT_NAME self . client_key = DEFAULT_CLIENT_KEY self . connection_options = DEFAULT_CONNECTION_OPTIONS self . middleware = DEFAULT_MIDDLEWARE self end
def options Reset all config options to their defaults
14,529
def valid? ( csdl , boolResponse = true ) requires ( { :csdl => csdl } ) res = DataSift . request ( :POST , 'validate' , @config , :csdl => csdl ) boolResponse ? res [ :http ] [ :status ] == 200 : res end
Checks if the syntax of the given CSDL is valid
14,530
def dpu ( hash = '' , historics_id = '' ) fail ArgumentError , 'Must pass a filter hash or Historics ID' if hash . empty? && historics_id . empty? fail ArgumentError , 'Must only pass hash or Historics ID; not both' unless hash . empty? || historics_id . empty? params = { } params . merge! ( hash : hash ) unless hash ....
Calculate the DPU cost of running a filter or Historics query
14,531
def synx_issues ( git . modified_files + git . added_files ) . select { | f | f . include? '.xcodeproj' } . reduce ( [ ] ) { | i , f | i + synx_project ( f ) } end
Triggers Synx on all projects that were modified or added to the project . Returns accumulated list of issues for those projects .
14,532
def valid_token? uri = URI . join ( Teambition :: API_DOMAIN , "/api/applications/#{Teambition.client_key}/tokens/check" ) req = Net :: HTTP :: Get . new ( uri ) req [ 'Authorization' ] = "OAuth2 #{token}" res = Net :: HTTP . start ( uri . hostname , uri . port , use_ssl : true ) do | https | https . request ( req ) en...
Validate the token
14,533
def core_sha1 ( x , len ) x [ len >> 5 ] ||= 0 x [ len >> 5 ] |= 0x80 << ( 24 - len % 32 ) x [ ( ( len + 64 >> 9 ) << 4 ) + 15 ] = len w = Array . new ( 80 , 0 ) a = 1_732_584_193 b = - 271_733_879 c = - 1_732_584_194 d = 271_733_878 e = - 1_009_589_776 i = 0 while i < x . length olda = a oldb = b oldc = c oldd = d old...
Calculate the SHA - 1 of an array of big - endian words and a bit length
14,534
def sha1_ft ( t , b , c , d ) return ( b & c ) | ( ( ~ b ) & d ) if t < 20 return b ^ c ^ d if t < 40 return ( b & c ) | ( b & d ) | ( c & d ) if t < 60 b ^ c ^ d end
Perform the appropriate triplet combination function for the current iteration
14,535
def core_hmac_sha1 ( key , data ) bkey = str2binb ( key ) bkey = core_sha1 ( bkey , key . length * $chrsz ) if bkey . length > 16 ipad = Array . new ( 16 , 0 ) opad = Array . new ( 16 , 0 ) i = 0 while i < 16 ipad [ i ] = ( bkey [ i ] || 0 ) ^ 0x36363636 opad [ i ] = ( bkey [ i ] || 0 ) ^ 0x5C5C5C5C i += 1 end hash = c...
Calculate the HMAC - SHA1 of a key and some data
14,536
def str2binb ( str ) bin = [ ] mask = ( 1 << $chrsz ) - 1 i = 0 while i < str . length * $chrsz bin [ i >> 5 ] ||= 0 bin [ i >> 5 ] |= ( str [ i / $chrsz ] & mask ) << ( 32 - $chrsz - i % 32 ) i += $chrsz end bin end
Convert an 8 - bit or 16 - bit string to an array of big - endian words In 8 - bit function characters > 255 have their hi - byte silently ignored .
14,537
def binb2b64 ( binarray ) tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' str = '' i = 0 while i < binarray . length * 4 triplet = ( ( ( binarray [ i >> 2 ] . to_i >> 8 * ( 3 - i % 4 ) ) & 0xFF ) << 16 ) | ( ( ( binarray [ i + 1 >> 2 ] . to_i >> 8 * ( 3 - ( i + 1 ) % 4 ) ) & 0xFF ) << 8 ) | ( (...
Convert an array of big - endian words to a base - 64 string
14,538
def create ( label = '' , status = 'active' , master = '' ) fail ArgumentError , 'label is missing' if label . empty? params = { label : label } params . merge! ( status : status ) unless status . empty? params . merge! ( master : master ) if [ TrueClass , FalseClass ] . include? ( master . class ) DataSift . request (...
Creates a new Identity
14,539
def list ( label = '' , per_page = '' , page = '' ) params = { } params . merge! ( label : label ) unless label . empty? params . merge! ( per_page : per_page ) unless per_page . empty? params . merge! ( page : page ) unless page . empty? DataSift . request ( :GET , 'account/identity' , @config , params ) end
Returns a list of Identities
14,540
def handle_resource ( definition , parent , parent_params ) if definition . is_a? Array return definition . each { | d | handle_resource ( d , parent , parent_params ) } end unless definition . is_a? Hash definition = { definition => nil } end definition . each do | name , child_definition | if ! parent_params || ! par...
Definition can be either a name array or hash .
14,541
def search ( query , type = nil ) checking_type ( type ) type = set_type ( type ) unless type . nil? if query . nil? puts 'Enter the text to search' text = gets end json = JSON . parse ( connect_google ( @api_key , type , query ) ) @total_count = json [ "totalItems" ] @items = json [ "items" ] end
Google books search
14,542
def filter ( query , type = nil ) checking_filter_type ( type ) filter_type = set_filter_type ( type ) unless type . nil? json = JSON . parse ( connect_google ( @api_key , nil , query , filter_type ) ) @total_count = json [ "totalItems" ] @items = json [ "items" ] end
Google books filtration
14,543
def valid? ( params , bool_response = true ) requires params res = DataSift . request ( :POST , 'push/validate' , @config , params ) bool_response ? res [ :http ] [ :status ] == 200 : res end
Check that a Push subscription definition is valid
14,544
def log_for ( id , page = 1 , per_page = 20 , order_by = :request_time , order_dir = :desc ) params = { :id => id } requires params params . merge! ( :page => page , :per_page => per_page , :order_by => order_by , :order_dir => order_dir ) DataSift . request ( :GET , 'push/log' , @config , params ) end
Retrieve log messages for a specific subscription
14,545
def log ( page = 1 , per_page = 20 , order_by = :request_time , order_dir = :desc ) params = { :page => page , :per_page => per_page , :order_by => order_by , :order_dir => order_dir } DataSift . request ( :GET , 'push/log' , @config , params ) end
Retrieve log messages for all subscriptions
14,546
def get_by_hash ( hash , page = 1 , per_page = 20 , order_by = :created_at , order_dir = :desc , include_finished = 0 , all = false ) params = { :hash => hash } requires params params . merge! ( :page => page , :per_page => per_page , :order_by => order_by , :order_dir => order_dir , :include_finished => include_finish...
Get details of the subscription with the given filter hash
14,547
def get_by_historics_id ( historics_id , page = 1 , per_page = 20 , order_by = :created_at , order_dir = :desc , include_finished = 0 , all = false ) params = { :historics_id => historics_id , :page => page , :per_page => per_page , :order_by => order_by , :order_dir => order_dir , :include_finished => include_finished...
Get details of the subscription with the given Historics ID
14,548
def get ( page = 1 , per_page = 20 , order_by = :created_at , order_dir = :desc , include_finished = 0 , all = false ) params = { :page => page , :per_page => per_page , :order_by => order_by , :order_dir => order_dir , :include_finished => include_finished , :all => all } DataSift . request ( :GET , 'push/get' , @conf...
Get details of all subscriptions within the given page constraints
14,549
def pull ( id , size = 52_428_800 , cursor = '' , callback = nil ) params = { :id => id } requires params params . merge! ( :size => size , :cursor => cursor ) params . merge! ( { :on_interaction => callback } ) unless callback . nil? DataSift . request ( :GET , 'pull' , @config , params , { } , 30 , 30 , true ) end
Pull data from a pull type Push Subscription
14,550
def edit ( title , text , opts = { } ) opts [ :bot ] = opts . key? ( :bot ) ? opts [ :bot ] : true params = { action : 'edit' , title : title , text : text , nocreate : 1 , format : 'json' , token : get_token } params [ :summary ] ||= opts [ :summary ] params [ :minor ] = '1' if opts [ :minor ] params [ :bot ] = '1' if...
Performs a standard non - creation edit .
14,551
def create_page ( title , text , opts = { } ) opts [ :bot ] = opts . key? ( :bot ) ? opts [ :bot ] : true opts [ :summary ] ||= 'New page' params = { action : 'edit' , title : title , text : text , summary : opts [ :summary ] , createonly : 1 , format : 'json' , token : get_token } params [ :bot ] = '1' if opts [ :bot ...
Creates a new page .
14,552
def upload ( url , filename = nil ) params = { action : 'upload' , url : url , token : get_token } filename = filename . nil? ? url . split ( '/' ) [ - 1 ] : filename . sub ( / / , '' ) ext = filename . split ( '.' ) [ - 1 ] allowed_extensions = get_allowed_file_extensions raise MediaWiki :: Butt :: UploadInvalidFileEx...
Uploads a file from a URL .
14,553
def move ( from , to , opts = { } ) opts [ :talk ] = opts . key? ( :talk ) ? opts [ :talk ] : true params = { action : 'move' , from : from , to : to , token : get_token } params [ :reason ] ||= opts [ :reason ] params [ :movetalk ] = '1' if opts [ :talk ] params [ :noredirect ] = '1' if opts [ :suppress_redirect ] res...
Performs a move on a page .
14,554
def delete ( title , reason = nil ) params = { action : 'delete' , title : title , token : get_token } params [ :reason ] = reason unless reason . nil? response = post ( params ) return true if response [ 'delete' ] raise MediaWiki :: Butt :: EditError . new ( response . dig ( 'error' , 'code' ) || 'Unknown error code'...
Deletes a page .
14,555
def list_all app = :: Middleman :: Application . new do config [ :exit_before_ready ] = true end app_config = app . config . clone app . shutdown! app_config [ :targets ] . each do | target | target_org = app_config [ :target ] . to_s target_req = target [ 0 ] . to_s path_org = app_config [ :build_dir ] path_req = path...
List all targets .
14,556
def render_with_layout_and_partials ( format ) template = MailEngine :: MailTemplate . where ( :path => "#{controller_path}/#{action_name}" , :format => format , :locale => I18n . locale , :partial => false , :for_marketing => false ) . first template = MailEngine :: MailTemplate . where ( :path => action_name , :forma...
render template with layout and partials
14,557
def record if File . exist? DIFILE CSV . open ( DIFILE , 'a' ) { | csv | csv << [ @user , @message , @time ] } else CSV . open ( DIFILE , 'a' ) do | csv | csv << %w[ user message time ] csv << [ @user , @message , @time ] end end puts '✓'.g r een rescue StandardError => e abort 'Broken' . magenta + e end
generates new recording as csv row to new or existing DIANE file
14,558
def slug ( user ) abort 'User is nil. Fuck off.' . magenta if user . nil? user . downcase . strip . tr ( ' ' , '_' ) . gsub ( / \w / , '' ) end
normalizes and slugifies recording user handle
14,559
def connection opts = { } connection = Faraday . new ( opts ) do | conn | if opts [ :force_urlencoded ] conn . request :url_encoded else conn . request :json end conn . request :json conn . use FaradayMiddleware :: FollowRedirects conn . use FaradayMiddleware :: Mashify conn . use FaradayMiddleware :: ParseJson , :cont...
Create a connection to send request
14,560
def message ( transformer = Undefined ) return @custom_message if @custom_message transformer = self . transformer if Undefined . equal? ( transformer ) transformer . transform ( self ) end
Configure a Violation instance
14,561
def together old = Thread . current . eldritch_group group = Group . new Thread . current . eldritch_group = group yield group group . join_all Thread . current . eldritch_group = old end
Creates a group of async call and blocks
14,562
def start return if @state != :stopped Service . start ( @options [ :ampq_uri ] , @options [ :threadpool_size ] ) EM . run do @channel = AMQP :: Channel . new ( @@connection ) @channel . on_error do | ch , channel_close | message = "Channel exception: [#{channel_close.reply_code}] #{channel_close.reply_text}" puts mess...
start the service
14,563
def stop return if @state != :started @service_queue . unsubscribe decisecond_timeout = @options [ :timeout ] / 100 waited_deciseconds = 0 while ( @transactions . length > 0 || @processing_messages > 0 ) && waited_deciseconds < decisecond_timeout sleep ( 0.1 ) waited_deciseconds += 1 end @channel . close @state = :stop...
Stop the Service
14,564
def process_service_queue_message ( metadata , payload ) service_to_reply_to = metadata . reply_to message_replying_to = metadata . message_id this_message_id = AlchemyFlux :: Service . generateUUID ( ) delivery_tag = metadata . delivery_tag operation = proc { @processing_messages += 1 begin response = @service_fn . ca...
RECIEVING MESSAGES process messages on the service queue
14,565
def process_response_queue_message ( metadata , payload ) response_queue = @transactions . delete metadata . correlation_id response_queue << payload if response_queue end
process a response message
14,566
def process_returned_message ( basic_return , metadata , payload ) response_queue = @transactions . delete metadata [ :message_id ] response_queue << MessageNotDeliveredError if response_queue end
process a returned message
14,567
def send_message ( exchange , routing_key , message , options ) message_options = options . merge ( { :routing_key => routing_key } ) message = message . to_json EventMachine . next_tick do exchange . publish message , message_options end end
send a message to an exchange with routing key
14,568
def send_request_to_service ( service_name , message ) if block_given? EventMachine . defer do yield send_request_to_service ( service_name , message ) end else send_HTTP_request ( @channel . default_exchange , service_name , message ) end end
send a request to a service this will wait for a response
14,569
def send_request_to_resource ( message ) routing_key = path_to_routing_key ( message [ 'path' ] ) if block_given? EventMachine . defer do yield send_request_to_resource ( message ) end else send_HTTP_request ( @resources_exchange , routing_key , message ) end end
send a message to a resource
14,570
def path_to_routing_key ( path ) new_path = "" path . split ( '' ) . each_with_index do | c , i | if c == '/' and i != 0 and i != path . length - 1 new_path += '.' elsif c != '/' new_path += c end end new_path end
Takes a path and converts it into a routing key
14,571
def format_HTTP_message ( message ) message = { 'body' => message [ 'body' ] || "" , 'verb' => message [ 'verb' ] || "GET" , 'headers' => message [ 'headers' ] || { } , 'path' => message [ 'path' ] || "/" , 'query' => message [ 'query' ] || { } , 'scheme' => message [ 'protocol' ] || 'http' , 'host' => message [ 'hostn...
format the HTTP message
14,572
def gets begin data = make_http_request @hash = send ( @@formats [ @format ] [ :oembed_parser ] , data ) rescue RuntimeError => e if e . message == "401" return nil elsif e . message == "501" raise UnsupportedError , "#{@format} not supported by #{@domain}" elsif e . message == "404" raise Error , "#{@url} not found" e...
Calling + gets + returns a hash containing the oembed data .
14,573
def load_format requested_format = nil raise ArgumentError , "Requested format not supported" if ! requested_format . nil? && @@formats [ requested_format ] . nil? @format = requested_format || @@default_format attempted_formats = "" begin attempted_formats += @@formats [ @format ] [ :require ] require @@formats [ @for...
Call with no argument to use default
14,574
def create_post_portlet_page page = Cms :: Page . find_by_name ( portlet_name = "#{@blog.name}: Post" ) || Cms :: Page . create! ( :name => portlet_name , :path => "/#{@blog.name_for_path}/post" , :section => @section , :template_file_name => "default.html.erb" , :hidden => true ) page . publish create_route ( page , p...
The second page that is created holds the BlogPostPortlet and displays the individual post view along with it s comments .
14,575
def err ( message , code : nil ) @state [ :result ] = false @state [ :errors ] . push ( message : message , code : code ) raise message if @options [ :exceptions ] end
This function can be used to stop the command execution and add a new error . Using err inside a callback should not stop the execution but should avoid the call of the next callback . Every time you call this function a new error should be added to the errors list . If the exceptions option is active it should raise a...
14,576
def _init_command_data ( params ) @state = { result : true , errors : [ ] } initial_options = { exceptions : false , nullify_empty_params : false } default_options = _safe_default_options || { } params_options = params [ :_options ] || { } @options = initial_options . merge ( default_options ) . merge ( params_options ...
This function initializes the command required data .
14,577
def _validate_single_params validations = _safe_validations validations . each do | val | value_to_validate = _value_to_validate ( val ) validator = Evnt :: Validator . new ( value_to_validate , val [ :options ] ) if validator . passed? @params [ val [ :param ] ] = validator . value else error = val [ :options ] [ :err...
This function validates the single parameters sets with the validates method .
14,578
def choose ( key , * choices ) all_choices = choices . flatten index = ( get_unit ( key ) * all_choices . length ) . floor index = all_choices . length - 1 if index > all_choices . length - 1 all_choices [ index ] end
Calls get_unit with key to get value between 0 . 0 and 1 . 0 then converts that value to an index within the given list of choices . choices can be an array or an argument list of arbitrary size .
14,579
def permitter ( pclass = permitter_class ) pinstance = ( @permitter_class_to_permitter ||= { } ) [ pclass ] return pinstance if pinstance current_authorizer_method = ActionController :: Permitter . current_authorizer_method ? ActionController :: Permitter . current_authorizer_method . to_sym : nil @permitter_class_to_p...
Returns a new instance of the permitter by initializing it with params current_user current_ability .
14,580
def handle_in_source_state if @state_machine . initial_queue . nil? raise RuntimeError , "State machine not started yet." end if Dispatch :: Queue . current . to_s != @state_machine . initial_queue . to_s raise RuntimeError , "#{self.class.event_type}:#{@event_trigger_value} must be " "called from the queue where the s...
Delegates handling the transition to the source state which makes sure that there are no ambiguous transitions for the same event .
14,581
def actual_send ( type , time , id , data ) prefix = "#{@namespace}_" unless @namespace . nil? type = type . to_s . gsub RESERVED_CHARS_REGEX , '_' message = { type : "#{prefix}#{type}" } message [ :time ] = time . iso8601 unless time . nil? message [ :id ] = id unless id . nil? message [ :data ] = data unless data . n...
Actually send the given data to a socket and potentially log it along the way .
14,582
def link_to_tracked ( name , track_path = "/" , options = { } , html_options = { } ) raise AnalyticsError . new ( "You must set Rubaidh::GoogleAnalytics.defer_load = false to use outbound link tracking" ) if GoogleAnalytics . defer_load == true html_options . merge! ( { :onclick => tracking_call ( track_path ) } ) link...
Creates a link tag of the given + name + using a URL created by the set of + options + with outbound link tracking under + track_path + in Google Analytics . The + html_options + will accept a hash of attributes for the link tag .
14,583
def link_to_tracked_if ( condition , name , track_path = "/" , options = { } , html_options = { } , & block ) raise AnalyticsError . new ( "You must set Rubaidh::GoogleAnalytics.defer_load = false to use outbound link tracking" ) if GoogleAnalytics . defer_load == true html_options . merge! ( { :onclick => tracking_cal...
Creates a link tag of the given + name + using a URL created by the set of + options + if + condition + is true with outbound link tracking under + track_path + in Google Analytics . The + html_options + will accept a hash of attributes for the link tag .
14,584
def link_to_tracked_unless_current ( name , track_path = "/" , options = { } , html_options = { } , & block ) raise AnalyticsError . new ( "You must set Rubaidh::GoogleAnalytics.defer_load = false to use outbound link tracking" ) if GoogleAnalytics . defer_load == true html_options . merge! ( { :onclick => tracking_cal...
Creates a link tag of the given + name + using a URL created by the set of + options + unless the current request URI is the same as the link s with outbound link tracking under + track_path + in Google Analytics . If the request URI is the same as the link URI only the name is returned or the block is yielded if one e...
14,585
def simple_sidekiq_delay_for ( interval , options = { } ) Proxy . new ( simple_delayed_worker , self , options . merge ( 'at' => Time . now . to_f + interval . to_f ) ) end
Enqueue a job to handle the delayed action after an elapsed interval
14,586
def simple_sidekiq_delay_until ( timestamp , options = { } ) Proxy . new ( simple_delayed_worker , self , options . merge ( 'at' => timestamp . to_f ) ) end
Enqueue a job to handle the delayed action after at a certain time
14,587
def simple_sidekiq_delay_spread ( options = { } ) local_opts = options . dup spread_duration = Utils . extract_option ( local_opts , :spread_duration , 1 . hour ) . to_f spread_in = Utils . extract_option ( local_opts , :spread_in , 0 ) . to_f spread_at = Utils . extract_option ( local_opts , :spread_at ) spread_method...
Enqueue a job to handle the delayed action in a given timeframe
14,588
def handle_dispatched_message ( reactor , data ) log_debug "#{self.class} trying to dispatch message #{data.inspect}" message = reactor . parse_json_data ( data ) final_data = message . present? && message . is_a? ( Hash ) ? message . to_json : data . to_json reactor . websocket << final_data end
If the message can be parsed into a Hash it will respond to the reactor s websocket connection with the same message in JSON format otherwise will try send the message how it is and escaped into JSON format
14,589
def build_all app = :: Middleman :: Application . new do config [ :exit_before_ready ] = true end build_list = app . config [ :targets ] . each_key . collect { | item | item . to_s } bad_builds = [ ] build_list . each do | target | bad_builds << target unless Build . start ( [ '--target' , target ] ) end unless bad_bui...
Build all targets .
14,590
def ruby_aocolumns result = [ ] column_def_keys = %w[ asSorting bSearchable bSortable bUseRendered bVisible fnRender iDataSort mDataProp sClass sDefaultContent sName sSortDataType sTitle sType sWidth link_to ] index = 0 @datatable . columns . each_value do | column_hash | column_result = { } column_hash . each do | key...
returns a ruby hash of
14,591
def parse_tokens ( data ) tokens = { } data . split ( "\n" ) . each do | t | tokens . merge! ( { t . split ( '=' ) . first . downcase . to_sym => t . split ( '=' ) . last } ) end return tokens end
Parse the authentication tokens out of the response and makes them available as a hash
14,592
def get_provider ( provider_id = nil , user_name = nil ) params = MagicParams . format ( parameter1 : provider_id , parameter2 : user_name ) results = magic ( "GetProvider" , magic_params : params ) results [ "getproviderinfo" ] end
a wrapper around GetProvider
14,593
def get_providers ( security_filter = nil , name_filter = nil , show_only_providers_flag = "Y" , internal_external = "I" , ordering_authority = nil , real_provider = "N" ) params = MagicParams . format ( parameter1 : security_filter , parameter2 : name_filter , parameter3 : show_only_providers_flag , parameter4 : inter...
a wrapper around GetProviders
14,594
def get_patient_problems ( patient_id , show_by_encounter = "N" , assessed = nil , encounter_id = nil , filter_on_id = nil , display_in_progress = nil ) params = MagicParams . format ( user_id : @allscripts_username , patient_id : patient_id , parameter1 : show_by_encounter , parameter2 : assessed , parameter3 : encoun...
a wrapper around GetPatientProblems
14,595
def get_results ( patient_id , since = nil ) params = MagicParams . format ( user_id : @allscripts_username , patient_id : patient_id , parameter1 : since ) results = magic ( "GetResults" , magic_params : params ) results [ "getresultsinfo" ] end
a wrapper around GetResults
14,596
def get_schedule ( start_date , end_date , other_username = nil ) params = MagicParams . format ( user_id : @allscripts_username , parameter1 : format_date_range ( start_date , end_date ) , parameter4 : other_username ) results = magic ( "GetSchedule" , magic_params : params ) results [ "getscheduleinfo" ] end
a wrapper around GetSchedule returns appointments scheduled under the the user for a given date range
14,597
def get_encounter_list ( patient_id = "" , encounter_type = "" , when_or_limit = "" , nostradamus = 0 , show_past_flag = "Y" , billing_provider_user_name = "" ) params = MagicParams . format ( user_id : @allscripts_username , patient_id : patient_id , parameter1 : encounter_type , parameter2 : when_or_limit , parameter...
a wrapper around GetEncounterList
14,598
def get_list_of_dictionaries params = MagicParams . format ( user_id : @allscripts_username ) results = magic ( "GetListOfDictionaries" , magic_params : params ) results [ "getlistofdictionariesinfo" ] end
a wrapper around GetListOfDictionaries which returns list of all dictionaries
14,599
def get_dictionary ( dictionary_name ) params = MagicParams . format ( user_id : @allscripts_username , parameter1 : dictionary_name ) results = magic ( "GetDictionary" , magic_params : params ) results [ "getdictionaryinfo" ] end
a wrapper around GetDictionary which returnsentries from a specific dictionary .