idx
int64
0
24.9k
question
stringlengths
68
4.14k
target
stringlengths
9
749
13,200
def register_to_parent ( item ) fail Error , 'None belonging' unless parent_id? ( item ) ids << item . id self << item item end
Register a resource in collection
13,201
def build_row ( object , index = table . collection . index ( object ) ) row = BodyRow . new ( object , self ) row . alternate = alternate ? index . send ( "#{alternate}?" ) : false @builder . call ( row . builder , object , index ) if @builder row . html end
Builds a row for an object in the table .
13,202
def values_desc_by_occurency values = cards . map ( & :value ) values . sort do | a , b | coefficient_occurency = ( values . count ( a ) <=> values . count ( b ) ) coefficient_occurency . zero? ? - ( a <=> b ) : - coefficient_occurency end end
Make descending order primary by occurency and secondary by value
13,203
def content number_to_skip = 0 html = '' table . header . column_names . each do | column | number_to_skip -= 1 and next if number_to_skip > 0 if cell = @cells [ column ] number_to_skip = ( cell [ :colspan ] || 1 ) - 1 else cell = Cell . new ( column , nil ) end html << cell . html end html end
Builds the row s cells based on the order of the columns in the header . If a cell cannot be found for a specific column then a blank cell is rendered .
13,204
def kill_instances ( instances ) running_instances = instances . compact . select do | instance | instance_by_id ( instance . instance_id ) . state . name == 'running' end instance_ids = running_instances . map ( & :instance_id ) return nil if instance_ids . empty? @logger . notify ( "aws-sdk: killing EC2 instance(s) #...
Kill all instances .
13,205
def kill_zombie_volumes @logger . notify ( "aws-sdk: Kill Zombie Volumes!" ) volume_count = 0 regions . each do | region | @logger . debug "Reviewing: #{region}" available_volumes = client ( region ) . describe_volumes ( :filters => [ { :name => 'status' , :values => [ 'available' ] , } ] ) . volumes available_volumes ...
Destroy any volumes marked available INCLUDING THOSE YOU DON T OWN! Use with care .
13,206
def launch_all_nodes @logger . notify ( "aws-sdk: launch all hosts in configuration" ) ami_spec = YAML . load_file ( @options [ :ec2_yaml ] ) [ "AMI" ] global_subnet_id = @options [ 'subnet_id' ] global_subnets = @options [ 'subnet_ids' ] if global_subnet_id and global_subnets raise RuntimeError , 'Config specifies bot...
Create EC2 instances for all hosts tag them and wait until they re running . When a host provides a subnet_id create the instance in that subnet otherwise prefer a CONFIG subnet_id . If neither are set but there is a CONFIG subnet_ids list attempt to create the host in each specified subnet which might fail due to capa...
13,207
def wait_for_status_netdev ( ) @hosts . each do | host | if host [ 'platform' ] =~ / / wait_for_status ( :running , @hosts ) wait_for_status ( nil , @hosts ) do | instance | instance_status_collection = client . describe_instance_status ( { :instance_ids => [ instance . instance_id ] } ) first_instance = instance_statu...
Handles special checks needed for netdev platforms .
13,208
def add_tags @hosts . each do | host | instance = host [ 'instance' ] @logger . notify ( "aws-sdk: Add tags for #{host.name}" ) tags = [ { :key => 'jenkins_build_url' , :value => @options [ :jenkins_build_url ] , } , { :key => 'Name' , :value => host . name , } , { :key => 'department' , :value => @options [ :departmen...
Add metadata tags to all instances
13,209
def modify_network_interface @hosts . each do | host | instance = host [ 'instance' ] host [ 'sg_cidr_ips' ] = host [ 'sg_cidr_ips' ] || '0.0.0.0/0' ; sg_cidr_ips = host [ 'sg_cidr_ips' ] . split ( ',' ) @logger . notify ( "aws-sdk: Update network_interface for #{host.name}" ) security_group = ensure_group ( instance [...
Add correct security groups to hosts network_interface as during the create_instance stage it is too early in process to configure
13,210
def populate_dns @hosts . each do | host | @logger . notify ( "aws-sdk: Populate DNS for #{host.name}" ) instance = host [ 'instance' ] host [ 'ip' ] = instance . public_ip_address || instance . private_ip_address host [ 'private_ip' ] = instance . private_ip_address host [ 'dns_name' ] = instance . public_dns_name || ...
Populate the hosts IP address from the EC2 dns_name
13,211
def enable_root ( host ) if host [ 'user' ] != 'root' if host [ 'platform' ] =~ / / enable_root_f5 ( host ) elsif host [ 'platform' ] =~ / / enable_root_netscaler ( host ) else copy_ssh_to_root ( host , @options ) enable_root_login ( host , @options ) host [ 'user' ] = 'root' end host . close end end
Enables root access for a host when username is not root
13,212
def ensure_key_pair ( region ) pair_name = key_name ( ) delete_key_pair ( region , pair_name ) create_new_key_pair ( region , pair_name ) end
Creates the KeyPair for this test run
13,213
def delete_key_pair_all_regions ( keypair_name_filter = nil ) region_keypairs_hash = my_key_pairs ( keypair_name_filter ) region_keypairs_hash . each_pair do | region , keypair_name_array | keypair_name_array . each do | keypair_name | delete_key_pair ( region , keypair_name ) end end end
Deletes key pairs from all regions
13,214
def my_key_pairs ( name_filter = nil ) keypairs_by_region = { } key_name_filter = name_filter ? "#{name_filter}-*" : key_name regions . each do | region | keypairs_by_region [ region ] = client ( region ) . describe_key_pairs ( :filters => [ { :name => 'key-name' , :values => [ key_name_filter ] } ] ) . key_pairs . map...
Gets the Beaker user s keypairs by region
13,215
def delete_key_pair ( region , pair_name ) kp = client ( region ) . describe_key_pairs ( :key_names => [ pair_name ] ) . key_pairs . first unless kp . nil? @logger . debug ( "aws-sdk: delete key pair in region: #{region}" ) client ( region ) . delete_key_pair ( :key_name => pair_name ) end rescue Aws :: EC2 :: Errors :...
Deletes a given key pair
13,216
def create_new_key_pair ( region , pair_name ) @logger . debug ( "aws-sdk: importing new key pair: #{pair_name}" ) client ( region ) . import_key_pair ( :key_name => pair_name , :public_key_material => public_key ) begin client ( region ) . wait_until ( :key_pair_exists , { :key_names => [ pair_name ] } , :max_attempts...
Create a new key pair for a given Beaker run
13,217
def group_id ( ports ) if ports . nil? or ports . empty? raise ArgumentError , "Ports list cannot be nil or empty" end unless ports . is_a? Set ports = Set . new ( ports ) end "Beaker-#{Zlib.crc32(ports.inspect)}" end
Return a reproducable security group identifier based on input ports
13,218
def create_ping_group ( region_or_vpc , sg_cidr_ips = [ '0.0.0.0/0' ] ) @logger . notify ( "aws-sdk: Creating group #{PING_SECURITY_GROUP_NAME}" ) cl = region_or_vpc . is_a? ( String ) ? client ( region_or_vpc ) : client params = { :description => 'Custom Beaker security group to enable ping' , :group_name => PING_SECU...
Create a new ping enabled security group
13,219
def create_group ( region_or_vpc , ports , sg_cidr_ips = [ '0.0.0.0/0' ] ) name = group_id ( ports ) @logger . notify ( "aws-sdk: Creating group #{name} for ports #{ports.to_s}" ) @logger . notify ( "aws-sdk: Creating group #{name} with CIDR IPs #{sg_cidr_ips.to_s}" ) cl = region_or_vpc . is_a? ( String ) ? client ( re...
Create a new security group
13,220
def add_ingress_rule ( cl , sg_group , cidr_ip , from_port , to_port , protocol = 'tcp' ) cl . authorize_security_group_ingress ( :cidr_ip => cidr_ip , :ip_protocol => protocol , :from_port => from_port , :to_port => to_port , :group_id => sg_group . group_id , ) end
Authorizes connections from certain CIDR to a range of ports
13,221
def load_fog_credentials ( dot_fog = '.fog' ) default = get_fog_credentials ( dot_fog ) raise "You must specify an aws_access_key_id in your .fog file (#{dot_fog}) for ec2 instances!" unless default [ :aws_access_key_id ] raise "You must specify an aws_secret_access_key in your .fog file (#{dot_fog}) for ec2 instances!...
Return a hash containing the fog credentials for EC2
13,222
def compute_relative_speed @results = @results . map do | r | avgs = averages res = r [ :results ] avg_rt = avgs [ :response_time ] avg_rps = avgs [ :req_per_sec ] f_rt = ( ( res [ :response_time ] . to_f - avg_rt ) / avg_rt * 100 ) . round ( 1 ) f_rps = ( ( res [ :req_per_sec ] . to_f - avg_rps ) / avg_rps * 100 ) . r...
Returns only the results with the relative speed
13,223
def symbolize_hash_keys ( hash ) hash . inject ( { } ) do | new_hash , ( key , value ) | new_hash [ ( key . to_sym rescue key ) || key ] = value new_hash end hash end
note that returning hash without symbolizing anything does not cause this to fail
13,224
def start extract_and_configure if config . managed? @pid = spawn ( config . env , * process_arguments ) while ! status sleep 1 end end end
Start fcrepo and wait for it to become available
13,225
def stop if config . managed? && started? Process . kill 'HUP' , pid while status sleep 1 end Process . waitpid ( pid ) end @pid = nil end
Stop fcrepo and wait for it to finish exiting
13,226
def status return true unless config . managed? return false if pid . nil? begin Process . getpgid ( pid ) rescue Errno :: ESRCH return false end begin TCPSocket . new ( host , port ) . close Net :: HTTP . start ( host , port ) do | http | http . request ( Net :: HTTP :: Get . new ( '/' ) ) end true rescue Errno :: ECO...
Check the status of a managed fcrepo service
13,227
def clean! stop remove_instance_dir! FileUtils . remove_entry ( config . download_path ) if File . exists? ( config . download_path ) FileUtils . remove_entry ( config . tmp_save_dir , true ) if File . exists? config . tmp_save_dir md5 . clean! FileUtils . remove_entry ( config . version_file ) if File . exists? config...
Clean up any files fcrepo_wrapper may have downloaded
13,228
def remove_instance_dir! FileUtils . remove_entry ( config . instance_dir , true ) if File . exists? config . instance_dir end
Clean up any files in the fcrepo instance dir
13,229
def extract return config . instance_dir if extracted? jar_file = download FileUtils . mkdir_p config . instance_dir FileUtils . cp jar_file , config . binary_path self . extracted_version = config . version config . instance_dir end
extract a copy of fcrepo to instance_dir Does noting if fcrepo already exists at instance_dir
13,230
def exit ( ret ) @exit_status = ret if defined? Rbkb :: Cli :: TESTING throw ( ( ( ret == 0 ) ? :exit_zero : :exit_err ) , ret ) else Kernel . exit ( ret ) end end
Instantiates a new Executable object .
13,231
def add_range_opts ( fkey , lkey ) @oparse . on ( "-r" , "--range=START[:END]" , "Start and optional end range" ) do | r | raise "-x and -r are mutually exclusive" if @parser_got_range @parser_got_range = true unless / / . match ( r ) raise "invalid range #{r.inspect}" end @opts [ fkey ] = $1 . to_i @opts [ lkey ] = $2...
Implements numeric and hex range options via - r and - x
13,232
def create_transaction ( payment_method , transaction ) unless get_valid? return make_response_with_exception ( Exceptions :: APIKeyInvalidException . new ( 'API key, password or Rapid endpoint missing or invalid' ) , CreateTransactionResponse ) end begin case payment_method when Enums :: PaymentMethod :: DIRECT url = ...
Creates a transaction either using an authorisation the responsive shared page transparent redirect or direct as the source of funds
13,233
def query_transaction_by_filter ( filter ) index_of_value = filter . calculate_index_of_value if index_of_value . nil? return make_response_with_exception ( Exceptions :: APIKeyInvalidException . new ( 'Invalid transaction filter' ) , QueryTransactionResponse ) end case index_of_value when Enums :: TransactionFilter ::...
Query a transaction by one of four properties transaction id access code invoice number invoice reference
13,234
def refund ( refund ) unless @is_valid return make_response_with_exception ( Exceptions :: APIKeyInvalidException . new ( 'API key, password or Rapid endpoint missing or invalid' ) , RefundResponse ) end begin url = @web_url + Constants :: TRANSACTION_METHOD request = Message :: RefundProcess :: RefundMsgProcess . crea...
Refunds all or part of a transaction
13,235
def create_customer ( payment_method , customer ) unless get_valid? return make_response_with_exception ( Exceptions :: APIKeyInvalidException . new ( 'API key, password or Rapid endpoint missing or invalid' ) , CreateCustomerResponse ) end begin case payment_method when Enums :: PaymentMethod :: DIRECT url = @web_url ...
Creates a token customer to store card details in the secure eWAY Vault for charging later
13,236
def update_customer ( payment_method , customer ) unless get_valid? return make_response_with_exception ( Exceptions :: APIKeyInvalidException . new ( 'API key, password or Rapid endpoint missing or invalid' ) , CreateCustomerResponse ) end begin case payment_method when Enums :: PaymentMethod :: DIRECT url = @web_url ...
Updates an existing token customer for the merchant in their eWAY account .
13,237
def query_customer ( token_customer_id ) @logger . debug ( 'Query customer with id:' + token_customer_id . to_s ) if @logger unless @is_valid return make_response_with_exception ( Exceptions :: APIKeyInvalidException . new ( 'API key, password or Rapid endpoint missing or invalid' ) , QueryCustomerResponse ) end begin ...
Returns the details of a Token Customer . This includes the masked card information for displaying in a UI
13,238
def settlement_search ( search_request ) unless @is_valid return make_response_with_exception ( Exceptions :: APIKeyInvalidException . new ( 'API key, password or Rapid endpoint missing or invalid' ) , QueryCustomerResponse ) end begin request = Message :: TransactionProcess :: SettlementSearchMsgProcess . create_reque...
Performs a search of settlements
13,239
def query_transaction_with_path ( request , request_path ) unless @is_valid return make_response_with_exception ( Exceptions :: APIKeyInvalidException . new ( 'API key, password or Rapid endpoint missing or invalid' ) , QueryTransactionResponse ) end begin if request . nil? || request == '' url = @web_url + request_pat...
Perform a transaction query with the given path
13,240
def validate_api_param set_valid ( true ) if @api_key . nil? || @api_key . empty? || @password . nil? || @password . empty? add_error_code ( Constants :: API_KEY_INVALID_ERROR_CODE ) set_valid ( false ) end if @rapid_endpoint . nil? || @rapid_endpoint . empty? add_error_code ( Constants :: LIBRARY_NOT_HAVE_ENDPOINT_ERR...
Validates the Rapid API key password and endpoint
13,241
def parser_endpoint_to_web_url prop_name = nil if Constants :: RAPID_ENDPOINT_PRODUCTION . casecmp ( @rapid_endpoint ) . zero? prop_name = Constants :: GLOBAL_RAPID_PRODUCTION_REST_URL_PARAM elsif Constants :: RAPID_ENDPOINT_SANDBOX . casecmp ( @rapid_endpoint ) . zero? prop_name = Constants :: GLOBAL_RAPID_SANDBOX_RES...
Converts an endpoint string to a URL
13,242
def verify_endpoint_url ( web_url ) begin resource = RestClient :: Resource . new web_url resource . get rescue RestClient :: Exception => e if e . http_code == 404 set_valid ( false ) end end end
Checks the Rapid endpoint url
13,243
def call ( call , access_token = false , params = { } , risk_token = false , client_ip = false ) path = call . start_with? ( '/' ) ? call : call . prepend ( '/' ) url = URI . parse ( api_endpoint + path ) call = Net :: HTTP :: Post . new ( url . path , { 'Content-Type' => 'application/json' , 'User-Agent' => 'WePay Rub...
Execute a call to the WePay API .
13,244
def make_request ( call , url ) request = Net :: HTTP . new ( url . host , url . port ) request . read_timeout = 30 request . use_ssl = true response = request . start { | http | http . request ( call ) } JSON . parse ( response . body ) end
Make the HTTP request to the endpoint .
13,245
def all instance_variables . inject ( { } ) do | h , v | var = v . to_s . sub ( '@' , '' ) h . merge ( var . to_sym => send ( var ) ) end end
Default values INSANE . Must be refactored Maybe create a yaml or json file to import for default values
13,246
def match_keys values . each do | v | Textoken . expression_err ( "#{v}: is not permitted." ) unless yaml . key? ( v ) add_regexps ( yaml [ v ] ) end end
here we do check for option values user supplied option values has to be declared at option_values . yml
13,247
def episode ( number ) episodes . detect { | epi | epi . index . to_i == number . to_i } end
Select a particular episode
13,248
def convert input_io , options = { } @exception = nil iam "Retrieving cookies... " , false do response = self . class . get '/tools/webfont-generator' @cookies = ( response . headers . get_fields ( "Set-Cookie" ) || [ ] ) . join ( ";" ) fail "Failed to retrieve cookies" if @cookies . empty? self . class . headers ( { "...
Convert a font file to a webfont kit
13,249
def play_media ( key , user_agent = nil , http_cookies = nil , view_offset = nil ) if ! key . is_a? ( String ) && key . respond_to? ( :key ) key = key . key end url = player_url + '/application/playMedia?' url += "path=#{CGI::escape(server.url+key)}" url += "&key=#{CGI::escape(key)}" url += "&userAgent=#{user_agent}" i...
Plays a video that is in the library
13,250
def screenshot ( width , height , quality ) url = player_url + '/application/screenshot?' url += "width=#{width}" url += "&height=#{height}" url += "&quality=#{quality}" ping url end
Take a screenshot of whats on the Plex Client
13,251
def season ( number ) seasons . detect { | sea | sea . index . to_i == number . to_i } end
Select a particular season
13,252
def first_season seasons . inject { | a , b | a . index . to_i < b . index . to_i && a . index . to_i > 0 ? a : b } end
Selects the first season of this show that is on the Plex Server Does not select season 0
13,253
def tokens options . collection . each do | option | if @findings . nil? @findings = option . tokenize ( self ) else @findings &= option . tokenize ( self ) end end Tokenizer . new ( self ) . tokens end
we do take intersection array of results returning from multiple options
13,254
def gremlin ( gremlin ) raise ArgumentError , 'gremlin query is blank' if blank? gremlin response = call_server ( :method => :post , :uri => "command/#{@database}/gremlin/#{CGI::escape(gremlin)}" ) entries = process_response ( response ) do raise NotFoundError , 'record not found' if response . body =~ / / end rslt = e...
Executes a Gremlin command against the database .
13,255
def process_response ( response ) raise ArgumentError , 'response is null' if response . nil? if block_given? yield end if 401 == response . code raise UnauthorizedError , compose_error_message ( response ) elsif 500 == response . code raise ServerError , compose_error_message ( response ) elsif 2 != ( response . code ...
Processes a HTTP response .
13,256
def compose_error_message ( http_response , max_len = 200 ) msg = http_response . body . gsub ( "\n" , ' ' ) msg = "#{msg[0..max_len]} ..." if msg . size > max_len msg end
Composes message of an error raised if the HTTP response doesn t correspond with expectation .
13,257
def dialects_for ( symbols ) info = self . class . tag_dispatching_name ( symbols , "_diatag" ) raise ArgumentError , "No tag for #{symbols}" unless respond_to? ( info ) send ( info ) end
Returns the dialects used to parse the blocks associated with symbols as previously installed by define_tag_method .
13,258
def render ( fn , scope = nil , buffer = "" ) if scope . nil? case fn when String then buffer << fn when Proc then fn . call ( self , buffer ) when Template then fn . call ( @scope , buffer ) when TiltTemplate then buffer << fn . render ( @scope ) else raise ArgumentError , "Unable to render `#{fn}`" end buffer else wi...
rendering Renders fn to a buffer optionally extending the current scope .
13,259
def evaluate ( expr , * default , & bl ) case expr when Symbol , String catch ( :fail ) do return scope . evaluate ( expr , self , * default , & bl ) end raise NameError , "Unable to find `#{expr}` on #{scope}" else evaluate ( render ( expr ) , * default , & bl ) end end
Evaluates expr in the current scope . expr can be either
13,260
def security_group_id resp = ec2 . describe_security_groups ( filters : [ { name : "vpc-id" , values : [ vpc_id ] } , { name : "group-name" , values : [ "default" ] } ] ) resp . security_groups . first . group_id end
default security group
13,261
def process count = 0 loop do entries = Entry . next_batch! ( self ) if entries . nil? || entries . empty? break if Entry . ready_count ( self ) == 0 else batch = Batch . new ( self , entries ) if defined? ( @batch_handler ) && @batch_handler @batch_handler . call ( batch ) else batch . submit! end count += entries . s...
Process the queue . Exits when there are no more entries to process at the current time . Returns the number of entries processed .
13,262
def get_mandatory_attribute ( name ) key = name . to_s raise :: ArgumentError , "unknown attribute, name=#{key}" unless self . include? key self [ key ] end
Gets an attribute value that has to be presented .
13,263
def property ( name ) raise ArgumentError , 'no properties defined on class' if properties . nil? props = properties . select { | i | i [ 'name' ] == name . to_s } raise :: ArgumentError , "unknown property, name=#{name}" if props . empty? raise :: ArgumentError , "too many properties found, name=#{name}" if props . si...
Gets a property with the given name .
13,264
def blank? ( str ) str . nil? or ( str . is_a? String and str . strip . empty? ) end
Checks if a given string is either nil or empty string .
13,265
def load_custom_helpers Dir . glob ( "#{Forger.root}/app/helpers/**/*_helper.rb" ) . each do | path | filename = path . sub ( %r{ } , '' ) . sub ( '.rb' , '' ) module_name = filename . classify first_char = path [ 0 .. 0 ] path = "./#{path}" unless %w[ . / ] . include? ( first_char ) require path self . class . send :i...
Load custom helper methods from project
13,266
def attrs @attrs . inject ( { } ) do | attrs , ( key , value ) | attrs . merge! ( key => respond_to? ( key ) ? send ( key ) : value ) end end
Retrieve the attributes of an object
13,267
def database_exists? ( options ) rslt = true begin get_database options rescue OrientdbError rslt = false end rslt end
Checks existence of a given database . Client has not to be connected to see databases suitable to connect .
13,268
def class_exists? ( name ) rslt = true begin get_class name rescue OrientdbError => e raise e if e . is_a? ConnectionError and e . message == 'not connected' rslt = false end rslt end
Checks existence of a given class .
13,269
def drop_class ( name , options = { } ) raise ArgumentError , 'class name is blank' if blank? ( name ) opt_pattern = { :mode => :nil } verify_options ( options , opt_pattern ) if :strict == options [ :mode ] response = get_database children = response [ 'classes' ] . select { | i | i [ 'superClass' ] == name } unless c...
Removes a class from the schema .
13,270
def create_property ( clazz , property , type , options = { } ) raise ArgumentError , "class name is blank" if blank? ( clazz ) raise ArgumentError , "property name is blank" if blank? ( property ) opt_pattern = { :mandatory => :optional , :notnull => :optional , :min => :optional , :max => :optional , :readonly => :op...
Creates a new property in the schema . You need to create the class before .
13,271
def time_around ( & block ) start = Time . now rslt = block . call query_log ( "#{aop_context[:class].name}##{aop_context[:method]}" , "elapsed time = #{Time.now - start} [s]" ) rslt end
Around advice to meassure and print the method time .
13,272
def constant_node ( name , value , options = { } ) attr_reader name . to_sym define_method ( "parse_#{name}" . to_sym ) do instance_variable_set ( "@#{name}" , value ) end register ( name , options [ :private ] ) end
Defines a method on your class returning a constant .
13,273
def node ( name , type , options = { } , & block ) attr_reader name . to_sym options [ :local_context ] = @local_context xpath = NodeXPath . new ( name , options ) . xpath define_method ( "parse_#{name}" . to_sym ) do evaluate_args = [ xpath , AwesomeXML :: Type . for ( type , self . class . name ) , options ] instance...
Defines a method on your class returning a parsed value
13,274
def validate_url_domain ( u ) u = "#{u}" u = "/" if u . empty? begin domained_url = @host + u unless ( u . split ( "/" ) . first || "" ) . match ( / \: \. / ) domained_url ||= u httpped_url = "http://" + domained_url unless domained_url [ 0 .. 3 ] == 'http' httpped_url ||= domained_url uri = URI . parse ( httpped_url )...
Normalize and validate the URLs on the page for comparison
13,275
def check_localizable_omissions localizable_files = not_deleted_localizable_files keys_by_file = extract_keys_from_files ( localizable_files ) entries = localizable_strings_missed_entries ( keys_by_file ) print_missed_entries entries unless entries . empty? end
Checks whether there are any missed entries in all Localizable . strings from PR s changeset files and prints out any found entries .
13,276
def extract_keys_from_files ( localizable_files ) keys_from_file = { } localizable_files . each do | file | lines = File . readlines ( file ) keys = lines . map { | e | e . split ( "=" ) . first } keys = keys . select do | e | e != "\n" && ! e . start_with? ( "/*" ) && ! e . start_with? ( "//" ) end keys_from_file [ fi...
A hash with keyes - Localizable . strings file and values - modified keys from file
13,277
def title ( title , options = { } ) options . merge! ( title : title ) params = build_params ( options ) get '/' , params end
Retrieves a movie or show based on its title .
13,278
def id ( imdb_id , options = { } ) options . merge! ( id : imdb_id ) params = build_params ( options ) get '/' , params end
Retrieves a movie or show based on its IMDb ID .
13,279
def search ( title ) results = get '/' , { s : title } if results [ :search ] search = results . search search . size == 1 ? title ( search [ 0 ] . title ) : search else results end end
Search for a movie by its title .
13,280
def convert_hash_keys ( value ) case value when Array value . map { | v | convert_hash_keys ( v ) } when Hash Hash [ value . map { | k , v | [ k . to_snake_case . to_sym , convert_hash_keys ( v ) ] } ] else value end end
Performs a method on all hash keys .
13,281
def build_params ( options ) params = { } params [ :t ] = options [ :title ] if options [ :title ] params [ :i ] = options [ :id ] if options [ :id ] params [ :y ] = options [ :year ] if options [ :year ] params [ :plot ] = options [ :plot ] if options [ :plot ] params [ :season ] = options [ :season ] if options [ :se...
Build parameters for a request .
13,282
def transform_error2_response ( error ) response = [ "#{error.message}: #{error.http_body}" , error . http_code ] def response . body self [ 0 ] end def response . code self [ 1 ] end response end
Fakes an error thrown by the library into a response object with methods code and body .
13,283
def connection return @connection unless @connection . nil? options = { } options [ :proxy ] = proxy unless proxy . nil? options [ :scheme ] , options [ :host ] , options [ :port ] = url . scan ( / \/ \/ / ) . first @connection ||= Excon :: Connection . new ( options ) end
Gets Excon connection .
13,284
def headers ( options ) rslt = { 'Authorization' => basic_auth_header ( options [ :user ] , options [ :password ] ) } rslt [ 'Cookie' ] = "#{SESSION_COOKIE_NAME}=#{session_id}" if ! session_id . nil? and ! options [ :no_session ] rslt [ 'Content-Type' ] = options [ :content_type ] if options . include? :content_type rs...
Get request headers prepared with session ID and Basic Auth .
13,285
def set_default_configuration ActiveSupport :: Deprecation . warn ( "The environment variable RAILS_DATAROOT will be deprecated in an upcoming release, please use OOD_DATAROOT instead." ) if ENV [ 'RAILS_DATAROOT' ] self . dataroot = ENV [ 'OOD_DATAROOT' ] || ENV [ 'RAILS_DATAROOT' ] self . dataroot ||= "~/#{ENV['OOD_P...
Sets the default configuration for this object .
13,286
def parse_clusters ( config ) OodCore :: Clusters . load_file ( config || '/etc/ood/config/clusters.d' ) rescue OodCore :: ConfigurationNotFound OodCore :: Clusters . new ( [ ] ) end
Read in cluster config and parse it
13,287
def convert_to_latex ( node ) latex_code = nil Open3 . popen3 ( "pandoc -f json -t latex --wrap=none" ) { | stdin , stdout , stderr , wait_thr | stdin . write ( node . to_json ) stdin . close latex_code = stdout . read pid = wait_thr . pid exit_status = wait_thr . value } latex_code end
Converte node para latex
13,288
def dependencies ( scopes = nil ) if scopes unless scopes . is_a? Array scopes = [ scopes ] end end if Naether . platform == 'java' if scopes . nil? deps = @project . getDependenciesNotation ( ) else deps = @project . getDependenciesNotation ( scopes ) end elsif scopes list = Naether :: Java . convert_to_java_list ( sc...
Get dependences for Project as notations
13,289
def invoke ( * opts ) config = { :maven_home => ENV [ 'maven.home' ] || ENV [ 'MAVEN_HOME' ] || '/usr/share/maven' , :local_repo => File . expand_path ( '~/.m2/repository' ) } if opts . last . is_a? Hash config = config . merge ( opts . pop ) end goals = opts pom = @project . getPomFile ( ) . getAbsolutePath ( ) invoke...
Invoke a Maven goal
13,290
def api_version return @api_version unless @api_version . nil? xml = http_get ( "/" ) / '/api/product_info/version' major = ( xml / 'version' ) . first [ :major ] minor = ( xml / 'version' ) . first [ :minor ] build = ( xml / 'version' ) . first [ :build ] revision = ( xml / 'version' ) . first [ :revision ] @api_versi...
Construct a new ovirt client class . mandatory parameters username password api_entrypoint - for example me
13,291
def emit_builtin_reg_class ( node ) arg = node . args [ 0 ] Util . assert! { arg . ty . kind == Kind :: PTR } ty = arg . ty . ptr if ty . kind == Kind :: STRUCT emit ( "mov $2, #eax" ) elsif Type . is_flotype ( ty ) emit ( "mov $1, #eax" ) else emit ( "mov $0, #eax" ) end end
Set the register class for parameter passing to RAX . 0 is INTEGER 1 is SSE 2 is MEMORY .
13,292
def synced ( strategy : :updated_since , ** options ) options . assert_valid_keys ( :associations , :data_key , :fields , :globalized_attributes , :id_key , :include , :initial_sync_since , :local_attributes , :mapper , :only_updated , :remove , :auto_paginate , :transaction_per_page , :delegate_attributes , :query_par...
Enables synced for ActiveRecord model .
13,293
def synchronize ( scope : scope_from_relation , strategy : synced_strategy , ** options ) options . assert_valid_keys ( :api , :fields , :include , :remote , :remove , :query_params , :association_sync , :auto_paginate , :transaction_per_page ) options [ :remove ] = synced_remove unless options . has_key? ( :remove ) o...
Performs synchronization of given remote objects to local database .
13,294
def reset_synced ( scope : scope_from_relation ) options = { scope : scope , strategy : synced_strategy , only_updated : synced_only_updated , initial_sync_since : synced_initial_sync_since , timestamp_strategy : synced_timestamp_strategy , synced_endpoint : synced_endpoint } Synced :: Synchronizer . new ( self , optio...
Reset last sync timestamp for given scope this forces synced to sync all the records on the next sync . Useful for cases when you add a new column to be synced and you use updated since strategy for faster synchronization .
13,295
def add_remote_repository ( url , username = nil , password = nil ) if username @resolver . addRemoteRepositoryByUrl ( url , username , password ) else @resolver . addRemoteRepositoryByUrl ( url ) end end
Add remote repository
13,296
def build_artifacts = ( artifacts ) @resolver . clearBuildArtifacts ( ) unless artifacts . is_a? Array artifacts = [ artifacts ] end artifacts . each do | artifact | if artifact . is_a? Hash notation , opts = artifact . shift if opts . is_a? Hash @resolver . add_build_artifact ( notation , opts [ :path ] , opts [ :pom ...
Set local Build Artifacts that will be used in the Dependency Resolution
13,297
def add_pom_dependencies ( pom_path , scopes = [ 'compile' ] ) if Naether . platform == 'java' @resolver . addDependencies ( pom_path , scopes ) else list = Naether :: Java . convert_to_java_list ( scopes ) @resolver . _invoke ( 'addDependencies' , 'Ljava.lang.String;Ljava.util.List;' , pom_path , list ) end end
Add dependencies from a Maven POM
13,298
def dependencies = ( dependencies ) @resolver . clearDependencies ( ) unless dependencies . is_a? Array dependencies = [ dependencies ] end dependencies . each do | dependent | if dependent . is_a? Hash key = dependent . keys . first if key =~ / \. /i scopes = nil if dependent [ key ] . is_a? Array scopes = dependent [...
Set the dependencies
13,299
def dependencies_graph ( nodes = nil ) nodes = @resolver . getDependenciesGraph ( ) unless nodes graph = { } if Naether . platform == 'java' nodes . each do | k , v | deps = dependencies_graph ( v ) graph [ k ] = Naether :: Java . convert_to_ruby_hash ( deps ) end else iterator = nodes . entrySet ( ) . iterator ( ) ; w...
Dependencies as a Graph of nested Hashes