based on http://as.rubyonrails.org/classes/File.html
355811
def atomic_write(file_name)
      temp_dir = File.join(Geminabox.data, "_temp")
      FileUtils.mkdir_p(temp_dir)
      temp_file = Tempfile.new("." + File.basename(file_name), temp_dir)
      temp_file.binmode
      yield temp_file
      temp_file.close
      File.rename(temp_file.path, file_name)
      File.chmod(Geminabox.gem_permissions, file_name)
    end
831792
def file_handler
      @_element_file_handler = ElementFileHandler.new(keytechkit.base_url, keytechkit.username, keytechkit.password) if @_element_file_handler.nil?
      @_element_file_handler
    end
814292
def mount_rails_info
      match '/rails/info' => 'rails_info/properties#index', via: :get, via: :get, as: 'rails_info'
  
      match '/rails/info/properties' => 'rails_info/properties#index', via: :get, via: :get, as: 'rails_info_properties'
      match '/rails/info/routes' => 'rails_info/routes#index', via: :get, as: 'rails_info_routes'
      
      match '/rails/info/model' => 'rails_info/model#index', via: :get, as: 'rails_info_model'
      
      match '/rails/info/data' => 'rails_info/data#index', via: :get, as: 'rails_info_data', via: :get, as: 'rails_info_data'
      post '/rails/info/data/update_multiple' => 'rails_info/data#update_multiple', via: :post, as: 'rails_update_multiple_rails_info_data'
      
      match '/rails/info/logs/server' => 'rails_info/logs/server#new', via: :get, as: 'new_rails_info_server_log'
      put '/rails/info/logs/server' => 'rails_info/logs/server#update', via: :put, as: 'rails_info_server_log'
      
      get '/rails/info/logs/server/big' => 'rails_info/logs/server#big'
      
      match '/rails/info/logs/test/rspec' => 'rails_info/logs/test/rspec#new', via: :get, as: 'new_rails_info_rspec_log'
      put '/rails/info/logs/test/rspec' => 'rails_info/logs/test/rspec#update', via: :put, as: 'rails_info_rspec_log'
      
      match '/rails/info/stack_traces/new' => 'rails_info/stack_traces#new', via: :get, as: 'new_rails_info_stack_trace'
      post '/rails/info/stack_traces' => 'rails_info/stack_traces#create', via: :post, as: 'rails_info_stack_trace'
      
      namespace 'rails_info', path: 'rails/info' do
        namespace 'system' do
          resources :directories, only: :index
        end
        
        namespace 'version_control' do
          resources :filters, only: [:new, :create]
          
          resources :diffs, only: :new
        end
      end
    end
989109
def as_href(from_path)
      if @options.all_one_file
        "#" + path
      else
        RDoc::Markup::ToHtml.gen_relative_url from_path, path
      end
    end
1217440
def pages(*args)
      return if args.nil? or args.empty?

      test_file_dir = class_eval{  self::TestFileDir }
      default_page_dir = File.join(test_file_dir, "pages")
      #puts "debug: default_page_dir :#{default_page_dir}}"
      page_dir = default_page_dir

      page_files = []
      args.each do |x|
        if x.class == Hash && x[:page_dir]
          page_dir = x[:page_dir]
        else
          page_files << x
        end
      end

      if page_files.size == 1 && page_files[0] == :all
        Dir[File.expand_path(page_dir)+ "/*_page.rb"].each { |page_file|
          load page_file
        }
        return
      end

      page_files.each do |page|
        page_file = File.join(page_dir, page.to_s)
        load page_file
      end
    end
1032410
def executeRubyComponents
      fileDir = File.dirname(@fileName)
      #puts "Executing ruby components in directory #{fileDir} ..."
      Dir.chdir(fileDir) do
        for rubyComponent in @rubyComponents
          rubyCode = rubyComponent.text
          #puts ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
          #puts "Executing ruby (line #{rubyComponent.lineNumber}) #{rubyCode.inspect} ..."
          @pageObject.instance_eval(rubyCode, @fileName, rubyComponent.lineNumber)
          #puts "Finished executing ruby at line #{rubyComponent.lineNumber}"
        end
      end
      #puts "Finished executing ruby components."
    end
808985
def rake(file = nil, options = {})
      if file.nil?
        perform_set_operation :rake, options
      else
        file = File.expand_path(file)
        chdir(File.dirname(file)) do
          perform_set_operation(:rake, options.merge(:rakefile => file))
        end
      end
    end
1091247
def generate
      template = File.read(template_path)
      cloudfile = ERB.new(template, nil, "%<>-")
      cloudfile.result(binding)
    end
1213689
def load_enviroment(file = nil)
        file ||= "."

        if File.directory?(file) && File.exists?(File.expand_path("#{file}/config/environment.rb"))
          require 'rails'
          require File.expand_path("#{file}/config/environment.rb")
          if defined?(::Rails) && ::Rails.respond_to?(:application)
            # Rails 3
            ::Rails.application.eager_load!
          elsif defined?(::Rails::Initializer)
            # Rails 2.3
            $rails_rake_task = false
            ::Rails::Initializer.run :load_application_classes
          end
        elsif File.file?(file)
          require File.expand_path(file)
        end
      end
1167072
def load
      @comments = self.build
      max_size = @comments.values.max_by(&:size).try(:size)
      
      load_comments(Rails.root.join('app', 'controllers').to_s, max_size) do |file, line|
        if get_finder === line
          found_method = $1
          
          comments = build_comments(found_method, line.chomp.match(/^(\s*)[^\s]*/)[1])
          file.write(comments.join) unless file.trailing?(comments)
          
          @comments.delete(found_method)
          get_finder(true)
        end
        
        file.write(line)
      end
    end
695941
def to_html(filename)
      rows = annotate(filename)
      ERB.new(IO.read(File.dirname(__FILE__) + "/annotate/template.erb")).result(binding)
    rescue Sass::SyntaxError=>error
      error = Sass::SyntaxError.exception_to_css error, @options.merge(:full_exception=>true)
      ERB.new(IO.read(File.dirname(__FILE__) + "/annotate/template.erb")).result(binding)
    end
1229551
def get_class(class_entry)
      result = nil
      for path in class_entry.path_names
        path = RiWriter.class_desc_path(path, class_entry)
        desc = File.open(path) {|f| RI::Description.deserialize(f) }
        if result
          result.merge_in(desc)
        else
          result = desc
        end
      end
      result
    end
738011
def load(path)
      if File.directory?(path)
        Dir[path+"/**/*.rb"].each do |file|
          # Ruby 1.8 doesn't understand that "jsduck/tag/tag" and
          # "./lib/jsduck/tag/tag.rb" refer to the same file.  So
          # explicitly avoid loading this file (as it's required on
          # top already) to prevent warnings of constants getting
          # defined multiple times.
          require(file) unless file =~ /jsduck\/tag\/tag\.rb$/
        end
      else
        require(path)
      end
    end
1343730
def yaml?(file)
      line = open(file) { |f| line = f.gets }
      line.index "!ruby/object:Gem::Specification"
    end
301886
def html_options
      html_opts = options.fetch(:html) { Hash.new }
      html_opts[:id] ||= autogenerated_item_id

      classes = [html_opts[:class], selected_class, active_leaf_class]
      classes = classes.flatten.compact.join(' ')
      html_opts[:class] = classes if classes && !classes.empty?

      html_opts
    end
804980
def resolve
    options[:rootpath]   ||= Pathname.pwd
    options[:rootpath]     = Pathname.new(options[:rootpath])
    options[:namespaces] ||= []
    options[:preset]     ||= resolve_preset

    if %w{rails rails-engine}.include?(options[:preset])
      options[:rootpath]     = detect_engine_root                                if options[:preset]     == 'rails-engine'
      options[:namespaces]   = load_rails_default_namespaces(options[:rootpath]) if options[:namespaces] == []
      options[:basepath]   ||= options[:rootpath] + 'config'
    else
      options[:basepath]   ||= options[:rootpath]
    end

    options[:encryption_keys]   = Keys::Encryption.resolve(filenames:  options[:encryption_keys],
                                                           namespaces: options[:namespaces],
                                                           rootpath:   options[:rootpath])
    options[:decryption_keys]   = Keys::Decryption.resolve(filenames:  options[:decryption_keys],
                                                           namespaces: options[:namespaces],
                                                           rootpath:   options[:rootpath])
    options[:basepath]          = Pathname.new(options[:basepath])
    options[:files]           ||= [
                                    options[:basepath] + 'settings*.yml',
                                    options[:basepath] + 'settings',
                                  ]

    options
  end
371608
def classes_file(flag_leaf=False):
    
    if __flag_first:
        __setup()

    if not flag_leaf:
        return _classes_file

    return [cls for cls in _classes_file if cls not in _classes_file_superclass]