Sha256: 51cfac8873ccb341e497366d825a967507cfee9edec58a4fe82b7b73a21e2b37

Contents?: true

Size: 1.37 KB

Versions: 10

Compression:

Stored size: 1.37 KB

Contents

#!/usr/bin/env ruby 

#this is to open all of the editable text files in the current and all subdirectories into geany
if !File.exist?("/usr/bin/geany") 
   exit "Put geany or a link to it in /usr/bin and this will work. "
end

class Geanyfy
   attr_accessor :filelist, :openables, :subs

   def initialize
      @openables = ["*.php","*.rb","*.sql","*.py","*.h","*.c","*.java","*.js","*.html","*.htm","*.css", "*.xml"]
      @filelist = []
      @subs = []
      get_file_list(ENV["PWD"])
      open_all_files
   end

   def get_file_list(curdir)
      match_openables(curdir)
      alldirs = Dir.glob(curdir+"/**")
      alldirs.each do |f|
         get_file_list(f) if File.directory?(f) && ![".",".."].include?( f) 
      end
   end

   def match_openables(dir_string)
      #returns an array of filenames that are of the type specified by @openables
      @openables.each do |o|
         dir_string += File::SEPARATOR if dir_string[-1,1] != File::SEPARATOR
         @filelist.concat Dir[dir_string+o]
      end 
   end   

   def open_all_files
      puts "geanyfy opening #{@filelist.size} files"
        @filelist.each do |f|
          @command = "geany #{f} &"
          puts "#{@command}"
          Kernel.fork do 
            `#{@command}`
          sleep 1000          
          end
              
      end
      puts "geanyfy - editing #{@filelist.size} files"
   end

end 

g=Geanyfy.new

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rmthemegen-0.0.49 bin/geanyfy
rmthemegen-0.0.48 bin/geanyfy
rmthemegen-0.0.47 bin/geanyfy
rmthemegen-0.0.46 bin/geanyfy
rmthemegen-0.0.45 bin/geanyfy
rmthemegen-0.0.44 bin/geanyfy
rmthemegen-0.0.42 bin/geanyfy
rmthemegen-0.0.41 bin/geanyfy
rmthemegen-0.0.40 bin/geanyfy
rmthemegen-0.0.39 bin/geanyfy.rb