spirit 0.1.0.pre → 0.1.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,7 +17,7 @@ module Spirit
17
17
  # @param [Hash] opts options for {::Redcarpet}
18
18
  def initialize(source, opts={})
19
19
  opts = MARKDOWN_EXTENSIONS.merge opts
20
- rndr = Render::HTML.new
20
+ rndr = Render::HTML.new(name: opts[:name])
21
21
  @engine = ::Redcarpet::Markdown.new(rndr, opts)
22
22
  @data = case
23
23
  when source.respond_to?(:to_str) then source.to_str
@@ -36,6 +36,7 @@ module Spirit
36
36
  super CONFIGURATION.merge options
37
37
  @nav, @headers = Navigation.new, Headers.new
38
38
  @prob, @img = 0, 0 # indices for Problem #, Figure #
39
+ @name = options.delete(:name) || 'untitled'
39
40
  end
40
41
 
41
42
  # Pygmentizes code blocks.
@@ -104,7 +105,7 @@ module Spirit
104
105
  def problem(yaml)
105
106
  problem = Problem.parse(yaml)
106
107
  Spirit.logger.record :problem, "ID: #{problem.id}"
107
- problem.save! and problem.render(index: @prob += 1)
108
+ problem.save!(@name) and problem.render(index: @prob += 1)
108
109
  rescue RenderError
109
110
  yaml
110
111
  end
@@ -88,7 +88,7 @@ module Spirit
88
88
  # Saves the answer to a file on disk.
89
89
  # @todo TODO should probably show some error message in the preview,
90
90
  # so that the author doesn't have to read the logs.
91
- def save!
91
+ def save!(name)
92
92
  raise RenderError.new('Invalid problem.') unless valid?
93
93
  solution = File.join(Spirit::SOLUTION_DIR, id + Spirit::SOLUTION_EXT)
94
94
  File.open(solution, 'wb+') { |file| Marshal.dump answer, file }
@@ -1,4 +1,4 @@
1
1
  # ~*~ encoding: utf-8 ~*~
2
2
  module Spirit
3
- VERSION = '0.1.0.pre'
3
+ VERSION = '0.1.0.pre.1'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spirit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre
4
+ version: 0.1.0.pre.1
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-19 00:00:00.000000000 Z
12
+ date: 2013-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: haml
@@ -239,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
239
  version: '0'
240
240
  segments:
241
241
  - 0
242
- hash: 4141328948887272079
242
+ hash: 905689092355795232
243
243
  required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  none: false
245
245
  requirements: