magic_reveal 2.4.0.2 → 2.4.0.3

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: ef3ebbd0e2d2b2310a04a204fa9d180b256bc2a6
4
- data.tar.gz: 83ca908557fa7b2444abd666d86f64fa674ab0af
3
+ metadata.gz: 2b53a440c6c17843ed3cbb674c89b63d79013280
4
+ data.tar.gz: 51b923b1b1ec22de5cbcd0687cceeac3baaec5a1
5
5
  SHA512:
6
- metadata.gz: 9f8f146b2ae5377270f5a5a3bdafb798e99860d92f90b18eb466a98bbaa6070e38b91527c4eb3a56019277077be64455fc961c6d73c8b441935e4abaa8dd6a01
7
- data.tar.gz: 65e1377de6d882644bf01d8b6708a585cec9970bb0a8f520cb34e1f8d716235943091a15cb352d8a2c5cfe63d27288afa9212f552092e4e08769e0ce9f206d32
6
+ metadata.gz: a19868412da70365a0ebb6ba483ffd5abf5b534b07f02d1a48e5e54b7efa91e7e4ca4b3f043cda4027749223544bf02fc4dd4f13541414ab8e08727da72acb62
7
+ data.tar.gz: 473620ab43a5a622a5940e112ccd6cd6b3f18f21612181efb041897f68a799351fdeb29d6111495a3a70464e15559f21e446cdd7bc45ccbcbfbe1d2b7ffd3f1e
data/Guardfile CHANGED
@@ -1,4 +1,4 @@
1
- guard :rspec, :cli => "--color --order default --format progress" do
1
+ guard :rspec, :cli => "--color --order default --format doc" do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
3
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
4
  watch('spec/spec_helper.rb') { "spec" }
@@ -2,6 +2,7 @@ require 'redcarpet'
2
2
  require 'sinatra/base'
3
3
  require 'magic_reveal/slide_renderer'
4
4
  require 'magic_reveal/index_libber'
5
+ require 'magic_reveal/project_config'
5
6
 
6
7
  begin
7
8
  require 'better_errors'
@@ -21,24 +22,25 @@ module MagicReveal
21
22
 
22
23
  set :public_folder, Dir.getwd
23
24
 
24
- helpers do
25
- def markdown
26
- @markdown ||= SlideRenderer.markdown_renderer
27
- end
25
+ get '/' do
26
+ slides = Pathname.pwd + 'slides.md'
27
+ markdown = SlideRenderer.markdown_renderer
28
+ libber = IndexLibber.new
28
29
 
29
- def index_html_path
30
- @index_html_path ||= Pathname.pwd + 'reveal.js' + 'index.html'
31
- end
32
- end
30
+ libber.author = Identifier.name
31
+ libber.slides = markdown.render slides.read
32
+
33
+ config = ProjectConfig.new(Pathname.pwd + 'config.json')
34
+ libber.add_github_forkme config.json['github'] if config.json.key? 'github'
33
35
 
34
- get '/' do
35
- slides = markdown.render File.read('slides.md')
36
- libber = MagicReveal::IndexLibber.new index_html_path.read
37
- libber.update_author MagicReveal::Identifier.name
38
- libber.update_description "A Magical Presentiation"
39
- libber.update_slides slides
40
36
  libber.to_s
41
37
  end
42
38
 
39
+ get '/index.js' do
40
+ content_type :js
41
+ config = ProjectConfig.new(Pathname.pwd + 'config.json')
42
+ config.to_s
43
+ end
44
+
43
45
  end
44
46
  end
@@ -4,6 +4,7 @@ require 'magic_reveal/cli/options'
4
4
  require 'magic_reveal/creator'
5
5
  require 'magic_reveal/slide_renderer'
6
6
  require 'magic_reveal/index_libber'
7
+ require 'magic_reveal/project_config'
7
8
 
8
9
  module MagicReveal
9
10
  class Cli
@@ -49,17 +50,20 @@ module MagicReveal
49
50
 
50
51
  def create_static
51
52
  slides = Pathname.pwd + 'slides.md'
52
- reveal_js_html = Pathname.pwd + 'reveal.js' + 'index.html'
53
- index_html = Pathname.pwd + 'index.html'
54
-
55
53
  markdown = SlideRenderer.markdown_renderer
56
- slides = markdown.render slides.read
57
- libber = IndexLibber.new reveal_js_html.read
58
- libber.update_author Identifier.name
59
- libber.update_description "A Magical Presentiation"
60
- libber.update_slides slides
54
+ libber = IndexLibber.new
55
+ config = ProjectConfig.new(Pathname.pwd + 'config.json')
56
+
57
+ libber.author = Identifier.name
58
+ libber.slides = markdown.render slides.read
59
+
60
+ libber.add_github_forkme config.json['github'] if config.json.key? 'github'
61
+
62
+ index_html = Pathname.pwd + 'index.html'
63
+ index_html.open('w') { |f| f.print libber }
61
64
 
62
- index_html.open('w') { |f| f.print libber.to_s }
65
+ js_file = Pathname.pwd + 'index.js'
66
+ js_file.open('w') { |f| f.print config.to_js }
63
67
  end
64
68
 
65
69
  def avenge_programmer
@@ -3,6 +3,7 @@ require 'pathname'
3
3
 
4
4
  require 'magic_reveal/version'
5
5
  require 'magic_reveal/reveal_js_fetcher'
6
+ require 'magic_reveal/project_config'
6
7
 
7
8
  module MagicReveal
8
9
  class Creator
@@ -27,26 +28,21 @@ module MagicReveal
27
28
 
28
29
  def create_project(project)
29
30
  top_dir = directory + project
30
- reveal_dir = top_dir + 'reveal.js'
31
31
  gemfile = top_dir + 'Gemfile'
32
32
 
33
33
  top_dir.mkdir
34
34
 
35
- reveal_js_fetcher.save_to(reveal_dir)
35
+ reveal_js_fetcher.save_important_parts_to(top_dir)
36
36
 
37
37
  FileUtils.copy_file template_slides.to_s, (top_dir + 'slides.md').to_s
38
38
  FileUtils.copy_file template_config_ru.to_s, (top_dir + 'config.ru').to_s
39
+ FileUtils.copy_file ProjectConfig::DEFAULT_TEMPLATE.to_s, (top_dir + 'config.json').to_s
39
40
  gemfile.open('w') do |f|
40
41
  f.puts "source 'https://rubygems.org'"
41
42
  f.puts
42
43
  f.puts "gem 'magic_reveal', '~> #{VERSION}'"
43
44
  end
44
45
 
45
- reveal_dir.children.each do |subdir|
46
- next unless subdir.directory?
47
- (top_dir + subdir.basename).make_symlink(subdir.relative_path_from(top_dir))
48
- end
49
-
50
46
  Dir.chdir(top_dir.to_s) do
51
47
  system 'bundle install'
52
48
  end
@@ -7,29 +7,79 @@ module MagicReveal
7
7
  class IndexLibber
8
8
  attr_reader :html
9
9
 
10
- def initialize html_text
10
+ def initialize html_text=nil
11
+ if html_text.nil?
12
+ template_path = Pathname.new(__FILE__).dirname + 'template.html'
13
+ html_text = template_path.read
14
+ end
11
15
  @html = Nokogiri::HTML(html_text, &:noblanks)
16
+ # Add autogenerated comment
17
+ #html.children.first.add_previous_sibling(Nokogiri::XML::Comment.new("Generated at #{Time.now}"))
18
+ html.root.children.first.before Nokogiri::XML::Comment.new(html, "Generated at #{Time.now}")
12
19
  end
13
20
 
14
- def update_author author
15
- if meta = html.at_xpath("//meta[@name='author']")
16
- meta.set_attribute('content', author)
21
+ def set_meta name, content
22
+ meta = html.at_css("meta[@name='#{name}']")
23
+ if !meta
24
+ meta = Nokogiri::XML::Node.new('meta', html)
25
+ meta[:name] = name
26
+
27
+ parent = (head = html.at('head')) ? head : html.root
28
+ parent << meta
17
29
  end
30
+ meta[:content] = content
18
31
  end
19
32
 
20
- def update_description description
21
- if meta = html.at_xpath("//meta[@name='description']")
22
- meta.set_attribute('content', description)
23
- end
33
+ def title= title
34
+ html.title = title
35
+ end
36
+
37
+ def author= author
38
+ set_meta 'author', author
39
+ end
40
+
41
+ def description= description
42
+ set_meta 'description', description
24
43
  end
25
44
 
26
- def update_slides slides_text
27
- slides = Nokogiri::HTML(slides_text).css('section')
28
- if container = html.at_css('div.reveal div.slides')
29
- container.children = slides
45
+ def theme= theme
46
+ # <link rel="stylesheet" href="css/theme/default.css" id="theme">
47
+ node = html.at_css("link#theme")
48
+ if !node
49
+ node = Nokogiri::XML::Node.new('link', html)
50
+ node[:id] = 'theme'
51
+ node[:rel] = 'stylesheet'
52
+
53
+ parent = (head = html.at('head')) ? head : html.root
54
+ parent << node
30
55
  end
56
+ node[:href] = "css/theme/#{theme}.css"
57
+ end
58
+
59
+ def slides= text
60
+ slides = Nokogiri::HTML.fragment(text).children
61
+ container = html.at_css('div.reveal div.slides')
62
+ container.children = slides
31
63
  headers = slides.css('h1', 'h2', 'h3', 'h4', 'h5', 'h6')
32
- html.title = headers.first.text unless headers.nil? || headers.empty?
64
+ self.title = headers.first.text unless headers.nil? || headers.empty?
65
+ end
66
+
67
+ def add_github_forkme project
68
+ a = Nokogiri::XML::Node.new('a', html)
69
+ a[:class] = 'fork-me'
70
+ a[:style] = 'display: none;'
71
+ a[:href] = "https://github.com/#{project}"
72
+ img = Nokogiri::XML::Node.new('img', html)
73
+ img[:style] = "position: absolute; top: 0; right: 0; border: 0;"
74
+ img[:src]="https://a248.e.akamai.net/camo.github.com/e6bef7a091f5f3138b8cd40bc3e114258dd68ddf/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67"
75
+ img[:alt] = "Fork me on GitHub"
76
+ script = Nokogiri::XML::Node.new('script', html)
77
+ script.content = "if( !navigator.userAgent.match( /iphone|ipod|android|ipad|blackberry/gi ) && !!document.querySelector ) { document.querySelector('.fork-me' ).style.display = 'block'; }"
78
+
79
+ parent = (body = html.at('body')) ? body : html.root
80
+ parent << a
81
+ a << img
82
+ parent << script
33
83
  end
34
84
 
35
85
  def to_s
@@ -0,0 +1,49 @@
1
+ require 'pathname'
2
+ require 'json'
3
+
4
+ module MagicReveal
5
+ class ProjectConfig
6
+ DEFAULT_TEMPLATE = File.expand_path('../template-config.json', __FILE__)
7
+ attr_reader :json
8
+
9
+ def initialize io_or_path
10
+ io = io_or_path.respond_to?(:read) ? io_or_path : Pathname.new(io_or_path)
11
+ @json = JSON::load(io.read)
12
+ end
13
+
14
+ def dependencies
15
+ out = []
16
+ # you always want this
17
+ out << '{ src: "lib/js/classList.js", condition: function() { return !document.body.classList; } }'
18
+
19
+ if json['plugins'].include? 'highlight'
20
+ out << '{ src: "plugin/highlight/highlight.js", async: true, callback: function() { hljs.initHighlightingOnLoad(); } }'
21
+ end
22
+ if json['plugins'].include? 'zoom'
23
+ out << '{ src: "plugin/zoom-js/zoom.js", async: true, condition: function() { return !!document.body.classList; } }'
24
+ end
25
+ if json['plugins'].include? 'notes'
26
+ out << '{ src: "plugin/notes/notes.js", async: true, condition: function() { return !!document.body.classList; } }'
27
+ end
28
+
29
+ "\"dependencies\": [\n#{out.join(",\n")}\n]"
30
+ end
31
+
32
+ def to_js
33
+ var = []
34
+ keys = json.keys.reject { |k| ['dependencies', 'github'].include?(k) }
35
+ keys.each do |key|
36
+ value = json[key]
37
+ var << " #{key}: #{value.to_json}"
38
+ end
39
+
40
+ out = []
41
+ out << "/* Generated at #{Time.now} */"
42
+ out << "var config = {"
43
+ out << "#{var.join(",\n")},\n#{dependencies}"
44
+ out << "\n};"
45
+ out << "Reveal.initialize(config);"
46
+ out.join("\n")
47
+ end
48
+ end
49
+ end
@@ -1,3 +1,4 @@
1
+ require 'fileutils'
1
2
  require 'magic_reveal/version'
2
3
  require 'magic_reveal/conductor'
3
4
 
@@ -27,5 +28,18 @@ module MagicReveal
27
28
  conductor.unpack(zipfile, reveal_dir)
28
29
  end
29
30
  end
31
+
32
+ def save_important_parts_to(reveal_dir)
33
+ reveal_dir = Pathname.new reveal_dir
34
+ reveal_dir.mkdir unless reveal_dir.exist?
35
+
36
+ Dir.mktmpdir do |tmpdir|
37
+ tmp_reveal_dir = Pathname(tmpdir) + 'reveal.js'
38
+ save_to(tmp_reveal_dir.to_s)
39
+ tmp_reveal_dir.children.select(&:directory?).each do |dir|
40
+ FileUtils.cp_r(dir.to_s, (reveal_dir + dir.basename).to_s)
41
+ end
42
+ end
43
+ end
30
44
  end
31
45
  end
@@ -47,7 +47,7 @@ module MagicReveal
47
47
  if code =~ %r{\A\s*@@source\s*=\s*(.*)\s*\Z}
48
48
  File.read($1)
49
49
  else
50
- code
50
+ code.sub(%r{\A\s*}, '').sub(%r{\s*\Z}, '')
51
51
  end
52
52
  end
53
53
 
@@ -0,0 +1,14 @@
1
+ {
2
+ "controls": true,
3
+ "progress": true,
4
+ "history": true,
5
+ "overview": true,
6
+ "center": true,
7
+ "theme": "default",
8
+ "transition": "default",
9
+ "plugins": [
10
+ "highlight",
11
+ "notes",
12
+ "zoom"
13
+ ]
14
+ }
@@ -0,0 +1,35 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>A Magical presentation</title>
6
+
7
+ <meta name="apple-mobile-web-app-capable" content="yes" />
8
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
9
+
10
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
11
+
12
+ <link rel="stylesheet" href="css/reveal.min.css">
13
+ <link rel="stylesheet" href="css/theme/default.css" id="theme">
14
+
15
+ <!-- For syntax highlighting -->
16
+ <link rel="stylesheet" href="lib/css/zenburn.css">
17
+
18
+ <!-- If the query includes 'print-pdf', use the PDF print sheet -->
19
+ <script>
20
+ document.write( '<link rel="stylesheet" href="css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
21
+ </script>
22
+
23
+ <!--[if lt IE 9]>
24
+ <script src="lib/js/html5shiv.js"></script>
25
+ <![endif]-->
26
+ </head>
27
+
28
+ <body>
29
+ <div class="reveal"> <div class="slides"></div> </div>
30
+
31
+ <script src="lib/js/head.min.js"></script>
32
+ <script src="js/reveal.min.js"></script>
33
+ <script src="index.js"></script>
34
+ </body>
35
+ </html>
@@ -1,4 +1,4 @@
1
1
  module MagicReveal
2
2
  REVEAL_JS_VERSION = "2.4.0"
3
- VERSION = "#{REVEAL_JS_VERSION}.2"
3
+ VERSION = "#{REVEAL_JS_VERSION}.3"
4
4
  end
data/magic-reveal.gemspec CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency "rake"
31
31
  spec.add_development_dependency "guard-rspec", "~> 3.0"
32
32
  spec.add_development_dependency "rspec", "~> 2.14"
33
+ spec.add_development_dependency "faker"
33
34
  spec.add_development_dependency "coveralls", "~> 0.6"
34
35
  spec.add_development_dependency "better_errors"
35
36
  spec.add_development_dependency "binding_of_caller"
@@ -30,8 +30,8 @@ describe MagicReveal::Creator do
30
30
  it "fetches and saves reveal.js" do
31
31
  subject.create_project(project)
32
32
  expect(fetcher).
33
- to have_received(:save_to).
34
- with(@tmpdir + project + 'reveal.js')
33
+ to have_received(:save_important_parts_to).
34
+ with(@tmpdir + project)
35
35
  end
36
36
 
37
37
  it "copies the template_slides" do
@@ -3,46 +3,95 @@ require 'magic_reveal/index_libber'
3
3
 
4
4
  describe MagicReveal::IndexLibber do
5
5
  subject { described_class.new html_text }
6
+ let(:html_text) { nil }
6
7
 
7
- describe ".update_author" do
8
- let(:html_text) { '<meta name="author" content="Hakim El Hattab">' }
8
+ describe ".set_meta" do
9
+ shared_examples "it is passed a name and content" do
10
+ let(:name) { "name#{rand 99}" }
11
+ let(:content) { "any old content ###{rand 99}" }
9
12
 
10
- it "replaces the author" do
11
- author = "Joe Cool #{rand 99}"
12
- subject.update_author author
13
- expect(subject.to_s).to match %r{content=.#{Regexp.quote author}.}
13
+ it "creates the node" do
14
+ subject.set_meta name, content
15
+
16
+ node = subject.html.at_css("meta[@name=#{name}]")
17
+ expect(node).to_not be_nil
18
+
19
+ content_attr = node[:content]
20
+ expect(content_attr).to eq(content)
21
+ end
22
+ end
23
+
24
+ context "with a html > meta node" do
25
+ let(:html_text) { "<!DOCTYPE html><meta name=\"#{name}\" content=\"#{content}\"><p>text" }
26
+
27
+ it_behaves_like "it is passed a name and content"
28
+ end
29
+
30
+ context "with a html > head > meta node" do
31
+ let(:html_text) { "<!DOCTYPE html><head><meta name=\"#{name}\" content=\"#{content}\"></head><p>text" }
32
+
33
+ it_behaves_like "it is passed a name and content"
34
+ end
35
+
36
+ context "without a meta node" do
37
+ let(:html_text) { '<!DOCTYPE html><p>text' }
38
+
39
+ it_behaves_like "it is passed a name and content"
14
40
  end
15
41
  end
16
42
 
17
- describe ".update_description" do
18
- let(:html_text) { '<meta name="description" content="A framework for easily creating beautiful presentations using HTML">' }
43
+ describe ".author=" do
44
+ it "calls set_meta" do
45
+ author = Faker::Name.name
46
+ subject.should_receive(:set_meta).with('author', author)
47
+ subject.author = author
48
+ end
49
+ end
19
50
 
20
- it "replaces the description" do
21
- description = "#{rand 99} luft balloons"
22
- subject.update_description description
23
- expect(subject.html.at('meta').get_attribute('content')).to eq(description)
51
+ describe ".description=" do
52
+ it "calls set_meta" do
53
+ description = Faker::Lorem.paragraph
54
+ subject.should_receive(:set_meta).with('description', description)
55
+ subject.description = description
24
56
  end
25
57
  end
26
58
 
27
- describe ".update_slides" do
28
- let(:slides) { '<section><h2>life with Joe</h2><p>&hellip;is good</section>' * 2 }
29
- let(:html_text) { '<!DOCTYPE html><title>bogus</title><div class="reveal"><div class="slides"><section>text</section></div></div>' }
59
+ describe ".slides=" do
60
+ let(:title) { Faker::Lorem.sentence }
61
+ let(:paragraph) { Faker::Lorem.paragraph }
62
+ let(:slides) { "<section><h2>#{title}</h2><p>#{paragraph}</section>" * 2 }
30
63
 
31
64
  it "inserts the slides" do
32
- subject.update_slides slides
33
- expect(subject.to_s).to include('life with Joe')
65
+ subject.slides = slides
66
+ expect(subject.html.at_css('h2').text).to eq(title)
67
+ expect(subject.html.at_css('p').text).to eq(paragraph)
34
68
  end
35
69
 
36
70
  it "sets the title from the first Hx item" do
37
- subject.update_slides slides
38
- expect(subject.html.at_css('title').text).to eq('life with Joe')
71
+ subject.slides = slides
72
+ expect(subject.html.at_css('title').text).to eq(title)
39
73
  end
40
74
  end
41
75
 
42
- context "with random html" do
43
- let(:html_text) { "<!DOCTYPE html>\n<body>\n<p>text here\n</body>" }
76
+ describe ".theme=" do
77
+ let(:theme) { Faker::Name.first_name }
44
78
 
45
- its(:to_s) { should match %r{<body>\s*<p>text here\s*</p>\s*</body>} }
46
- its(:to_s) { should be_kind_of(String) }
79
+ it "sets the theme node" do
80
+ subject.theme = theme
81
+ expect(subject.html.at_css('#theme')[:href]).to match(%r{/#{theme}\.css\Z})
82
+ end
83
+
84
+ context "with an empty doc" do
85
+ let(:html_text) { "<!DOCTYPE html>text" }
86
+
87
+ it "handles creating a new link#theme node" do
88
+ subject.theme = theme
89
+ link = subject.html.at_css('link')
90
+ expect(link).to_not be_nil
91
+ expect(link[:id]).to eq('theme')
92
+ expect(link[:rel]).to eq('stylesheet')
93
+ expect(link[:href]).to match(%r{/#{theme}\.css\Z})
94
+ end
95
+ end
47
96
  end
48
97
  end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+ require 'magic_reveal/project_config'
3
+
4
+ describe MagicReveal::ProjectConfig do
5
+ subject { described_class.new io }
6
+ let(:io) { MagicReveal::ProjectConfig::DEFAULT_TEMPLATE }
7
+ let(:data_ruby) { { "random" => rand(99) }.to_json }
8
+ let(:data_json) { data_ruby.to_json }
9
+
10
+ describe "#new" do
11
+ it "calls io_or_path.read" do
12
+ io.should_receive(:read).with()
13
+ subject
14
+ end
15
+
16
+ context "with a string" do
17
+ it "converts strings to Pathname" do
18
+ pio = Pathname.new(io)
19
+ Pathname.should_receive(:new).with(io).and_return(pio)
20
+ subject
21
+ end
22
+ end
23
+ end
24
+
25
+ describe ".dependencies" do
26
+ it "should look like the example" do
27
+ example = <<-EOF
28
+ "dependencies": [
29
+ { src: "lib/js/classList.js", condition: function() { return !document.body.classList; } },
30
+ { src: "plugin/highlight/highlight.js", async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
31
+ { src: "plugin/zoom-js/zoom.js", async: true, condition: function() { return !!document.body.classList; } },
32
+ { src: "plugin/notes/notes.js", async: true, condition: function() { return !!document.body.classList; } }
33
+ ]
34
+ EOF
35
+ example.gsub!(%r{^\s*}, '').chomp!
36
+ subject.dependencies.gsub(%r{^\s*}, '').should eq(example)
37
+ end
38
+ end
39
+
40
+ describe ".to_js" do
41
+ it "returns a string" do
42
+ expect(subject.to_js).to be_kind_of(String)
43
+ end
44
+ end
45
+ end
@@ -99,6 +99,10 @@ describe MagicReveal::SlideRenderer do
99
99
  expect(subject.block_code('whatever', nil)).
100
100
  to match(%r{</code></pre>})
101
101
  end
102
+
103
+ it "doesn't add whitespace after code and before </code>" do
104
+ expect(subject.block_code('mouse', nil)).to match(%r{mouse</code>})
105
+ end
102
106
  end
103
107
 
104
108
  describe "prepare_code" do
@@ -119,6 +123,16 @@ describe MagicReveal::SlideRenderer do
119
123
  text = "#{rand 99} luft balloons."
120
124
  expect(subject.prepare_code text).to eq(text)
121
125
  end
126
+
127
+ it "strips leading whitespace" do
128
+ expect(subject.prepare_code " \t\nmouse").
129
+ to eq('mouse')
130
+ end
131
+
132
+ it "strips trailing whitespace" do
133
+ expect(subject.prepare_code "mouse\n\t ").
134
+ to eq('mouse')
135
+ end
122
136
  end
123
137
  end
124
138
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
  require 'pathname'
3
+ require 'faker'
3
4
 
4
5
  EXAMPLE_DATA = Pathname.new(__FILE__).dirname + 'data'
5
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magic_reveal
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0.2
4
+ version: 2.4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Höltje
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-15 00:00:00.000000000 Z
11
+ date: 2013-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ~>
137
137
  - !ruby/object:Gem::Version
138
138
  version: '2.14'
139
+ - !ruby/object:Gem::Dependency
140
+ name: faker
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: coveralls
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -273,9 +287,12 @@ files:
273
287
  - lib/magic_reveal/creator.rb
274
288
  - lib/magic_reveal/identifier.rb
275
289
  - lib/magic_reveal/index_libber.rb
290
+ - lib/magic_reveal/project_config.rb
276
291
  - lib/magic_reveal/reveal_js_fetcher.rb
277
292
  - lib/magic_reveal/slide_renderer.rb
293
+ - lib/magic_reveal/template-config.json
278
294
  - lib/magic_reveal/template-config.ru
295
+ - lib/magic_reveal/template.html
279
296
  - lib/magic_reveal/version.rb
280
297
  - magic-reveal.gemspec
281
298
  - spec/data/wrapped.zip
@@ -286,6 +303,7 @@ files:
286
303
  - spec/magic_reveal/creator_spec.rb
287
304
  - spec/magic_reveal/identifier_spec.rb
288
305
  - spec/magic_reveal/index_libber_spec.rb
306
+ - spec/magic_reveal/project_config_spec.rb
289
307
  - spec/magic_reveal/reveal_js_fetcher_spec.rb
290
308
  - spec/magic_reveal/slide_renderer_spec.rb
291
309
  - spec/magic_reveal_spec.rb
@@ -323,6 +341,7 @@ test_files:
323
341
  - spec/magic_reveal/creator_spec.rb
324
342
  - spec/magic_reveal/identifier_spec.rb
325
343
  - spec/magic_reveal/index_libber_spec.rb
344
+ - spec/magic_reveal/project_config_spec.rb
326
345
  - spec/magic_reveal/reveal_js_fetcher_spec.rb
327
346
  - spec/magic_reveal/slide_renderer_spec.rb
328
347
  - spec/magic_reveal_spec.rb