slide_hero 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ba41a9d72122a93c31a9aacb8b410f940ee8455
4
- data.tar.gz: c878af46810347583ab517442e9e6d60bba35705
3
+ metadata.gz: 7412ed3f8e771683d9a861f4873cb426323f25b0
4
+ data.tar.gz: 70c8c9d3dadbfa3ebc399e18394c377948acbd00
5
5
  SHA512:
6
- metadata.gz: 826eb9577377c8b9a9e9030db14c4a662e1071c3b9a66da06785a5d7ff3e3866db33a220a98ed023bf9ead67b57a62d4463c8384eb0875e5341b8cc5e7469231
7
- data.tar.gz: dcde6333cd24cfb2db0647fcd47f838b2bbed118bf5b287202140a56e1eeab5c99716c26c4fb4903be1adebb2a878f2815facc831b274a442409432d8f9f086c
6
+ metadata.gz: a3ae4ec73cefdd4ca4154adfcc75032148f46ddcc5f7f150d6976beb48656f7f56ef7b3737fc8b9b002315cb1d6337ded401ef1878fd7c761ed2094f7434412d
7
+ data.tar.gz: fcd6928a0f84a85223d3c14bc381bcf1b1c4e897e96dd9c970f13a154f5aa0728014a4cc102f7e6e0672ce2aab4c1f3c6bcf99fa1c0c5b453174bc5efcaccea3
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ slide_hero
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ ruby '2.0.0'
1
2
  source 'https://rubygems.org'
2
3
 
3
4
  # Specify your gem's dependencies in slide_hero.gemspec
data/README.md CHANGED
@@ -9,7 +9,9 @@ Requires Ruby 2.0.0
9
9
 
10
10
  Add this line to your application's Gemfile:
11
11
 
12
- gem 'slide_hero'
12
+ ```ruby
13
+ gem 'slide_hero'
14
+ ```
13
15
 
14
16
  And then execute:
15
17
 
@@ -48,107 +50,180 @@ The DSL for SlideHero was created to add expressibility to creating slides.
48
50
 
49
51
  **presentation**
50
52
 
51
-
52
- presentation "My Presentation" do
53
-
54
- end
53
+ ```ruby
54
+ presentation "My Presentation" do
55
+
56
+ end
57
+ ```
55
58
 
56
59
  `#presentation` indicates the beginning of a presentation. You can have one of these per file. The String passed is used as the title for the presentation.
57
60
 
58
61
  **slide**
59
62
 
60
- presentation "My Presentation" do
61
- slide "A slide" do
62
- #…
63
- end
64
- end
63
+ ```ruby
64
+ presentation "My Presentation" do
65
+ slide "A slide" do
66
+ #…
67
+ end
68
+ end
69
+ ```
65
70
 
66
71
  `#slide` is used to create a new slide. The string is the headline of the slide. `#slide` can take an optional argument of `headline_size:`. Valid options are :small, :medium, :large. These create h3, h2, and h1 elements respectively.
67
72
 
68
- presentation "My Presentation" do
69
- slide "A slide", headline_size: :small do
70
- #…
71
- end
72
- end
73
-
73
+ ```ruby
74
+ presentation "My Presentation" do
75
+ slide "A slide", headline_size: :small do
76
+ #…
77
+ end
78
+ end
79
+ ```
80
+
74
81
  `#slide` can have transitions applied as well. Valid transitions are: :cube, :page, :concave, :zoom, :linear, :fade, :none, and :default
75
82
 
76
- presentation "My Presentation" do
77
- slide "A slide", transition: :slide do
78
- #…
79
- end
80
- end
81
-
83
+ ```ruby
84
+ presentation "My Presentation" do
85
+ slide "A slide", transition: :slide do
86
+ #…
87
+ end
88
+ end
89
+ ```
90
+ **defaults**
91
+
92
+ ```ruby
93
+ presentation "My Presentation" do
94
+ defaults headline_size: :medium, transition: :fade
95
+
96
+ slide "A slide" do
97
+ #…
98
+ end
99
+
100
+ slide "Some slides override", headline_size: :large do
101
+ #…#…
102
+ end
103
+ end
104
+ ```
105
+
106
+ You can set slide defaults for `headline_size` or `transition` by using `#defaults`. A slide default applies to all slides unless an individual slide overrides it.
107
+
82
108
  **points**
83
109
 
84
- presentation "My Presentation" do
85
- slide "A slide" do
86
- point "An interesting Point"
87
- end
88
- end
110
+ ```ruby
111
+ presentation "My Presentation" do
112
+ slide "A slide" do
113
+ point "An interesting Point"
114
+ end
115
+ end
116
+ ```
89
117
 
90
118
  `#point` adds p tag wrapped text to your presentation
91
119
 
92
120
  **grouped_slides**
93
121
 
94
- presentation "My Presentation" do
95
- grouped_slides do
96
- slide "Slide 1" do
97
- end
98
- slide "Slide 2" do
99
- end
100
- end
122
+ ```ruby
123
+ presentation "My Presentation" do
124
+ grouped_slides do
125
+ slide "Slide 1" do
126
+ end
127
+ slide "Slide 2" do
101
128
  end
129
+ end
130
+ end
131
+ ```
102
132
 
103
133
  `#grouped_slides` lets you nest slides. In reveal, this translates into vertical slides.
104
134
 
105
135
  **lists**
106
136
 
107
-
108
- presentation "My Presentation" do
109
-
110
- slide "Slide 1" do
111
- list do
112
- point "An interesting point about monkeys"
113
- point "An even more interesting point about nargles"
114
- end
115
- end
116
- slide "Slide 2" do
117
- list(:ordered) do
118
- point "I should go first"
119
- point "I'm ok going second"
120
- end
121
- end
137
+ ```ruby
138
+ presentation "My Presentation" do
139
+ slide "Slide 1" do
140
+ list do
141
+ point "An interesting point about monkeys"
142
+ point "An even more interesting point about nargles"
122
143
  end
144
+ end
145
+ slide "Slide 2" do
146
+ list(:ordered) do
147
+ point "I should go first"
148
+ point "I'm ok going second"
149
+ end
150
+ end
151
+ end
152
+ ```
123
153
 
124
154
  `#list` must be nested in a slide. It takes an optional argument of :ordered to
125
155
  create an ordered list. List items are added by the `#point` method.
126
156
 
127
157
  **code**
128
158
 
159
+ ```ruby
160
+ presentation "My Presentation" do
161
+ slide "A slide" do
162
+ code(:ruby) do
163
+ "working_code.rb"
164
+ end
165
+ end
166
+ end
167
+ ```
168
+
169
+ `#code` must be nested in a slide. It loads any code file in the same directory as the file.
170
+ The language passed as an argument will be embedded in the markup.
171
+ code must be in the `code` folder. An optional second argument of a base location can be passed into the code method. Your folder must also have a `code` folder.
172
+ All supported languages can be found on the [Highlight.js Page](http://softwaremaniacs.org/media/soft/highlight/test.html)
173
+
174
+ **note**
175
+
176
+ ```ruby
177
+ presentation "My Presentation" do
178
+ slide "A slide" do
179
+ note "Remind them to shower"
180
+ end
181
+ end
182
+ ```
183
+
184
+ `#note` must be nested in a slide. These will show up on speaker's notes.
185
+
186
+ **image**
187
+
188
+ ```ruby
189
+ presentation "My Presentation" do
190
+ slide "A slide" do
191
+ image "chunky_bacon.png"
192
+ end
193
+ end
194
+ ```
195
+ `#image` must be nested in a slide. All images in the images folder will be ported over on compilation. Use the name of the image, with out the 'images' subfolder
196
+ In this example, it will load an image named 'chunky_bacon.png in the images folder.
197
+
198
+ **media**
199
+
129
200
  presentation "My Presentation" do
130
- slide "A slide" do
131
- code(:ruby) do
132
- "working_code.rb"
133
- end
201
+ slide "A slide with video" do
202
+ media "video.mp4", type: video
203
+ end
204
+
205
+ slide "A slide with video" do
206
+ media "audio.mp3", type: audio
134
207
  end
135
208
  end
136
209
 
137
- `#code` must be nested in a slide. It loads any code file in the same directory as the file.
210
+ `#media` must be nested in a slide. This will create an auto playing video or audio element on the slide. Files must be in the audio or video directory.
138
211
 
139
212
  #### Animation
140
213
 
141
214
  Animation for points are supported.
142
215
 
143
- #…
144
- slide do
145
- point "My point", animation: "grow"
146
- list do
147
- point "My", animation: "step"
148
- point "Staggered", animation: "step"
149
- point "List", animation: "step"
150
- end
151
- end
216
+ ```ruby
217
+ #…
218
+ slide do
219
+ point "My point", animation: "grow"
220
+ list do
221
+ point "My", animation: "step"
222
+ point "Staggered", animation: "step"
223
+ point "List", animation: "step"
224
+ end
225
+ end
226
+ ```
152
227
 
153
228
  Supported animations are: step, grow, shrink, roll-in, fade-out, highlight-red, highlight-green, and highlight-blue
154
229
 
data/bin/slidehero CHANGED
@@ -10,26 +10,52 @@ class PresentationGenerator < Thor
10
10
  def new(name)
11
11
  @name = name
12
12
  template 'templates/new_presentation.tt', "#{name}/presentation.rb"
13
+ ['/images', '/audio', '/video', '/code']. each do |media|
14
+ empty_directory "#{name}/#{media}"
15
+ end
13
16
  end
14
17
 
15
18
  desc "compile PRESENTATION_NAME (defaults to presentation.rb", "Compile presentation"
16
- def compile(name = 'presentation.rb')
17
- directory 'vendor/reveal.js', 'presentation'
18
- File.open('presentation/index.html', 'w+') do |f|
19
+ def compile(name = 'presentation.rb', folder="presentation")
20
+ directory 'vendor/reveal.js', folder
21
+ move_slide_files(name, folder)
22
+ end
23
+
24
+ desc "move_slide_files NAME DEST_FOLDER", "Only move the user generated files"
25
+ def move_slide_files(name, folder)
26
+ ['/images', '/audio', '/video', '/code']. each do |media|
27
+ FileUtils.cp_r(File.dirname(File.realdirpath(name)) + media, "#{folder}")
28
+ end
29
+
30
+ File.open("#{folder}/index.html", 'w+') do |f|
19
31
  f.puts eval(File.read(name), SlideHero.get_binding)
20
32
  end
21
33
  end
22
34
 
23
35
  desc "serve FILENAME", "starts a server running your presentation on port 9292"
24
36
  def serve(name = 'presentation.rb')
25
- directory 'vendor/reveal.js', '.tmp'
26
- File.open('.tmp/index.html', 'w+') do |f|
27
- f.puts eval(File.read(name), SlideHero.get_binding)
28
- end
37
+ compile(name, '.tmp')
29
38
  puts "Go checkout your awesome presentation at http://localhost:9292!"
30
- system("rackup #{Gem.loaded_specs['slide_hero'].full_gem_path}/config.ru")
31
- rescue Interrupt
39
+
40
+ rackupPid = Process.spawn("rackup #{Gem.loaded_specs['slide_hero'].full_gem_path}/config.ru")
41
+
42
+ last_update = Time.now
43
+ loop do
44
+ if File.mtime(name) > last_update
45
+ puts "File change noted!"
46
+ puts "Recompiling"
47
+ move_slide_files(name, '.tmp')
48
+ last_update = File.mtime(name)
49
+ end
50
+ sleep 1
51
+ end
52
+
53
+ rescue Exception => e
54
+ puts e
55
+ Process.kill(9, rackupPid) rescue Errno::ESRCH
32
56
  remove_dir '.tmp'
57
+ puts "GOING DOWN!"
58
+ exit 0
33
59
  end
34
60
  end
35
61
 
data/config.ru CHANGED
@@ -1,5 +1,5 @@
1
1
  use Rack::Static,
2
- :urls => ["/images", "/js", "/css", "/lib", "/plugin"],
2
+ :urls => ["/audio", "/video", "/code", "/images", "/js", "/css", "/lib", "/plugin"],
3
3
  :root => ".tmp"
4
4
 
5
5
  run lambda { |env|
@@ -1,8 +1,10 @@
1
1
  module SlideHero
2
2
  class Code
3
- def initialize(language, &code_file)
3
+ attr_reader :language, :source, :location
4
+ def initialize(language, code_path=Dir.pwd, &code_file)
4
5
  @language = language
5
- @source = File.read("#{Dir.pwd}/#{code_file.call}")
6
+ @location = "#{code_path}/code/#{code_file.call}"
7
+ @source = File.read(location)
6
8
  rescue Errno::ENOENT
7
9
  abort "#{Dir.pwd}/#{code_file.call} not found"
8
10
  end
@@ -1,6 +1,7 @@
1
1
  module SlideHero
2
2
  class GroupedSlides
3
- def initialize(&block)
3
+ def initialize(slide_defaults={}, &block)
4
+ @slide_defaults = slide_defaults
4
5
  instance_eval(&block)
5
6
  end
6
7
 
@@ -10,8 +11,8 @@ module SlideHero
10
11
  'lib/slide_hero/views/grouped_slides.html.erb')).render(self)
11
12
  end
12
13
 
13
- def slide(headline, &block)
14
- slides << Slide.new(headline, &block).compile
14
+ def slide(headline, **kwargs, &block)
15
+ slides << Slide.new(headline, @slide_defaults.merge(**kwargs), &block).compile
15
16
  end
16
17
 
17
18
  def slides
@@ -0,0 +1,23 @@
1
+ module SlideHero
2
+ class Image
3
+ attr_reader :location, :alt_text, :width, :height
4
+ def initialize(location, alt_text="", width:nil, height:nil)
5
+ @location = location
6
+ @alt_text = alt_text
7
+ @width = width
8
+ @height = height
9
+ end
10
+
11
+ def compile
12
+ %{<img#{width_attribute}#{height_attribute} src="images/#{location}" alt="#{alt_text}">}
13
+ end
14
+
15
+ def height_attribute
16
+ %{ height="#{height}"} if height
17
+ end
18
+
19
+ def width_attribute
20
+ %{ width="#{width}"} if width
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,13 @@
1
+ module SlideHero
2
+ class Media
3
+ attr_reader :url, :type
4
+ def initialize(url, type: :video)
5
+ @url = url
6
+ @type = type
7
+ end
8
+
9
+ def compile
10
+ %{<#{type} data-autoplay src="#{type}/#{url}"></#{type}>}
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module SlideHero
2
+ class Note
3
+ attr_reader :text
4
+ def initialize(text)
5
+ @text = text
6
+ end
7
+
8
+ def compile
9
+ %{<aside class="notes">#{text}</aside>}
10
+ end
11
+ end
12
+ end
@@ -5,6 +5,7 @@ module SlideHero
5
5
  attr_reader :title
6
6
  def initialize(title, &block)
7
7
  @title = title
8
+ @slide_defaults = {}
8
9
  instance_eval(&block)
9
10
  end
10
11
 
@@ -17,12 +18,16 @@ module SlideHero
17
18
  end
18
19
  end
19
20
 
21
+ def defaults(args)
22
+ @slide_defaults = args
23
+ end
24
+
20
25
  def slide(title, **kwargs, &slide_block)
21
- slides << Slide.new(title, **kwargs, &slide_block).compile
26
+ slides << Slide.new(title, @slide_defaults.merge(**kwargs), &slide_block).compile
22
27
  end
23
28
 
24
29
  def grouped_slides(&block)
25
- slides << GroupedSlides.new(&block).compile
30
+ slides << GroupedSlides.new(@slide_defaults, &block).compile
26
31
  end
27
32
 
28
33
  def collected_slides
@@ -16,21 +16,33 @@ module SlideHero
16
16
  end
17
17
 
18
18
  def point(text, animation: nil)
19
- points << Point.new(text, animation: nil).compile
19
+ points << Point.new(text, animation: animation).compile
20
20
  end
21
21
 
22
22
  def list(style=:unordered, &block)
23
23
  points << List.new(style, &block).compile
24
24
  end
25
25
 
26
- def code(language, &code)
27
- points << Code.new(language, &code).compile
26
+ def code(*args, &code)
27
+ points << Code.new(*args, &code).compile
28
28
  end
29
29
 
30
30
  def points
31
31
  @points ||= []
32
32
  end
33
33
 
34
+ def note(text)
35
+ points << Note.new(text).compile
36
+ end
37
+
38
+ def image(*args, **kwargs)
39
+ points << Image.new(*args, **kwargs).compile
40
+ end
41
+
42
+ def media(*args, **kwargs)
43
+ points << Media.new(*args, **kwargs).compile
44
+ end
45
+
34
46
  private
35
47
  def size_to_markup
36
48
  {
@@ -1,3 +1,3 @@
1
1
  module SlideHero
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,3 +1,3 @@
1
- <pre><code data-trim>
2
- <%= @source %>
1
+ <pre><code data-trim class="<%= language %>">
2
+ <%= source %>
3
3
  </code></pre>
@@ -37,6 +37,11 @@
37
37
 
38
38
  theme: Reveal.getQueryHash().theme, // available themes are in /css/theme
39
39
  transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none
40
+ leap: {
41
+ naturalSwipe : true, // Invert swipe gestures
42
+ pointerOpacity : 0.5, // Set pointer opacity to 0.5
43
+ pointerColor : '#d80000' // Red pointer
44
+ },
40
45
 
41
46
  // Optional libraries used to extend on reveal.js
42
47
  dependencies: [
@@ -45,7 +50,9 @@
45
50
  { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
46
51
  { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
47
52
  { src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } },
48
- { src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } }
53
+ { src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } },
54
+ { src: 'plugin/remotes/remotes.js', async: true, condition: function() { return !!document.body.classList; } },
55
+ { src: 'plugin/leap/leap.js', async: true }
49
56
  ]
50
57
  });
51
58
 
data/lib/slide_hero.rb CHANGED
@@ -6,6 +6,9 @@ require_relative "slide_hero/list_point"
6
6
  require_relative "slide_hero/grouped_slides"
7
7
  require_relative "slide_hero/code"
8
8
  require_relative "slide_hero/presentation"
9
+ require_relative "slide_hero/note"
10
+ require_relative "slide_hero/image"
11
+ require_relative "slide_hero/media"
9
12
  require_relative "slide_hero/dsl"
10
13
 
11
14
  module SlideHero
@@ -2,12 +2,32 @@ require 'minitest_helper'
2
2
 
3
3
  module SlideHero
4
4
  describe Code do
5
+ it "takes an optional base path of where to look for files" do
6
+ code = Code.new(:ruby, File.join(Dir.pwd,"test","fixtures")) do
7
+ "testclass.rb"
8
+ end
9
+ code.location.must_equal(File.join(Dir.pwd,"test","fixtures","code", "testclass.rb"))
10
+ end
11
+ it "exposes language from initialization value" do
12
+ code = Code.new(:ruby, File.join(Dir.pwd,"test","fixtures")) do
13
+ "testclass.rb"
14
+ end
15
+ code.language.must_equal :ruby
16
+ end
17
+
18
+ it "exposes source from initialization value" do
19
+ code = Code.new(:ruby, File.join(Dir.pwd,"test","fixtures")) do
20
+ "testclass.rb"
21
+ end
22
+ code.source.must_include "class Working"
23
+ end
24
+
5
25
  it "formats code properly" do
6
- code = Code.new(:ruby) do
7
- "test/fixtures/testclass.rb"
26
+ code = Code.new(:ruby, File.join(Dir.pwd,"test","fixtures")) do
27
+ "testclass.rb"
8
28
  end
9
29
 
10
- code.compile.strip.must_equal '<pre><code data-trim>
30
+ code.compile.strip.must_equal '<pre><code data-trim class="ruby">
11
31
  class Working
12
32
  def some_method
13
33
  "woot!"
@@ -25,5 +45,6 @@ end
25
45
  end
26
46
  end.must_raise SystemExit
27
47
  end
48
+
28
49
  end
29
50
  end
@@ -15,13 +15,24 @@ module SlideHero
15
15
  it "passes code properly" do
16
16
  pres = presentation "Code" do
17
17
  slide "Code test" do
18
- code(:ruby) do
19
- "test/fixtures/testclass.rb"
18
+ code(:ruby, File.join(Dir.pwd,"test","fixtures")) do
19
+ "testclass.rb"
20
20
  end
21
21
  end
22
22
  end
23
23
 
24
24
  pres.must_include "class Working"
25
25
  end
26
+ it "handles defaults properly" do
27
+ pres = presentation "Defaults" do
28
+ defaults headline_size: :medium
29
+ slide "Outer Slide"
30
+ grouped_slides do
31
+ slide "Inner Slide"
32
+ end
33
+ end
34
+ pres.must_include "<h2>Outer Slide</h2>"
35
+ pres.must_include "<h2>Inner Slide</h2>"
36
+ end
26
37
  end
27
38
  end
@@ -24,6 +24,24 @@ module SlideHero
24
24
  "</section>" +
25
25
  "</section>"
26
26
  end
27
+
28
+ it "takes all arguments slide handles" do
29
+ grouped_slides = GroupedSlides.new do
30
+ slide "Title", headline_size: :medium, transition: :zoom do
31
+ point "Made one"
32
+ end
33
+ end
34
+
35
+ grouped_slides.compile.must_include "transition"
36
+ grouped_slides.compile.must_include "h2"
37
+ end
38
+ end
39
+
40
+ it "can have defaults passed in" do
41
+ grouped_slides = GroupedSlides.new(headline_size: :medium) do
42
+ slide "Title"
43
+ end
44
+ grouped_slides.compile.must_include "<h2>Title</h2>"
27
45
  end
28
46
  end
29
47
  end
@@ -0,0 +1,15 @@
1
+ require 'minitest_helper'
2
+
3
+ module SlideHero
4
+ describe Image do
5
+ it "takes an image path and renders appropriate markup" do
6
+ image = Image.new("cornify.gif", "Unicorn", width: 280, height: 326)
7
+ image.compile.must_equal %{<img width="280" height="326" src="images/cornify.gif" alt="Unicorn">}
8
+ end
9
+
10
+ it "doesn't require all fields" do
11
+ image = Image.new("cornify.gif")
12
+ image.compile.must_equal %{<img src="images/cornify.gif" alt="">}
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ require 'minitest_helper'
2
+
3
+ module SlideHero
4
+ describe Media do
5
+ describe "initialization" do
6
+ it "is initialized with a url" do
7
+ media = Media.new("http://www.youtube.com/watch?v=dQw4w9WgXcQ", type: :video)
8
+ media.url.must_equal "http://www.youtube.com/watch?v=dQw4w9WgXcQ"
9
+ media.type.must_equal :video
10
+ end
11
+ end
12
+
13
+ describe "video type" do
14
+ it "compiles to html fragment" do
15
+ media = Media.new("file.mp4", type: :video)
16
+ media.compile.must_equal %{<video data-autoplay src="video/file.mp4"></video>}
17
+ end
18
+ end
19
+
20
+ describe "audio type" do
21
+ it "compiles to html fragment" do
22
+ media = Media.new("audio.mp3", type: :audio)
23
+ media.compile.must_equal %{<audio data-autoplay src="audio/audio.mp3"></audio>}
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,10 @@
1
+ require 'minitest_helper'
2
+
3
+ module SlideHero
4
+ describe Note do
5
+ it "Properly wraps notes" do
6
+ note = Note.new("Remind them of this")
7
+ assert_equal(note.compile, "<aside class=\"notes\">Remind them of this</aside>")
8
+ end
9
+ end
10
+ end
@@ -23,6 +23,17 @@ module SlideHero
23
23
  pres.slides.count.must_equal 1
24
24
  end
25
25
 
26
+ it "adds defaults to slides" do
27
+ pres = Presentation.new("slides with defaults") do
28
+ defaults headline_size: :small
29
+
30
+ slide "My slide" do
31
+ point "an amazing point"
32
+ end
33
+ end
34
+ pres.slides.first.must_include "h3"
35
+ end
36
+
26
37
  it "takes all of slide's options" do
27
38
  pres = Presentation.new("slides") do
28
39
  slide("My slide", headline_size: :small, transition: :default) do
@@ -32,6 +43,17 @@ module SlideHero
32
43
  pres.slides.count.must_equal 1
33
44
  end
34
45
 
46
+ it "overrides slide's defaults" do
47
+ pres = Presentation.new("slides") do
48
+ defaults headline_size: :medium
49
+
50
+ slide("My slide", headline_size: :small, transition: :default) do
51
+ point "Bananas are tastey"
52
+ end
53
+ end
54
+ pres.slides.first.must_include "h3"
55
+ end
56
+
35
57
  it "takes grouped_slides" do
36
58
  pres = Presentation.new("slides") do
37
59
  grouped_slides do
@@ -84,7 +84,7 @@ module SlideHero
84
84
 
85
85
  assert_dom_match slide.compile, "<section data-transition=\"default\">"+
86
86
  "<h1>Animation</h1>" +
87
- "<p>I'm animated!</p>" +
87
+ "<p class=\"fragment \">I'm animated!</p>" +
88
88
  "</section>"
89
89
 
90
90
  end
@@ -126,14 +126,14 @@ module SlideHero
126
126
  describe "#code" do
127
127
  it "embeds code in a slide" do
128
128
  slide = Slide.new "Code" do
129
- code(:ruby) do
130
- "test/fixtures/testclass.rb"
129
+ code(:ruby, File.join(Dir.pwd,"test","fixtures")) do
130
+ "testclass.rb"
131
131
  end
132
132
  end
133
133
 
134
134
  assert_dom_match slide.compile, "<section data-transition=\"default\">" +
135
135
  "<h1>Code</h1>" +
136
- "<pre><code data-trim>
136
+ "<pre><code data-trim class=\"ruby\">
137
137
  class Working
138
138
  def some_method
139
139
  \"woot!\"
@@ -143,5 +143,37 @@ end
143
143
  </code></pre></section>"
144
144
  end
145
145
  end
146
+
147
+ describe "#note" do
148
+ it "returns a formatted note" do
149
+ slide = Slide.new "Note" do
150
+ note "Don't forget to bring a towel"
151
+ end
152
+ assert_dom_match slide.compile, "<section data-transition=\"default\">" +
153
+ "<h1>Note</h1>" +
154
+ "<aside class=\"notes\">Don't forget to bring a towel</aside>" +
155
+ "</section>"
156
+ end
157
+ end
158
+
159
+ describe "#image" do
160
+ it "returns a formatted Image" do
161
+ slide = Slide.new "Image" do
162
+ image("cornify.gif", "Unicorn", width: 280, height: 326)
163
+ end
164
+
165
+ slide.compile.must_include %{<img width="280" height="326" src="images/cornify.gif" alt="Unicorn">}
166
+ end
167
+ end
168
+
169
+ describe "#media" do
170
+ it "returns a formatted media element" do
171
+ slide = Slide.new "Video" do
172
+ media "video.mp4", type: :video
173
+ end
174
+
175
+ slide.compile.must_include %{<video data-autoplay src="video/video.mp4"></video>}
176
+ end
177
+ end
146
178
  end
147
179
  end
@@ -7,6 +7,9 @@ require_relative 'slide_hero/grouped_slides_spec'
7
7
  require_relative 'slide_hero/code_spec'
8
8
  require_relative 'slide_hero/presentation_spec'
9
9
  require_relative 'slide_hero/dsl_spec'
10
+ require_relative 'slide_hero/note_spec'
11
+ require_relative 'slide_hero/image_spec'
12
+ require_relative 'slide_hero/media_spec'
10
13
 
11
14
  describe ::SlideHero do
12
15
  it "has a version" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slide_hero
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Nunez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-16 00:00:00.000000000 Z
11
+ date: 2013-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tilt
@@ -131,6 +131,8 @@ extensions: []
131
131
  extra_rdoc_files: []
132
132
  files:
133
133
  - .gitignore
134
+ - .ruby-gemset
135
+ - .ruby-version
134
136
  - .travis.yml
135
137
  - Gemfile
136
138
  - Guardfile
@@ -143,8 +145,11 @@ files:
143
145
  - lib/slide_hero/code.rb
144
146
  - lib/slide_hero/dsl.rb
145
147
  - lib/slide_hero/grouped_slides.rb
148
+ - lib/slide_hero/image.rb
146
149
  - lib/slide_hero/list.rb
147
150
  - lib/slide_hero/list_point.rb
151
+ - lib/slide_hero/media.rb
152
+ - lib/slide_hero/note.rb
148
153
  - lib/slide_hero/point.rb
149
154
  - lib/slide_hero/presentation.rb
150
155
  - lib/slide_hero/slide.rb
@@ -160,13 +165,16 @@ files:
160
165
  - lib/slide_hero/views/unordered_list.html.erb
161
166
  - slide_hero.gemspec
162
167
  - templates/new_presentation.tt
163
- - test/fixtures/testclass.rb
168
+ - test/fixtures/code/testclass.rb
164
169
  - test/minitest_helper.rb
165
170
  - test/slide_hero/code_spec.rb
166
171
  - test/slide_hero/dsl_spec.rb
167
172
  - test/slide_hero/grouped_slides_spec.rb
173
+ - test/slide_hero/image_spec.rb
168
174
  - test/slide_hero/list_point_spec.rb
169
175
  - test/slide_hero/list_spec.rb
176
+ - test/slide_hero/media_spec.rb
177
+ - test/slide_hero/note_spec.rb
170
178
  - test/slide_hero/point_spec.rb
171
179
  - test/slide_hero/presentation_spec.rb
172
180
  - test/slide_hero/slide_spec.rb
@@ -259,18 +267,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
259
267
  version: '0'
260
268
  requirements: []
261
269
  rubyforge_project:
262
- rubygems_version: 2.1.6
270
+ rubygems_version: 2.1.10
263
271
  signing_key:
264
272
  specification_version: 4
265
273
  summary: Used for creating slide decks backed by reveal.js
266
274
  test_files:
267
- - test/fixtures/testclass.rb
275
+ - test/fixtures/code/testclass.rb
268
276
  - test/minitest_helper.rb
269
277
  - test/slide_hero/code_spec.rb
270
278
  - test/slide_hero/dsl_spec.rb
271
279
  - test/slide_hero/grouped_slides_spec.rb
280
+ - test/slide_hero/image_spec.rb
272
281
  - test/slide_hero/list_point_spec.rb
273
282
  - test/slide_hero/list_spec.rb
283
+ - test/slide_hero/media_spec.rb
284
+ - test/slide_hero/note_spec.rb
274
285
  - test/slide_hero/point_spec.rb
275
286
  - test/slide_hero/presentation_spec.rb
276
287
  - test/slide_hero/slide_spec.rb
File without changes