puppet-courseware-manager 0.6.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36a9e74fc4e32ff8eba79b73b7fda4eee3e6b6d8
4
- data.tar.gz: 6896d7dad5206c44fdef7e251e0f35b132f2a2e8
3
+ metadata.gz: 437863d336c96a49cb06d1408f8adeb5596dfc08
4
+ data.tar.gz: 6c372f7ec27c63a6e3986c44a6bc38466effcf85
5
5
  SHA512:
6
- metadata.gz: f088969a94f5d90a9a9954bc301731a51f0d40e8e05493a3964cedb61ed67730bb0da0ebd7557d0ab84073d64807eadf6ce84bee4bf902c05d9a6cc1fb493c23
7
- data.tar.gz: e75e95efd177e911c26288e386b0fbaf532dd0cfa497c5436778916fdbac88d1125d9e77c1d99f158c78ce353e75cc7d6285c46a92562d2e558847517da38e69
6
+ metadata.gz: 0e6f9934a4e590a0504491f52fdd10e142da58e67a6b7327fb98c6302b8da75aacde5c1dfc426eb460c9de21b2271672ece630aa1c5a16a3c38c3be359a11f38
7
+ data.tar.gz: 56dad38430244340e114f54df83e1aad599858dda115cafb6a58c23d78a4e48780154f4e22726b84a3ca3667f63159b2557f485789d307fe89b517dc5870ae90
data/CHANGELOG.txt CHANGED
@@ -1,6 +1,13 @@
1
1
  # Courseware Manager
2
2
  ## Release Notes
3
3
 
4
+ ### v0.6.1
5
+ * Generate release notes for shared content
6
+ * Allow different schemes for different git remotes
7
+ * More robust printing options, such as key/id CLI args
8
+ * Catch empty PDF files when printing shared content
9
+
10
+
4
11
  ### v0.6.0
5
12
  * Can now work with topic directories.
6
13
  * Knows how to identify obsolete slides and images across all courses.
data/bin/courseware CHANGED
@@ -39,6 +39,14 @@ optparse = OptionParser.new { |opts|
39
39
  cmdlineopts[:nocache] = true
40
40
  end
41
41
 
42
+ opts.on("-e ID", "--event-id ID", "Event ID to use for generated PDF files") do |opt|
43
+ cmdlineopts[:event_id] = opt
44
+ end
45
+
46
+ opts.on("-k KEY", "--key KEY", "Key to encrypt PDF files with") do |opt|
47
+ cmdlineopts[:key] = opt
48
+ end
49
+
42
50
  opts.on("-d", "--debug", "Display debugging messages") do
43
51
  cmdlineopts[:debug] = true
44
52
  end
@@ -16,13 +16,23 @@ class Courseware::Printer
16
16
 
17
17
  if @config[:pdf][:watermark]
18
18
  showoff = Courseware.parse_showoff(@config[:presfile])
19
+ default = @event_id[/-?(\w*)$/, 1] rescue nil
19
20
 
20
- @event_id = showoff['event_id'] || Courseware.question('Enter the Event ID:')
21
- @password = showoff['key'] || Courseware.question('Enter desired password:', (@event_id[/-?(\w*)$/, 1] rescue nil))
21
+ @event_id = @config[:event_id] || showoff['event_id'] || Courseware.question('Enter the Event ID:')
22
+ @password = @config[:key] || showoff['key'] || Courseware.question('Enter desired password:', default)
22
23
 
23
24
  if @config[:nocache]
24
- @watermark_style = File.join('_support', 'watermark.css')
25
- @watermark_pdf = File.join('_support', 'watermark.pdf')
25
+ # Find the '_support' directory, up to three levels up
26
+ # This allows some flexibility in how the courseware repository is laid out
27
+ path = '_support'
28
+ 3.times do
29
+ break if File.exist?(path)
30
+ path = File.join('..', path)
31
+ end
32
+ raise "No support files found" unless File.directory?(path)
33
+
34
+ @watermark_style = File.join(path, 'watermark.css')
35
+ @watermark_pdf = File.join(path, 'watermark.pdf')
26
36
  else
27
37
  @watermark_style = File.join(@config[:cachedir], 'templates', 'watermark.css')
28
38
  @watermark_pdf = File.join(@config[:cachedir], 'templates', 'watermark.pdf')
@@ -178,7 +188,8 @@ class Courseware::Printer
178
188
  system(*command.flatten)
179
189
  raise 'Error generating PDF files' unless $?.success?
180
190
 
181
- if `pdftk #{output} dump_data | grep NumberOfPages`.chomp == 'NumberOfPages: 1'
191
+ pagecount = `pdftk #{output} dump_data`.each_line.select {|l| l.match /NumberOfPages/ }.first.split.last.to_i rescue nil
192
+ if [1, 2].include? pagecount
182
193
  puts "#{output} is empty; aborting and cleaning up."
183
194
  FileUtils.rm(output)
184
195
  return
@@ -105,10 +105,29 @@ class Courseware::Repository
105
105
  end
106
106
 
107
107
  def releasenotes(last, version)
108
+ # get used files from showoff and combine them into a single array
109
+ used = JSON.parse(`showoff info --json`).values.reduce(:+)
110
+ logs = `git log --name-only --no-merges --pretty="format:* (%h) %s [%aN]" #{last}..HEAD`
111
+ curr = nil
112
+ keep = []
113
+
114
+ # sanitize
115
+ used.map! {|i| i.sub('_shared', '_content') }
116
+ used.map! {|i| i.sub('_images/shared', '_images') }
117
+
118
+ # now iterate through and select log entries that change files this presentation uses
119
+ logs.each_line do |line|
120
+ if (curr.nil? or line.start_with? '*')
121
+ curr = line
122
+ else
123
+ keep << curr if used.include? line.strip
124
+ end
125
+ end
126
+
108
127
  str = "### #{version}\n"
109
128
  str << "{{{Please summarize the release here}}}\n"
110
129
  str << "\n"
111
- str << `git log --no-merges --pretty="format:* (%h) %s [%aN]" #{last}..HEAD -- .`
130
+ str << keep.uniq.join
112
131
  str
113
132
  end
114
133
 
@@ -126,25 +145,24 @@ class Courseware::Repository
126
145
  private
127
146
 
128
147
  def configure_courseware
129
- courseware = "#{@config[:github][:public]}/#{@config[:github][:repository]}"
130
- upstream = "#{@config[:github][:development]}/#{@config[:github][:repository]}"
148
+ check_remote('courseware', "#{@config[:github][:public]}/#{@config[:github][:repository]}")
149
+ check_remote('upstream', "#{@config[:github][:development]}/#{@config[:github][:repository]}")
150
+ end
131
151
 
132
- # Check the origin to see which scheme we should use
133
- origin = `git config --get remote.origin.url`.chomp
134
- if origin =~ /^(git@|https:\/\/)github.com[:\/].*\/#{@config[:github][:repository]}(?:-.*)?(?:.git)?$/
152
+ def check_remote(remote, url)
153
+ existing = `git config --get remote.#{remote}.url`.chomp
154
+ if existing =~ /^(git@|https:\/\/)github.com[:\/].*\/#{@config[:github][:repository]}(?:-.*)?(?:.git)?$/
135
155
  case $1
136
156
  when 'git@'
137
- ensure_remote('courseware', "git@github.com:#{courseware}.git")
138
- ensure_remote('upstream', "git@github.com:#{upstream}.git")
157
+ ensure_remote(remote, "git@github.com:#{url}.git")
139
158
  when 'https://'
140
- ensure_remote('courseware', "https://github.com/#{courseware}.git")
141
- ensure_remote('upstream', "https://github.com/#{upstream}.git")
159
+ ensure_remote(remote, "https://github.com/#{url}.git")
142
160
  end
143
- elsif origin.empty?
161
+ elsif existing.empty?
144
162
  $logger.warn 'Your origin remote is not set properly.'
145
163
  $logger.warn 'Generating PDF files and other local operations will work properly, but many repository actions will fail.'
146
164
  else
147
- raise "Your origin (#{origin}) does not appear to be configured correctly."
165
+ raise "Your remote (#{existing}) does not appear to be configured correctly."
148
166
  end
149
167
  end
150
168
 
@@ -1,4 +1,4 @@
1
1
  class Courseware
2
- VERSION = '0.6.0'
2
+ VERSION = '0.6.1'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-courseware-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Ford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-06 00:00:00.000000000 Z
11
+ date: 2017-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mdl