Changeset 4420 for lang/ruby/userscripts_org
- Timestamp:
- 01/11/08 14:34:33 (5 years ago)
- Files:
-
- 1 modified
-
lang/ruby/userscripts_org/trunk/bin/userjs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/ruby/userscripts_org/trunk/bin/userjs
r4419 r4420 49 49 EOB 50 50 }, 51 52 "install" => OptionParser.new { |opts| 53 opts.banner = <<-EOB.gsub(/^\t+/, "") 54 Usage: #{NAME} install [opts] <filename> 55 56 Install <filename> script. 57 EOB 58 59 parser.separator "" 60 61 parser.separator "Options:" 62 parser.on('-l', '--symlink', "Replace installed file with symlink.") do 63 @symlink = true 64 end 65 }, 66 51 67 } 52 68 … … 133 149 end 134 150 151 def cmd_install 152 abort @subparsers[@subcommand].help if @argv.empty? 153 file = Pathname.new(@argv.first).realpath 154 prev = scan 155 install_userjs(file) 156 installed = catch(:break) { 157 loop do 158 scan.each do |f,time| 159 if prev.key?(f) 160 throw :break, f unless prev[f] == time 161 else 162 throw :break, f 163 end 164 end 165 sleep 1 166 end 167 } 168 puts "#{file} was installed as #{installed}." 169 puts "#{installed} will be replaced with symlink to #{file}." 170 171 FileUtils.symlink(file, installed, :force => true) 172 puts "done" 173 end 174 135 175 136 176 private … … 142 182 })).login 143 183 end 184 185 def profile_dir 186 home = Pathname.new ENV["HOME"] 187 home + "Library/Application Support/Firefox/Profiles" 188 end 189 190 def scan 191 Pathname.glob(profile_dir + "*/gm_scripts/**/*.user.js").inject({}) {|r,i| 192 r[i] = i.mtime 193 r 194 } 195 end 196 197 def install_userjs(path) 198 system("open", "-a", "Firefox", path.to_s) 199 puts "Complete the install on Firefox" 200 end 144 201 end 145 202
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)