payment_day 0.1.2 → 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
  SHA256:
3
- metadata.gz: a279d6517217a079c005e643cf8ed2800d5738c870f46143debd39d30a6cf8d1
4
- data.tar.gz: dcf679700489acc4548e0c008f6a23cd61d08bfa9bc934bcb16ca16c81c04142
3
+ metadata.gz: 6e8eac69e44a25f3069daac105862597e6f763fbe4594828b5b5b1d6a500f5b5
4
+ data.tar.gz: ca33ec1cb95f81285f18fdaf6d77dccc4d75ebc11b4fb62689d1c0f38e974393
5
5
  SHA512:
6
- metadata.gz: 465d44ca851085f3bfc56ffdd14eb877a56baa625abad29fb8787d5c94bf5eab8e579a9595ff6538afe01baa50f9c091cf962c7e675751dadc73f1e72eca8ca5
7
- data.tar.gz: f113f82e0799a51150959e007bd64db74e78fb2d243487414cd8bc1d5ecc37301c145e5c42ecebe9b4514b19b9797a4a6535a4fe3cb136e97dc2a91acf249f2a
6
+ metadata.gz: 07f40ba0b61cebf07ca5f8a2430f059bf52b9af6182a4bb4f6c38f7d9045771645e01074faf1cbcc8072f9c12acae43398322b148b78662fe44ecab85056e412
7
+ data.tar.gz: d4dd9e1c99c42e93197aeef849eb229c70fecb1ef3be93d09905af25667b648589af3ccf44c78b769e76bc733a1662ad69ef208d193b48c66bf107ac87a1aec1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- payment_day (0.1.1)
4
+ payment_day (0.1.2)
5
5
  rainbow (~> 3.1)
6
6
  terminal-table (~> 3.0)
7
7
  thor (~> 1.2)
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 | (-a) | [default: false]
40
- --columns | | (-c) | [default: 10]
41
- --dayname | --no-dayname | (-n) | [default: true]
42
- --duplicates | --no-duplicates | (-d) | [default: false]
43
- --footer | --no-footer | (-f) | [default: true]
44
- --separator | --no-separator | (-s) | [default: true]
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 list 2023 2024 2025-2027
48
+ payment_day view 2023 2024 2025-2027
48
49
  ```
49
50
 
50
51
  ## Contributing
@@ -6,14 +6,19 @@ require "thor"
6
6
  module PaymentDay
7
7
  # CLI class for PayDay
8
8
  class CLI < Thor
9
- desc "list", "Lists all pay days for the given year(s)"
10
- method_option :ascii, aliases: "-a", type: :boolean, default: false
11
- method_option :columns, aliases: "-c", type: :numeric, default: 10
12
- method_option :dayname, aliases: "-n", type: :boolean, default: true
13
- method_option :duplicates, aliases: "-d", type: :boolean, default: false
14
- method_option :footer, aliases: "-f", type: :boolean, default: true
15
- method_option :separator, aliases: "-s", type: :boolean, default: true
16
- def list(*years)
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|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PaymentDay
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
5
5
  end
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 = default_options.merge options.transform_keys(&:to_sym)
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
- unless !@options[:footer] || (page.nil? || (page == 1 && pages == 1))
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payment_day
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PuLLi