total_recall 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +18 -0
- data/CHANGELOG.md +42 -28
- data/README.md +5 -4
- data/Rakefile +1 -10
- data/lib/total_recall.rb +31 -4
- data/lib/total_recall/templates/sample.yml.tt +2 -2
- data/lib/total_recall/templates/simple.yml.tt +7 -8
- data/lib/total_recall/version.rb +1 -1
- data/spec/spec_helper.rb +7 -3
- data/spec/total_recall/total_recall_spec.rb +22 -0
- data/total_recall.gemspec +8 -8
- metadata +23 -25
- data/.travis.yml +0 -3
- data/spec/spec.opts +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4eeb842cfe9ee4786bc22a2727a1020e8cdb3fff
|
4
|
+
data.tar.gz: 46034a06760f81a905ffd0b384ebf2f4ac9f5751
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f97bacdd8edd27e009edc074681213d1c00eedbb2981a7c4da89e605966376b5c9c8a9d1024017d0cec90a2ad04858c3c0fa30c0aacc240a8427a2a944d2087a
|
7
|
+
data.tar.gz: d746904a4b9f9f5a16eda0a7917d876e11749c2f0aa5dddbccd30fc4e36bfec242c0e4f7e2e54b775b0021d6dbfedea311c340a94fa6a76391bcd998cc72ddf1
|
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
.spec: &spec
|
2
|
+
tags:
|
3
|
+
- docker
|
4
|
+
script:
|
5
|
+
- bundle install --binstubs --path vendor --without production --jobs $(nproc) > /dev/null
|
6
|
+
- bin/rspec
|
7
|
+
|
8
|
+
spec2.1:
|
9
|
+
image: ruby:2.1
|
10
|
+
<<: *spec
|
11
|
+
|
12
|
+
spec2.3:
|
13
|
+
image: ruby:2.3
|
14
|
+
<<: *spec
|
15
|
+
|
16
|
+
spec2.4:
|
17
|
+
image: ruby:2.4
|
18
|
+
<<: *spec
|
data/CHANGELOG.md
CHANGED
@@ -1,46 +1,60 @@
|
|
1
|
-
# 0.
|
1
|
+
# 0.6.0 / 2017-03-08
|
2
|
+
|
3
|
+
* move repository to GitLab
|
4
|
+
|
5
|
+
* upgrade dependencies
|
6
|
+
|
7
|
+
* added option to use only transaction-section from template
|
8
|
+
|
9
|
+
This makes adding transactions to an existing ledger-file easier.
|
10
|
+
|
11
|
+
```bash
|
12
|
+
$ total_recall ledger -c bank.yml --transactions-only >> bank.dat
|
13
|
+
```
|
14
|
+
|
15
|
+
# 0.5.0 / 2014-06-11
|
2
16
|
|
3
17
|
* extend the ledger subcommand by passing it a file with customizations
|
4
18
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
19
|
+
```ruby
|
20
|
+
$ cat my_extension.rb
|
21
|
+
module MyExtension
|
22
|
+
def ask_account(*args)
|
23
|
+
# some custom stuff
|
24
|
+
super
|
25
|
+
end
|
11
26
|
end
|
12
|
-
|
13
|
-
TotalRecall::SessionHelper.include MyExtension
|
27
|
+
TotalRecall::SessionHelper.include MyExtension
|
14
28
|
|
15
|
-
|
16
|
-
|
29
|
+
$ total_recall ledger -c sample.yml -r ./my_extension.rb
|
30
|
+
```
|
17
31
|
|
18
32
|
* add version subcommand
|
19
33
|
|
20
34
|
* add default-helper
|
21
35
|
|
22
|
-
|
36
|
+
Let's you point to the default-value of an attribute:
|
23
37
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
38
|
+
```yaml
|
39
|
+
:context:
|
40
|
+
:transactions:
|
41
|
+
:__defaults__:
|
42
|
+
:a: 1
|
43
|
+
:a: !!proc |
|
44
|
+
ask("What value has a?", default: default)
|
45
|
+
```
|
32
46
|
|
33
47
|
* add transaction-helper
|
34
48
|
|
35
|
-
|
49
|
+
This allows you to use already set attributes of the transaction:
|
36
50
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
51
|
+
```yaml
|
52
|
+
:context:
|
53
|
+
:transactions:
|
54
|
+
:a: 1
|
55
|
+
:b: !!proc |
|
56
|
+
transaction.a.succ
|
57
|
+
```
|
44
58
|
|
45
59
|
# 0.4.0 / 2014-06-04
|
46
60
|
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
# TotalRecall [![
|
1
|
+
# TotalRecall [![build status](https://gitlab.com/eval/total_recall/badges/master/build.svg)](https://gitlab.com/eval/total_recall/commits/master)
|
2
|
+
|
2
3
|
|
3
4
|
Turn **any** csv-file into a [Ledger](http://ledger-cli.org/) journal.
|
4
5
|
|
@@ -14,7 +15,7 @@ gem install total_recall
|
|
14
15
|
|
15
16
|
```bash
|
16
17
|
total_recall sample
|
17
|
-
# An annotated config 'sample.yml' will be written the current directory.
|
18
|
+
# An annotated config 'sample.yml' will be written to the current directory.
|
18
19
|
```
|
19
20
|
|
20
21
|
### Generate a ledger
|
@@ -95,7 +96,7 @@ total_recall ledger -c my-bank.yml -r ./my_extension.rb
|
|
95
96
|
|
96
97
|
This makes it possible to add helpers or redefine existing ones:
|
97
98
|
|
98
|
-
```
|
99
|
+
```ruby
|
99
100
|
cat my_extension.rb
|
100
101
|
module MyExtension
|
101
102
|
# adding some options to an existing helper:
|
@@ -130,7 +131,7 @@ Gert Goet (eval) :: gert@thinkcreate.nl :: @gertgoet
|
|
130
131
|
|
131
132
|
(The MIT license)
|
132
133
|
|
133
|
-
Copyright (c)
|
134
|
+
Copyright (c) 2017 Gert Goet, ThinkCreate
|
134
135
|
|
135
136
|
Permission is hereby granted, free of charge, to any person obtaining
|
136
137
|
a copy of this software and associated documentation files (the
|
data/Rakefile
CHANGED
@@ -1,15 +1,6 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
1
|
require "bundler/gem_tasks"
|
3
2
|
require "rspec/core/rake_task"
|
4
3
|
|
5
|
-
RSpec::Core::RakeTask.new
|
6
|
-
t.rspec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
|
7
|
-
end
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
5
|
|
9
|
-
desc "Run the specs"
|
10
6
|
task :default => :spec
|
11
|
-
|
12
|
-
desc 'Removes trailing whitespace'
|
13
|
-
task :whitespace do
|
14
|
-
sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;}
|
15
|
-
end
|
data/lib/total_recall.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'yaml'
|
2
|
-
require
|
3
|
-
require
|
2
|
+
require 'thor'
|
3
|
+
require 'mustache'
|
4
4
|
require 'csv'
|
5
5
|
|
6
6
|
module TotalRecall
|
@@ -107,6 +107,7 @@ module TotalRecall
|
|
107
107
|
def initialize(options = {})
|
108
108
|
options = { file: 'total_recall.yml' }.merge(options)
|
109
109
|
@config_file = File.expand_path(options[:file])
|
110
|
+
@transactions_only = !!options[:transactions_only]
|
110
111
|
end
|
111
112
|
|
112
113
|
def config
|
@@ -136,6 +137,26 @@ module TotalRecall
|
|
136
137
|
end
|
137
138
|
end
|
138
139
|
|
140
|
+
def transactions_only_template
|
141
|
+
@transactions_only_template ||= begin
|
142
|
+
Mustache::Template.new("").tap do |t|
|
143
|
+
_transactions_tokens = proc { transactions_tokens }
|
144
|
+
t.define_singleton_method(:tokens) do |*|
|
145
|
+
_transactions_tokens.call
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def transactions_tokens
|
152
|
+
@transactions_tokens ||= begin
|
153
|
+
Mustache::Template.new(template).tokens.detect do |type, tag, *rest|
|
154
|
+
type == :mustache && tag == :section &&
|
155
|
+
[:mustache, :fetch, ["transactions"]]
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
139
160
|
def context
|
140
161
|
@context ||= config[:context].merge(transactions: transactions)
|
141
162
|
end
|
@@ -183,7 +204,11 @@ module TotalRecall
|
|
183
204
|
end
|
184
205
|
|
185
206
|
def ledger
|
186
|
-
|
207
|
+
tmp = @transactions_only ?
|
208
|
+
transactions_only_template :
|
209
|
+
template
|
210
|
+
|
211
|
+
Mustache.render(tmp, context)
|
187
212
|
end
|
188
213
|
end
|
189
214
|
|
@@ -196,11 +221,13 @@ module TotalRecall
|
|
196
221
|
desc "ledger", "Convert CONFIG to a ledger"
|
197
222
|
method_option :config, :aliases => "-c", :desc => "Config file", :required => true
|
198
223
|
method_option :require, :aliases => "-r", :desc => "File to load"
|
224
|
+
method_option :transactions_only, :type => :boolean
|
199
225
|
def ledger
|
200
226
|
load(options[:require]) if options[:require]
|
201
227
|
|
202
228
|
config_path = File.expand_path(options[:config])
|
203
|
-
puts TotalRecall::Config.new(file: config_path
|
229
|
+
puts TotalRecall::Config.new(file: config_path,
|
230
|
+
:transactions_only => options[:transactions_only]).ledger
|
204
231
|
end
|
205
232
|
|
206
233
|
desc "sample", "Generate an annotated config"
|
@@ -37,8 +37,8 @@
|
|
37
37
|
#:file: sample.csv
|
38
38
|
:raw: |-
|
39
39
|
"date";"description";"effective_data";"amount"
|
40
|
-
"
|
41
|
-
"
|
40
|
+
"2013-11-01";"Foo";"2013-11-02";"1.638,00"
|
41
|
+
"2013-11-02";"Bar";"2013-11-03";"-492,93"
|
42
42
|
:options:
|
43
43
|
# Any option accepted by CSV#new (http://www.ruby-doc.org/stdlib-2.1.1/libdoc/csv/rdoc/CSV.html#method-c-new).
|
44
44
|
:col_sep: ";"
|
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
{{# transactions}}
|
9
9
|
{{date}} {{{description}}}
|
10
|
-
{{to}}
|
10
|
+
{{to}} EUR {{amount}}
|
11
11
|
{{from}}
|
12
12
|
|
13
13
|
{{/ transactions}}
|
@@ -15,21 +15,20 @@
|
|
15
15
|
:csv:
|
16
16
|
#:file: <%= @name %>.csv
|
17
17
|
:raw: |-
|
18
|
-
"
|
19
|
-
"
|
18
|
+
"2013-11-01","Foo","2013-11-02","1.638,00"
|
19
|
+
"2013-11-02","Bar","2013-11-03","-492,93"
|
20
20
|
:options:
|
21
|
-
|
22
|
-
|
21
|
+
#:col_sep: ";"
|
22
|
+
#:headers: false
|
23
23
|
|
24
24
|
:context:
|
25
25
|
:transactions:
|
26
26
|
:__defaults__:
|
27
27
|
:from: !!proc |
|
28
28
|
ask_account("What account provides these transactions?", default: 'Assets:Checking')
|
29
|
-
|
30
|
-
:date: !!proc Date.parse(row[0])
|
29
|
+
:date: !!proc row[0]
|
31
30
|
:description: !!proc row[1]
|
32
31
|
:amount: !!proc row[3]
|
33
32
|
:to: !!proc |
|
34
|
-
render_row(columns: [0, 1, 3
|
33
|
+
render_row(columns: [0, 1, 3])
|
35
34
|
ask_account("To what account did the money go?")
|
data/lib/total_recall/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -106,6 +106,28 @@ describe TotalRecall::Config do
|
|
106
106
|
|
107
107
|
expect(instance.template).to eql('File template')
|
108
108
|
end
|
109
|
+
|
110
|
+
context 'transactions only' do
|
111
|
+
it 'takes only the transactions-section of the template into account' do
|
112
|
+
instance = instance_with_config(<<-CONFIG, :transactions_only => true)
|
113
|
+
:csv:
|
114
|
+
:raw: |-
|
115
|
+
row1
|
116
|
+
:context:
|
117
|
+
:a: 1
|
118
|
+
:transactions:
|
119
|
+
:b: !!proc row[0]
|
120
|
+
:template:
|
121
|
+
:raw: |-
|
122
|
+
{{a}}
|
123
|
+
{{# transactions}}
|
124
|
+
{{b}}
|
125
|
+
{{/ transactions}}
|
126
|
+
CONFIG
|
127
|
+
|
128
|
+
expect(instance.ledger).to eql("row1\n")
|
129
|
+
end
|
130
|
+
end
|
109
131
|
end
|
110
132
|
|
111
133
|
describe 'YAML types' do
|
data/total_recall.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["gert@thinkcreate.nl"]
|
11
11
|
gem.description = %q{Turn any csv into a Ledger journal}
|
12
12
|
gem.summary = %q{Turn any csv into a Ledger journal}
|
13
|
-
gem.homepage = "https://
|
13
|
+
gem.homepage = "https://gitlab.com/eval/total_recall/tree/master#totalrecall-"
|
14
14
|
gem.license = "MIT"
|
15
15
|
|
16
16
|
gem.files = `git ls-files -z`.split("\x0")
|
@@ -19,11 +19,11 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
21
|
gem.add_dependency 'thor', '~> 0.19'
|
22
|
-
gem.add_dependency 'terminal-table', '~> 1.
|
23
|
-
gem.add_dependency 'highline', '~> 1.
|
24
|
-
gem.add_dependency 'mustache', '~> 0
|
25
|
-
gem.add_development_dependency
|
26
|
-
gem.add_development_dependency
|
27
|
-
gem.add_development_dependency 'rspec', '~> 3.
|
28
|
-
gem.add_development_dependency 'fakefs'
|
22
|
+
gem.add_dependency 'terminal-table', '~> 1.7'
|
23
|
+
gem.add_dependency 'highline', '~> 1.7'
|
24
|
+
gem.add_dependency 'mustache', '~> 1.0'
|
25
|
+
gem.add_development_dependency 'bundler', '~> 1.11'
|
26
|
+
gem.add_development_dependency 'rake', '~> 12.0'
|
27
|
+
gem.add_development_dependency 'rspec', '~> 3.4'
|
28
|
+
gem.add_development_dependency 'fakefs', '~> 0.10'
|
29
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: total_recall
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gert Goet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -30,98 +30,98 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.7'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: highline
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.7'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
54
|
+
version: '1.7'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: mustache
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
61
|
+
version: '1.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
68
|
+
version: '1.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.11'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.11'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rake
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
89
|
+
version: '12.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
96
|
+
version: '12.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 3.
|
103
|
+
version: '3.4'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 3.
|
110
|
+
version: '3.4'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: fakefs
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
117
|
+
version: '0.10'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
124
|
+
version: '0.10'
|
125
125
|
description: Turn any csv into a Ledger journal
|
126
126
|
email:
|
127
127
|
- gert@thinkcreate.nl
|
@@ -132,7 +132,7 @@ extensions: []
|
|
132
132
|
extra_rdoc_files: []
|
133
133
|
files:
|
134
134
|
- ".gitignore"
|
135
|
-
- ".
|
135
|
+
- ".gitlab-ci.yml"
|
136
136
|
- CHANGELOG.md
|
137
137
|
- Gemfile
|
138
138
|
- README.md
|
@@ -143,11 +143,10 @@ files:
|
|
143
143
|
- lib/total_recall/templates/sample.yml.tt
|
144
144
|
- lib/total_recall/templates/simple.yml.tt
|
145
145
|
- lib/total_recall/version.rb
|
146
|
-
- spec/spec.opts
|
147
146
|
- spec/spec_helper.rb
|
148
147
|
- spec/total_recall/total_recall_spec.rb
|
149
148
|
- total_recall.gemspec
|
150
|
-
homepage: https://
|
149
|
+
homepage: https://gitlab.com/eval/total_recall/tree/master#totalrecall-
|
151
150
|
licenses:
|
152
151
|
- MIT
|
153
152
|
metadata: {}
|
@@ -167,11 +166,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
166
|
version: '0'
|
168
167
|
requirements: []
|
169
168
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.
|
169
|
+
rubygems_version: 2.5.2
|
171
170
|
signing_key:
|
172
171
|
specification_version: 4
|
173
172
|
summary: Turn any csv into a Ledger journal
|
174
173
|
test_files:
|
175
|
-
- spec/spec.opts
|
176
174
|
- spec/spec_helper.rb
|
177
175
|
- spec/total_recall/total_recall_spec.rb
|
data/.travis.yml
DELETED
data/spec/spec.opts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--color
|