hledger-forecast 1.5.1 → 1.5.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: '09b594c8b6cf3c239d070abbb2101cf63a7d2b987f4c2e6680ba02b160c29e24'
4
- data.tar.gz: 8df343c7d6baa56d46f053d83fb6152c26ef94308c96a493c4995b78ddfccf80
3
+ metadata.gz: 6f0e4168dd9c64b1de4aec0c02fcf1601ef926c0f2f911931052c627df53b922
4
+ data.tar.gz: bf24674eeae1cac5714ddd56a23cdd86059afaba3d376d8538424372f4ae74b0
5
5
  SHA512:
6
- metadata.gz: d395581b614dd9d9931701964959092a6a897ce16daad53b3f1b7b96583e4905962f09bfe3f0cdac1a2583d0e287bb4f602d53c1dc674cd1ecb1dc421c8cafd1
7
- data.tar.gz: 241f5d557cc7f777790fe3546a897aa2af73052b35555031bd0d13dcf4d9f65a117002da7c34726334bcec2b76eb3fb6a508dd699dfa7c9306c4980092776a3b
6
+ metadata.gz: 72666051a083ae0381717c58bcb7c09de8dd250df683d26a16bce25ebf79315323b5bd2d0b9f2a19f553ecf3fe0c0327b5449c7435f5b3a461b121a6ab810537
7
+ data.tar.gz: 83f063a2ca35895d5104b2ff573de4b44e28b731fd8461462e87c9fb0d84ed26b818383bcaaccb4a7f52e784a383af0350eaab3d7d49d1b01930f4eee19a7f4d
@@ -0,0 +1,22 @@
1
+ name: Release
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ release:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - name: publish gem
14
+ run: |
15
+ mkdir -p $HOME/.gem
16
+ touch $HOME/.gem/credentials
17
+ chmod 0600 $HOME/.gem/credentials
18
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
19
+ gem build *.gemspec
20
+ gem push *.gem
21
+ env:
22
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
@@ -1,4 +1,4 @@
1
- name: Tests
1
+ name: Test
2
2
 
3
3
  on:
4
4
  pull_request:
@@ -8,14 +8,13 @@ on:
8
8
 
9
9
  jobs:
10
10
  test:
11
-
12
11
  runs-on: ubuntu-latest
13
12
  strategy:
14
13
  matrix:
15
14
  ruby-version: ['3.0', '3.1', '3.2']
16
15
 
17
16
  steps:
18
- - uses: actions/checkout@v3
17
+ - uses: actions/checkout@v4
19
18
  - name: Update packages
20
19
  run: sudo apt-get update
21
20
  - name: Install packages
@@ -23,7 +22,8 @@ jobs:
23
22
  - name: Set up Ruby
24
23
  uses: ruby/setup-ruby@v1
25
24
  with:
26
- bundler-cache: true # runs 'bundle install' and caches installed gems
25
+ bundler-cache: true
27
26
  ruby-version: ${{ matrix.ruby-version }}
28
27
  - name: Run tests
29
- run: bundle exec rspec
28
+ run: |
29
+ bundle exec rspec
data/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  <a href="https://github.com/olimorris/hledger-forecast/stargazers"><img src="https://img.shields.io/github/stars/olimorris/hledger-forecast?color=c678dd&logoColor=e06c75&style=for-the-badge"></a>
9
9
  <a href="https://github.com/olimorris/hledger-forecast/issues"><img src="https://img.shields.io/github/issues/olimorris/hledger-forecast?color=%23d19a66&style=for-the-badge"></a>
10
10
  <a href="https://github.com/olimorris/hledger-forecast/blob/main/LICENSE"><img src="https://img.shields.io/github/license/olimorris/hledger-forecast?color=%2361afef&style=for-the-badge"></a>
11
- <a href="https://github.com/olimorris/hledger-forecast/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/olimorris/hledger-forecast/ci.yml?branch=main&label=tests&style=for-the-badge"></a>
11
+ <a href="https://github.com/olimorris/hledger-forecast/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/olimorris/hledger-forecast/test.yml?branch=main&label=tests&style=for-the-badge"></a>
12
12
  </p>
13
13
 
14
14
  **"Improved", you say?** Using a _CSV_ (or _YML_) file, forecasts can be quickly generated into a _journal_ file ready to be fed into [hledger](https://github.com/simonmichael/hledger). **A 16 line [CSV file](https://github.com/olimorris/hledger-forecast/blob/main/example.csv) can generate a 46 line hledger [forecast file](https://github.com/olimorris/hledger-forecast/blob/main/example.journal)!**
@@ -117,9 +117,18 @@ module HledgerForecast
117
117
  sum + item[row_to_sum]
118
118
  end
119
119
 
120
+ income = data.reduce(0) do |sum, item|
121
+ sum += item[row_to_sum] if item[row_to_sum] < 0
122
+ sum
123
+ end
124
+
125
+ savings = (total / income * 100).to_f.round(2)
126
+
120
127
  @table.add_separator
121
128
  @table.add_row [{ value: "TOTAL".bold, colspan: 2, alignment: :left },
122
129
  { value: format_amount(total).bold, alignment: :right }]
130
+ @table.add_row [{ value: "as a % of income".italic, colspan: 2, alignment: :left },
131
+ { value: "#{savings}%".italic, alignment: :right }]
123
132
  end
124
133
 
125
134
  def format_amount(amount)
@@ -1,3 +1,3 @@
1
1
  module HledgerForecast
2
- VERSION = "1.5.1"
2
+ VERSION = "1.5.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hledger-forecast
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oli Morris
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-01 00:00:00.000000000 Z
11
+ date: 2023-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -101,7 +101,8 @@ executables:
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - ".github/workflows/ci.yml"
104
+ - ".github/workflows/release.yml"
105
+ - ".github/workflows/test.yml"
105
106
  - ".gitignore"
106
107
  - ".rubocop.yml"
107
108
  - Gemfile
@@ -154,7 +155,7 @@ homepage: https://github.com/olimorris/hledger-forecast
154
155
  licenses:
155
156
  - MIT
156
157
  metadata: {}
157
- post_install_message:
158
+ post_install_message:
158
159
  rdoc_options: []
159
160
  require_paths:
160
161
  - lib
@@ -169,8 +170,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
170
  - !ruby/object:Gem::Version
170
171
  version: '0'
171
172
  requirements: []
172
- rubygems_version: 3.4.19
173
- signing_key:
173
+ rubygems_version: 3.3.5
174
+ signing_key:
174
175
  specification_version: 4
175
176
  summary: An extended wrapper around hledger's forecasting functionality
176
177
  test_files: