ledger_web 1.4.6 → 1.4.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -13,6 +13,8 @@ rescue LoadError => e
13
13
  require 'ledger_web'
14
14
  end
15
15
 
16
+ user_dir = "#{ENV['HOME']}/.ledger_web"
17
+
16
18
  OptionParser.new do |opts|
17
19
  opts.banner = "Usage: ledger_web [options]"
18
20
 
@@ -27,8 +29,14 @@ OptionParser.new do |opts|
27
29
  opts.on("-d", "--database-url URL", String, "Database URL to load into") do |d|
28
30
  LedgerWeb::Config.instance.set :database_url, d
29
31
  end
32
+
33
+ opts.on("-U", "--user-dir DIR", String, "Directory containing reports and config") do |d|
34
+ user_dir = d
35
+ end
30
36
  end.parse!
31
37
 
38
+ LedgerWeb::Config.instance.load_user_config(user_dir)
39
+
32
40
  LedgerWeb::Database.connect
33
41
 
34
42
  LedgerWeb::Watcher.run!
@@ -61,13 +61,26 @@ module LedgerWeb
61
61
  end
62
62
  end
63
63
 
64
+ def load_user_config(user_dir)
65
+ if LedgerWeb::Config.should_load_user_config && File.directory?(user_dir)
66
+ if File.directory? "#{user_dir}/reports"
67
+ dirs = self.get(:report_directories)
68
+ dirs.unshift "#{user_dir}/reports"
69
+ self.set :report_directories, dirs
70
+ end
71
+
72
+ if File.exists? "#{user_dir}/config.rb"
73
+ self.override_with(LedgerWeb::Config.from_file("#{user_dir}/config.rb"))
74
+ end
75
+ end
76
+ end
77
+
64
78
  def self.from_file(filename)
65
79
  File.open(filename) do |file|
66
80
  return eval(file.read, nil, filename)
67
81
  end
68
82
  end
69
83
 
70
-
71
84
  def self.instance
72
85
  @@instance ||= LedgerWeb::Config.new do |config|
73
86
  config.set :database_url, "postgres://localhost/ledger"
@@ -79,29 +92,16 @@ module LedgerWeb
79
92
  config.set :watch_interval, 5
80
93
  config.set :watch_stable_count, 3
81
94
  config.set :ledger_bin_path, "ledger"
82
-
95
+
83
96
  config.set :ledger_format, "%(quoted(xact.beg_line)),%(quoted(date)),%(quoted(payee)),%(quoted(account)),%(quoted(commodity)),%(quoted(quantity(scrub(display_amount)))),%(quoted(cleared)),%(quoted(virtual)),%(quoted(join(note | xact.note))),%(quoted(cost))\n"
84
-
97
+
85
98
  config.set :price_lookup_skip_symbols, ['$']
86
-
99
+
87
100
  func = Proc.new do |symbol, min_date, max_date|
88
101
  LedgerWeb::YahooPriceLookup.new(symbol, min_date, max_date).lookup
89
102
  end
90
103
  config.set :price_function, func
91
-
92
- ledger_web_dir = "#{ENV['HOME']}/.ledger_web"
93
-
94
- if LedgerWeb::Config.should_load_user_config && File.directory?(ledger_web_dir)
95
- if File.directory? "#{ledger_web_dir}/reports"
96
- dirs = config.get(:report_directories)
97
- dirs.unshift "#{ledger_web_dir}/reports"
98
- config.set :report_directories, dirs
99
- end
100
-
101
- if File.exists? "#{ledger_web_dir}/config.rb"
102
- config.override_with(LedgerWeb::Config.from_file("#{ledger_web_dir}/config.rb"))
103
- end
104
- end
104
+
105
105
  end
106
106
  end
107
107
  end
@@ -1,3 +1,3 @@
1
1
  module LedgerWeb
2
- VERSION = '1.4.6'
2
+ VERSION = '1.4.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ledger_web
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.6
4
+ version: 1.4.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-01 00:00:00.000000000Z
12
+ date: 2012-05-18 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pg