idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
17,500 | def box_score_four_factors ( game_id , range_type = 0 , start_period = 0 , end_period = 0 , start_range = 0 , end_range = 0 ) NbaStats :: Resources :: BoxScoreFourFactors . new ( get ( BOX_SCORE_FOUR_FACTORS_PATH , { :GameID => game_id , :RangeType => range_type , :StartPeriod => start_period , :EndPeriod => end_period... | Calls the boxscorefourfactors API and returns a BoxScoreFourFactors resource . |
17,501 | def matches? ( rendered ) @rendered = rendered matches = Nokogiri :: HTML :: Document . parse ( @rendered . to_s ) . css ( @name ) . select do | element | matches_attributes? ( element ) && matches_content? ( element ) && matches_criteria? ( element ) end matches_count? ( matches ) end | Answers whether or not the matcher matches any elements within + rendered + . |
17,502 | def grouped_attributes_description ( attributes ) make_sentence ( attributes . sort_by { | key , value | key . to_s } . map do | key , value | attribute_description ( key , value ) end ) end | Describes a group of attribute criteria combining them into a sentence fragment with punctuation and conjunctions if necessary . |
17,503 | def player_profile ( player_id , season , graph_start_season , graph_end_season , graph_stat = NbaStats :: Constants :: GRAPH_STAT_POINTS , season_type = NbaStats :: Constants :: SEASON_TYPE_REGULAR , league_id = NbaStats :: Constants :: LEAGUE_ID_NBA ) NbaStats :: Resources :: PlayerProfile . new ( get ( PLAYER_PROFIL... | Calls the playerprofile API and returns a PlayerProfile resource . |
17,504 | def player_career_stats ( player_id , per_mode = NbaStats :: Constants :: PER_MODE_TOTALS , league_id = NbaStats :: Constants :: LEAGUE_ID_NBA ) NbaStats :: Resources :: PlayerCareerStats . new ( get ( PLAYER_CAREER_STATS_PATH , { :PlayerID => player_id , :LeagueID => league_id , :PerMode => per_mode } ) ) end | Calls the playercareerstats API and returns a PlayerCareerStats resource . |
17,505 | def tokenize_non_expanded_string ( start_delimiter ) delimiter_depth = 0 matched_delimiter = is_matched_delimiter? ( start_delimiter ) end_delimiter = find_matching_delimiter ( start_delimiter ) advance until ( ( cchar == end_delimiter && delimiter_depth == 0 ) || @i >= @length ) if matched_delimiter delimiter_depth +=... | If a block is given it gets run after the final delimiter is detected . The primary purpose for this is to allow the capture of regex modifiers |
17,506 | def tokenize_heredoc_delimiter offset = 2 if cchar == '-' advance offset = 3 end if cchar =~ / / advance advance until / / . match ( cchar ) . nil? elsif / / . match ( cchar ) advance_through_quoted_delimiter ( cchar ) else return nil end @heredoc_delimiter = thunk [ offset .. - 1 ] capture_token ( :heredoc_delimiter )... | Called from tokenize_lt_operators when it identifies that << is a heredoc delimiter . Expects that << will already be included in the current thunk . |
17,507 | def to_hash load { } . tap do | hash | @_definition . each do | k , v | hash [ k ] = v end end end | Returns a hash based on the current definition of the resource |
17,508 | def respond_to? ( method ) load meth = method . to_s return true if is_embedded? ( meth ) return true if is_link? ( meth ) return true if meth . end_with? ( '=' ) and is_field? ( meth [ 0 ... - 1 ] ) return true if is_field? ( meth ) super end | Checks if this resource responds to a specific method |
17,509 | def get_embedded_resource ( method ) return @_embedded [ method ] if @_embedded . key? ( method ) @_embedded [ method ] = @_definition [ '_embedded' ] [ method ] if @_embedded [ method ] . kind_of? ( Array ) @_embedded [ method ] . tap do | ary | ary . map! { | definition | new_resource ( definition , true ) } unless a... | Returns the embedded resource |
17,510 | def get_linked_resource ( method ) return @_links [ method ] if @_links . key? ( method ) @_links [ method ] = @_definition [ '_links' ] [ method ] if @_links [ method ] and not @_links [ method ] . kind_of? ( self . class ) @_links [ method ] = new_resource ( self . class . build_self_link ( @_links [ method ] ) ) end... | Returns the linked resource |
17,511 | def method_missing ( method , * args , & block ) load meth = method . to_s return get_embedded_resource ( meth ) if is_embedded? ( meth ) return get_linked_resource ( meth ) if is_link? ( meth ) return @_changed [ meth [ 0 ... - 1 ] ] = args . first if meth . end_with? ( '=' ) and is_field? ( meth [ 0 ... - 1 ] ) retur... | Returns the requested embedded resource linked resource or field value also allows to set a new field value |
17,512 | def league_dash_player_stats ( season , measure_type = NbaStats :: Constants :: MEASURE_TYPE_BASE , per_mode = NbaStats :: Constants :: PER_MODE_GAME , plus_minus = NbaStats :: Constants :: NO , pace_adjust = NbaStats :: Constants :: NO , rank = NbaStats :: Constants :: NO , outcome = nil , location = nil , month = 0 ,... | Calls the leaguedashplayerstats API and returns a LeagueDashPlayerStats resource . |
17,513 | def box_score ( game_id , range_type = 0 , start_period = 0 , end_period = 0 , start_range = 0 , end_range = 0 ) NbaStats :: Resources :: BoxScore . new ( get ( BOX_SCORE_PATH , { :GameID => game_id , :RangeType => range_type , :StartPeriod => start_period , :EndPeriod => end_period , :StartRange => start_range , :EndR... | Calls the boxscore API and returns a BoxScore resource . |
17,514 | def has_roles? ( * args ) throw Exception . new ( "Must supply at least one role." ) if args . empty? roles . where ( name : args ) . count == args . count end | Determines if the user has all of the given roles linked to it . |
17,515 | def has_permission? ( action ) return true if Action . where ( name : action ) . count == 0 actions . where ( name : action ) . count > 0 end | Determines if the user has permission to a given action . If the action does not exist at all it is assumed the action is publicly available . |
17,516 | def scoreboard ( game_date = Date . today , day_offset = 0 , league_id = NbaStats :: Constants :: LEAGUE_ID_NBA ) NbaStats :: Resources :: Scoreboard . new ( get ( SCOREBOARD_PATH , { :LeagueID => league_id , :GameDate => game_date . strftime ( '%m-%d-%Y' ) , :DayOffset => day_offset } ) ) end | Calls the scoreboard API and returns a Scoreboard resource . |
17,517 | def get_keyword_from_url if request . env [ "REQUEST_PATH" ] req_url = request . env [ "REQUEST_PATH" ] . split ( "/" ) keyword_names = Keyword . all . map ( & :name ) keyword = req_url & keyword_names end end | grab the keyword form request url |
17,518 | def redis if defined? ( $redis ) && $redis Redis . new ( $redis . client . options ) elsif defined? ( REDIS ) && REDIS Redis . new ( REDIS . client . options ) else Redis . new end end | Get Redis that user might be using or instantiate a new one |
17,519 | def draft_combine_drill_results ( season_year , league_id = NbaStats :: Constants :: LEAGUE_ID_NBA ) NbaStats :: Resources :: DraftCombineDrillResults . new ( get ( DRAFT_COMBINE_DRILL_RESULTS_PATH , { :LeagueID => league_id , :SeasonYear => season_year } ) ) end | Calls the draftcombinedrillresults API and returns a DraftCombineDrillResults resource . |
17,520 | def play_by_play ( game_id , start_period = 0 , end_period = 0 ) NbaStats :: Resources :: PlayByPlay . new ( get ( PLAY_BY_PLAY_PATH , { :GameID => game_id , :StartPeriod => start_period , :EndPeriod => end_period } ) ) end | Calls the playbyplay API and returns a PlayByPlay resource . |
17,521 | def native ( flags ) native = Native :: KEvent . new native [ :ident ] = @ident native [ :filter ] = Native :: Flags . to_flag ( "EVFILT" , @filter ) native [ :flags ] = Native :: Flags . to_mask ( "EV" , @flags | flags ) native [ :fflags ] = Native :: Flags . to_mask ( "NOTE_#{@filter.to_s.upcase}" , @fflags ) native ... | Returns a C struct corresponding to this watcher . |
17,522 | def kevent! ( * flags ) if Native . kevent ( @queue . fd , native ( flags ) . pointer , 1 , nil , 0 , nil ) < 0 KQueue . handle_error end end | Runs the kevent C call with this Watcher s kevent struct as input . This effectively means telling kqueue to perform some action with this Watcher as an argument . |
17,523 | def draft_combine_non_stationary_shooting ( season_year , league_id = NbaStats :: Constants :: LEAGUE_ID_NBA ) NbaStats :: Resources :: DraftCombineNonStationaryShooting . new ( get ( DRAFT_COMBINE_NON_STATIONARY_SHOOTING_PATH , { :LeagueID => league_id , :SeasonYear => season_year } ) ) end | Calls the draftcombinenonstationaryshooting API and returns a DraftCombineNonStationaryShooting resource . |
17,524 | def convert_param_keys ( underscored_params ) pairs = underscored_params . map do | key , value | key = key . to_s . gsub ( / /i ) { $1 . upcase } [ key , value ] end Hash [ pairs ] end | Converts foo_bar_param to fooBarParam . |
17,525 | def box_score_misc ( game_id , range_type = 0 , start_period = 0 , end_period = 0 , start_range = 0 , end_range = 0 ) NbaStats :: Resources :: BoxScoreMisc . new ( get ( BOX_SCORE_MISC_PATH , { :GameID => game_id , :RangeType => range_type , :StartPeriod => start_period , :EndPeriod => end_period , :StartRange => start... | Calls the boxscoremisc API and returns a BoxScoreMisc resource . |
17,526 | def league_dash_team_stats ( season , date_from = nil , date_to = nil , game_scope = nil , game_segment = nil , last_n_games = 0 , location = nil , measure_type = NbaStats :: Constants :: MEASURE_TYPE_BASE , month = 0 , opponent_team_id = 0 , outcome = nil , pace_adjust = NbaStats :: Constants :: NO , per_mode = NbaSta... | Calls the leaguedashteamstats API and returns a LeagueDashTeamStats resource . |
17,527 | def player_game_log ( player_id , season , season_type = NbaStats :: Constants :: SEASON_TYPE_REGULAR , league_id = NbaStats :: Constants :: LEAGUE_ID_NBA ) NbaStats :: Resources :: PlayerGameLog . new ( get ( PLAYER_GAME_LOG_PATH , { :Season => season , :LeagueID => league_id , :PlayerID => player_id , :SeasonType => ... | Calls the playergamelog API and returns a PlayerGameLog resource . |
17,528 | def matches? ( rendered ) @rendered = rendered @failures = matchers . reject do | matcher | matcher . matches? ( rendered ) end @failures . empty? end | Initializes a matcher that matches multiple input elements . |
17,529 | def for ( * args ) @for = args . dup @for . extend ( DeepFlattening ) @for = @for . deep_flatten @components . each do | index , matcher | delegated_for ( index , matcher , @for ) end self end | Specifies the inputs names with more accuracy than the default regular expressions . It delegates to each matcher s + for + method . But it first appends the matcher s key to the last component of the input s name . |
17,530 | def delegated_for ( key , matcher , args ) args = args . dup args [ - 1 ] = args [ - 1 ] . to_s args [ - 1 ] += "(#{key})" matcher . for ( * args ) end | Set s + matcher + s input name according to + args + and + key + . |
17,531 | def assert_repo! begin repo rescue Exception raise Thor :: Error . new ( "#{repo_path} does not appear to be a git repository" ) end unless repo . repo . writable? raise Thor :: Error . new ( "Git repository at #{repo.repo.path} is read-only" ) end end | Check that we are in a git repo that we have write access to . |
17,532 | def current_branch repo . current_branch . tap { | b | raise Thor :: Error . new ( "No explicit branch passed and current head looks detached: #{b}" ) if b [ 0 ] == '(' } end | Get the current branch but raise an error if it looks like we re on a detched head . |
17,533 | def has_sign_off? ( commit_or_message ) message = commit_or_message . is_a? ( String ) ? commit_or_message : commit_or_message . message if message =~ / / $1 else nil end end | Check if a commit or commit message is already signed off . |
17,534 | def alt ( binary_or_uint ) case binary_or_uint when Integer alt_uint ( binary_or_uint ) when String alt_binary ( binary_or_uint ) else raise BadManipulationError , "Argument shouled be Integer or binary-encoded String." end end | Methods for generating modified binary . |
17,535 | def [] ( arg ) case when arg . is_a? ( Range ) index = @index . select { | i | arg . include? ( i ) } Mikon :: DataFrame . new ( index . map { | i | self . row ( i ) } , { index : index } ) when arg . is_a? ( Symbol ) self . column ( arg ) end end | Accessor for column and rows |
17,536 | def column ( label ) pos = @labels . index ( label ) raise "There is no column named " + label if pos . nil? Mikon :: Series . new ( label , @data [ pos ] , index : @index ) end | Access column with its name |
17,537 | def to_html ( threshold = 50 ) html = "<html><table><tr><td></td>" html += @labels . map { | label | "<th>" + label . to_s + "</th>" } . join html += "</tr>" self . each_row . with_index do | row , pos | next if pos > threshold && pos != self . length - 1 html += "<tr><th>" + @index [ pos ] . to_s + "</th>" html += @la... | IRuby notebook automatically call this method |
17,538 | def sort ( label , ascending = true ) i = @labels . index ( label ) raise "No column named" + label . to_s if i . nil? order = @data [ i ] . sorted_indices order . reverse! unless ascending self . sort_by . with_index { | val , i | order . index ( i ) } end | Sort by label |
17,539 | def row ( index ) pos = @index . index ( index ) arr = @data . map { | column | column [ pos ] } Mikon :: Row . new ( @labels , arr , index ) end | Access row using index |
17,540 | def block_yield ( parent , indent ) return unless accept :yield error :yield unless accept ( :line_feed ) . strip . empty? yield_node = [ :yield , nil , { } , [ ] , indent ] parent [ @children ] << yield_node end | Match a yield with a explicit or implicit target |
17,541 | def create authorize model @resource = model . new ( creation_params ) @resource . assign_attributes ( ** reflections_hash ) unless reflections_hash . nil? before_create_hook ( @resource ) if @resource . save after_create_hook ( @resource ) successful_response ( :create ) else errorful_resopnse ( :create , @resource . ... | The actual action method for creating new resource . |
17,542 | def is_reflection? ( c ) has_many = ActiveRecord :: Reflection :: HasManyReflection has_and_belongs_to_many = ActiveRecord :: Reflection :: HasAndBelongsToManyReflection has_many_through = ActiveRecord :: Reflection :: ThroughReflection result = c . is_a? ( has_many ) || c . is_a? ( has_and_belongs_to_many ) result || ... | Check whether the given column is a reflection or not . |
17,543 | def transform_to_one ( entity_class_or_decider , root : nil ) object = root ? raw_data [ root ] : raw_data transform_attributes_to_object ( entity_class_or_decider , object ) end | Transforms a response into one object based on the response s body . |
17,544 | def transform_to_many ( entity_class_or_decider , root : nil ) items = get_rooted_items ( root ) unless items . is_a? ( Array ) fail Dialers :: ImpossibleTranformationError . new ( response ) end items . map { | item | transform_attributes_to_object ( entity_class_or_decider , item ) } end | Transforms a response into many objects based on the response s body . |
17,545 | def add_url ( url , params = { } ) page = Page . new ( url , params ) yield ( page ) if block_given? internal_queue << page . to_json end | Enqueue an url no matter what |
17,546 | def should_be_visited? ( url , with_tracker = true ) case when ! allowed_by_robot? ( url ) false when ! @follow_links_like . empty? && @follow_links_like . none? { | p | url . path =~ p } false when @skip_links_like . any? { | p | url . path =~ p } false when page_expired? ( Page . new ( url ) ) true when with_tracker ... | URLs enqueue policy |
17,547 | def links_for ( page ) page . domain_aliases = domain_aliases @focus_crawl_block . nil? ? page . links : @focus_crawl_block . call ( page ) end | It extracts URLs from the page |
17,548 | def page_expired? ( page ) return false if @options [ :ttl_page ] . nil? stored_page = @storage . get ( page ) r = stored_page && stored_page . expired? ( @options [ :ttl_page ] ) @logger . debug { "Page #{page.url} marked as expired" } if r r end | whether a page is expired or not |
17,549 | def page_exists? ( page ) return false if page . user_data && page . user_data . p_seeded @storage . exists? ( page ) && ! page_expired? ( page ) end | whether a page exists or not |
17,550 | def enqueue ( url_to_visit , current_page ) page_to_visit = Page . new ( url_to_visit . to_s , referer : current_page . url . to_s , depth : current_page . depth + 1 ) internal_queue << page_to_visit . to_json to_track = @options [ :include_query_string_in_saved_page ] ? url_to_visit . to_s : url_to_visit . to_s . gsub... | The url is enqueued for a later visit |
17,551 | def execute_plugin ( method ) Polipus :: Plugin . plugins . each do | k , p | next unless p . respond_to? ( method ) @logger . info { "Running plugin method #{method} on #{k}" } ret_val = p . send ( method , self ) instance_eval ( & ret_val ) if ret_val . is_a? Proc end end | It invokes a plugin method if any |
17,552 | def set_default_url_option_for_request? RailsLocaleDetection . set_default_url_option === true || RailsLocaleDetection . set_default_url_option == :always || RailsLocaleDetection . set_default_url_option == :explicitly && params [ locale_key ] . present? end | returns true if the default url option should be set for this request |
17,553 | def join_guests if groups . empty? guest_group = :: Faalis :: Group . find_or_create_by ( name : 'Guest' , role : 'guest' ) self . groups << guest_group end end | It s totally obviuse . Join the guest group if no group provided |
17,554 | def attributes ( * fields_name , ** options , & block ) if options . include? :except @fields = resolve_model_reflections . reject do | field | options [ :except ] . include? field . to_sym end elsif options . include? :append @fields += options [ :append ] else fields_name . each do | name | unless @fields . include? ... | Base class for all the DSL property classes to be used as the yielded object inside each section DSL scope . |
17,555 | def resolve_model_reflections reflections = model . reflections columns = Set . new model . column_names new_fields = Set . new fields_to_remove = Set . new reflections . each do | name , column | has_many = ActiveRecord :: Reflection :: HasManyReflection has_and_belongs_to_many = ActiveRecord :: Reflection :: HasAndBe... | Replace foreign key names with their reflection names and create an array of model fields |
17,556 | def rails? ( * args ) version , comparator = args . pop , ( args . pop || :== ) result = if version . nil? defined? ( :: Rails ) elsif defined? ( :: Rails ) if :: Rails . respond_to? ( :version ) rails_version = Rails . version . to_f rails_version = rails_version . floor if version . is_a? ( Integer ) rails_version . ... | Return a boolean indicating whether the Rails constant is defined . It cannot identify Rails < 2 . 1 |
17,557 | def init return unless rails? if rails? ( :>= , 3 ) require 'ajax/railtie' else require 'ajax/action_controller' require 'ajax/action_view' Ajax . logger = :: Rails . logger :: ActionController :: Base . send ( :include , Ajax :: ActionController ) :: ActionController :: Dispatcher . middleware . insert_before ( Rack :... | Include framework hooks for Rails |
17,558 | def evaluate ( node , indent ) if node [ @value ] =~ Settings :: END_REMOVAL @template . pop if @template [ - 1 ] == [ :eval , 'end' ] end if node [ @value ] =~ Settings :: END_EXPLICIT Logger . error :compile , @template , :explicit_end , node end buffer_eval node [ @value ] node [ @children ] . each do | child | root... | Evaluate the embedded ruby code using the current context |
17,559 | def localized_scope langs = :: I18n . available_locales . join ( '|' ) scope '(:locale)' , locale : Regexp . new ( langs ) do yield end end | Allow localized scope |
17,560 | def api_routes ( version : :v1 ) namespace :api , defaults : { format : :json } do namespace version do yield if block_given? end end scope 'module' . to_sym => 'faalis' do get 'auth/profile/edit' , to : "profile#edit" post 'auth/profile/edit' , to : "profile#update" end namespace :api , defaults : { format : :json } d... | This method allow user to define his routes in api namespace |
17,561 | def to_h @data . reduce ( { } ) do | h , ( k , v ) | h [ k ] = v . is_a? ( __class__ ) ? v . to_h : v h end end | A convenience accessor to get a hash representation of the current state of the configuration |
17,562 | def from_h ( h ) @key_ambiguity_validator . validate! ( h ) h . each do | property , value | p = property . to_sym if value . is_a? ( :: Hash ) && __nested? ( p ) @data [ p ] . from_h ( value ) elsif __configurable? ( p ) __assign! ( p , value ) end end self end | A convenience accessor to instantiate a configuration from a hash |
17,563 | def if_node ( node , indent ) node [ @value ] . each_with_index do | value , index | case value when node [ @value ] . first then buffer_eval "if #{value}" when node [ @value ] . last then buffer_eval "else" else buffer_eval "elsif #{value}" end node [ @children ] [ index ] . each do | child | root child , indent end e... | Generate the code for a if - elsif - else control structure |
17,564 | def unless_node ( node , indent ) node [ @value ] . each_with_index do | value , index | case value when node [ @value ] . first then buffer_eval "unless #{value}" else buffer_eval "else" end node [ @children ] [ index ] . each do | child | root child , indent end end buffer_eval "end" end | Generate the code for a unless - else control structure |
17,565 | def case_node ( node , indent ) buffer_eval "case #{node[@options][:condition]}" node [ @value ] . each_with_index do | value , index | case value when node [ @value ] . last then buffer_eval 'else' else buffer_eval "when #{value}" end node [ @children ] [ index ] . each do | child | root child , indent end end buffer_... | Generate the code for a case - when - else control structure |
17,566 | def comment ( text ) comment_node = :: Nokogiri :: XML :: Comment . new ( doc , " #{text} " ) current_element . add_child ( comment_node ) end | Generate a comment |
17,567 | def node ( parent , indent = nil ) return unless ( name = lookahead ( :node_lookahead ) || lookahead ( :shorthand_lookahead ) ) return nil if KEYWORDS . include? name [ 0 ] . to_sym if ( node_name = accept :node ) node_name = node_name . to_sym shorthand = shorthand_attributes elsif ( shorthand = shorthand_attributes )... | Check if we match an node node with its attributes and possibly inline text |
17,568 | def shorthand_attributes ( atts = { } ) while ( key = accept :shorthand ) key = Settings :: SHORTHAND [ key . to_sym ] escaped = accept ( :unescaped_value ) ? false : true if ( value = accept ( :shorthand_node ) ) value = [ :expression , value . inspect , { escaped : escaped } ] elsif ( value = accept ( :exp_string ) )... | Accept node shorthand attributes . Each shorthand attribute is directly mapped to an attribute key |
17,569 | def attributes ( atts = { } , for_definition = false ) wrapped_attributes atts , for_definition attributes_assignments atts , false , for_definition atts end | Get element attributes |
17,570 | def wrapped_attributes ( list = { } , for_definition = false ) return unless ( bracket = accept :brackets ) accept_newline attributes_assignments list , true , for_definition accept_newline accept_stripped bracket . to_sym , :* list end | Check if we match node attributes |
17,571 | def attributes_assignments ( list , wrapped = true , for_definition = false ) if wrapped && lookahead ( :exp_identifier_stripped_lookahead ) . nil? || ! wrapped && lookahead ( :assignment_lookahead ) . nil? return list end return unless ( argument = accept_stripped :node ) argument = argument . to_sym if accept_strippe... | Get all attribute assignments as key = value pairs or standalone keys |
17,572 | def extend_attributes return unless accept :extend_attributes unescaped = accept :unescaped_value extension = expression ( false , false , false ) extension [ @options ] [ :escaped ] = ! unescaped extension end | Extend node attributes with hash from |
17,573 | def root ( parent = @root , min_indent = - 1 ) while ( @line = @code [ ( @i += 1 ) ] ) @j = 0 next if @line =~ / \A \s \Z / @offset = 0 indent = accept ( :indent ) . size unless min_indent < indent @i -= 1 break end @file . pop if @file [ - 1 ] [ 1 ] >= indent current_node = node ( parent , indent ) || text ( parent , ... | Analyze the input code and check for matching tokens . In case no match was found throw an exception . In special cases modify the token hash . |
17,574 | def define ( node ) definition = "def _opulent_definition_#{node[@value].to_s.tr '-', '_'}" parameters = [ ] node [ @options ] [ :parameters ] . each do | key , value | parameters << "#{key} = #{value[@value]}" end parameters << 'attributes = {}' parameters << 'indent' parameters << '&block' definition += '(' + paramet... | Write out definition node using ruby def |
17,575 | def respond_to_missing? ( method , include_private = false ) __respond_to_writer? ( method ) || __respond_to_method_for_read? ( method , * args , & block ) || __respond_to_method_for_write? ( method ) || super end | Respond to missing according to the method_missing implementation |
17,576 | def apply_definitions ( node ) process_definitions = proc do | children | children . each do | child | is_definition = if child [ @value ] == @current_def child [ @options ] [ :recursive ] else @definitions . key? ( child [ @value ] ) end child [ @type ] = :def if is_definition apply_definitions child if child [ @child... | Set each node as a defined node if a definition exists with the given node name unless we re inside a definition with the same name as the node because we want to avoid recursion . |
17,577 | def accept ( token , required = false , strip = false ) accept :whitespace if strip return nil unless @line if ( match = @line [ @offset .. - 1 ] . match ( Tokens [ token ] ) ) @offset += match [ 0 ] . size @j += match [ 0 ] . size return match [ 0 ] elsif required Logger . error :parse , @code , @i , @j , :expected , ... | Check and accept or reject a given token as long as we have tokens remaining . Shift the code with the match length plus any extra character count around the capture group |
17,578 | def indent_lines ( text , indent ) text ||= '' text . lines . map { | line | indent + line } . join end | Indent all lines of the input text using give indentation |
17,579 | def perform! ( resource_name , action , options = { } ) ClientOperations :: Perform . new ( resource_name , action , session , options ) . perform! end | Executes block with the access token |
17,580 | def password_required? if Devise . omniauth_configs . any? return ( provider . nil? || password . nil? ) && super else password . nil? && super end end | Omniauth users does not need password |
17,581 | def download ( style = 'original' , path = nil ) options = { session : session } options [ :download_path ] = path unless path . nil? request = RedboothRuby . request ( :download , nil , "files/#{id}/download/#{style}/#{name}" , { } , options ) request . body end | Returns a blop with the file data |
17,582 | def render ( scope = Object . new , locals = { } , & block ) if scope . instance_variable_defined? ( :@_opulent_buffer ) initial_buffer = scope . instance_variable_get ( :@_opulent_buffer ) else initial_buffer = [ ] end if scope . is_a? binding . class scope_object = eval 'self' , scope scope = scope_object . instance_... | Update render settings |
17,583 | def read ( input ) if input . is_a? Symbol @file = File . expand_path get_eval_file input File . read @file else @file = File . expand_path __FILE__ input end end | Read input as file or string input |
17,584 | def get_eval_file ( input ) input = input . to_s unless File . extname ( input ) == Settings :: FILE_EXTENSION input += Settings :: FILE_EXTENSION end input end | Add . op extension to input file if it isn t already set . |
17,585 | def buffer_attributes_to_hash ( attributes ) '{' + attributes . inject ( [ ] ) do | extend_map , ( key , attribute ) | extend_map << ( ":\"#{key}\" => " + if key == :class '[' + attribute . map do | exp | exp [ @value ] end . join ( ', ' ) + ']' else attribute [ @value ] end ) end . join ( ', ' ) + '}' end | Turn call node attributes into a hash string |
17,586 | def buffer_attributes ( attributes , extension ) buffer_class_attribute_type_check = proc do | variable , escape = true | class_variable = buffer_set_variable :local , variable buffer_eval "unless #{class_variable} and true === #{class_variable}" buffer_eval "if Array === #{class_variable}" ruby_code = "#{class_variabl... | Go through the node attributes and apply extension where needed |
17,587 | def buffer_split_by_interpolation ( string , escape = true ) begin case string when / \A \\ \# \{ / buffer_freeze '#{' string = $' when / \A \{ \{ \g \} \} / string = $' code = $1 if escape buffer_escape code else buffer code end when / \A \\ \\ \\ \\ \{ \\ / string_remaining = $' string_current = $& if escape && strin... | Split a string by its interpolation then check if it really needs to be escaped or not . Huge performance boost! |
17,588 | def __evaluate_configurable! entries = @properties . entries_at ( @path ) entries . each do | property , value | if value . is_a? ( Maps :: Properties :: Entry ) __install_property__ ( property ) else __install_nested_getter__ ( property ) end end end | Evaluates configurable properties and passes eventual hashes down to subconfigurations |
17,589 | def __assign! ( property , value ) @types . test! ( @path . add ( property ) , value ) v = @blocks . evaluate! ( @path . add ( property ) , value ) value = v unless v . nil? super ( property , value ) end | Assigns a value after running the assertions |
17,590 | def element ( name , * args , & block ) metadata = @inspector . get_metadata ( current_subject , name ) attributes = args . extract_options! . merge ( metadata ) subject_of_element = if args . empty? @inspector . get_value ( current_subject , name ) else args . shift end raise ArgumentError , "too many arguments" unles... | Generate an element . |
17,591 | def list_of ( name , * args , & block ) options = args . extract_options! list_subject = args . empty? ? name : args . shift raise ArgumentError , "too many arguments" unless args . empty? list_attributes = options [ :list_attributes ] || { } item_name = options [ :item_name ] || name . to_s . singularize item_attribut... | Generate a list of elements from Enumerable data . |
17,592 | def expression ( allow_assignments = true , wrapped = true , whitespace = true ) buffer = '' while ( term = ( whitespace ? accept ( :whitespace ) : nil ) || modifier || identifier || method_call || paranthesis || array || hash || symbol || percent || primary_term ) buffer += term if wrapped && ( op = operation || ( all... | Check if the parser matches an expression node |
17,593 | def array_elements ( buffer = '' ) if ( term = expression ) buffer += term [ @value ] if ( terminator = accept_stripped :comma ) accept_newline buffer += array_elements terminator end end error :array_elements_terminator if buffer . strip [ - 1 ] == ',' buffer end | Recursively gather expressions separated by a comma and add them to the expression buffer |
17,594 | def method_call method_code = '' while ( method_start = accept ( :exp_method_call ) ) method_code += method_start argument = call method_code += argument if argument end method_code == '' ? nil : method_code end | Accept a ruby method call modifier |
17,595 | def call_elements ( buffer = '' ) if ( symbol = accept_stripped :hash_symbol ) buffer += symbol if ( exp = expression ( true ) ) buffer += exp [ @value ] else error :call_elements end if ( terminator = accept_stripped :comma ) buffer += call_elements terminator end elsif ( exp = expression ( true ) ) buffer += exp [ @v... | Recursively gather expression attributes separated by a comma and add them to the expression buffer |
17,596 | def symbol return unless ( colon = accept :colon ) return undo colon if lookahead ( :whitespace ) if ( exp = expression ) . nil? error :symbol else colon + exp [ @value ] end end | Accept a ruby symbol defined through a colon and a trailing expression |
17,597 | def ternary_operator ( allow_assignments , wrapped ) if ( buffer = accept :exp_ternary ) buffer += expression ( allow_assignments , wrapped ) [ @value ] if ( else_branch = accept :exp_ternary_else ) buffer += else_branch buffer += expression ( allow_assignments , wrapped ) [ @value ] end return buffer end end | Accept ternary operator syntax |
17,598 | def serialize_ajax_info layout_name = if Ajax . app . rails? ( 3 ) if @_rendered_layout . is_a? ( String ) @_rendered_layout =~ / \/ \/ / ? $1 : @_rendered_layout elsif @_rendered_layout @_rendered_layout . variable_name end else active_layout end Ajax . set_header ( response , :layout , layout_name ) Ajax . set_header... | Convert the Ajax - Info hash to JSON before the request is sent . Invoked as an after filter . |
17,599 | def _layout_for_ajax ( default ) ajax_layout = self . class . read_inheritable_attribute ( :ajax_layout ) ajax_layout = if ajax_layout . nil? && default . nil? nil elsif ajax_layout . nil? && ! default . nil? if default =~ / \/ \/ / default elsif ! ( default =~ / \/ / ) "ajax/#{default.sub(/layouts(\/)?/, '')}" else de... | Return the layout to use for an AJAX request or nil if the default should be used . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.