payment_day 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +8 -7
- data/lib/payment_day/cli.rb +13 -8
- data/lib/payment_day/version.rb +1 -1
- data/lib/payment_day.rb +12 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e8eac69e44a25f3069daac105862597e6f763fbe4594828b5b5b1d6a500f5b5
|
4
|
+
data.tar.gz: ca33ec1cb95f81285f18fdaf6d77dccc4d75ebc11b4fb62689d1c0f38e974393
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07f40ba0b61cebf07ca5f8a2430f059bf52b9af6182a4bb4f6c38f7d9045771645e01074faf1cbcc8072f9c12acae43398322b148b78662fe44ecab85056e412
|
7
|
+
data.tar.gz: d4dd9e1c99c42e93197aeef849eb229c70fecb1ef3be93d09905af25667b648589af3ccf44c78b769e76bc733a1662ad69ef208d193b48c66bf107ac87a1aec1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -36,15 +36,16 @@ puts table # which can be printed like this
|
|
36
36
|
|
37
37
|
Option | Negated | Shortcut | Default
|
38
38
|
--- | ---: | ---: | ---:
|
39
|
-
--ascii | --no-ascii |
|
40
|
-
--columns | |
|
41
|
-
--dayname | --no-dayname |
|
42
|
-
--duplicates | --no-duplicates |
|
43
|
-
--footer | --no-footer |
|
44
|
-
--
|
39
|
+
--ascii | --no-ascii | -a | false
|
40
|
+
--columns | | -c | 10
|
41
|
+
--dayname | --no-dayname | -e | true
|
42
|
+
--duplicates | --no-duplicates | -d | false
|
43
|
+
--footer | --no-footer | -f | true
|
44
|
+
--header | --no-header | -h | true
|
45
|
+
--separator | --no-separator | -s | true
|
45
46
|
|
46
47
|
```bash
|
47
|
-
payment_day
|
48
|
+
payment_day view 2023 2024 2025-2027
|
48
49
|
```
|
49
50
|
|
50
51
|
## Contributing
|
data/lib/payment_day/cli.rb
CHANGED
@@ -6,14 +6,19 @@ require "thor"
|
|
6
6
|
module PaymentDay
|
7
7
|
# CLI class for PayDay
|
8
8
|
class CLI < Thor
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
method_option :
|
15
|
-
method_option :
|
16
|
-
|
9
|
+
def self.exit_on_failure?
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "view YEARS", "Lists all pay days for the given year(s)"
|
14
|
+
method_option :ascii, aliases: "-a", type: :boolean, default: false, desc: "Do you want to have a ASCII table printed?"
|
15
|
+
method_option :columns, aliases: "-c", type: :numeric, default: 10, desc: "How many years (columns) do you wanna display in one table?"
|
16
|
+
method_option :dayname, aliases: "-e", type: :boolean, default: true, desc: "Do you want see the day name?"
|
17
|
+
method_option :duplicates, aliases: "-d", type: :boolean, default: false, desc: "Do you want see duplicates?"
|
18
|
+
method_option :footer, aliases: "-f", type: :boolean, default: true, desc: "Do you want see the table footer?"
|
19
|
+
method_option :header, aliases: "-h", type: :boolean, default: true, desc: "Do you wanna see the table title?"
|
20
|
+
method_option :separator, aliases: "-s", type: :boolean, default: true, desc: "Do you want to have a separator for the rows printed?"
|
21
|
+
def view(*years)
|
17
22
|
years = PaymentDay::View.new(years, options).years
|
18
23
|
years = years.each_slice(options[:columns])
|
19
24
|
years.each_with_index do |yearsChunk, page|
|
data/lib/payment_day/version.rb
CHANGED
data/lib/payment_day.rb
CHANGED
@@ -8,13 +8,22 @@ require_relative "payment_day/version"
|
|
8
8
|
module PaymentDay
|
9
9
|
# View class
|
10
10
|
class View
|
11
|
+
DEFAULT_OPTIONS = {
|
12
|
+
ascii: false,
|
13
|
+
dayname: false,
|
14
|
+
duplicates: false,
|
15
|
+
footer: true,
|
16
|
+
page: nil,
|
17
|
+
pages: nil,
|
18
|
+
separator: true
|
19
|
+
}.freeze
|
20
|
+
|
11
21
|
attr_reader :pay_days, :years
|
12
22
|
|
13
23
|
def initialize(*years)
|
14
|
-
default_options = { separator: true, ascii: false, dayname: false, page: nil, pages: nil, duplicates: false, footer: true }
|
15
24
|
options = years.last.is_a?(Hash) ? years.slice!(-1) : {}
|
16
25
|
@months = []
|
17
|
-
@options =
|
26
|
+
@options = DEFAULT_OPTIONS.merge options.transform_keys(&:to_sym)
|
18
27
|
@years = prepare_years(years)
|
19
28
|
@pay_days = find_pay_days
|
20
29
|
end
|
@@ -28,7 +37,7 @@ module PaymentDay
|
|
28
37
|
@years.each_index { |v| t.align_column v.next, :center }
|
29
38
|
page = @options[:page]
|
30
39
|
pages = @options[:pages]
|
31
|
-
|
40
|
+
if @options[:footer] && pages > 1
|
32
41
|
t.add_row [{ colspan: @years.length.next, value: "Page #{page}/#{pages}",
|
33
42
|
alignment: :center }]
|
34
43
|
end
|