payment_day 0.1.2 → 0.2.1
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/README.md +18 -17
- data/lib/payment_day/cli.rb +15 -10
- data/lib/payment_day/version.rb +1 -1
- data/lib/payment_day.rb +18 -3
- metadata +2 -3
- data/Gemfile.lock +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 473ff17dc41c8fe9778cb7f81ad6d5d563eb1ae8a62a83f6cc535e3b0dcd76d8
|
4
|
+
data.tar.gz: f8080f220c6816d42f7588ce612ce22948e0b678f0b54c2dcdace2f9051cb314
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 336accb29ed0eaf542c978da383bb9233084071bb57fcd116e3ab573f62dc4e33c8283c1594835315c05d2bd87c9c0c082a98fc01e8503c9840524c279bcae25
|
7
|
+
data.tar.gz: 1b2a327752a17619233ad74985d9844b37da95aa8704bb838f5ae4a0a10a56832b441896dd703ccb20cc3a722c7b68016921308f957bb1f2280abd224884b2d8
|
data/README.md
CHANGED
@@ -6,27 +6,27 @@ Provides a class PaymentDay::View. This class generates the pay days for the giv
|
|
6
6
|
|
7
7
|
Install the gem and add to the application's Gemfile by executing:
|
8
8
|
|
9
|
-
$ bundle add
|
9
|
+
$ bundle add payment_day
|
10
10
|
|
11
11
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
12
|
|
13
|
-
$ gem install
|
13
|
+
$ gem install payment_day
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
17
|
```ruby
|
18
18
|
# Get the pay days
|
19
|
-
PaymentDay::View(2023).pay_days # return Array of Hash(es) with the pay_days
|
20
|
-
PaymentDay::View("2023").pay_days # accept String as input
|
21
|
-
PaymentDay::View(2023, 2024).pay_days # accept multiple years
|
22
|
-
PaymentDay::View([2023]).pay_days # accept Array's as input
|
23
|
-
PaymentDay::View("2023-2024").pay_days # accept String ranges
|
24
|
-
PaymentDay::View(2023..2024).pay_days # accept Range as input
|
25
|
-
PaymentDay::View(2023..2024, 2025, '2026').pay_days # accept a mix of all of them
|
19
|
+
PaymentDay::View.create(2023).pay_days # return Array of Hash(es) with the pay_days
|
20
|
+
PaymentDay::View.create("2023").pay_days # accept String as input
|
21
|
+
PaymentDay::View.create(2023, 2024).pay_days # accept multiple years
|
22
|
+
PaymentDay::View.create([2023]).pay_days # accept Array's as input
|
23
|
+
PaymentDay::View.create("2023-2024").pay_days # accept String ranges
|
24
|
+
PaymentDay::View.create(2023..2024).pay_days # accept Range as input
|
25
|
+
PaymentDay::View.create(2023..2024, 2025, '2026').pay_days # accept a mix of all of them
|
26
26
|
|
27
27
|
# Last parameter defines the options if set
|
28
28
|
# shows 2023 twice in the list of pay_days, default is false
|
29
|
-
PaymentDay::View(2023..2024, 2023, duplicates: true).pay_days
|
29
|
+
PaymentDay::View.create(2023..2024, 2023, duplicates: true).pay_days
|
30
30
|
|
31
31
|
table = PaymentDay::View(2023).list # returns a Terminal::Table instance
|
32
32
|
puts table # which can be printed like this
|
@@ -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,21 +6,26 @@ 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
|
-
|
17
|
-
|
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)
|
22
|
+
years = PaymentDay::View.create(years, options).years
|
18
23
|
years = years.each_slice(options[:columns])
|
19
24
|
years.each_with_index do |yearsChunk, page|
|
20
25
|
year_options = options.dup
|
21
26
|
year_options[:page] = page.next
|
22
27
|
year_options[:pages] = years.to_a.length
|
23
|
-
puts PaymentDay::View.
|
28
|
+
puts PaymentDay::View.create(yearsChunk, year_options).list()
|
24
29
|
end
|
25
30
|
end
|
26
31
|
end
|
data/lib/payment_day/version.rb
CHANGED
data/lib/payment_day.rb
CHANGED
@@ -8,17 +8,32 @@ 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
|
+
|
21
|
+
private_class_method :new
|
22
|
+
|
11
23
|
attr_reader :pay_days, :years
|
12
24
|
|
13
25
|
def initialize(*years)
|
14
|
-
default_options = { separator: true, ascii: false, dayname: false, page: nil, pages: nil, duplicates: false, footer: true }
|
15
26
|
options = years.last.is_a?(Hash) ? years.slice!(-1) : {}
|
16
27
|
@months = []
|
17
|
-
@options =
|
28
|
+
@options = DEFAULT_OPTIONS.merge options.transform_keys(&:to_sym)
|
18
29
|
@years = prepare_years(years)
|
19
30
|
@pay_days = find_pay_days
|
20
31
|
end
|
21
32
|
|
33
|
+
def self.create(*years)
|
34
|
+
new(*years)
|
35
|
+
end
|
36
|
+
|
22
37
|
def list
|
23
38
|
Terminal::Table.new do |t|
|
24
39
|
t.title = Rainbow("Pay days").bright
|
@@ -28,7 +43,7 @@ module PaymentDay
|
|
28
43
|
@years.each_index { |v| t.align_column v.next, :center }
|
29
44
|
page = @options[:page]
|
30
45
|
pages = @options[:pages]
|
31
|
-
|
46
|
+
if @options[:footer] && pages > 1
|
32
47
|
t.add_row [{ colspan: @years.length.next, value: "Page #{page}/#{pages}",
|
33
48
|
alignment: :center }]
|
34
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: payment_day
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PuLLi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|
@@ -64,7 +64,6 @@ extra_rdoc_files: []
|
|
64
64
|
files:
|
65
65
|
- CHANGELOG.md
|
66
66
|
- Gemfile
|
67
|
-
- Gemfile.lock
|
68
67
|
- LICENSE.txt
|
69
68
|
- README.md
|
70
69
|
- Rakefile
|
data/Gemfile.lock
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
payment_day (0.1.1)
|
5
|
-
rainbow (~> 3.1)
|
6
|
-
terminal-table (~> 3.0)
|
7
|
-
thor (~> 1.2)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
minitest (5.16.3)
|
13
|
-
rainbow (3.1.1)
|
14
|
-
rake (13.0.6)
|
15
|
-
terminal-table (3.0.2)
|
16
|
-
unicode-display_width (>= 1.1.1, < 3)
|
17
|
-
thor (1.2.1)
|
18
|
-
unicode-display_width (2.3.0)
|
19
|
-
|
20
|
-
PLATFORMS
|
21
|
-
arm64-darwin-22
|
22
|
-
|
23
|
-
DEPENDENCIES
|
24
|
-
minitest (~> 5.0)
|
25
|
-
payment_day!
|
26
|
-
rake (~> 13.0)
|
27
|
-
|
28
|
-
BUNDLED WITH
|
29
|
-
2.4.1
|