kielce 2.0.7 → 2.0.8

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: b71e938a27439dc182d4f293be066c26739729cd271abfc8695b364af6427c3f
4
- data.tar.gz: b678ac8cb3e446561057c4ff735003aae2ef79a8bdb7bb5693acf369f510d286
3
+ metadata.gz: 8299f85fe0175c8087808d0625f9b3e5a18f594d3ed08df91f1baaa49fa74334
4
+ data.tar.gz: 261fd01a64b7ff14038078e507289c248fa006e5b1b6d67bf5b870878c1eebfb
5
5
  SHA512:
6
- metadata.gz: e6378588e31c49b7d11c9904047e28c52b379bae8cd959416e604cc95431f6ccade37b3923996ba4d69df6aa6d5f57fd18805cac204f88f452380b4c4174988d
7
- data.tar.gz: 71b813b66206d93cdb33eb407a5b043fe1ba2ace10c3c2042c57e8cc558650c80d96c8c5d33c31b5c7f57da8e283ad5d85d485bd7fd6c6ca7309bf60f41ccb04
6
+ metadata.gz: 6e26f0f16f973f19b6f76cfaac66aaba597a64b646c7f725d21d0704cad2f9a3421b608767e2e863851c4c523cc4bc92d61926ee0614637efe717d06eb0ee814
7
+ data.tar.gz: 6a7cca87b401829750744a34a5954676f365de9dfe1836b2d16d1965433836df5be9673e7962f77ae2a0a2cfd7f82ded10c7c6e48dd4a88483f184d047e0aad2
data/lib/kielce.rb CHANGED
@@ -14,13 +14,13 @@ require "kielce/kielce"
14
14
  ##############################################################################################
15
15
 
16
16
  module Kielce
17
- VERSION = "2.0.7"
17
+ VERSION = "2.0.8"
18
18
 
19
19
  # Changelog
20
20
  #
21
+ # 2.0.8: Changed how missing schedule items are reported.
21
22
  # 2.0.4: Added a "target" option to "link", and made the timeline links open in a new tab.
22
23
 
23
-
24
24
  def self.run
25
25
 
26
26
  # TODO:
@@ -72,7 +72,7 @@ module Kielce
72
72
  context = Object.new
73
73
  $d = KielceLoader.load(file, context: context)
74
74
  $k = Kielce.new(context)
75
- result = $k.render(file)
75
+ result = $k.render(file)
76
76
  puts result if $k.error_count == 0
77
77
  rescue LoadingError => e
78
78
  $stderr.puts e.message
@@ -1,11 +1,10 @@
1
- require 'rubyXL'
2
- require_relative 'assignment'
1
+ require "rubyXL"
2
+ require_relative "assignment"
3
3
 
4
4
  # https://www.ablebits.com/office-addins-blog/2015/03/11/change-date-format-excel/
5
5
 
6
6
  module KielcePlugins
7
7
  module Schedule
8
-
9
8
  class Schedule
10
9
 
11
10
  #SCHEDULE_KEYS = [:week, :date, :topics, :notes, :reading, :milestones, :comments]
@@ -13,13 +12,13 @@ module KielcePlugins
13
12
 
14
13
  attr_accessor :assignments, :schedule_days
15
14
 
16
- def initialize(filename)
15
+ def initialize(filename)
17
16
  workbook = RubyXL::Parser.parse(filename)
18
- @assignments = build_assignments(build_rows(workbook['Assignments'], Assignment::ASSIGNMENT_KEYS))
19
- @schedule_days = build_schedule_days(build_rows(workbook['Schedule'], SCHEDULE_KEYS))
17
+ @assignments = build_assignments(build_rows(workbook["Assignments"], Assignment::ASSIGNMENT_KEYS))
18
+ @schedule_days = build_schedule_days(build_rows(workbook["Schedule"], SCHEDULE_KEYS))
20
19
  end
21
20
 
22
- def transform(value)
21
+ def transform(value, rowDate, end_of_semester)
23
22
  if value.is_a? String
24
23
  # Replace link markup
25
24
  value.gsub!(/\[\[([^\s]+)(\s+(\S.*)|\s*)\]\]/) do
@@ -29,14 +28,17 @@ module KielcePlugins
29
28
 
30
29
  value.gsub!(/<<(assign|due|ref)\s+(\S.+?)>>/) do
31
30
  #$stderr.puts "Found assignment ref #{$1} --- #{$2} -- #{@assignments[$2].inspect}"
32
- $stderr.puts "Assignment #{$2} not found" unless @assignments.has_key?($2)
31
+ unless @assignments.has_key?($2)
32
+ $stderr.puts "Assignment #{$2} not found"
33
+ exit(1)
34
+ end
33
35
 
34
36
  text = @assignments[$2].title(:full, true)
35
- if $1 == 'assign'
37
+ if $1 == "assign"
36
38
  "Assign #{text}"
37
- elsif $1 == 'due'
39
+ elsif $1 == "due"
38
40
  "<b>Due</b> #{text}"
39
- elsif $1 == 'ref'
41
+ elsif $1 == "ref"
40
42
  text
41
43
  else
42
44
  $stderr.puts "Unexpected match #{$1}"
@@ -44,29 +46,36 @@ module KielcePlugins
44
46
  end # end gsub!
45
47
 
46
48
  value.gsub!(/{{([^{}:]+):\s*([^{}]+)}}/) do
47
- text = $1
48
- link_rule = $2
49
-
50
- if (link_rule =~ /(.*)\!(.+)/)
51
- method = $1
52
- param = $2
53
-
54
- method = 'default' if method.empty?
55
- # $stderr.puts "Found link rule =>#{method}<= #{method.empty?} =>#{param}<="
56
-
57
- link = $d.course.notesTemplates.method_missing(method, param)
58
- else
59
- link = link_rule
60
- end
61
- # Suppress links if text begins with xx.
62
- text =~ /^xx/ ? '': "(<a target='_blank' href='#{link}'>#{text}</a>)"
63
- end # end gsub
49
+ text = $1
50
+ link_rule = $2
51
+ # $stderr.puts "Processing text #{text} with link rule #{link_rule}"
52
+
53
+ if (link_rule =~ /(.*)\!(.+)/)
54
+ method = $1
55
+ param = $2
56
+
57
+ method = "default" if method.empty?
58
+ # $stderr.puts "Found link rule =>#{method}<= #{method.empty?} =>#{param}<="
59
+
60
+ link = $d.course.notesTemplates.method_missing(method, param)
61
+ else
62
+ link = link_rule
63
+ end
64
64
 
65
+ # Don't provide links to notes if we haven't gone through those notes in lecture yet.
66
+ suppress = text =~ /^xx/ || (text=~ /^td_/ && (rowDate >= Date.today - 3 || Date.today >= end_of_semester))
67
+ text = text.gsub(/^td_/, "")
68
+
69
+ # Suppress links if text begins with xx.
70
+ suppress ? "" : "(<a target='_blank' href='#{link}'>#{text}</a>)"
71
+ end # end gsub
65
72
  end # end if value is string
66
73
  value
67
74
  end
68
75
 
69
76
  def build_rows(worksheet, keys)
77
+ row_date = nil
78
+ end_of_semester = nil
70
79
  # Remove the first (header) row, and any empty rows.
71
80
  # Also, remove any rows after "END"
72
81
  first = true
@@ -75,6 +84,12 @@ module KielcePlugins
75
84
  worksheet.each do |row|
76
85
  done = true if !row.nil? && !row[0].nil? && row[0].value == "END"
77
86
 
87
+ if !row.nil? && !row[0].nil? && row[0].value.is_a?(String) && (row[0].value =~ /^EO(T|S)$/)
88
+ end_of_semester = row[1].value
89
+ $stderr.puts "Found end of semester marker: #{end_of_semester}"
90
+ end
91
+
92
+
78
93
  unless first || row.nil? || done
79
94
  rows << row
80
95
  end
@@ -85,8 +100,9 @@ module KielcePlugins
85
100
  rows.map do |row|
86
101
  row_hash = { original: {} }
87
102
  keys.each_with_index do |item, index|
103
+ row_date = row[index].value if item == :date && !row[index].nil? && !row[index].value.nil?
88
104
  row_hash[:original][item] = row[index].nil? ? nil : row[index].value
89
- row_hash[item] = row[index].nil? ? nil : transform(row[index].value)
105
+ row_hash[item] = row[index].nil? ? nil : transform(row[index].value, row_date, end_of_semester)
90
106
  end
91
107
  row_hash
92
108
  end # end map
@@ -114,7 +130,7 @@ module KielcePlugins
114
130
 
115
131
  # create a new schedule_day Hash
116
132
  schedule_day = {
117
- begin_week: false
133
+ begin_week: false,
118
134
  }
119
135
 
120
136
  unless row[:week].nil?
@@ -128,18 +144,18 @@ module KielcePlugins
128
144
  end
129
145
 
130
146
  # push non-nil values onto the corresponding array
131
- # array_keys.each { |key| schedule_day[key] << row[key] unless row[key].nil? }
132
- array_keys.each do |key|
133
- val = row[key]
134
-
135
- # skip any completely empty cells (they produce a value of nil)
136
- # Replace a single period with a whitespace. (Thus producing an empty cell in the table)
137
- # Similarly, treat cells beginnign with // as a comment and produce an empty cell in the table)
138
- unless row[key].nil?
139
- val = "&nbsp;" if val == '.' || val =~ /^\s*\/\//
140
- schedule_day[key] << val
147
+ # array_keys.each { |key| schedule_day[key] << row[key] unless row[key].nil? }
148
+ array_keys.each do |key|
149
+ val = row[key]
150
+
151
+ # skip any completely empty cells (they produce a value of nil)
152
+ # Replace a single period with a whitespace. (Thus producing an empty cell in the table)
153
+ # Similarly, treat cells beginnign with // as a comment and produce an empty cell in the table)
154
+ unless row[key].nil?
155
+ val = "&nbsp;" if val == "." || val =~ /^\s*\/\//
156
+ schedule_day[key] << val
157
+ end
141
158
  end
142
- end
143
159
 
144
160
  # Look for assignments / due dates and add information to @assignment objects
145
161
  original_milestones = row[:original][:milestones]
@@ -177,19 +193,19 @@ TABLE
177
193
 
178
194
  first = true
179
195
  @schedule_days.each do |schedule_day|
180
- table << '<tr>'
196
+ table << "<tr>"
181
197
 
182
198
  if schedule_day[:begin_week]
183
199
  unless first
184
200
  # Add a blank row of horizontal lines
185
- table << '<td></td><td></td><td></td><td></td><td></td><td></td></tr>'
201
+ table << "<td></td><td></td><td></td><td></td><td></td><td></td></tr>"
186
202
  table << "<tr class='week_end'><td></td><td></td><td></td><td></td><td></td><td></td></tr>"
187
- table << '<tr>'
203
+ table << "<tr>"
188
204
  end
189
205
  first = false
190
206
  week_value = schedule_day[:week]
191
207
  else
192
- week_value = ''
208
+ week_value = ""
193
209
  end
194
210
 
195
211
  table << " <td class='week_column'>#{week_value}</td>"
@@ -274,7 +290,6 @@ PAGE
274
290
  STYLE
275
291
  end
276
292
 
277
-
278
293
  def assignment_list
279
294
  list = <<TABLE
280
295
  <table class='kielceAssignmentTable'>
@@ -285,9 +300,9 @@ STYLE
285
300
  </tr>
286
301
  TABLE
287
302
 
288
- by_date = @assignments.values.reject { |item| item.due.nil? || item.type == 'Lab' }.sort_by { |a| a.due }
303
+ by_date = @assignments.values.reject { |item| item.due.nil? || item.type == "Lab" }.sort_by { |a| a.due }
289
304
  by_date.each do |assignment|
290
- list += ' <tr>'
305
+ list += " <tr>"
291
306
  list += " <td class='kielceAssignmentTable_due'>#{assignment.due.strftime("%a. %-d %b.")}</td>\n"
292
307
  list += " <td class='kielceAssignmentTable_title'>#{assignment.title(:full, true)}</td>\n"
293
308
  list += " <td class='kielceAssignmentTable_details'>#{assignment.details}</td>\n"
@@ -305,10 +320,10 @@ TABLE
305
320
  <th>Details</th>
306
321
  </tr>
307
322
  TABLE
308
- assigned_labs = @assignments.values.select { |item| item.type == 'Lab' && !item.assigned.nil? }
323
+ assigned_labs = @assignments.values.select { |item| item.type == "Lab" && !item.assigned.nil? }
309
324
  by_date = assigned_labs.sort { |a, b| a.assigned <=> b.assigned }
310
325
  by_date.each do |assignment|
311
- list += ' <tr>'
326
+ list += " <tr>"
312
327
  list += " <td class='kielceAssignmentTable_due'>#{assignment.assigned.strftime("%a. %-d %b.")}</td>\n"
313
328
  list += " <td class='kielceAssignmentTable_title'>#{assignment.title(:full, true)}</td>\n"
314
329
  list += " <td class='kielceAssignmentTable_details'>#{assignment.details}</td>\n"
@@ -317,7 +332,7 @@ TABLE
317
332
  list += "</table>\n"
318
333
  list
319
334
  end
320
- end # end Schedule
321
- end # module
335
+ end # end Schedule
336
+ end # module
322
337
  end # end KielcePlugins
323
- #puts Schedule.new(ARGV[0]).timeline_page
338
+ #puts Schedule.new(ARGV[0]).timeline_page
metadata CHANGED
@@ -1,17 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kielce
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.7
4
+ version: 2.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachary Kurmas
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-07-26 00:00:00.000000000 Z
10
+ date: 2026-05-03 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: 'An ERB-based templating engine for generating course documents. '
14
- email:
15
13
  executables:
16
14
  - kielce
17
15
  extensions: []
@@ -31,7 +29,6 @@ homepage: https://github.com/kurmasz/KielceRB
31
29
  licenses:
32
30
  - MIT
33
31
  metadata: {}
34
- post_install_message:
35
32
  rdoc_options: []
36
33
  require_paths:
37
34
  - lib
@@ -46,8 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
43
  - !ruby/object:Gem::Version
47
44
  version: '0'
48
45
  requirements: []
49
- rubygems_version: 3.3.7
50
- signing_key:
46
+ rubygems_version: 3.6.9
51
47
  specification_version: 4
52
48
  summary: An ERB-based templating engine for generating course documents.
53
49
  test_files: []