ldgr 0.1.9 → 0.2.0

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
  SHA1:
3
- metadata.gz: 5a5adf1070c9805e0c5f9b7795a5053e68605190
4
- data.tar.gz: 17af8d0b4619d9c529d8417d063b7a9e791a5bd3
3
+ metadata.gz: fc54d8ad8843b07557dc9899ddcdb9e06660d04c
4
+ data.tar.gz: 8ec9ca15d94b1ce04e50eb3016cd486a4e4c5211
5
5
  SHA512:
6
- metadata.gz: e381ee9ba9d38eb313165aabc7bbbf2cedf3413b5b9af52f85be3634ffa4079d7e3f7e96d02ae7373b4db7fbb049c892760052b93cb34bfd183f92509b03d8f8
7
- data.tar.gz: d7764d3aa17416fdd1400067457c32fe2e0992e07c64e34694f75bf64791849494558f9bc09dd502b5384d63d71ffbff2185fb99310eb51bb5f88cb8db93b149
6
+ metadata.gz: 355664a991caf16c7dcb27a89ebb8c36a01a2cf6c8ae040e8b7471262eeb022d2d1052a263f6618ac128ddba4aedacf48bbf4771551b3c7920dc6995f5fe25d8
7
+ data.tar.gz: 9d6ae1acc579e2d0fdc4438a17078c0a93c266c4d909cf842f2c524e9328dccb699194cd06fc5c78ed3741138ff656d4465a613e7b17b28ffcd58ce47202fb89
data/ldgr.taskpaper ADDED
@@ -0,0 +1,7 @@
1
+ Tests:
2
+ - it can sort transactions
3
+ - it can clear transactions
4
+ - it can tag transactions
5
+ - it can output version
6
+ - it can output help
7
+ - it can open setup files
data/lib/ldgr/parser.rb CHANGED
@@ -25,6 +25,7 @@ module Ldgr
25
25
  PROGRAM_NAME = 'ldgr'
26
26
  MATCH = /(?=(\n\d\d\d\d-\d\d-\d\d)(=\d\d\d\d-\d\d-\d\d)*)|\z/
27
27
  OTHER_MATCH = /(?=(\d\d\d\d-\d\d-\d\d)(=\d\d\d\d-\d\d-\d\d)*)/
28
+ COMMANDS = %w(add sort tag clear open)
28
29
 
29
30
  attr_accessor :transactions_file, :config
30
31
 
@@ -53,29 +54,7 @@ module Ldgr
53
54
  # Returns a hash of user-specified config options.
54
55
  def user_config
55
56
  path = Pathname(FILEBASE + 'ldgr.yaml')
56
- YAML.load_file(path).to_h
57
- end
58
-
59
- # Public: available commands
60
- #
61
- # Examples
62
- #
63
- # commands
64
- #
65
- # Returns an array of command names.
66
- def commands
67
- %w(add sort tag clear open)
68
- end
69
-
70
- # Public: expected setup files
71
- #
72
- # Examples
73
- #
74
- # setup_files
75
- #
76
- # Returns an array of file names.
77
- def self.setup_files
78
- %w(transactions.dat accounts.dat budgets.dat aliases.dat commodities.dat setup.dat ledger.dat ldgr.yaml)
57
+ path.exist? ? YAML.load_file(path).to_h : {}
79
58
  end
80
59
 
81
60
  # Public: Kicks off the CLI
@@ -86,6 +65,8 @@ module Ldgr
86
65
  #
87
66
  # Returns nothing.
88
67
  def parse
68
+ setup
69
+
89
70
  cli = OptionParser.new do |o|
90
71
  o.banner = "Usage #{PROGRAM_NAME} [add|sort|tag|clear|open]"
91
72
  o.program_name = PROGRAM_NAME
@@ -103,7 +84,7 @@ module Ldgr
103
84
  end
104
85
 
105
86
  command = String(cli.parse(ARGV, into: config)[0])
106
- send(command) if commands.include? command
87
+ send(command) if COMMANDS.include? command
107
88
  end
108
89
 
109
90
  # Public: Adds a transaction to the transactions_file.
@@ -238,6 +219,8 @@ module Ldgr
238
219
  open_file(ARGV[1])
239
220
  end
240
221
 
222
+ private :open
223
+
241
224
  # Public: ldgr's default configuration options
242
225
  #
243
226
  # Examples
@@ -260,25 +243,13 @@ module Ldgr
260
243
  # Private: Prepares users' file system for ldgr.
261
244
  #
262
245
  # Returns nothing.
263
- def self.setup
264
- unless config_exist?
265
- FileUtils.mkdir_p(FILEBASE)
266
- setup_files.each do |file|
267
- FileUtils.touch("#{FILEBASE}#{file}")
268
- end
269
- end
270
- end
271
-
272
- # Private: Checks if user already has setup files created.
273
- #
274
- # Returns nothing.
275
- def self.config_exist?
276
- setup_files.each do |file|
277
- return false unless Pathname("#{FILEBASE}#{file}").exist?
246
+ def setup
247
+ setup_files = %w(transactions.dat accounts.dat budgets.dat aliases.dat commodities.dat setup.dat ledger.dat ldgr.yaml)
248
+ FileUtils.mkdir_p(FILEBASE)
249
+ setup_files.each do |file|
250
+ FileUtils.touch("#{FILEBASE}#{file}")
278
251
  end
279
- true
280
252
  end
281
-
282
- setup
253
+ private :setup
283
254
  end
284
255
  end
data/lib/ldgr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ldgr
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ldgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Pittman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-08 00:00:00.000000000 Z
11
+ date: 2017-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -98,6 +98,7 @@ files:
98
98
  - bin/ldgr
99
99
  - bin/setup
100
100
  - ldgr.gemspec
101
+ - ldgr.taskpaper
101
102
  - lib/ldgr.rb
102
103
  - lib/ldgr/parser.rb
103
104
  - lib/ldgr/transaction.rb