Commit 45475bda0fee5d75d228a4e117c27dc8ad77f472

Employ File.expand_path as appropriate

Any path in amazing will now understand tilde-syntax,
and the code doesn't need to handle relative paths directly.

Commit diff

lib/amazing/cli.rb

 
9292 def load_scripts
9393 scripts = @options[:include]
9494 @config["include"].each do |script|
95 script = "#{File.dirname(@options[:config])}/#{script}" if script[0] != ?/
95 script = File.expand_path(script, File.dirname(@options[:config]))
9696 scripts << script
9797 end
9898 if @options[:autoinclude]
toggle raw diff

lib/amazing/proc_file.rb

 
1212 include Enumerable
1313
1414 def self.parse_file(file)
15 file = "/proc/#{file}" if file[0] != ?/
15 file = File.expand_path(file, "/proc")
1616 new(File.new(file))
1717 end
1818
toggle raw diff

lib/amazing/widgets/file.rb

 
1919 default { @last }
2020
2121 init do
22 @file = "#{ENV["HOME"]}/#@file" if @file[0] != ?/
22 @file = ::File.expand_path(@file, "~")
2323 @lines = ::File.readlines(@file).map {|line| line.chomp }
2424 @first = @lines.first || ""
2525 @last = @lines.last || ""
toggle raw diff

lib/amazing/widgets/maildir.rb

 
1414 init do
1515 raise WidgetError, "No directories configured" unless @directories
1616 @directories.each do |glob|
17 glob = "#{ENV["HOME"]}/#{glob}" if glob[0] != ?/
17 glob = ::File.expand_Path(glob, "~")
1818 @count += Dir["#{glob}/*"].size
1919 end
2020 end
toggle raw diff

lib/amazing/widgets/raggle.rb

 
88 class Raggle < Widget
99 description "Unread posts in raggle"
1010 dependency "pstore", "Ruby standard library"
11 option :feed_list_path, "Path to feeds list", ".raggle/feeds.yaml"
12 option :feed_cache_path, "Path to feeds cache", ".raggle/feed_cache.store"
11 option :feed_list_path, "Path to feeds list", "~/.raggle/feeds.yaml"
12 option :feed_cache_path, "Path to feeds cache", "~/.raggle/feed_cache.store"
1313 field :count, "Ammount of unread posts", 0
1414 default { @count }
1515
1616 init do
17 @feed_list_path = "#{ENV["HOME"]}/#@feed_list_path" if @feed_list_path[0] != ?/
17 @feed_list_path = ::File.expand_path(@feed_list_path, "~")
1818 feeds = YAML.load_file(@feed_list_path)
19 @feed_cache_path = "#{ENV["HOME"]}/#{@feed_cache_path}" if @feed_cache_path[0] != ?/
19 @feed_cache_path = ::File.expand_path(@feed_cache_path, "~")
2020 cache = PStore.new(@feed_cache_path)
2121 cache.transaction(false) do
2222 feeds.each do |feed|
toggle raw diff