burglar 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 888fdf0ab4e0f0037eabacae540eedce6a207c536293349d49e1bc62b8d105f9
4
- data.tar.gz: edb2f35b6c5ed890affdc40569b8452453d542fcaf186a33b3f51c2e0bfcdef6
3
+ metadata.gz: 6216d1a78c1c8cf040d1f05fbc23cd210db14c33d5946e6ebc35bfe143ef782c
4
+ data.tar.gz: 6ecaaa773f6d408c63ebf6d235d4732e49e46753add3eaec57e77f1d14917868
5
5
  SHA512:
6
- metadata.gz: 066c3e9b82f892de1fdbbf6e505a6a73a282fd4217cbafefe70a617e93221ec765d50a015ee54887ff51ecbd0ec0d4e035af2ad0e7b5d8cf84e63aa9435eaeb9
7
- data.tar.gz: a48ee6e96da7dce706951edc2bfe8e8569a2f4db21eef42c65512ac041b8a66e6080cd1c6b5caa89487416949a9b1734fcd721b5eaf7688f3ca914c5e0af80c6
6
+ metadata.gz: e5459f2dd460a78461633502456f28a1602681992692ddb026c6674408ca19438b9b936cba146d3cc7c1ac684c0253a3632c19131ef4de2c551ce1f26ca9f6f0
7
+ data.tar.gz: 65277338a161f948b1873b854068c2e291026b4fd53d481e69732d7d251a1e4a592b3772d0ea89976a3c13b9650d0a1d6eccc9530c4ab704d67b1f351b126205
@@ -2,8 +2,6 @@
2
2
 
3
3
  require 'burglar'
4
4
  require 'mercenary'
5
- require 'cymbal'
6
- require 'yaml'
7
5
  require 'date'
8
6
 
9
7
  def add_common_opts(c)
@@ -13,12 +11,6 @@ def add_common_opts(c)
13
11
  c.option :pending, '-p', '--pending', 'Include pending transactions'
14
12
  end
15
13
 
16
- def load_config(file)
17
- file ||= '~/.burglar.yml'
18
- file = File.expand_path file
19
- Cymbal.symbolize YAML.safe_load(File.read(file))
20
- end
21
-
22
14
  def date_parse_or_default(string, default)
23
15
  return default unless string
24
16
  Date.parse(string)
@@ -34,7 +26,6 @@ Mercenary.program(:burglar) do |p|
34
26
  p.action do |_, options|
35
27
  options[:end] = date_parse_or_default(options[:end], Date.today)
36
28
  options[:begin] = date_parse_or_default(options[:begin], options[:end] - 30)
37
- config = load_config(options[:config]).merge(options)
38
29
  puts Burglar.new(config).transactions
39
30
  end
40
31
  end
@@ -1,9 +1,15 @@
1
+ require 'cymbal'
2
+ require 'yaml'
3
+
1
4
  module Burglar
5
+ # Default config file
6
+ DEFAULT_CONFIG_FILE = '~/.burglar.yml'.freeze
7
+
2
8
  ##
3
9
  # Collection of banks
4
10
  class Heist
5
11
  def initialize(params = {})
6
- @options = params
12
+ @options = load_options(params)
7
13
  end
8
14
 
9
15
  def banks
@@ -17,5 +23,17 @@ module Burglar
17
23
  entries: banks.map { |_, v| v.transactions.entries }.flatten.sort
18
24
  )
19
25
  end
26
+
27
+ private
28
+
29
+ def load_config(file)
30
+ file ||= DEFAULT_CONFIG_FILE
31
+ file = File.expand_path file
32
+ Cymbal.symbolize YAML.safe_load(File.read(file))
33
+ end
34
+
35
+ def load_options(params)
36
+ load_config(params[:config]).merge(params)
37
+ end
20
38
  end
21
39
  end
@@ -3,5 +3,5 @@
3
3
  ##
4
4
  # Set the version (needed for Mercenary -v)
5
5
  module Burglar
6
- VERSION = '0.1.1'.freeze
6
+ VERSION = '0.1.2'.freeze
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: burglar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Les Aker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-12 00:00:00.000000000 Z
11
+ date: 2019-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cymbal