idx int64 0 24.9k | question stringlengths 68 4.14k | target stringlengths 9 749 |
|---|---|---|
19,600 | def value_map ( value ) v = case value . class when Array value . join ( ',' ) when Range "#{value.first}-#{value.last}" when Hash if value . has_key? ( :or ) "|#{value[:or].join(',')}" elsif value . has_key? ( :not ) "~#{value[:not].join(',')}" end when TrueClass "Y" when FalseClass "N" else value end v end | Take values like true and false convert them to Y or N . make collections into joint strings . |
19,601 | def label ( rec , attr , enum = nil ) if ! enum enum = rec . class . const_get ( attr . to_s . camelize ) raise ( NameError , "wrong constant name #{attr}" ) if ! enum end if ! @enum_map [ enum ] @enum_map [ enum ] = { } end value = rec . attributes [ attr . to_s ] if label = @enum_map [ enum ] [ value ] @hit += 1 labe... | return label of rec . attr where attr is enum value . |
19,602 | def rights_equal ( rights_attr ) f_rights = Array . wrap ( fedora . fetch ( 'rights' , { } ) . fetch ( rights_attr , [ ] ) ) . sort b_rights = Array . wrap ( bendo . fetch ( 'rights' , { } ) . fetch ( rights_attr , [ ] ) ) . sort return 0 if f_rights == b_rights 1 end | compare array or element for equivalence |
19,603 | def compare_everything_else error_count = 0 exclude_keys = [ 'rights' , 'rels-ext' , 'metadata' , 'thumbnail-file' ] all_keys_to_check = ( bendo . keys + fedora . keys - exclude_keys ) . uniq all_keys_to_check . each do | key | bendo_value = bendo . fetch ( key , nil ) fedora_value = fedora . fetch ( key , nil ) next i... | compare what remains |
19,604 | def normalize_value ( values ) Array . wrap ( values ) . map do | value | value . is_a? ( String ) ? value . gsub ( "\n" , "" ) : value end end | Because sometimes we have carriage returns and line breaks but we really don t care |
19,605 | def conditions return [ '1=0' ] if ! valid? if @val . blank? [ ] else op = '=?' val = @val if val =~ / \* / op = ' like ?' val = @val . gsub ( / \* / , '%' ) end [ "#{@col}#{op}" , val ] end end | implement to generate search - conditions |
19,606 | def start puts "== Connected to #{redis.client.id}" puts "== Waiting for commands from `#{options[:queue]}`" if options [ :daemon ] puts "== Daemonizing..." Daemons . daemonize end loop do begin cid = redis . blpop ( options [ :queue ] , 10 ) [ 1 ] if cmd = commands [ cid . to_s ] puts "\e[33m[#{Time.now}]\e[0m Reactin... | It starts the consumer loop . |
19,607 | def set_conf ( conf ) begin conf = load_conf ( conf ) @svn_user = conf [ 'svn_user' ] @svn_pass = conf [ 'svn_pass' ] @force_checkout = conf [ 'force_checkout' ] @svn_repo_master = conf [ 'svn_repo_master' ] @svn_repo_working_copy = conf [ 'svn_repo_working_copy' ] @svn_repo_config_path = conf [ 'svn_repo_config_path' ... | set config file with abs path |
19,608 | def add ( files = [ ] , recurse = true , force = false , no_ignore = false ) raise ArgumentError , 'files is empty' unless files svn_session ( ) do | svn | begin files . each do | ef | svn . add ( ef , recurse , force , no_ignore ) end rescue Exception => excp raise RepoAccessError , "Add Failed: #{excp.message}" end e... | add entities to the repo |
19,609 | def delete ( files = [ ] , recurs = false ) svn_session ( ) do | svn | begin svn . delete ( files ) rescue Exception => err raise RepoAccessError , "Delete Failed: #{err.message}" end end end | delete entities from the repository |
19,610 | def commit ( files = [ ] , msg = '' ) if files and files . empty? or files . nil? then files = self . svn_repo_working_copy end rev = '' svn_session ( msg ) do | svn | begin rev = svn . commit ( files ) . revision rescue Exception => err raise RepoAccessError , "Commit Failed: #{err.message}" end end rev end | commit entities to the repository |
19,611 | def _pre_update_entries @pre_up_entries = Array . new @modified_entries = Array . new list_entries . each do | ent | e_name = ent [ :entry_name ] stat = ent [ :status ] if @limit_to_dir_path fle = File . join ( self . svn_repo_working_copy , e_name ) next unless fle . include? @limit_to_dir_path end @pre_up_entries . p... | get list of entries before doing an update |
19,612 | def _post_update_entries post_up_entries = Array . new list_entries . each { | ent | if @limit_to_dir_path fle = File . join ( self . svn_repo_working_copy , ent [ :entry_name ] ) next unless fle . include? @limit_to_dir_path end post_up_entries . push ent [ :entry_name ] } added = post_up_entries - @pre_up_entries rem... | get list of entries after doing an update |
19,613 | def revert ( file_path = '' ) if file_path . empty? then file_path = self . svn_repo_working_copy end svn_session ( ) { | svn | svn . revert ( file_path ) } end | discard working copy changes get current repository entry |
19,614 | def render extensions . reverse . inject ( content ) do | output , ext | if template_type = Tilt [ ext ] template_options = Massimo . config . options_for ( ext [ 1 .. - 1 ] ) template = template_type . new ( source_path . to_s , @line , template_options ) { output } template . render ( template_scope , template_locals... | Runs the content through any necessary filters templates etc . |
19,615 | def process FileUtils . mkdir_p ( output_path . dirname ) output_path . open ( 'w' ) do | f | f . write render end end | Writes the rendered content to the output file . |
19,616 | def convert ( destination , options = { } , & block ) options . symbolize_keys! process ( destination , @source . convert_command , options , & block ) end | Generate new video file |
19,617 | def customer_outstanding_invoices ( code = nil ) now = Time . now customer_invoices ( code ) . reject do | i | i [ :paidTransactionId ] || i [ :billingDatetime ] > now end end | Returns an array of any currently outstanding invoices for the given customer . |
19,618 | def customer_item ( item_code = nil , code = nil ) sub_item = retrieve_item ( customer_subscription ( code ) , :items , item_code ) plan_item = retrieve_item ( customer_plan ( code ) , :items , item_code ) return nil unless sub_item && plan_item item = plan_item . dup item [ :quantity ] = sub_item [ :quantity ] item en... | Info about the given item for the given customer . Merges the plan item info with the subscription item info . |
19,619 | def customer_item_quantity_remaining ( item_code = nil , code = nil ) item = customer_item ( item_code , code ) item ? item [ :quantityIncluded ] - item [ :quantity ] : 0 end | The amount remaining for a given item for a given customer . |
19,620 | def customer_item_quantity_overage ( item_code = nil , code = nil ) over = - customer_item_quantity_remaining ( item_code , code ) over = 0 if over <= 0 over end | The overage amount for the given item for the given customer . 0 if they are still under their limit . |
19,621 | def customer_item_quantity_overage_cost ( item_code = nil , code = nil ) item = customer_item ( item_code , code ) return 0 unless item overage = customer_item_quantity_overage ( item_code , code ) item [ :overageAmount ] * overage end | The current overage cost for the given item for the given customer . |
19,622 | def customer_active? ( code = nil ) subscription = customer_subscription ( code ) if subscription [ :canceledDatetime ] && subscription [ :canceledDatetime ] <= Time . now false else true end end | Get an array representation of a single customer s current subscription |
19,623 | def customer_waiting_for_paypal? ( code = nil ) subscription = customer_subscription ( code ) if subscription [ :canceledDatetime ] && subscription [ :canceledDatetime ] <= Time . now && subscription [ :cancelType ] == 'paypal-wait' true else false end end | Is this customer s account pending paypal preapproval confirmation? |
19,624 | def process_controllers process_services modules = Jinda :: Module . all modules . each do | m | next if controller_exists? ( m . code ) puts " Rails generate controller #{m.code}" end end | Mock generate controller for test Otherwise test will call rails g controller |
19,625 | def edgarj_rescue_sub ( ex , message ) logger . info ( "#{ex.class} #{ex.message} bactrace:\n " + ex . backtrace . join ( "\n " ) ) respond_to do | format | format . html { flash [ :error ] = message redirect_to top_path } format . js { flash . now [ :error ] = message render 'message_popup' } end end | rescue callback sub method to show message by flush on normal http request or by popup - dialog on Ajax request . |
19,626 | def find! ( client , options = { } ) @client = client raise ArgumentError , 'No :id given' unless options [ :id ] path = api_url ( options ) + "/#{options[:id]}" response = client . make_request! ( path , :get ) new ( @client ) . tap do | resource | resource . attributes . merge! ( options ) resource . handle_response ... | Finds a resource by an id and any options passed in |
19,627 | def find ( client , options = { } , & block ) find! ( client , options , & block ) rescue FreshdeskAPI :: Error :: ClientError nil end | Finds returning nil if it fails |
19,628 | def deobfuscate ( original , rescue_with_original_id = true ) if original . kind_of? ( Array ) return original . map { | value | deobfuscate ( value , true ) } elsif ! ( original . kind_of? ( Integer ) || original . kind_of? ( String ) ) return original end obfuscated_id = original . to_s . delete ( '^0-9' ) . first ( ... | If rescue_with_original_id is set to true the original ID will be returned when its Obfuscated Id is not found |
19,629 | def callback @stripe_user = current_user code = params [ :code ] @response = @client . auth_code . get_token ( code , { :headers => { 'Authorization' => "Bearer(::Configuration['stripe_secret_key'])" } } ) @stripe_user . stripe_access_token = @response . token @stripe_user . stripe_key = @response . params [ 'stripe_pu... | Brings back the authcode from Stripe and makes another call to Stripe to convert to a authtoken |
19,630 | def adjust! ( attributes = { } , reload = false ) return true if attributes . empty? reload_conditions = if reload model_key = model . key ( repository . name ) Query . target_conditions ( self , model_key , model_key ) end adjust_attributes = adjust_attributes ( attributes ) repository . adjust ( adjust_attributes , s... | increment or decrement attributes on a collection |
19,631 | def add_parameters ( pValue ) unless ( ( pValue . respond_to? ( :has_key? ) && pValue . length == 1 ) || pValue . respond_to? ( :to_str ) ) return nil end @parameters . push ( pValue ) end | Add parameters inside function . |
19,632 | def add_conditional ( pConditional , pBehaviour = Languages :: KEEP_LEVEL ) return nil unless ( pConditional . instance_of? Languages :: ConditionalData ) add_with_manager ( pConditional , 'conditional' , pBehaviour ) end | Add conditional element inside function . |
19,633 | def add_repetition ( pRepetition , pBehaviour = Languages :: KEEP_LEVEL ) return nil unless ( pRepetition . instance_of? Languages :: RepetitionData ) add_with_manager ( pRepetition , 'repetition' , pBehaviour ) end | Add repetition element inside function . |
19,634 | def add_block ( pBlock , pBehaviour = Languages :: KEEP_LEVEL ) return nil unless ( pBlock . instance_of? Languages :: BlockData ) add_with_manager ( pBlock , 'block' , pBehaviour ) end | Add block element inside function . |
19,635 | def << ( fromTo ) return nil unless fromTo . is_a? ( Languages :: FunctionAbstract ) @name = fromTo . name @parameters = fromTo . parameters @managerCondLoopAndBlock = fromTo . managerCondLoopAndBlock @visibility = fromTo . visibility @comments = fromTo . comments @type = @type end | Copy elements from an object of FunctionAbstract to specific element |
19,636 | def add_with_manager ( pElementToAdd , pMetaData , pBehaviour ) case pBehaviour when Languages :: KEEP_LEVEL @managerCondLoopAndBlock . send ( "add_#{pMetaData}" , pElementToAdd ) when Languages :: UP_LEVEL @managerCondLoopAndBlock . decrease_deep_level @managerCondLoopAndBlock . send ( "add_#{pMetaData}" , pElementToA... | Add to a manager conditional or repetition . |
19,637 | def http_request ( url ) url = URIParser . new ( url ) . with_scheme CLI . put_header ( url ) CLI . log "Beginning HTTP request for #{url}" response = HTTParty . get ( url , headers : { "User-Agent" => "news-scraper-#{NewsScraper::VERSION}" } ) raise ResponseError . new ( error_code : response . code , message : respon... | Perform an HTTP request with a standardized response |
19,638 | def detect ( sentences ) results = post ( '/detect' , body : build_sentences ( sentences ) . to_json ) results . map { | r | Types :: DetectionResult . new ( r ) } end | Identifies the language of a piece of text . |
19,639 | def determine_markdown_renderer @markdown = if installed? ( 'github/markdown' ) GitHubWrapper . new ( @content ) elsif installed? ( 'redcarpet/compat' ) Markdown . new ( @content , :fenced_code , :safelink , :autolink ) elsif installed? ( 'redcarpet' ) RedcarpetCompat . new ( @content ) elsif installed? ( 'rdiscount' )... | Create a new compatibility instance . |
19,640 | def to_markdown lines = @bare_content . split ( "\n" ) markdown = "" while current_line = lines . shift if current_line =~ BIRD_TRACKS_REGEX current_line = remove_bird_tracks ( current_line ) current_line << slurp_remaining_bird_tracks ( lines ) markdown << "```haskell\n#{current_line}\n```\n" else markdown << current_... | Initialize a new literate Haskell renderer . |
19,641 | def remove_bird_tracks ( line ) tracks = line . scan ( BIRD_TRACKS_REGEX ) [ 0 ] ( tracks . first == " " ) ? tracks [ 1 ] : tracks . join end | Remove Bird - style comment markers from a line of text . |
19,642 | def slurp_remaining_bird_tracks ( lines ) tracked_lines = [ ] while lines . first =~ BIRD_TRACKS_REGEX tracked_lines << remove_bird_tracks ( lines . shift ) end if tracked_lines . empty? "" else "\n" + tracked_lines . join ( "\n" ) end end | Given an Array of lines pulls from the front of the Array until the next line doesn t match our bird tracks regex . |
19,643 | def sample total , @usages = nil , { } timestamp = Time . now File . foreach ( '/proc/stat' ) do | line | case line when / \d / next when CPU times = $~ . captures processor_id = times [ 0 ] = times [ 0 ] . to_i ( 1 ... times . size ) . each { | i | times [ i ] = times [ i ] . to_f / USER_HZ } times << timestamp << tim... | Take one sample of CPU usage data for every processor in this computer and store them in the + usages + attribute . |
19,644 | def include_year_in_dates? if @time . year != Date . today . year return true end if @time . year == Date . today . year && @time . month < ( Date . today . month - 4 ) return true end end | Should years be included in dates? |
19,645 | def parse_response ( response ) unless response . body raise ResponseError , 'PaynetEasy response is empty' end response_fields = Hash [ CGI . parse ( response . body ) . map { | key , value | [ key , value . first ] } ] Response . new response_fields end | Parse PaynetEasy response from string to Response object |
19,646 | def run! raise_error_if_development_or_master story = @configuration . story fail ( "Could not find story associated with branch" ) unless story story . can_merge? commit_message = options [ :commit_message ] if story . release? story . merge_release! ( commit_message , @options ) else story . merge_to_roots! ( commit_... | Finishes a Pivotal Tracker story |
19,647 | def reload response = @client . get ( "/SMS/#{self.message_id}" ) self . set_parameters ( Elk :: Util . parse_json ( response . body ) ) response . code == 200 end | Reloads a SMS from server |
19,648 | def find_for_provider ( token , provider ) return nil unless token [ 'uid' ] props = { :uid => token [ 'uid' ] . downcase , provider : provider . downcase } user = where ( props ) . first unless user user = create! ( whitelist ( props ) ) end user end | token is an omniauth hash |
19,649 | def to_fastq opts = { } if fastq? "@#{@header}\n#{@seq}\n+#{@desc}\n#{qual}" else qual = opts . fetch :qual , "I" check_qual qual desc = opts . fetch :desc , "" qual_str = make_qual_str qual "@#{@header}\n#{@seq}\n+#{desc}\n#{qual_str}" end end | Returns a fastA record ready to print . |
19,650 | def module_info mod , types = parse , Set . new mod . classes . each { | c | types . add? ( c . type ) } return { name : mod . name , code : mod . module_id , types : types } end | Create a new ModuleParser with an optional module code |
19,651 | def create upsert do @record = model . new ( permitted_params ( :create ) ) @record_saved = @record on_upsert raise ActiveRecord :: RecordNotSaved if ! @record . valid? @record . save @record = model . new end end | save new record |
19,652 | def show @record = user_scoped . find ( params [ :id ] ) respond_to do | format | format . html { prepare_list @search = page_info . record render :action => 'index' } format . js end end | Show detail of one record . Format of html & js should be supported . |
19,653 | def update upsert do @record = model . find ( user_scoped . find ( params [ :id ] ) . id ) if ! @record . update_attributes ( permitted_params ( :update ) ) raise ActiveRecord :: RecordInvalid . new ( @record ) end end end | save existence modified record |
19,654 | def search_save SavedVcontext . save ( current_user , nil , params [ :saved_page_info_name ] , page_info ) render :update do | page | page << "Edgarj.SearchSavePopup.close();" page . replace 'edgarj_load_condition_menu' , :partial => 'edgarj/load_condition_menu' end rescue ActiveRecord :: ActiveRecordError app_rescue r... | Ajax method to save search conditions |
19,655 | def csv_download filename = sprintf ( "%s-%s.csv" , model_name , Time . now . strftime ( "%Y%m%d-%H%M%S" ) ) file = Tempfile . new ( filename , Settings . edgarj . csv_dir ) csv_visitor = EdgarjHelper :: CsvVisitor . new ( view_context ) file . write CSV . generate_line ( model . columns . map { | c | c . name } ) for ... | zip - > address completion |
19,656 | def drawer_class @_drawer_cache ||= if self . class == Edgarj :: EdgarjController Edgarj :: Drawer :: Normal else ( self . class . name . gsub ( / / , '' ) . singularize + 'Drawer' ) . constantize end end | derive drawer class from this controller . |
19,657 | def column_type ( col_name ) cache = Cache . instance cache . klass_hash [ @_klass_str ] ||= { } if v = cache . klass_hash [ @_klass_str ] [ col_name . to_s ] cache . hit += 1 v else cache . miss += 1 col = @_klass_str . constantize . columns . find { | c | c . name == col_name . to_s } if col cache . klass_hash [ @_kl... | cache column type |
19,658 | def create ( attributes = { } ) attributes = attributes . symbolize_keys if attributes . respond_to? ( :symbolize_keys ) object = self . new ( attributes ) if object . present? && object . valid? if persistence_class == self object . id = nil unless exists? ( object . id ) object . save else object = PersistenceAdapter... | Creates an object and persists it . |
19,659 | def to_html time_header , rows = '<th></th>' , Array . new end_time = Time . new ( 2013 , 1 , 1 , 21 , 0 , 0 ) @time = Time . new ( 2013 , 1 , 1 , 9 , 0 , 0 ) while @time < end_time time_header += "<th>#{@time.strftime("%-k:%M")}</th>" @time += 900 end ( 0 .. 4 ) . each do | day | classes = @timetable . classes_for_day... | HTML5 representation of the timetable |
19,660 | def read_configuration_file ( pPath = '.kuniri.yml' ) if ! ( File . exist? ( pPath ) ) set_default_configuration else safeInfo = SafeYAML . load ( File . read ( pPath ) ) @configurationInfo = safeInfo . map do | key , value | [ key . tr ( ':' , '' ) . to_sym , value ] end . to_h verify_syntax end return @configurationI... | In this method it is checked the configuration file syntax . |
19,661 | def page page if page_exists? ( page ) return BasicPage . new ( self , normalize_page ( page ) ) else if null_page return null_page_instance else return nil end end end | create page instance by page number . if page number you specified was not existed nil would be returned . note page start at 1 not zero . |
19,662 | def scrape article_urls = Extractors :: GoogleNewsRss . new ( query : @query ) . extract transformed_articles = [ ] article_urls . each do | article_url | payload = Extractors :: Article . new ( url : article_url ) . extract article_transformer = Transformers :: Article . new ( url : article_url , payload : payload ) b... | Initialize a Scraper object |
19,663 | def train ( query : '' ) article_urls = Extractors :: GoogleNewsRss . new ( query : query ) . extract article_urls . each do | url | Trainer :: UrlTrainer . new ( url ) . train end end | Fetches articles from Extraction sources and trains on the results |
19,664 | def key ( name , * args ) options = args . extract_options! name = name . to_s json_type = args . first || String raise ArgumentError . new ( "too many arguments (must be 1 or 2 plus an options hash)" ) if args . length > 1 field = FieldDefinition . new ( name , :type => json_type , :default => options [ :default ] ) f... | Create a schema on the class for a particular field . Define a single valued field in the schema . The first argument is the field name . This must be unique for the class accross all attributes . |
19,665 | def many ( name , * args ) name = name . to_s options = args . extract_options! type = args . first || name . singularize . classify . constantize field = FieldDefinition . new ( name , :type => type , :multivalued => true ) fields [ name ] = field add_json_validations ( field , options ) define_many_json_accessor ( fi... | Define a multi valued field in the schema . The first argument is the field name . This must be unique for the class accross all attributes . |
19,666 | def classes_for_day ( day ) days_classes = ClassArray . new self . each { | c | days_classes << c if c . day == day } days_classes . count > 0 ? days_classes : nil end | Returns an array of all the classes for the day |
19,667 | def earliest_class earliest = self . first self . each { | c | earliest = c if c . time < earliest . time } earliest end | Returns the earliest class in the module |
19,668 | def save opts = { } opts [ 'priority' ] = priority if priority opts [ 'date_string' ] = date if date unless ( task_details . has_key? ( 'id' ) ) result = self . class . create ( self . content , self . project_id , opts ) else result = self . class . update ( self . content , self . id , opts ) end self . content = res... | Saves the task |
19,669 | def replace ( * attributes ) attributes = safe_array ( attributes ) user_modification_guard seen = { } filtered = [ ] attributes . each do | value | matchable = matchable ( value ) unless seen [ matchable ] filtered << value seen [ matchable ] = true end end @target . replace ( filtered ) self end | Does a complete replacement of the attributes . Multiple attributes can be given as either multiple arguments or as an array . |
19,670 | def method_missing ( method_name , * args ) if method_name . to_s =~ / / @attrs [ $1 . to_sym ] = args [ 0 ] else val = @attrs [ method_name . to_sym ] case column_type ( method_name ) when :integer if val =~ / \d / val . to_i else val end else val end end end | Build SearchForm object from ActiveRecord klass and attrs . |
19,671 | def parse ( string ) return nil unless string . is_a? ( String ) uri = Addressable :: URI . parse ( string ) scheme = uri . scheme return nil unless scheme self . secure = true if scheme . match ( / \Z /m ) host = uri . host host = '/' unless host && host != '' self . host = host self . port = uri . port . to_s if uri ... | Parse a WebSocket URL . |
19,672 | def to_s string = '' string += 'ws' string += 's' if self . secure string += '://' string += self . host string += ':' + self . port . to_s if self . port string += self . resource_name || '/' return string end | Construct a WebSocket URL . |
19,673 | def logger ( name , options = { } , & block ) use_adapter = options . key? ( :adapter ) ? get_adapter ( options . delete ( :adapter ) ) : self . adapter use_adapter . logger ( name , options ) . tap do | logger | yield ( logger ) if block_given? end end | Get a new logger instance for supplied named logger or class name . |
19,674 | def get_adapter ( adp ) adp = Loggr :: Adapter :: NOP if ! adp adp = adp . to_s . gsub ( / \/ / ) { "::#{$1.upcase}" } . gsub ( / / ) { $1 . upcase } if adp . is_a? ( Symbol ) clazz = adp if adp . respond_to? ( :to_str ) const = begin Loggr :: Adapter . const_get ( adp . to_s ) rescue begin Loggr :: Adapter . const_get... | Try to get adapter class from Symbol String or use Object as - is . |
19,675 | def name_parse_special_characters ( val ) use_this = val . dup while [ "!" , "/" , "*" ] . include? ( use_this . to_s [ - 1 , 1 ] ) do if use_this . to_s [ - 1 , 1 ] == '!' @escape_xml = false use_this . chop! end if use_this . to_s [ - 1 , 1 ] == '/' @self_closing = true use_this . chop! end if use_this . to_s [ - 1 ,... | name = Converts name into proper XML node name |
19,676 | def value = ( val ) case val when :: String then @value = val . to_s when :: Hash then @value = val when :: Array then @value = val when :: OpenStruct then @value = val when :: DateTime then @value = val . strftime XS_DATETIME_FORMAT when :: Time then @value = val . strftime XS_DATETIME_FORMAT when :: Date then @value ... | name_parse_special_characters Custom Setter for |
19,677 | def handle_semicolon ( pLine ) commentLine = [ ] if pLine =~ / / @flagMultipleLineComment = true elsif pLine =~ / / @flagMultipleLineComment = false end unless @flagMultipleLineComment == true || pLine =~ / / return pLine . split ( / / ) end commentLine << pLine end | Puts every statement in a single line |
19,678 | def find ( source = @source ) scope = 0 filter = "(objectClass=*)" if source . respond_to? ( :search2_ext ) source . search2 ( to_s , scope , filter ) elsif source . respond_to? ( :search ) Array ( source . search ( :base => to_s , :scope => scope , :filter => filter , :limit => 1 ) ) else raise RuntimeError , "missing... | If a source object was given it is used to search for the DN . Otherwise an exception is raised . |
19,679 | def domain components = rdns . map { | rdn | rdn [ :dc ] } . compact components . join ( '.' ) unless components . empty? end | Join all DC elements with periods . |
19,680 | def generate_local_jnlp ( options = { } ) @local_jnlp = Nokogiri :: XML ( @jnlp . to_s ) jnlp_elem = ( @local_jnlp / "jnlp" ) . first jnlp_elem [ :codebase ] = "file:#{@local_cache_dir}" jnlp_elem [ :href ] = @local_jnlp_href @jars . each do | jar | j = @local_jnlp . at ( "//jar[@href=#{jar.href}]" ) j . remove_attribu... | Copies the original Hpricot jnlp into |
19,681 | def resource_paths ( options = { } ) if options [ :include_pack_gs ] cp_jars = @jars . empty? ? [ ] : @jars . collect { | j | j . local_path_pack_gz } cp_nativelibs = @nativelibs . empty? ? [ ] : @nativelibs . collect { | n | n . local_path_pack_gz } resources = cp_jars + cp_nativelibs else cp_jars = @jars . empty? ? [... | Returns an array containing all the local paths for this jnlp s resources . |
19,682 | def write_local_classpath_shell_script ( filename = "#{@name[/[A-Za-z0-9_-]*/]}_classpath.sh" , options = { } ) script = "export CLASSPATH=$CLASSPATH#{local_classpath(options)}" File . open ( filename , 'w' ) { | f | f . write script } end | Writes a shell script to the local filesystem that will export a modified CLASSPATH environmental variable with the paths to the resources used by this jnlp . |
19,683 | def write_jnlp ( options = { } ) dir = options [ :dir ] || '.' path = options [ :path ] || @path . gsub ( / \/ / , '' ) Dir . chdir ( dir ) do FileUtils . mkdir_p ( File . dirname ( path ) ) File . open ( path , 'w' ) { | f | f . write to_jnlp ( options [ :jnlp ] ) } if options [ :snapshot ] snapshot_path = "#{File.dir... | Writes a local copy of the original jnlp . |
19,684 | def write_local_jnlp ( filename = @local_jnlp_name ) destination = File . expand_path ( filename ) unless @local_jnlp_href == destination @local_jnlp_href = destination @local_jnlp_name = File . basename ( destination ) self . generate_local_jnlp end File . open ( filename , 'w' ) { | f | f . write to_local_jnlp } end | Writes a local file - based jnlp . |
19,685 | def require_resources if RUBY_PLATFORM =~ / / resource_paths ( :remove_jruby => true ) . each { | res | require res } true else false end end | This will add all the jars for this jnlp to the effective classpath for this Java process . |
19,686 | def unobtrusive_date_text_picker_tag ( name , date = Date . current , options = { } , html_options = { } ) date ||= Date . current options = merge_defaults_for_text_picker ( options ) DateTimePickerSelector . new ( date , options , html_options ) . text_date_picker ( name ) end | Creates the text field based date picker with the calendar widget without a model object . |
19,687 | def update_cache ( source = @url , destination = @local_path , options = { } ) unless destination raise ArgumentError , "Must specify destination directory when updatng resource" , caller end file_exists = File . exists? ( destination ) if file_exists && @signature_verified == nil verify_signature end unless file_exist... | Copies the file referenced in _source_ to _destination_ _source_ can be a url or local file path _destination_ must be a local path |
19,688 | def verify_signature if @local_path if RUBY_PLATFORM =~ / / begin jarfile = java . util . jar . JarInputStream . new ( FileInputStream . new ( @local_path ) , true ) @signature_verified = true rescue NativeException @signature_verified = false end else response = IO . popen ( "jarsigner -verify #{@local_path}" ) { | io... | Verifies signature of locallly cached resource |
19,689 | def draw_belongs_to_clear_link ( f , col_name , popup_field , parent_name , default_label ) if Settings . edgarj . belongs_to . disable_clear_link f . hidden_field ( col_name ) else ( ' ' + link_to ( "[#{I18n.t('edgarj.default.clear')}]" , '#' , onClick : "Edgarj.Popup.clear('#{j(popup_field.id_target)}','#{... | draw clear link for belongs_to popup data - entry field |
19,690 | def draw_belongs_to_field ( f , popup_path , col_name , model = f . object . class ) col = model . columns . detect { | c | c . name == col_name . to_s } return "no column found" if ! col parent_model = model . belongs_to_AR ( col ) return "parent_model is nil" if ! parent_model parent_obj = f . object . belongs_to_AR ... | draw belongs_to popup data - entry field |
19,691 | def flag_on? ( column_value , bitset , flag ) val = column_value || 0 ( val & bitset . const_get ( flag ) ) != 0 end | Is flag in column_value on? |
19,692 | def get_bitset ( model , col ) bitset_name = col . name . camelize + 'Bitset' if model . const_defined? ( bitset_name , false ) _module = model . const_get ( bitset_name ) _module . is_a? ( Module ) ? _module : nil else nil end end | get bitset Module . |
19,693 | def draw_column_bitset ( rec , col_or_sym , bitset ) turn_on_flags = [ ] value = rec . send ( get_column_name ( col_or_sym ) ) for flag in bitset . constants do turn_on_flags << flag if flag_on? ( value , bitset , flag ) end turn_on_flags . map { | f | rec . class . human_const_name ( bitset , f ) } . join ( ' ' ) end | draw bitset column in list . |
19,694 | def draw_column_enum ( rec , col_or_sym , enum ) Edgarj :: EnumCache . instance . label ( rec , get_column_name ( col_or_sym ) , enum ) end | draw enum column in list . |
19,695 | def adrs_str_sub ( model , prefix , element ) e = model . send ( prefix + element ) e . blank? ? '' : e end | return address element string or |
19,696 | def adrs_str ( model , adrs_prefix ) result = '' for adrs_element in [ 'prefecture' , 'city' , 'other' , 'bldg' ] do result << adrs_str_sub ( model , adrs_prefix , adrs_element ) end result end | model & adrs_prefix - > address string |
19,697 | def permitted? ( requested_flags = 0 ) current_user_roles . any? { | ug | ug . admin? } || current_model_permissions . any? { | cp | cp . permitted? ( requested_flags ) } end | return true if login user has enough permission on current controller . |
19,698 | def has_serialized ( name , & block ) serialize name , Hash initializer = Serializer :: Initializer . new block . call ( initializer ) initializer . each do | method , options | define_method "#{method}" do hash = send ( name ) result = hash [ method . to_sym ] if hash if hash . nil? or result . nil? send ( "#{name}=" ... | Add serializer to a class . |
19,699 | def parse_table ( table_rows ) classes = Tableau :: ClassArray . new @day = 0 table_rows . delete ( table_rows . first ) table_rows . each do | row | @time = Time . new ( 2013 , 1 , 1 , 9 , 0 , 0 ) row_items = row . xpath ( 'td' ) row_items . delete ( row_items . first ) row_items . each do | cell | if cell . attribute... | Parse the module table for any classes |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.