magic_reveal 2.6.1.2 → 2.6.1.4

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.
@@ -4,6 +4,7 @@ require 'cgi'
4
4
  require 'magic_reveal/version'
5
5
 
6
6
  module MagicReveal
7
+ # Custom renderer so the HTML is the right format for Reveal.js.
7
8
  class SlideRenderer < Redcarpet::Render::HTML
8
9
  include Redcarpet::Render::SmartyPants
9
10
  attr_accessor :has_shown_slides
@@ -14,11 +15,11 @@ module MagicReveal
14
15
 
15
16
  def self.markdown_renderer
16
17
  Redcarpet::Markdown.new(
17
- self.new,
18
- :space_after_headers => true,
19
- :filter_html => true,
20
- :fenced_code_blocks => true,
21
- :no_intra_emphasis => true,
18
+ new,
19
+ space_after_headers: true,
20
+ filter_html: true,
21
+ fenced_code_blocks: true,
22
+ no_intra_emphasis: true
22
23
  )
23
24
  end
24
25
 
@@ -31,39 +32,34 @@ module MagicReveal
31
32
  has_shown_slides ? '</section>' : ''
32
33
  end
33
34
 
34
- def header(text, header_level)
35
- output = []
36
- if has_shown_slides
37
- output << "</section>"
38
- else
35
+ def header(text, header_level, anchor = nil)
36
+ [].tap do |output|
37
+ output << '</section>' if has_shown_slides
39
38
  @has_shown_slides = true
40
- end
41
- output << "<section>"
42
- output << "<h#{header_level}>#{text}</h#{header_level}>"
43
- output.join("\n")
39
+ anchor_html = anchor ? " id=\"#{anchor}\"" : ''
40
+
41
+ output << '<section>'
42
+ output << "<h#{header_level}#{anchor_html}>#{text}</h#{header_level}>"
43
+ end.join("\n")
44
44
  end
45
45
 
46
46
  def prepare_code(code)
47
- if code =~ %r{\A\s*@@source\s*=\s*(.*)\s*\Z}
48
- File.read($1)
47
+ if code =~ /\A\s*@@source\s*=\s*(?<filename>.*)\s*\Z/
48
+ File.read Regexp.last_match[:filename]
49
49
  else
50
- code.sub(%r{\A\s*}, '').sub(%r{\s*\Z}, '')
50
+ code.sub(/\A\s*/, '').sub(/\s*\Z/, '')
51
51
  end
52
52
  end
53
53
 
54
54
  def block_code(code, language)
55
- output = []
56
- if language
57
- output << "<pre class=\"#{language}\">"
58
- else
59
- output << "<pre>"
60
- end
61
- output << "<code>"
55
+ [].tap do |output|
56
+ output << (language ? "<pre class=\"#{language}\">" : '<pre>')
57
+ output << '<code>'
62
58
 
63
- output << CGI::escapeHTML(prepare_code code)
64
- output << "</code>"
65
- output << "</pre>"
66
- output.join("")
59
+ output << CGI.escapeHTML(prepare_code code)
60
+ output << '</code>'
61
+ output << '</pre>'
62
+ end.join('')
67
63
  end
68
64
  end
69
65
  end
@@ -1,4 +1,5 @@
1
+ # Version information
1
2
  module MagicReveal
2
3
  REVEAL_JS_VERSION = '2.6.1'
3
- VERSION = "#{REVEAL_JS_VERSION}.2"
4
+ VERSION = "#{REVEAL_JS_VERSION}.4"
4
5
  end
@@ -4,45 +4,41 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'magic_reveal/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "magic_reveal"
7
+ spec.name = 'magic_reveal'
8
8
  spec.version = MagicReveal::VERSION
9
- spec.authors = ["Christian Höltje"]
10
- spec.email = ["docwhat@gerf.org"]
9
+ spec.authors = ['Christian Höltje']
10
+ spec.email = ['docwhat@gerf.org']
11
11
  spec.description = %q{Create presentations with markdown and ease!}
12
12
  spec.summary = %q{Create presentations using markdown and reveal.js}
13
- spec.homepage = "https://github.com/docwhat/magic_reveal"
14
- spec.license = "MIT"
13
+ spec.homepage = 'https://github.com/docwhat/magic_reveal'
14
+ spec.license = 'MIT'
15
15
 
16
- spec.files = `git ls-files`.split($/)
16
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.required_ruby_version = '>= 1.9.2'
21
+ spec.required_ruby_version = '>= 1.9.3'
22
22
 
23
- spec.add_dependency "sinatra", "~> 1.4"
24
- spec.add_dependency "redcarpet", "~> 3.0"
25
- spec.add_dependency "archive-zip", "~> 0.6"
26
- spec.add_dependency "sys-admin", "~> 1.6"
27
- spec.add_dependency "nokogiri", "~> 1.5"
28
- spec.add_dependency "highline", "~> 1.6"
23
+ spec.add_dependency 'sinatra', '~> 1.4'
24
+ spec.add_dependency 'redcarpet', '~> 3.0'
25
+ spec.add_dependency 'archive-zip', '~> 0.6'
26
+ spec.add_dependency 'sys-admin', '~> 1.6'
27
+ spec.add_dependency 'nokogiri', '~> 1.5'
28
+ spec.add_dependency 'highline', '~> 1.6'
29
29
 
30
- spec.add_development_dependency "bundler", "~> 1.3"
31
- spec.add_development_dependency "rake"
32
- spec.add_development_dependency "guard", "~> 1.8"
33
- spec.add_development_dependency "guard-rspec", "~> 3.0"
34
- spec.add_development_dependency "rspec", "~> 2.14"
35
- spec.add_development_dependency "faker"
36
- spec.add_development_dependency "coveralls", "~> 0.6"
37
- spec.add_development_dependency "better_errors"
38
- spec.add_development_dependency "binding_of_caller"
30
+ spec.add_development_dependency 'bundler', '~> 1.3'
31
+ spec.add_development_dependency 'rake'
32
+ spec.add_development_dependency 'guard', '~> 2.4'
33
+ spec.add_development_dependency 'guard-rspec', '~> 4.2'
34
+ spec.add_development_dependency 'guard-rubocop', '~> 1.0'
35
+ spec.add_development_dependency 'rspec', '~> 2.14'
36
+ spec.add_development_dependency 'faker'
37
+ spec.add_development_dependency 'coveralls', '~> 0.7'
38
+ spec.add_development_dependency 'better_errors'
39
+ spec.add_development_dependency 'binding_of_caller'
39
40
 
40
- #For detecting changes in the filesystem
41
- spec.add_development_dependency 'rb-inotify'
42
- spec.add_development_dependency 'rb-fsevent'
43
- spec.add_development_dependency 'rb-fchange'
44
-
45
- #For displaying notices
41
+ # For displaying notices
46
42
  spec.add_development_dependency 'terminal-notifier-guard'
47
43
  spec.add_development_dependency 'libnotify'
48
44
  end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+ require 'magic_reveal/slide_renderer'
3
+
4
+ describe 'integration of SlideRenderer with Redcarpet' do
5
+ let(:markdown) do
6
+ return <<-EOF
7
+ # Title
8
+
9
+ Some text `here`.
10
+
11
+ ## Second level header
12
+
13
+ ```
14
+ Fenced code goes here.
15
+ ```
16
+
17
+ ### Third level header
18
+
19
+ Indented code goes here.
20
+
21
+ EOF
22
+ end
23
+
24
+ it 'does not have errors' do
25
+ renderer = MagicReveal::SlideRenderer.markdown_renderer
26
+ expect(renderer.render markdown)
27
+ .to be_kind_of(String)
28
+ end
29
+ end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'magic_reveal/cli/options'
3
3
 
4
4
  describe MagicReveal::Cli::Options do
5
- describe ".parse" do
5
+ describe '.parse' do
6
6
  before { subject.parse args }
7
7
 
8
8
  context "given 'new <project>'" do
@@ -43,7 +43,7 @@ describe MagicReveal::Cli::Options do
43
43
  its(:command) { should be(:help) }
44
44
  end
45
45
 
46
- context "given no arguments" do
46
+ context 'given no arguments' do
47
47
  let(:args) { [] }
48
48
 
49
49
  its(:command) { should be(:help) }
@@ -1,35 +1,34 @@
1
1
  require 'spec_helper'
2
2
  require 'magic_reveal/cli'
3
3
 
4
-
5
4
  describe MagicReveal::Cli do
6
- describe ".run" do
7
- context "with a null options" do
5
+ describe '.run' do
6
+ context 'with a null options' do
8
7
  let(:options) { double(MagicReveal::Cli::Options).as_null_object }
9
- let(:args) { double("ARGV") }
8
+ let(:args) { double('ARGV') }
10
9
  before do
11
10
  subject.stub(:show_help)
12
11
  subject.stub(:avenge_programmer)
13
12
  subject.stub(:options).and_return(options)
14
13
  end
15
14
 
16
- context "command=nil" do
15
+ context 'command=nil' do
17
16
  before { subject.run args }
18
17
 
19
- it "parses the args" do
18
+ it 'parses the args' do
20
19
  expect(options).to have_received(:parse).with(args)
21
20
  end
22
21
 
23
- it "fetches the command" do
22
+ it 'fetches the command' do
24
23
  expect(options).to have_received(:command)
25
24
  end
26
25
 
27
- it "avenges the programmer" do
26
+ it 'avenges the programmer' do
28
27
  expect(subject).to have_received(:avenge_programmer)
29
28
  end
30
29
  end
31
30
 
32
- context "command=new" do
31
+ context 'command=new' do
33
32
  let(:creator) { double(MagicReveal::Creator).as_null_object }
34
33
  before do
35
34
  subject.creator = creator
@@ -37,19 +36,19 @@ describe MagicReveal::Cli do
37
36
  subject.run args
38
37
  end
39
38
 
40
- it "fetches the project" do
39
+ it 'fetches the project' do
41
40
  expect(options).to have_received(:project)
42
41
  end
43
42
 
44
- it "creates the project" do
45
- expect(creator).
46
- to have_received(:create_project).
47
- with(options.project)
43
+ it 'creates the project' do
44
+ expect(creator)
45
+ .to have_received(:create_project)
46
+ .with(options.project)
48
47
  end
49
48
  end
50
49
 
51
- context "command=help" do
52
- it "shows help" do
50
+ context 'command=help' do
51
+ it 'shows help' do
53
52
  subject.stub(:show_help)
54
53
  subject.should_receive(:show_help).and_return(nil)
55
54
  options.stub(:command).and_return(:help)
@@ -57,8 +56,8 @@ describe MagicReveal::Cli do
57
56
  end
58
57
  end
59
58
 
60
- context "command=start" do
61
- it "starts the server" do
59
+ context 'command=start' do
60
+ it 'starts the server' do
62
61
  subject.stub(:start_server)
63
62
  subject.should_receive(:start_server).and_return(nil)
64
63
  options.stub(:command).and_return(:start)
@@ -66,8 +65,8 @@ describe MagicReveal::Cli do
66
65
  end
67
66
  end
68
67
 
69
- context "command=static" do
70
- it "creates a static file" do
68
+ context 'command=static' do
69
+ it 'creates a static file' do
71
70
  subject.stub(:create_static)
72
71
  subject.should_receive(:create_static).and_return(nil)
73
72
  options.stub(:command).and_return(:static)
@@ -77,17 +76,16 @@ describe MagicReveal::Cli do
77
76
  end
78
77
  end
79
78
 
80
- describe ".creator" do
81
- it "sends new to creator" do
79
+ describe '.creator' do
80
+ it 'sends new to creator' do
82
81
  MagicReveal::Creator.should_receive(:new).with(Dir.getwd)
83
82
  subject.creator
84
83
  end
85
84
  end
86
85
 
87
- describe ".options" do
86
+ describe '.options' do
88
87
  it "responds to 'parse'" do
89
88
  subject.options.should respond_to(:parse)
90
89
  end
91
90
  end
92
-
93
91
  end
@@ -13,29 +13,29 @@ describe MagicReveal::Conductor do
13
13
 
14
14
  its(:url) { should be_kind_of(URI) }
15
15
 
16
- describe ".fetch" do
17
- it "should save a file" do
18
- subject.url = "http://google.com/"
16
+ describe '.fetch' do
17
+ it 'should save a file' do
18
+ subject.url = 'http://google.com/'
19
19
  save_file = @tmpdir + 'index.html'
20
20
  subject.fetch save_file
21
21
  save_file.should exist
22
22
  end
23
23
  end
24
24
 
25
- describe ".unpack" do
25
+ describe '.unpack' do
26
26
  let(:unpack_dir) { @tmpdir + "unpack-#{rand 200}" }
27
- context "given a zipfile" do
27
+ context 'given a zipfile' do
28
28
  let(:zipfile) { EXAMPLE_DATA + 'wrapped.zip' }
29
29
 
30
- it "unpacks and unwraps the zipfile" do
30
+ it 'unpacks and unwraps the zipfile' do
31
31
  subject.unpack zipfile, unpack_dir
32
32
  (unpack_dir + 'testfile.md').should exist
33
33
  end
34
34
 
35
- context "and the unpack directory exists already" do
35
+ context 'and the unpack directory exists already' do
36
36
  before { unpack_dir.mkdir }
37
37
 
38
- it "should raise an error" do
38
+ it 'should raise an error' do
39
39
  expect { subject.unpack zipfile, unpack_dir }.to raise_error(MagicReveal::Error)
40
40
  end
41
41
  end
@@ -9,39 +9,44 @@ describe MagicReveal::Creator do
9
9
  subject.reveal_js_fetcher = fetcher
10
10
  end
11
11
 
12
- context "with a temporary directory" do
12
+ context 'with a temporary directory' do
13
13
  subject { described_class.new @tmpdir }
14
- around { |example| Dir.mktmpdir { |dir| @tmpdir = Pathname.new dir; example.run } }
14
+ around do |example|
15
+ Dir.mktmpdir do |dir|
16
+ @tmpdir = Pathname.new dir
17
+ example.run
18
+ end
19
+ end
15
20
 
16
21
  its(:directory) { should eq(@tmpdir) }
17
22
 
18
- describe "create_project" do
23
+ describe 'create_project' do
19
24
  let(:project) { "project#{rand 99}" }
20
25
  before do
21
26
  FileUtils.stub(:copy_file)
22
27
  Pathname.any_instance.stub(:children).and_return([])
23
28
  end
24
29
 
25
- it "makes the project directory" do
30
+ it 'makes the project directory' do
26
31
  subject.create_project(project)
27
32
  expect(@tmpdir + project).to be_directory
28
33
  end
29
34
 
30
- it "fetches and saves reveal.js" do
35
+ it 'fetches and saves reveal.js' do
31
36
  subject.create_project(project)
32
- expect(fetcher).
33
- to have_received(:save_important_parts_to).
34
- with(@tmpdir + project)
37
+ expect(fetcher)
38
+ .to have_received(:save_important_parts_to)
39
+ .with(@tmpdir + project)
35
40
  end
36
41
 
37
- it "copies the template_slides" do
42
+ it 'copies the template_slides' do
38
43
  src = subject.template_slides
39
44
  dst = @tmpdir + project + 'slides.md'
40
45
  FileUtils.should_receive(:copy_file).with(src.to_s, dst.to_s)
41
46
  subject.create_project(project)
42
47
  end
43
48
 
44
- it "copies the template_config_ru" do
49
+ it 'copies the template_config_ru' do
45
50
  src = subject.template_config_ru
46
51
  dst = @tmpdir + project + 'config.ru'
47
52
  FileUtils.should_receive(:copy_file).with(src.to_s, dst.to_s)
@@ -49,23 +54,23 @@ describe MagicReveal::Creator do
49
54
  end
50
55
  end
51
56
 
52
- describe "update_project" do
57
+ describe 'update_project' do
53
58
  let(:project) { @tmpdir + "project#{rand 99}" }
54
59
 
55
- it "fetches and saves reveal.js" do
60
+ it 'fetches and saves reveal.js' do
56
61
  subject.update_project(project)
57
- expect(fetcher).
58
- to have_received(:save_important_parts_to).
59
- with(project)
62
+ expect(fetcher)
63
+ .to have_received(:save_important_parts_to)
64
+ .with(project)
60
65
  end
61
66
  end
62
67
 
63
- describe ".template_slides" do
68
+ describe '.template_slides' do
64
69
  its(:template_slides) { should be_kind_of(Pathname) }
65
70
  its(:template_slides) { should be_file }
66
71
  end
67
72
 
68
- describe ".template_config_ru" do
73
+ describe '.template_config_ru' do
69
74
  its(:template_config_ru) { should be_kind_of(Pathname) }
70
75
  its(:template_config_ru) { should be_file }
71
76
  end
@@ -5,55 +5,55 @@ describe MagicReveal::Identifier do
5
5
  subject { described_class.new sys_admin }
6
6
  let(:sys_admin) { double(Sys::Admin).as_null_object }
7
7
 
8
- describe ".name" do
8
+ describe '.name' do
9
9
  before do
10
10
  sys_admin.stub(:respond_to?)
11
11
  end
12
12
 
13
- it "gets the login" do
13
+ it 'gets the login' do
14
14
  subject.name
15
15
  expect(sys_admin).to have_received(:get_login)
16
16
  end
17
17
 
18
- it "passes the login to get_user" do
18
+ it 'passes the login to get_user' do
19
19
  subject.name
20
20
  expect(sys_admin).to have_received(:get_user).with(sys_admin.get_login)
21
21
  end
22
22
 
23
- context "the user has a full_name" do
23
+ context 'the user has a full_name' do
24
24
  let(:user) { double(Sys::Admin::User) }
25
25
  before do
26
26
  sys_admin.stub(:get_user).with(sys_admin.get_login).and_return(user)
27
27
  sys_admin.stub(:respond_to?).with(:full_name).and_return(true)
28
28
  end
29
29
 
30
- it "returns the full_name" do
31
- name = double("full_name")
30
+ it 'returns the full_name' do
31
+ name = double('full_name')
32
32
  user.should receive(:full_name).and_return(name)
33
33
  expect(subject.name).to eq(name)
34
34
  end
35
35
  end
36
36
 
37
- context "the user has a simple gecos" do
37
+ context 'the user has a simple gecos' do
38
38
  let(:user) { double(Sys::Admin::User) }
39
39
  before do
40
40
  sys_admin.stub(:get_user).with(sys_admin.get_login).and_return(user)
41
41
  end
42
42
 
43
- it "returns the gecos" do
43
+ it 'returns the gecos' do
44
44
  gecos = "Joe Cool #{rand 99}"
45
45
  user.should receive(:gecos).and_return(gecos)
46
46
  expect(subject.name).to eq(gecos)
47
47
  end
48
48
  end
49
49
 
50
- context "the user has a comma-delimited gecos" do
50
+ context 'the user has a comma-delimited gecos' do
51
51
  let(:user) { double(Sys::Admin::User) }
52
52
  before do
53
53
  sys_admin.stub(:get_user).with(sys_admin.get_login).and_return(user)
54
54
  end
55
55
 
56
- it "returns the gecos" do
56
+ it 'returns the gecos' do
57
57
  name = "Joe Cool #{rand 99}"
58
58
  gecos = "#{name},White House,412 555-1212,"
59
59
  user.should receive(:gecos).and_return(gecos)
@@ -61,35 +61,35 @@ describe MagicReveal::Identifier do
61
61
  end
62
62
  end
63
63
 
64
- context "the user has an empty comma-delimited gecos" do
65
- it "returns the gecos" do
64
+ context 'the user has an empty comma-delimited gecos' do
65
+ it 'returns the gecos' do
66
66
  login = "joecool#{rand 99}"
67
67
  user = double(Sys::Admin::User)
68
68
 
69
69
  sys_admin.stub(:get_login).and_return(login)
70
70
  sys_admin.stub(:get_user).with(login).and_return(user)
71
71
 
72
- user.should receive(:gecos).and_return(",,,")
72
+ user.should receive(:gecos).and_return(',,,')
73
73
  expect(subject.name).to eq(login)
74
74
  end
75
75
  end
76
76
 
77
- context "the user has an empty gecos" do
78
- it "returns the gecos" do
77
+ context 'the user has an empty gecos' do
78
+ it 'returns the gecos' do
79
79
  login = "joecool#{rand 99}"
80
80
  user = double(Sys::Admin::User)
81
81
 
82
82
  sys_admin.stub(:get_login).and_return(login)
83
83
  sys_admin.stub(:get_user).with(login).and_return(user)
84
84
 
85
- user.should receive(:gecos).and_return("")
85
+ user.should receive(:gecos).and_return('')
86
86
  expect(subject.name).to eq(login)
87
87
  end
88
88
  end
89
89
  end
90
90
 
91
- describe "#name (an alias)" do
92
- it "calls .name on an instance" do
91
+ describe '#name (an alias)' do
92
+ it 'calls .name on an instance' do
93
93
  instance = double(described_class).as_null_object
94
94
  described_class.stub(:new).and_return(instance)
95
95
  expect(described_class.name).to be(instance.name)