mo2tex 1.0.0 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0d4a3e29680a83e0ed36be6adb016ccbae0514ae391b20ae47cf9636afa5af0
4
- data.tar.gz: 89558d4aedee21d11e805100bb4382ce5e9f8074e5e605ec7ffc2153fc07320f
3
+ metadata.gz: c715fef710c9144154aceaa77a10137751823c1820de13f0f72aedeb1167c71e
4
+ data.tar.gz: e4f860857f59181d7d2b58342915a7d7bfc2f6392fd5eb11283c51baa3fe0d6d
5
5
  SHA512:
6
- metadata.gz: c0b52b0888cfad63b7f2ea9ac5ff0dad89b883fa64b2bd2f68b9c8c6ecfd46275aaf786da78a8ddca98765a85a80fc3f7c74768eb210d107149f46e87acb5fdd
7
- data.tar.gz: d8ad2fa5702a9bf2337ab2aab272afc8424da4b0a27ee1407f44226f5661dd75f770bb221f2faa4dde8a87f75cb8e1afeaa0591036133fe9c88a3689e4dbb3ff
6
+ metadata.gz: 26f07223a6bad0b70004475bf6fb84822e5861232f80c26c9220205833e6b77d2af4c4d4cbe4cdc4c7b397e84abf968e624a5a731dcac6bd0d32bb300f6a39ff
7
+ data.tar.gz: 3f6ec6ec2bed786f976313e01be027615c0f9e011a6ccd5843093ed3421b77bf10098a4ebe992190ade255da66286d7fb82422ab6666cea6e8196ae9fa55e10a
data/README.md CHANGED
@@ -1,22 +1,45 @@
1
- # `mo2tex` - A pure `ruby` monteore-to-`latex` table generator
1
+ # `mo2tex` - A pure `ruby` monteore-to-`latex`, `ical` and `pic` table generator
2
2
 
3
3
  ![[pipeline](https://gitlab.com/SMELAT/mo2tex)](https://gitlab.com/SMELAT/mo2tex/badges/master/pipeline.svg)
4
4
 
5
- `mo2tex` is a pure `ruby` monteore-to-`latex` table generator
5
+ `mo2tex` is a pure `ruby` monteore-to-`latex`, `ical` and `pic` table generator
6
6
 
7
7
  ## Installation
8
8
 
9
9
  Install the gem and add to the application's Gemfile by executing:
10
10
 
11
+ ```sh
11
12
  $ bundle add mo2tex
13
+ ```
12
14
 
13
15
  If bundler is not being used to manage dependencies, install the gem by executing:
14
16
 
17
+ ```sh
15
18
  $ gem install mo2tex
19
+ ```
20
+
21
+ ## Configuration
22
+
23
+ You will have to write a `yaml` configuration file before using `mo2tex`.
24
+ Please check the [example provided](./config/courses.yml) for a sample configuration file.
16
25
 
17
26
  ## Usage
18
27
 
19
- TODO: Write usage instructions here
28
+ After installation, you should be able to run:
29
+
30
+ ```sh
31
+ $ m2l <config file> # this should create a latex file on standard out with your monteore listing
32
+ ```
33
+
34
+ Please check the [example provided](./config/courses.yml) for a configuration file.
35
+
36
+ ```sh
37
+ $ m2c <config file> > <ical calendar file> # this should create an ical file on standard out which you can upload anywhere fitting
38
+ ```
39
+
40
+ ```sh
41
+ $ m2p <config file> | groff -p -mpic -Tpdf -P-pa4 # this should create a pdf file on standard out with a table of the lessons
42
+ ```
20
43
 
21
44
  ## Development
22
45
 
data/Rakefile CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
+ require 'rdoc/task'
6
+
7
+ RDoc::Task.new do |rdoc|
8
+ rdoc.main = "README.md"
9
+ rdoc.rdoc_files.include(rdoc.main, "lib/**/*.rb")
10
+ end
5
11
 
6
12
  RSpec::Core::RakeTask.new(:spec)
7
13
 
@@ -8,6 +8,5 @@ maxpsht=29.7
8
8
  textwid=maxpswid-scale
9
9
  textht =maxpsht-1.035*scale
10
10
 
11
- copy "config/templates/pic/objects.pic"
11
+ copy "<%= self.absolute_pic_objects_include_path -%>"
12
12
  .PE
13
-
data/exe/m2c CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- version = '1.0.0'
3
+ version = '1.0.2'
4
4
  ourlib = File.join(ENV['HOME'], '.rvm', 'gems', 'ruby-3.4.0-preview1@mo2tex', 'gems', "mo2tex-#{version}", 'lib')
5
5
  $:<< File.join('.', 'lib')
6
6
  $:<< ourlib
data/exe/m2l CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- version = '1.0.0'
3
+ version = '1.0.2'
4
4
  ourlib = File.join(ENV['HOME'], '.rvm', 'gems', 'ruby-3.4.0-preview1@mo2tex', 'gems', "mo2tex-#{version}", 'lib')
5
5
  $:<< File.join('.', 'lib')
6
6
  $:<< ourlib
data/exe/m2p CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- version = '1.0.0'
3
+ version = '1.0.2'
4
4
  ourlib = File.join(ENV['HOME'], '.rvm', 'gems', 'ruby-3.4.0-preview1@mo2tex', 'gems', "mo2tex-#{version}", 'lib')
5
5
  $:<< File.join('.', 'lib')
6
6
  $:<< ourlib
data/lib/mo2tex/pic.rb CHANGED
@@ -114,11 +114,26 @@ module Mo2tex
114
114
  def pic_time
115
115
  return sprintf("%s-%s", self.slot.dtstart.hm_to_s, self.slot.dtend.hm_to_s)
116
116
  end
117
-
117
+
118
118
  def pic_title
119
- return self.slot.title.sub(/^.*([TB][RN])/, '\1')
119
+ result = self.slot.class == Event ? make_pic_title : self.slot.title
120
+ return result
120
121
  end
121
-
122
+
123
+ alias_method :title, :pic_title
124
+
125
+ private
126
+
127
+ TITLE_RANGE = 2..4 # the title is in this range
128
+ ANN_RANGE = 5..-1
129
+
130
+ def make_pic_title
131
+ sep = self.slot.title.gsub(/_+/, ' ').split(/ /)
132
+ acro = sep[TITLE_RANGE].map { |w| w[0] }.join
133
+ ann = sep[ANN_RANGE].join(' ')
134
+ return sprintf("%s (%s)", ann, acro)
135
+ end
136
+
122
137
  end
123
138
 
124
139
  class Container < Base
@@ -200,12 +215,16 @@ module Mo2tex
200
215
  result = ''
201
216
  self.pages.each do
202
217
  |page|
203
- result += self.header
218
+ result += self.header.result(binding)
204
219
  result += self.body.result(binding)
205
220
  result += self.trailer.result(binding)
206
221
  end
207
222
  return result
208
223
  end
224
+
225
+ def absolute_pic_objects_include_path
226
+ return File.expand_path(File.join(['..'] * 3, 'config', 'templates', 'pic', 'objects.pic'), __FILE__)
227
+ end
209
228
 
210
229
  DAYS_PER_PAGE = 12
211
230
  DAYS_PER_ROW = 4
@@ -273,7 +292,8 @@ module Mo2tex
273
292
  end
274
293
 
275
294
  def read_header
276
- return read('header.pic')
295
+ template = read('header.pic.erb')
296
+ return ERB.new(template, trim_mode: '-')
277
297
  end
278
298
 
279
299
  def read_trailer
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mo2tex
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.2"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mo2tex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicola Bernardini
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2024-12-05 00:00:00.000000000 Z
10
+ date: 2025-01-10 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rdoc
@@ -65,7 +65,8 @@ dependencies:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
- description: mo2tex transforms a Monte Ore calendar into a Tex table
68
+ description: mo2tex transforms a Monte Ore calendar into a LaTex table, or an ical
69
+ file, or a pic table
69
70
  email:
70
71
  - nicola.bernardini.rome@gmail.com
71
72
  executables:
@@ -86,7 +87,7 @@ files:
86
87
  - config/templates/latex/header.tex
87
88
  - config/templates/latex/trailer.tex
88
89
  - config/templates/pic/body.pic.erb
89
- - config/templates/pic/header.pic
90
+ - config/templates/pic/header.pic.erb
90
91
  - config/templates/pic/objects.pic
91
92
  - config/templates/pic/trailer.pic.erb
92
93
  - exe/m2c
@@ -132,5 +133,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
133
  requirements: []
133
134
  rubygems_version: 3.6.0.dev
134
135
  specification_version: 4
135
- summary: mo2tex transforms a Monte Ore calendar into a Tex table
136
+ summary: mo2tex transforms a Monte Ore calendar into a LaTex table, or an ical file,
137
+ or a pic table
136
138
  test_files: []