calrom 0.2.0 → 0.3.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/CHANGELOG.md +22 -1
- data/README.md +69 -4
- data/lib/calrom.rb +4 -0
- data/lib/calrom/cli.rb +40 -3
- data/lib/calrom/config.rb +48 -3
- data/lib/calrom/formatter/calendars.rb +22 -0
- data/lib/calrom/formatter/csv.rb +28 -0
- data/lib/calrom/formatter/easter.rb +1 -1
- data/lib/calrom/formatter/json.rb +38 -0
- data/lib/calrom/option_parser.rb +95 -14
- data/lib/calrom/rc_parser.rb +10 -0
- data/lib/calrom/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d42310796615e6626842e77d06cf282159c50ce621910d7c44f61cfdc0de91ae
|
4
|
+
data.tar.gz: eb40b6b35e68543447d12ebb1ca91be7212a07c92e392ce50cc994b48e9103c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66a58f4609c50cd65f581bf9cbc8e8c52c2d7330b475d0d45fd0cec9cf6c63d16259c2bbaf83bfde1726486bf8916edc399dd0b9e70287882e34b461fa0f010f
|
7
|
+
data.tar.gz: 7dd18b19ba33a6caa6da2ebb08eedcd0ca12ebcb56f8500e75c35acd61509bfcfe53541608937c205677bd3ad36c951aff197ef02915f020721051a652b8a304
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,27 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## [0.
|
3
|
+
## [0.3.0] 2020-06-21
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- date range selection: options `--today`, `--tomorrow`, `--yesterday`
|
8
|
+
- specifying the `--calendar=` option multiple times layers the calendars
|
9
|
+
- file path can be provided as argument to the `--calendar=` option
|
10
|
+
- option `--locale=` to specify language of localized calendar strings
|
11
|
+
- language of the (last loaded) sanctorale data is by default used for localized strings
|
12
|
+
- output is by default not colorized when not printing to a terminal
|
13
|
+
- configuration files
|
14
|
+
- `/etc/calromrc`
|
15
|
+
- `$HOME/.calromrc`
|
16
|
+
- specified by the `--config=` option
|
17
|
+
- machine-readable output formats `--format=csv`, `--format=json`
|
18
|
+
- option `--calendars` to list bundled calendars
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
|
22
|
+
- crash on option parsing errors other than invalid option
|
23
|
+
|
24
|
+
## [0.2.0] 2020-06-16
|
4
25
|
|
5
26
|
### Added
|
6
27
|
|
data/README.md
CHANGED
@@ -46,6 +46,29 @@ Print liturgical calendar for the current month (default):
|
|
46
46
|
|
47
47
|
`$ calrom 2028-01-15 2028-03-07`
|
48
48
|
|
49
|
+
### Selecting calendar
|
50
|
+
|
51
|
+
There are a few calendars bundled in calrom (actually in the calendarium-romanum gem)
|
52
|
+
and ready to use. List them:
|
53
|
+
|
54
|
+
`$ calrom --calendars`
|
55
|
+
|
56
|
+
Each entry of the listing contains an ID of the calendar, it's name and language code.
|
57
|
+
Use calendar ID to request General Roman Calendar in Latin:
|
58
|
+
|
59
|
+
`$ calrom --calendar=universal-la`
|
60
|
+
|
61
|
+
You can prepare [your own calendar data][carodata] and load them:
|
62
|
+
|
63
|
+
`$ calrom --calendar=path/to/my_calendar.txt`
|
64
|
+
|
65
|
+
If you specify more than one calendar, they are loaded "layered" one over another
|
66
|
+
(from left to right), which comes in handy when extending a general calendar
|
67
|
+
with just a few additional and/or differing celebrations, e.g. solemnities (titular, dedication)
|
68
|
+
of the local church:
|
69
|
+
|
70
|
+
`$ calrom --calendar=universal-la --calendar=path/to/our_local_celebrations.txt`
|
71
|
+
|
49
72
|
### Data presentation settings
|
50
73
|
|
51
74
|
Print detailed listing:
|
@@ -56,6 +79,45 @@ Disable colours:
|
|
56
79
|
|
57
80
|
`$ calrom --no-color`
|
58
81
|
|
82
|
+
Machine-readable output formats:
|
83
|
+
|
84
|
+
`$ calrom --format=json` - prints JSON array containing one object per day.
|
85
|
+
The object contents mimick output of the [Church Calendar API v0][calapidoc].
|
86
|
+
|
87
|
+
`$ calrom --format=csv` - prints a CSV, one celebration per line
|
88
|
+
(i.e. there is one or more lines for each liturgical day).
|
89
|
+
|
90
|
+
### Configuration files
|
91
|
+
|
92
|
+
`calrom` looks for configuration files `/etc/calromrc` and `~/.calromrc`.
|
93
|
+
They are processed in this order and both are used if available.
|
94
|
+
Their syntax is that of shell options and arguments (with the sole exception that newline
|
95
|
+
is not considered end of shell input, but generic whitespace), supported are all options and arguments
|
96
|
+
accepted by the command.
|
97
|
+
It usually makes sense to use configuration files only for the most fundamental settings
|
98
|
+
you will never change, like selecting calendar (if you know you will always check this single one)
|
99
|
+
or disabling colours (if you hate colourful output).
|
100
|
+
|
101
|
+
If a custom configuration file location is specified on the command line,
|
102
|
+
`$ calrom --config=path/to/my/custom/config`, the standard system-wide and user-specific configuration
|
103
|
+
files are *not* loaded.
|
104
|
+
|
105
|
+
Example configuration file, loading the proper calendar of the archdiocese of Prague
|
106
|
+
and disabling colours:
|
107
|
+
|
108
|
+
```bash
|
109
|
+
# shell-like comments can be used in configuration files
|
110
|
+
|
111
|
+
--calendar=czech-cs # celebrations common for the whole Czech Republic
|
112
|
+
--calendar=czech-cechy-cs # Bohemia
|
113
|
+
--calendar=czech-praha-cs # archdiocese of Prague
|
114
|
+
--calendar=/home/igneus/calendar_data/local_church.txt # path to a custom calendar file with proper celebrations of the parish where I live (titular feast of the church, dedication)
|
115
|
+
|
116
|
+
--no-color # disable colours
|
117
|
+
```
|
118
|
+
|
119
|
+
(Configuration file format is inspired by [.rspec][dotrspec].)
|
120
|
+
|
59
121
|
## Running tests
|
60
122
|
|
61
123
|
Clone the repository, `$ bundle install` to install dependencies, then:
|
@@ -69,14 +131,14 @@ Clone the repository, `$ bundle install` to install dependencies, then:
|
|
69
131
|
## Project roadmap
|
70
132
|
|
71
133
|
* [x] detailed listing of a day/month/year/range of dates
|
72
|
-
* [ ] month/year overview - options and output mostly mimicking
|
134
|
+
* [ ] month/year overview - options and output mostly mimicking
|
73
135
|
the BSD Unix [`cal`][cal] utility,
|
74
136
|
but with liturgical colours and celebration ranks
|
75
137
|
* [ ] condensed format (but with detailed information) suitable for awesome/i3 toolbars etc.
|
76
|
-
* [
|
138
|
+
* [x] machine-readable detailed listing
|
77
139
|
* [ ] year summary: lectionary cycles, movable feasts
|
78
|
-
* [
|
79
|
-
* [
|
140
|
+
* [x] configuration file to set default options
|
141
|
+
* [x] specify calendar data path (with support for layering several calendars)
|
80
142
|
* [ ] option to auto-select one of optional celebrations - with multiple supported strategies (prefer ferial, take first non-ferial, configured whitelist, blacklist)
|
81
143
|
* [ ] integrate online data sources
|
82
144
|
* [ ] interactive browsing
|
@@ -114,6 +176,9 @@ command line interface
|
|
114
176
|
GNU/GPL 3.0 or later
|
115
177
|
|
116
178
|
[caro]: https://github.com/igneus/calendarium-romanum
|
179
|
+
[carodata]: https://github.com/igneus/calendarium-romanum/tree/master/data
|
180
|
+
[calapidoc]: http://calapi.inadiutorium.cz/api-doc
|
117
181
|
[semver]: https://semver.org/
|
118
182
|
[cal]: https://www.freebsd.org/cgi/man.cgi?query=cal
|
119
183
|
[taoup]: http://www.catb.org/esr/writings/taoup/html/ch10s05.html
|
184
|
+
[dotrspec]: https://relishapp.com/rspec/rspec-core/v/2-0/docs/configuration/read-command-line-configuration-options-from-files
|
data/lib/calrom.rb
CHANGED
@@ -10,11 +10,15 @@ require 'calrom/cli'
|
|
10
10
|
require 'calrom/option_parser'
|
11
11
|
require 'calrom/config'
|
12
12
|
require 'calrom/date_range'
|
13
|
+
require 'calrom/rc_parser'
|
13
14
|
require 'calrom/exceptions'
|
14
15
|
require 'calrom/formatter/formatter'
|
15
16
|
require 'calrom/formatter/list'
|
16
17
|
require 'calrom/formatter/overview'
|
18
|
+
require 'calrom/formatter/csv'
|
19
|
+
require 'calrom/formatter/json'
|
17
20
|
require 'calrom/formatter/easter'
|
21
|
+
require 'calrom/formatter/calendars'
|
18
22
|
require 'calrom/highlighter/no'
|
19
23
|
require 'calrom/highlighter/list'
|
20
24
|
require 'calrom/highlighter/overview'
|
data/lib/calrom/cli.rb
CHANGED
@@ -2,15 +2,52 @@ module Calrom
|
|
2
2
|
class CLI
|
3
3
|
def self.call(argv)
|
4
4
|
begin
|
5
|
-
|
6
|
-
|
5
|
+
config_files = OptionParser.call(argv).configs
|
6
|
+
|
7
|
+
config = OptionParser.call(
|
8
|
+
rc_options(config_files.empty? ? nil : config_files) +
|
9
|
+
argv
|
10
|
+
)
|
11
|
+
|
12
|
+
calendar = config.calendar
|
13
|
+
rescue ::OptionParser::ParseError, InputError => e
|
7
14
|
STDERR.puts e.message
|
8
15
|
exit 1
|
9
16
|
end
|
10
17
|
|
11
|
-
|
18
|
+
I18n.locale = config.locale
|
12
19
|
|
13
20
|
config.formatter.call calendar, config.date_range
|
14
21
|
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# options loaded from configuration files
|
26
|
+
def self.rc_options(paths = nil)
|
27
|
+
return [] if paths == ['']
|
28
|
+
|
29
|
+
paths ||=
|
30
|
+
['/etc/calromrc', '~/.calromrc']
|
31
|
+
.collect {|f| File.expand_path f }
|
32
|
+
.select {|f| File.file? f }
|
33
|
+
|
34
|
+
paths.collect do |f|
|
35
|
+
begin
|
36
|
+
content = File.read(f)
|
37
|
+
rescue Errno::ENOENT
|
38
|
+
raise InputError.new("Configuration file \"#{f}\" not found")
|
39
|
+
end
|
40
|
+
|
41
|
+
options = RcParser.call content
|
42
|
+
|
43
|
+
begin
|
44
|
+
OptionParser.call(options)
|
45
|
+
rescue ::OptionParser::ParseError => e
|
46
|
+
raise InputError.new("Error loading '#{f}': #{e.message}")
|
47
|
+
end
|
48
|
+
|
49
|
+
options
|
50
|
+
end.flatten
|
51
|
+
end
|
15
52
|
end
|
16
53
|
end
|
data/lib/calrom/config.rb
CHANGED
@@ -1,14 +1,45 @@
|
|
1
1
|
module Calrom
|
2
2
|
class Config
|
3
|
+
DEFAULT_DATA = CR::Data::GENERAL_ROMAN_ENGLISH
|
4
|
+
DEFAULT_LOCALE = :en
|
5
|
+
|
3
6
|
def initialize
|
4
7
|
self.today = Date.today
|
5
8
|
self.date_range = Month.new(today.year, today.month)
|
9
|
+
self.sanctorale = []
|
10
|
+
self.configs = []
|
6
11
|
end
|
7
12
|
|
8
|
-
attr_accessor :today, :date_range, :formatter, :colours
|
13
|
+
attr_accessor :today, :date_range, :formatter, :colours, :sanctorale, :locale, :configs
|
9
14
|
|
10
15
|
def calendar
|
11
|
-
CR::PerpetualCalendar.new(sanctorale:
|
16
|
+
CR::PerpetualCalendar.new(sanctorale: build_sanctorale)
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_sanctorale
|
20
|
+
if @sanctorale.empty?
|
21
|
+
return DEFAULT_DATA.load
|
22
|
+
end
|
23
|
+
|
24
|
+
data = @sanctorale.collect do |s|
|
25
|
+
if s == '-'
|
26
|
+
CR::SanctoraleLoader.new.load_from_string STDIN.read
|
27
|
+
elsif File.file? s
|
28
|
+
CR::SanctoraleLoader.new.load_from_file s
|
29
|
+
elsif CR::Data[s]
|
30
|
+
CR::Data[s].load
|
31
|
+
else
|
32
|
+
raise InputError.new "\"#{s}\" is neither a file, nor a valid identifier of a bundled calendar. " +
|
33
|
+
"Valid identifiers are: " +
|
34
|
+
CR::Data.each.collect(&:siglum).inspect
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
CR::SanctoraleFactory.create_layered(*data)
|
39
|
+
end
|
40
|
+
|
41
|
+
def locale
|
42
|
+
@locale || locale_in_file_name || DEFAULT_LOCALE
|
12
43
|
end
|
13
44
|
|
14
45
|
def formatter
|
@@ -16,17 +47,31 @@ module Calrom
|
|
16
47
|
Formatter::List.new highlighter(Highlighter::List), today
|
17
48
|
elsif @formatter == :easter
|
18
49
|
Formatter::Easter.new
|
50
|
+
elsif @formatter == :calendars
|
51
|
+
Formatter::Calendars.new highlighter(Highlighter::Overview), today
|
52
|
+
elsif @formatter == :csv
|
53
|
+
Formatter::Csv.new
|
54
|
+
elsif @formatter == :json
|
55
|
+
Formatter::Json.new
|
19
56
|
else
|
20
57
|
Formatter::Overview.new highlighter(Highlighter::Overview), today
|
21
58
|
end
|
22
59
|
end
|
23
60
|
|
24
61
|
def highlighter(colourful)
|
25
|
-
if self.colours == false
|
62
|
+
if (self.colours == false || (self.colours.nil? && !STDOUT.isatty))
|
26
63
|
return Highlighter::No.new
|
27
64
|
end
|
28
65
|
|
29
66
|
colourful.new
|
30
67
|
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def locale_in_file_name
|
72
|
+
locale = (sanctorale.last || DEFAULT_DATA.siglum).split('-').last&.to_sym
|
73
|
+
|
74
|
+
I18n.available_locales.include?(locale) ? locale : nil
|
75
|
+
end
|
31
76
|
end
|
32
77
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Calrom
|
4
|
+
module Formatter
|
5
|
+
# Prints list of available bundled calendars
|
6
|
+
class Calendars < Formatter
|
7
|
+
def call(calendar, date_range)
|
8
|
+
last_locale = nil
|
9
|
+
CR::Data.each do |d|
|
10
|
+
meta = load_front_matter d
|
11
|
+
puts if last_locale && last_locale != meta['locale']
|
12
|
+
puts "%-20s: %s [%s]" % [d.siglum, meta['title'], meta['locale']]
|
13
|
+
last_locale = meta['locale']
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def load_front_matter(data_file)
|
18
|
+
YAML.load File.read data_file.path
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
3
|
+
module Calrom
|
4
|
+
module Formatter
|
5
|
+
class Csv
|
6
|
+
def call(calendar, date_range)
|
7
|
+
CSV do |out|
|
8
|
+
out << %w(date title symbol rank rank_num colour season)
|
9
|
+
|
10
|
+
date_range.each do |date|
|
11
|
+
day = calendar[date]
|
12
|
+
day.celebrations.each do |c|
|
13
|
+
out << [
|
14
|
+
day.date,
|
15
|
+
c.title,
|
16
|
+
c.symbol,
|
17
|
+
c.rank.short_desc,
|
18
|
+
c.rank.priority,
|
19
|
+
c.colour.symbol,
|
20
|
+
day.season.symbol
|
21
|
+
]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Calrom
|
4
|
+
module Formatter
|
5
|
+
# JSON format mimicking Church Calendar API v0 (https://github.com/igneus/church-calendar-api)
|
6
|
+
class Json
|
7
|
+
def call(calendar, date_range)
|
8
|
+
# We build the outer JSON Array manually in order to be able to print
|
9
|
+
# vast amounts of calendar data without risking RAM exhaustion.
|
10
|
+
print "["
|
11
|
+
|
12
|
+
date_range.each_with_index do |date, i|
|
13
|
+
day = calendar[date]
|
14
|
+
hash = {
|
15
|
+
date: date,
|
16
|
+
season: day.season.symbol,
|
17
|
+
season_week: day.season_week,
|
18
|
+
celebrations: day.celebrations.collect do |c|
|
19
|
+
{
|
20
|
+
title: c.title,
|
21
|
+
symbol: c.symbol,
|
22
|
+
colour: c.colour.symbol,
|
23
|
+
rank: c.rank.short_desc,
|
24
|
+
rank_num: c.rank.priority
|
25
|
+
}
|
26
|
+
end,
|
27
|
+
weekday: date.strftime('%A'),
|
28
|
+
}
|
29
|
+
|
30
|
+
puts "," if i > 0
|
31
|
+
print JSON.generate hash
|
32
|
+
end
|
33
|
+
|
34
|
+
puts "]"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/calrom/option_parser.rb
CHANGED
@@ -6,6 +6,12 @@ module Calrom
|
|
6
6
|
class OptionParser
|
7
7
|
using PatternMatch
|
8
8
|
|
9
|
+
class CustomizedOptionParser < ::OptionParser
|
10
|
+
def separator(string)
|
11
|
+
super "\n" + string
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
9
15
|
def self.call(argv)
|
10
16
|
self.new.call(argv)
|
11
17
|
end
|
@@ -21,16 +27,38 @@ module Calrom
|
|
21
27
|
|
22
28
|
range_type = nil
|
23
29
|
|
24
|
-
opt_parser =
|
25
|
-
opts.
|
26
|
-
|
27
|
-
end
|
30
|
+
opt_parser = CustomizedOptionParser.new do |opts|
|
31
|
+
opts.banner = <<~EOS
|
32
|
+
Usage: calrom [options] [arg1 [arg2]]
|
28
33
|
|
29
|
-
|
30
|
-
|
31
|
-
|
34
|
+
Specifying date range (cal/ncal-compatible):
|
35
|
+
|
36
|
+
calrom - current month
|
37
|
+
calrom -m 5 - May of the current year
|
38
|
+
calrom -m 5p - May of the previous year
|
39
|
+
calrom -m 5f - May of the following year
|
40
|
+
calrom -m 5 2000 - May 2000
|
41
|
+
calrom 5 2000 - also May 2000
|
42
|
+
calrom 2000 - whole year 2000
|
43
|
+
calrom -y 2000 - also whole year 2000
|
44
|
+
calrom -y - whole current year
|
45
|
+
|
46
|
+
Specifying date range (not cal-compatible):
|
47
|
+
|
48
|
+
calrom 2000-05-31 - specified day (only)
|
49
|
+
calrom 2000-05-31 2000-07-01 - arbitrary date range
|
50
|
+
calrom (--yesterday|--today|--tomorrow)
|
51
|
+
|
52
|
+
EOS
|
53
|
+
|
54
|
+
opts.separator 'Configuration files'
|
55
|
+
|
56
|
+
opts.on('--config=CONFIG', 'load configuration from file (may be used multiple times, all specified files will be loaded)') do |value|
|
57
|
+
config.configs << value
|
32
58
|
end
|
33
59
|
|
60
|
+
opts.separator 'Options selecting date range'
|
61
|
+
|
34
62
|
# cal
|
35
63
|
opts.on('-m MONTH', '--month=MONTH', 'display the specified month. \'f\' or \'p\' can be appended to display the same month of the following or previous year respectively') do |value|
|
36
64
|
range_type = :month
|
@@ -47,28 +75,79 @@ module Calrom
|
|
47
75
|
range_type = :year
|
48
76
|
end
|
49
77
|
|
78
|
+
opts.on('--yesterday', 'display previous day') do |value|
|
79
|
+
day = Date.today - 1
|
80
|
+
range_type = :day
|
81
|
+
end
|
82
|
+
|
83
|
+
opts.on('--today', 'display current day') do |value|
|
84
|
+
day = Date.today
|
85
|
+
range_type = :day
|
86
|
+
end
|
87
|
+
|
88
|
+
opts.on('--tomorrow', 'display following day') do |value|
|
89
|
+
day = Date.today + 1
|
90
|
+
range_type = :day
|
91
|
+
end
|
92
|
+
|
93
|
+
opts.separator "Options configuring liturgical calendar"
|
94
|
+
|
95
|
+
opts.on('-c CAL', '--calendar=CAL', 'specify (sanctorale) calendar to use. If repeated, layers all specified calendars one over another') do |value|
|
96
|
+
config.sanctorale << value
|
97
|
+
end
|
98
|
+
|
99
|
+
locales_help = I18n.available_locales.join(', ')
|
100
|
+
opts.on('--locale=LOCALE', "override language in which temporale celebration titles are rendered (supported: #{locales_help})") do |value|
|
101
|
+
config.locale = value.to_sym
|
102
|
+
end
|
103
|
+
|
104
|
+
opts.separator 'Options affecting presentation'
|
105
|
+
|
106
|
+
opts.on('-l', '--list', 'display detailed listing of days and celebrations (synonym to --format=list)') do
|
107
|
+
config.formatter = :list
|
108
|
+
end
|
109
|
+
|
110
|
+
supported_formats = %i(overview list csv json)
|
111
|
+
formats_help = supported_formats.join(', ')
|
112
|
+
opts.on('--format=FORMAT', supported_formats, "specify output format (supported: #{formats_help})") do |value|
|
113
|
+
config.formatter = value
|
114
|
+
end
|
115
|
+
|
116
|
+
# cal
|
117
|
+
opts.on('-e', '--easter', 'display date of Easter (only)') do
|
118
|
+
config.formatter = :easter
|
119
|
+
end
|
120
|
+
|
121
|
+
opts.on('--calendars', 'list bundled calendars') do |value|
|
122
|
+
config.formatter = :calendars
|
123
|
+
end
|
124
|
+
|
125
|
+
opts.on('--[no-]color', 'enable/disable colours (enabled by default)') do |value|
|
126
|
+
config.colours = value
|
127
|
+
end
|
128
|
+
|
129
|
+
opts.separator 'Debugging options'
|
130
|
+
|
50
131
|
# cal
|
51
132
|
opts.on('-d YM', '--current-month=YM', 'use given month (YYYY-MM) as the current month (for debugging of date range selection)') do |value|
|
52
133
|
year, month = value.split '-'
|
53
134
|
end
|
54
135
|
|
55
136
|
# cal
|
56
|
-
opts.on('-H DATE', '--highlight-date=DATE', 'use given date as the current date (for debugging of highlighting') do |value|
|
137
|
+
opts.on('-H DATE', '--highlight-date=DATE', 'use given date as the current date (for debugging of highlighting)') do |value|
|
57
138
|
config.today = validate_day value
|
58
139
|
end
|
59
140
|
|
60
|
-
opts.
|
61
|
-
config.colours = value
|
62
|
-
end
|
141
|
+
opts.separator 'Information regarding calrom'
|
63
142
|
|
64
|
-
opts.
|
143
|
+
opts.on('-V', '--version', 'display calrom version') do
|
65
144
|
puts 'calrom v' + Calrom::VERSION
|
66
145
|
exit
|
67
146
|
end
|
68
147
|
|
69
148
|
# Normally optparse defines this option by default, but once -H option is added,
|
70
149
|
# for some reason -h (if not defined explicitly) is treated as -H.
|
71
|
-
opts.
|
150
|
+
opts.on('-h', '--help', 'display this help') do
|
72
151
|
puts opts
|
73
152
|
exit
|
74
153
|
end
|
@@ -138,6 +217,8 @@ module Calrom
|
|
138
217
|
end
|
139
218
|
|
140
219
|
def validate_day(day)
|
220
|
+
return day if day.is_a? Date
|
221
|
+
|
141
222
|
Date.parse(day)
|
142
223
|
rescue ArgumentError
|
143
224
|
raise InputError.new("not a valid date #{day}")
|
@@ -156,7 +237,7 @@ module Calrom
|
|
156
237
|
Month.new(year, month)
|
157
238
|
end
|
158
239
|
|
159
|
-
beginning =
|
240
|
+
beginning = CR::Calendar::EFFECTIVE_FROM
|
160
241
|
if range.first < beginning
|
161
242
|
raise InputError.new("implemented calendar system in use only since #{beginning}")
|
162
243
|
end
|
data/lib/calrom/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calrom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Pavlík
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: calendarium-romanum
|
@@ -133,14 +133,18 @@ files:
|
|
133
133
|
- lib/calrom/config.rb
|
134
134
|
- lib/calrom/date_range.rb
|
135
135
|
- lib/calrom/exceptions.rb
|
136
|
+
- lib/calrom/formatter/calendars.rb
|
137
|
+
- lib/calrom/formatter/csv.rb
|
136
138
|
- lib/calrom/formatter/easter.rb
|
137
139
|
- lib/calrom/formatter/formatter.rb
|
140
|
+
- lib/calrom/formatter/json.rb
|
138
141
|
- lib/calrom/formatter/list.rb
|
139
142
|
- lib/calrom/formatter/overview.rb
|
140
143
|
- lib/calrom/highlighter/list.rb
|
141
144
|
- lib/calrom/highlighter/no.rb
|
142
145
|
- lib/calrom/highlighter/overview.rb
|
143
146
|
- lib/calrom/option_parser.rb
|
147
|
+
- lib/calrom/rc_parser.rb
|
144
148
|
- lib/calrom/version.rb
|
145
149
|
homepage: https://github.com/calendarium-romanum/calrom
|
146
150
|
licenses:
|