magic_reveal 2.4.0.1 → 2.4.0.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: 5d5c1f685fc06356224773be6c761b559d20dcb7
4
- data.tar.gz: f6061b79e83be0baf5637ee4957045881c3bf3cf
3
+ metadata.gz: ef3ebbd0e2d2b2310a04a204fa9d180b256bc2a6
4
+ data.tar.gz: 83ca908557fa7b2444abd666d86f64fa674ab0af
5
5
  SHA512:
6
- metadata.gz: e638920d89ab90ffcea767da5676b43c77954a93ee68bd42ad3ff86ff501319a91b60ca693e37e7b3ae9cac918d9f40d7b4e02e01c532eb0527a92bc1a921a2f
7
- data.tar.gz: 4ba1e2768b60d18b3a54ad24cc8ab858ba4db57d210a61f039c78a46de6d2c527d94e90403a7e27a16a41c466952a12e684ffe657a92488a16d0ae3679f6f5ac
6
+ metadata.gz: 9f8f146b2ae5377270f5a5a3bdafb798e99860d92f90b18eb466a98bbaa6070e38b91527c4eb3a56019277077be64455fc961c6d73c8b441935e4abaa8dd6a01
7
+ data.tar.gz: 65e1377de6d882644bf01d8b6708a585cec9970bb0a8f520cb34e1f8d716235943091a15cb352d8a2c5cfe63d27288afa9212f552092e4e08769e0ce9f206d32
data/README.md CHANGED
@@ -39,10 +39,16 @@ Feel free to replace [vim](http://vim.org/) with the editor of your choice.
39
39
 
40
40
  ### Viewing the presentation
41
41
 
42
- $ rackup
42
+ $ magic-reveal start
43
43
 
44
44
  Then open your browser to [`http://localhost:9292`](http://localhost:9292).
45
45
 
46
+ ### Write a static index.html
47
+
48
+ $ magic-reveal static
49
+
50
+ This generates a static `index.html` suitable for committing to git.
51
+
46
52
  ### The format of slides.md
47
53
 
48
54
  Magic Reveal uses [github-flavored
@@ -19,17 +19,11 @@ module MagicReveal
19
19
  end
20
20
  end
21
21
 
22
- set :public_folder, File.expand_path('reveal.js', Dir.getwd)
22
+ set :public_folder, Dir.getwd
23
23
 
24
24
  helpers do
25
25
  def markdown
26
- @markdown ||= Redcarpet::Markdown.new(
27
- MagicReveal::SlideRenderer.new,
28
- :space_after_headers => true,
29
- :filter_html => true,
30
- :fenced_code_blocks => true,
31
- :no_intra_emphasis => true,
32
- )
26
+ @markdown ||= SlideRenderer.markdown_renderer
33
27
  end
34
28
 
35
29
  def index_html_path
@@ -2,6 +2,8 @@ require 'forwardable'
2
2
 
3
3
  require 'magic_reveal/cli/options'
4
4
  require 'magic_reveal/creator'
5
+ require 'magic_reveal/slide_renderer'
6
+ require 'magic_reveal/index_libber'
5
7
 
6
8
  module MagicReveal
7
9
  class Cli
@@ -19,10 +21,53 @@ module MagicReveal
19
21
  end
20
22
 
21
23
  # Action Classes
24
+ def show_help
25
+ puts "Usage: #{program_name} <command>"
26
+ puts
27
+ puts " new <name>"
28
+ puts " Creates new presentation in directory <name>"
29
+ puts
30
+ puts " start [options]"
31
+ puts " Starts serving the presentation in the current directory"
32
+ puts
33
+ puts " static"
34
+ puts " Creates a static index.html file from your slides"
35
+ puts
36
+ exit
37
+ end
38
+
22
39
  def creator
23
40
  @creator ||= Creator.new(Dir.getwd)
24
41
  end
25
42
 
43
+ def start_server
44
+ require 'rack'
45
+ ARGV.shift
46
+ Rack::Server.start
47
+ exit
48
+ end
49
+
50
+ def create_static
51
+ slides = Pathname.pwd + 'slides.md'
52
+ reveal_js_html = Pathname.pwd + 'reveal.js' + 'index.html'
53
+ index_html = Pathname.pwd + 'index.html'
54
+
55
+ 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
61
+
62
+ index_html.open('w') { |f| f.print libber.to_s }
63
+ end
64
+
65
+ def avenge_programmer
66
+ puts "The programmer messed up."
67
+ puts "Please file a bug at https://github.com/docwhat/magic_reveal"
68
+ exit 13
69
+ end
70
+
26
71
  def options
27
72
  @options ||= Options.new
28
73
  end
@@ -33,10 +78,14 @@ module MagicReveal
33
78
  case command
34
79
  when :new
35
80
  creator.create_project(project)
81
+ when :start
82
+ start_server
83
+ when :static
84
+ create_static
85
+ when :help
86
+ show_help
36
87
  else
37
- puts "Usage: #{program_name}"
38
- puts
39
- puts "This isn't written yet."
88
+ avenge_programmer
40
89
  end
41
90
  end
42
91
  end
@@ -19,9 +19,11 @@ module MagicReveal
19
19
  @command = :new
20
20
  @project = args[1]
21
21
  end
22
- when 'help'
23
- @command = :help
24
- else
22
+ when 'start'
23
+ @command = :start
24
+ when 'static'
25
+ @command = :static
26
+ else # including help
25
27
  @command = :help
26
28
  end
27
29
  end
@@ -33,6 +33,7 @@ module MagicReveal
33
33
  top_dir.mkdir
34
34
 
35
35
  reveal_js_fetcher.save_to(reveal_dir)
36
+
36
37
  FileUtils.copy_file template_slides.to_s, (top_dir + 'slides.md').to_s
37
38
  FileUtils.copy_file template_config_ru.to_s, (top_dir + 'config.ru').to_s
38
39
  gemfile.open('w') do |f|
@@ -41,6 +42,11 @@ module MagicReveal
41
42
  f.puts "gem 'magic_reveal', '~> #{VERSION}'"
42
43
  end
43
44
 
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
+
44
50
  Dir.chdir(top_dir.to_s) do
45
51
  system 'bundle install'
46
52
  end
@@ -28,6 +28,8 @@ module MagicReveal
28
28
  if container = html.at_css('div.reveal div.slides')
29
29
  container.children = slides
30
30
  end
31
+ headers = slides.css('h1', 'h2', 'h3', 'h4', 'h5', 'h6')
32
+ html.title = headers.first.text unless headers.nil? || headers.empty?
31
33
  end
32
34
 
33
35
  def to_s
@@ -12,6 +12,16 @@ module MagicReveal
12
12
  super(no_styles: true)
13
13
  end
14
14
 
15
+ def self.markdown_renderer
16
+ 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,
22
+ )
23
+ end
24
+
15
25
  def doc_header
16
26
  @has_shown_slides = false
17
27
  "<!-- generated by magic_reveal v#{VERSION} on #{Time.now} -->"
@@ -1,4 +1,4 @@
1
1
  module MagicReveal
2
2
  REVEAL_JS_VERSION = "2.4.0"
3
- VERSION = "#{REVEAL_JS_VERSION}.1"
3
+ VERSION = "#{REVEAL_JS_VERSION}.2"
4
4
  end
@@ -19,6 +19,18 @@ describe MagicReveal::Cli::Options do
19
19
  its(:project) { should be_nil }
20
20
  end
21
21
 
22
+ context "given 'start'" do
23
+ let(:args) { %w[start] }
24
+
25
+ its(:command) { should be(:start) }
26
+ end
27
+
28
+ context "given 'static'" do
29
+ let(:args) { %w[static] }
30
+
31
+ its(:command) { should be(:static) }
32
+ end
33
+
22
34
  context "given 'help'" do
23
35
  let(:args) { %w{help} }
24
36
 
@@ -7,7 +7,11 @@ describe MagicReveal::Cli do
7
7
  context "with a null options" do
8
8
  let(:options) { double(MagicReveal::Cli::Options).as_null_object }
9
9
  let(:args) { double("ARGV") }
10
- before { subject.stub(:options).and_return(options) }
10
+ before do
11
+ subject.stub(:show_help)
12
+ subject.stub(:avenge_programmer)
13
+ subject.stub(:options).and_return(options)
14
+ end
11
15
 
12
16
  context "command=nil" do
13
17
  before { subject.run args }
@@ -19,6 +23,10 @@ describe MagicReveal::Cli do
19
23
  it "fetches the command" do
20
24
  expect(options).to have_received(:command)
21
25
  end
26
+
27
+ it "avenges the programmer" do
28
+ expect(subject).to have_received(:avenge_programmer)
29
+ end
22
30
  end
23
31
 
24
32
  context "command=new" do
@@ -39,11 +47,38 @@ describe MagicReveal::Cli do
39
47
  with(options.project)
40
48
  end
41
49
  end
50
+
51
+ context "command=help" do
52
+ it "shows help" do
53
+ subject.stub(:show_help)
54
+ subject.should_receive(:show_help).and_return(nil)
55
+ options.stub(:command).and_return(:help)
56
+ subject.run args
57
+ end
58
+ end
59
+
60
+ context "command=start" do
61
+ it "starts the server" do
62
+ subject.stub(:start_server)
63
+ subject.should_receive(:start_server).and_return(nil)
64
+ options.stub(:command).and_return(:start)
65
+ subject.run args
66
+ end
67
+ end
68
+
69
+ context "command=static" do
70
+ it "creates a static file" do
71
+ subject.stub(:create_static)
72
+ subject.should_receive(:create_static).and_return(nil)
73
+ options.stub(:command).and_return(:static)
74
+ subject.run args
75
+ end
76
+ end
42
77
  end
43
78
  end
44
79
 
45
80
  describe ".creator" do
46
- it "narf" do
81
+ it "sends new to creator" do
47
82
  MagicReveal::Creator.should_receive(:new).with(Dir.getwd)
48
83
  subject.creator
49
84
  end
@@ -3,8 +3,11 @@ require 'magic_reveal/creator'
3
3
  require 'pathname'
4
4
 
5
5
  describe MagicReveal::Creator do
6
- before { subject.reveal_js_fetcher = fetcher }
7
6
  let(:fetcher) { double(MagicReveal::RevealJsFetcher).as_null_object }
7
+ before do
8
+ subject.stub(:system) # This is an integration test thingy.
9
+ subject.reveal_js_fetcher = fetcher
10
+ end
8
11
 
9
12
  context "with a temporary directory" do
10
13
  subject { described_class.new @tmpdir }
@@ -14,7 +17,10 @@ describe MagicReveal::Creator do
14
17
 
15
18
  describe "create_project" do
16
19
  let(:project) { "project#{rand 99}" }
17
- before { FileUtils.stub(:copy_file) }
20
+ before do
21
+ FileUtils.stub(:copy_file)
22
+ Pathname.any_instance.stub(:children).and_return([])
23
+ end
18
24
 
19
25
  it "makes the project directory" do
20
26
  subject.create_project(project)
@@ -26,11 +26,16 @@ describe MagicReveal::IndexLibber do
26
26
 
27
27
  describe ".update_slides" do
28
28
  let(:slides) { '<section><h2>life with Joe</h2><p>&hellip;is good</section>' * 2 }
29
- let(:html_text) { '<!DOCTYPE html><div class="reveal"><div class="slides"><section>text</section></div></div>' }
29
+ let(:html_text) { '<!DOCTYPE html><title>bogus</title><div class="reveal"><div class="slides"><section>text</section></div></div>' }
30
30
 
31
- it "does stuff" do
31
+ it "inserts the slides" do
32
32
  subject.update_slides slides
33
- puts subject
33
+ expect(subject.to_s).to include('life with Joe')
34
+ end
35
+
36
+ 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')
34
39
  end
35
40
  end
36
41
 
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.1
4
+ version: 2.4.0.2
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-14 00:00:00.000000000 Z
11
+ date: 2013-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra