puppet-courseware-manager 0.5.1 → 0.5.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
  SHA1:
3
- metadata.gz: 920d9ead0c7f53930949fc216271fd862730d3af
4
- data.tar.gz: eacf4a3bfa5f1f90ff38e5eb1d67a80c660101a3
3
+ metadata.gz: 5eb2df1ef67e6ef21fd53cb49d0fbba4cca60715
4
+ data.tar.gz: 97851ebba09d5ae7db6543c0b6fca90fdd3585f8
5
5
  SHA512:
6
- metadata.gz: cb0b92b90e8221ca981d913a0db22c399baaf7b20b82e7b9970018d2df010ddfc6ce16d7316100596c24e2f9c19493d369a4436085ec762e01f42712bf6884e5
7
- data.tar.gz: 3f17f6a5c3cf8977124686a9de48cefb8837129c6c3f63b54ad42c3ef4e2174415caa7b5829f80a27a33fcbbf018ad0441bf55e07ec866b551e1ea4c0daa5883
6
+ metadata.gz: edb197aa9f1dd9a6aba1461c5effccf5aaa786bcc2f6ec078cc6c6ccef68d698c1ae83507dc41c709c1e82b69ef5f40e17fc94ac213a0f15f33cca09defaa3cb
7
+ data.tar.gz: e4dc9bd3d1a5d9d95be834f71c1335ae7f7d940552290957e0bf8b492c5c1e063c5d2551cf4b5344d2d3a4ceadea171f8030ef5558d6376dd7b6fc8774fa2c20
data/CHANGELOG.txt CHANGED
@@ -1,6 +1,11 @@
1
1
  # Courseware Manager
2
2
  ## Release Notes
3
3
 
4
+ ### v0.5.2
5
+ * Add support for Showoff named sections, making it possible to validate new courses.
6
+ * Add support for packaging more showoff formats.
7
+ * Add support for running headless, so we can generate PDFs in the classroom.
8
+
4
9
  ### v0.5.1
5
10
  * Support modular presentations
6
11
  * Allow watermarked PDF files via metadata in showoff
data/bin/courseware CHANGED
@@ -31,6 +31,14 @@ optparse = OptionParser.new { |opts|
31
31
  cmdlineopts[:presfile] = opt
32
32
  end
33
33
 
34
+ opts.on("-o", "--output DIRECTORY", "Output directory to place generated files in.") do |opt|
35
+ cmdlineopts[:output] = opt
36
+ end
37
+
38
+ opts.on("-n", "--no-cache", "Don't cache template content") do
39
+ cmdlineopts[:nocache] = true
40
+ end
41
+
34
42
  opts.on("-d", "--debug", "Display debugging messages") do
35
43
  cmdlineopts[:debug] = true
36
44
  end
@@ -58,6 +66,7 @@ config ||= YAML.load_file(File.expand_path('../courseware.yaml')) rescue {}
58
66
  config.merge!(cmdlineopts)
59
67
  # finally, apply defaults to any unset options
60
68
  config[:templates] ||= 'git@github.com:puppetlabs/courseware-templates.git'
69
+ config[:nocache] ||= false
61
70
  config[:cachedir] ||= '~/.courseware'
62
71
  config[:stylesheet] ||= 'courseware.css'
63
72
  config[:renderer] ||= :wkhtmltopdf
data/lib/courseware.rb CHANGED
@@ -19,8 +19,8 @@ class Courseware
19
19
  @manager = Courseware::Manager.new(config, @repository)
20
20
  else
21
21
  require 'courseware/dummy'
22
- @repository = Courseware::Dummy.new
23
- @manager = Courseware::Dummy.new
22
+ @repository = Courseware::Dummy.new(config)
23
+ @manager = Courseware::Dummy.new(config)
24
24
  $logger.debug "Running outside a valid git repository."
25
25
  end
26
26
  end
@@ -4,8 +4,10 @@ class Courseware::Cache
4
4
  def initialize(config)
5
5
  @config = config
6
6
 
7
- clone
8
- update
7
+ unless @config[:nocache]
8
+ clone
9
+ update
10
+ end
9
11
  end
10
12
 
11
13
  def clone
@@ -53,7 +53,7 @@ class Courseware::Composer
53
53
 
54
54
  subject ||= Courseware.choose_variant
55
55
  subject = subject.to_s
56
- content = JSON.parse(File.read(subject))
56
+ content = Courseware.parse_showoff(subject)
57
57
  variant = File.basename(subject, '.json')
58
58
  current = @repository.current(@coursename)
59
59
 
@@ -69,13 +69,18 @@ class Courseware::Composer
69
69
  FileUtils.cp subject, "build/#{variant}/showoff.json"
70
70
 
71
71
  content['sections'].each do |section|
72
- path = section['include']
73
- next if path.nil?
72
+ if section.is_a? Hash
73
+ path = section['include']
74
+ else
75
+ path = section
76
+ end
74
77
 
75
78
  dir = File.dirname path
76
79
  FileUtils.mkdir_p "build/#{variant}/#{dir}"
77
80
  FileUtils.cp path, "build/#{variant}/#{path}"
78
81
 
82
+ next unless section.is_a? Hash
83
+
79
84
  files = JSON.parse(File.read(path))
80
85
  files.each do |file|
81
86
  FileUtils.cp "#{dir}/#{file}", "build/#{variant}/#{dir}/#{file}"
@@ -1,4 +1,21 @@
1
1
  class Courseware::Dummy
2
+ attr_reader :coursename, :prefix
3
+
4
+ def initialize(config, repository=nil, generator=nil, printer=nil)
5
+ @config = config
6
+
7
+ showoff = Courseware.parse_showoff(@config[:presfile])
8
+ @coursename = showoff['name']
9
+ @prefix = showoff['name'].gsub(' ', '_')
10
+ @sections = showoff['sections']
11
+ @password = showoff['key']
12
+ @current = showoff['courseware_release']
13
+ end
14
+
15
+ def current(prefix)
16
+ @current
17
+ end
18
+
2
19
  def method_missing(meth, *args, &block)
3
20
  raise "Cannot call #{meth} without a working courseware repository"
4
21
  end
@@ -32,7 +32,8 @@ class Courseware::Manager
32
32
  sections = @sections.dup
33
33
 
34
34
  # This seems backwards, but we do it this way to get a case sensitive match
35
- Dir.glob('**/*.md') do |file|
35
+ # http://stackoverflow.com/questions/357754/can-i-traverse-symlinked-directories-in-ruby-with-a-glob -- Baby jesus is crying.
36
+ Dir.glob("**{,/*/**}/*.md") do |file|
36
37
  sections.delete(file)
37
38
  end
38
39
  return if sections.empty?
@@ -3,9 +3,10 @@ require 'rubygems'
3
3
  class Courseware::Repository
4
4
 
5
5
  def initialize(config)
6
- raise 'This is not a courseware repository' unless Courseware::Repository.repository?
7
6
  @config = config
7
+ return if @config[:nocache]
8
8
 
9
+ raise 'This is not a courseware repository' unless Courseware::Repository.repository?
9
10
  configure_courseware
10
11
  end
11
12
 
@@ -90,12 +90,20 @@ class Courseware
90
90
  # TODO: I'm not happy with this being here, but I don't see a better place for it just now
91
91
  def self.parse_showoff(filename)
92
92
  showoff = JSON.parse(File.read(filename))
93
- sections = showoff['sections'].map do |entry|
94
- next entry if entry.is_a? String
95
- next nil unless entry.is_a? Hash
96
- next nil unless entry.include? 'include'
93
+ sections = showoff['sections'].map do |entry, section|
94
+ next entry if entry.is_a? String and section.nil?
95
+
96
+ if entry.is_a? Hash
97
+ file = entry['include']
98
+ else
99
+ file = section
100
+ end
101
+
102
+ unless file
103
+ puts "Malformed entry: #{entry.inspect} - #{section.inspect}"
104
+ next nil
105
+ end
97
106
 
98
- file = entry['include']
99
107
  path = File.dirname(file)
100
108
  data = JSON.parse(File.read(file))
101
109
 
@@ -1,4 +1,4 @@
1
1
  class Courseware
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
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.5.1
4
+ version: 0.5.2
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-02-10 00:00:00.000000000 Z
11
+ date: 2017-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mdl
@@ -65,21 +65,21 @@ extensions: []
65
65
  extra_rdoc_files: []
66
66
  files:
67
67
  - CHANGELOG.txt
68
- - README.txt
69
68
  - LICENSE
69
+ - README.txt
70
70
  - bin/courseware
71
+ - lib/courseware.rb
71
72
  - lib/courseware/cache.rb
72
73
  - lib/courseware/composer.rb
73
74
  - lib/courseware/dummy.rb
74
75
  - lib/courseware/generator.rb
75
76
  - lib/courseware/help.rb
76
- - lib/courseware/manager/validators.rb
77
77
  - lib/courseware/manager.rb
78
+ - lib/courseware/manager/validators.rb
78
79
  - lib/courseware/printer.rb
79
80
  - lib/courseware/repository.rb
80
81
  - lib/courseware/utils.rb
81
82
  - lib/courseware/version.rb
82
- - lib/courseware.rb
83
83
  homepage: http://github.com/puppetlabs/courseware-manager
84
84
  licenses:
85
85
  - Apache-2.0
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  requirements: []
102
102
  rubyforge_project:
103
- rubygems_version: 2.0.14.1
103
+ rubygems_version: 2.6.10
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: Manage the development lifecycle of Puppet courseware. Not for general consumption.