slide_hero 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/.tags +105 -0
- data/Gemfile +1 -1
- data/README.md +47 -25
- data/lib/slide_hero/remote_image.rb +48 -0
- data/lib/slide_hero/slide.rb +5 -1
- data/lib/slide_hero/version.rb +1 -1
- data/lib/slide_hero.rb +3 -2
- data/slide_hero.gemspec +1 -0
- data/test/fixtures/images/image.png +0 -0
- data/test/slide_hero/remote_image_spec.rb +52 -0
- data/test/slide_hero/slide_spec.rb +21 -0
- data/test/slide_hero_spec.rb +1 -0
- metadata +45 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffefa6937d5400b1106dd9fe5fcbb632bfdaa1d1
|
4
|
+
data.tar.gz: f5a1dddee91bcc53336e99ab562a2f82777ee3d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adef2cd82d6a4c26ceb86f7d2cbe489aaff6bef1f1b2fe781c00ce8f5be465bc9ecefd1d764f4bfb1809ed42bd5fcecec727e2e98dcbed9ca5059790d1a2f943
|
7
|
+
data.tar.gz: 96e91f45863e3d43df3d9fdcec19fff2aa3b74392401289b981dcbd526e2660d19f842e6674c54977b22d7d9d16d8942cd2074515c66904f8c024c0325efbd36
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.1
|
data/.tags
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
|
2
|
+
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
|
3
|
+
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
|
4
|
+
!_TAG_PROGRAM_NAME Exuberant Ctags //
|
5
|
+
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
|
6
|
+
!_TAG_PROGRAM_VERSION 5.8 //
|
7
|
+
Code ./lib/slide_hero/code.rb /^ class Code$/;" c class:SlideHero
|
8
|
+
DSL ./lib/slide_hero/dsl.rb /^ module DSL$/;" m class:SlideHero
|
9
|
+
GroupedSlides ./lib/slide_hero/grouped_slides.rb /^ class GroupedSlides$/;" c class:SlideHero
|
10
|
+
Image ./lib/slide_hero/image.rb /^ class Image$/;" c class:SlideHero
|
11
|
+
List ./lib/slide_hero/list.rb /^ class List$/;" c class:SlideHero
|
12
|
+
ListPoint ./lib/slide_hero/list_point.rb /^ class ListPoint$/;" c class:SlideHero
|
13
|
+
Media ./lib/slide_hero/media.rb /^ class Media$/;" c class:SlideHero
|
14
|
+
Note ./lib/slide_hero/note.rb /^ class Note$/;" c class:SlideHero
|
15
|
+
Plugins ./lib/slide_hero/plugins.rb /^ module Plugins$/;" m class:SlideHero
|
16
|
+
Point ./lib/slide_hero/point.rb /^ class Point$/;" c class:SlideHero
|
17
|
+
Presentation ./lib/slide_hero/presentation.rb /^ class Presentation$/;" c class:SlideHero
|
18
|
+
Slide ./lib/slide_hero/slide.rb /^ class Slide$/;" c class:SlideHero
|
19
|
+
SlideHero ./lib/slide_hero.rb /^module SlideHero$/;" m
|
20
|
+
SlideHero ./lib/slide_hero/code.rb /^module SlideHero$/;" m
|
21
|
+
SlideHero ./lib/slide_hero/dsl.rb /^module SlideHero$/;" m
|
22
|
+
SlideHero ./lib/slide_hero/grouped_slides.rb /^module SlideHero$/;" m
|
23
|
+
SlideHero ./lib/slide_hero/image.rb /^module SlideHero$/;" m
|
24
|
+
SlideHero ./lib/slide_hero/list.rb /^module SlideHero$/;" m
|
25
|
+
SlideHero ./lib/slide_hero/list_point.rb /^module SlideHero$/;" m
|
26
|
+
SlideHero ./lib/slide_hero/media.rb /^module SlideHero$/;" m
|
27
|
+
SlideHero ./lib/slide_hero/note.rb /^module SlideHero$/;" m
|
28
|
+
SlideHero ./lib/slide_hero/plugins.rb /^module SlideHero$/;" m
|
29
|
+
SlideHero ./lib/slide_hero/point.rb /^module SlideHero$/;" m
|
30
|
+
SlideHero ./lib/slide_hero/presentation.rb /^module SlideHero$/;" m
|
31
|
+
SlideHero ./lib/slide_hero/slide.rb /^module SlideHero$/;" m
|
32
|
+
SlideHero ./lib/slide_hero/version.rb /^module SlideHero$/;" m
|
33
|
+
SlideHero ./test/slide_hero/code_spec.rb /^module SlideHero$/;" m
|
34
|
+
SlideHero ./test/slide_hero/dsl_spec.rb /^module SlideHero$/;" m
|
35
|
+
SlideHero ./test/slide_hero/grouped_slides_spec.rb /^module SlideHero$/;" m
|
36
|
+
SlideHero ./test/slide_hero/image_spec.rb /^module SlideHero$/;" m
|
37
|
+
SlideHero ./test/slide_hero/list_point_spec.rb /^module SlideHero$/;" m
|
38
|
+
SlideHero ./test/slide_hero/list_spec.rb /^module SlideHero$/;" m
|
39
|
+
SlideHero ./test/slide_hero/media_spec.rb /^module SlideHero$/;" m
|
40
|
+
SlideHero ./test/slide_hero/note_spec.rb /^module SlideHero$/;" m
|
41
|
+
SlideHero ./test/slide_hero/plugins_spec.rb /^module SlideHero$/;" m
|
42
|
+
SlideHero ./test/slide_hero/point_spec.rb /^module SlideHero$/;" m
|
43
|
+
SlideHero ./test/slide_hero/presentation_spec.rb /^module SlideHero$/;" m
|
44
|
+
SlideHero ./test/slide_hero/slide_spec.rb /^module SlideHero$/;" m
|
45
|
+
Working ./test/fixtures/code/testclass.rb /^class Working$/;" c
|
46
|
+
Working ./test/slide_hero/code_spec.rb /^ class Working$/;" c
|
47
|
+
Working ./test/slide_hero/slide_spec.rb /^ class Working$/;" c
|
48
|
+
animation ./lib/slide_hero/point.rb /^ def animation$/;" f class:SlideHero.Point
|
49
|
+
animation_class ./lib/slide_hero/list_point.rb /^ def animation_class$/;" f class:SlideHero.ListPoint
|
50
|
+
assert_dom_includes ./test/minitest_helper.rb /^def assert_dom_includes(expected, actual)$/;" f
|
51
|
+
assert_dom_match ./test/minitest_helper.rb /^def assert_dom_match(expected, actual)$/;" f
|
52
|
+
code ./lib/slide_hero/slide.rb /^ def code(*args, &code)$/;" f class:SlideHero.Slide
|
53
|
+
collected_slides ./lib/slide_hero/presentation.rb /^ def collected_slides$/;" f class:SlideHero.Presentation
|
54
|
+
compile ./lib/slide_hero/code.rb /^ def compile$/;" f class:SlideHero.Code
|
55
|
+
compile ./lib/slide_hero/grouped_slides.rb /^ def compile$/;" f class:SlideHero.GroupedSlides
|
56
|
+
compile ./lib/slide_hero/image.rb /^ def compile$/;" f class:SlideHero.Image
|
57
|
+
compile ./lib/slide_hero/list.rb /^ def compile$/;" f class:SlideHero.List
|
58
|
+
compile ./lib/slide_hero/media.rb /^ def compile$/;" f class:SlideHero.Media
|
59
|
+
compile ./lib/slide_hero/note.rb /^ def compile$/;" f class:SlideHero.Note
|
60
|
+
compile ./lib/slide_hero/point.rb /^ def compile$/;" f class:SlideHero.Point
|
61
|
+
compile ./lib/slide_hero/presentation.rb /^ def compile$/;" f class:SlideHero.Presentation
|
62
|
+
compile ./lib/slide_hero/slide.rb /^ def compile$/;" f class:SlideHero.Slide
|
63
|
+
data_attributes ./lib/slide_hero/slide.rb /^ def data_attributes$/;" f class:SlideHero.Slide
|
64
|
+
defaults ./lib/slide_hero/presentation.rb /^ def defaults(args)$/;" f class:SlideHero.Presentation
|
65
|
+
dom_clean ./test/minitest_helper.rb /^def dom_clean(html)$/;" f
|
66
|
+
get_binding ./lib/slide_hero.rb /^ def self.get_binding$/;" F class:SlideHero
|
67
|
+
grouped_slides ./lib/slide_hero/presentation.rb /^ def grouped_slides(&block)$/;" f class:SlideHero.Presentation
|
68
|
+
height_attribute ./lib/slide_hero/image.rb /^ def height_attribute$/;" f class:SlideHero.Image
|
69
|
+
image ./lib/slide_hero/slide.rb /^ def image(*args, **kwargs)$/;" f class:SlideHero.Slide
|
70
|
+
initialize ./lib/slide_hero/code.rb /^ def initialize(language, code_path=Dir.pwd, &code_file)$/;" f class:SlideHero.Code
|
71
|
+
initialize ./lib/slide_hero/grouped_slides.rb /^ def initialize(slide_defaults={}, &block)$/;" f class:SlideHero.GroupedSlides
|
72
|
+
initialize ./lib/slide_hero/image.rb /^ def initialize(location, alt_text="", width:nil, height:nil)$/;" f class:SlideHero.Image
|
73
|
+
initialize ./lib/slide_hero/list.rb /^ def initialize(style=:unordered, &block)$/;" f class:SlideHero.List
|
74
|
+
initialize ./lib/slide_hero/list_point.rb /^ def initialize(text, options={})$/;" f class:SlideHero.ListPoint
|
75
|
+
initialize ./lib/slide_hero/media.rb /^ def initialize(url, type: :video)$/;" f class:SlideHero.Media
|
76
|
+
initialize ./lib/slide_hero/note.rb /^ def initialize(text)$/;" f class:SlideHero.Note
|
77
|
+
initialize ./lib/slide_hero/point.rb /^ def initialize(text, animation: nil)$/;" f class:SlideHero.Point
|
78
|
+
initialize ./lib/slide_hero/presentation.rb /^ def initialize(title, &block)$/;" f class:SlideHero.Presentation
|
79
|
+
initialize ./lib/slide_hero/slide.rb /^ def initialize(headline=nil, headline_size: :medium, transition: :default, background_color: nil, &point_block)$/;" f class:SlideHero.Slide
|
80
|
+
list ./lib/slide_hero/list.rb /^ def list(style=:unordered, &block)$/;" f class:SlideHero.List
|
81
|
+
list ./lib/slide_hero/slide.rb /^ def list(style=:unordered, &block)$/;" f class:SlideHero.Slide
|
82
|
+
media ./lib/slide_hero/slide.rb /^ def media(*args, **kwargs)$/;" f class:SlideHero.Slide
|
83
|
+
note ./lib/slide_hero/slide.rb /^ def note(text)$/;" f class:SlideHero.Slide
|
84
|
+
plugins ./lib/slide_hero/presentation.rb /^ def plugins$/;" f class:SlideHero.Presentation
|
85
|
+
point ./lib/slide_hero/list.rb /^ def point(text, animation: nil)$/;" f class:SlideHero.List
|
86
|
+
point ./lib/slide_hero/slide.rb /^ def point(text, animation: nil)$/;" f class:SlideHero.Slide
|
87
|
+
points ./lib/slide_hero/list.rb /^ def points$/;" f class:SlideHero.List
|
88
|
+
points ./lib/slide_hero/slide.rb /^ def points$/;" f class:SlideHero.Slide
|
89
|
+
presentation ./lib/slide_hero/dsl.rb /^ def presentation(title, &slide_block)$/;" f class:SlideHero.DSL
|
90
|
+
reveal ./lib/slide_hero/plugins.rb /^ def self.reveal$/;" F class:SlideHero.Plugins
|
91
|
+
reveal_list ./lib/slide_hero/plugins.rb /^ def self.reveal_list$/;" F class:SlideHero.Plugins
|
92
|
+
set_plugins ./lib/slide_hero/presentation.rb /^ def set_plugins(*plugin_list)$/;" f class:SlideHero.Presentation
|
93
|
+
set_theme ./lib/slide_hero/presentation.rb /^ def set_theme(theme)$/;" f class:SlideHero.Presentation
|
94
|
+
size_to_markup ./lib/slide_hero/slide.rb /^ def size_to_markup$/;" f class:SlideHero.Slide
|
95
|
+
slide ./lib/slide_hero/grouped_slides.rb /^ def slide(headline, **kwargs, &block)$/;" f class:SlideHero.GroupedSlides
|
96
|
+
slide ./lib/slide_hero/presentation.rb /^ def slide(title, **kwargs, &slide_block)$/;" f class:SlideHero.Presentation
|
97
|
+
slides ./lib/slide_hero/grouped_slides.rb /^ def slides$/;" f class:SlideHero.GroupedSlides
|
98
|
+
slides ./lib/slide_hero/presentation.rb /^ def slides$/;" f class:SlideHero.Presentation
|
99
|
+
some_method ./test/fixtures/code/testclass.rb /^ def some_method$/;" f class:Working
|
100
|
+
some_method ./test/slide_hero/code_spec.rb /^ def some_method$/;" f class:Working
|
101
|
+
some_method ./test/slide_hero/slide_spec.rb /^ def some_method$/;" f class:Working
|
102
|
+
template_path ./lib/slide_hero.rb /^ def self.template_path$/;" F class:SlideHero
|
103
|
+
theme ./lib/slide_hero/presentation.rb /^ def theme$/;" f class:SlideHero.Presentation
|
104
|
+
to_s ./lib/slide_hero/list_point.rb /^ def to_s$/;" f class:SlideHero.ListPoint
|
105
|
+
width_attribute ./lib/slide_hero/image.rb /^ def width_attribute$/;" f class:SlideHero.Image
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,21 @@
|
|
1
1
|
# SlideHero
|
2
2
|
|
3
|
-
SlideHero is a gem for creating presentations backed by reveal.js through a
|
4
|
-
Ruby DSL.
|
3
|
+
SlideHero is a gem for creating presentations backed by reveal.js through a
|
4
|
+
Ruby DSL.
|
5
|
+
|
6
|
+
``` ruby
|
7
|
+
presentation "My Presentation" do
|
8
|
+
slide "A slide" do
|
9
|
+
point "An interesting Point"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
```
|
13
|
+
|
14
|
+
That's it!
|
5
15
|
|
6
16
|
## Installation
|
7
17
|
|
8
|
-
Requires Ruby 2.
|
18
|
+
Requires Ruby 2.1
|
9
19
|
|
10
20
|
Add this line to your application's Gemfile:
|
11
21
|
|
@@ -27,21 +37,21 @@ All features are accessible through the `slidehero` command.
|
|
27
37
|
### Generator
|
28
38
|
|
29
39
|
slidehero new presentation_name
|
30
|
-
|
31
|
-
This creates a new folder named `presentation_name` in the current directory. Inside, there is a sample file called `presentation.rb`.
|
40
|
+
|
41
|
+
This creates a new folder named `presentation_name` in the current directory. Inside, there is a sample file called `presentation.rb`.
|
32
42
|
|
33
43
|
### Server
|
34
44
|
|
35
45
|
slidehero serve
|
36
|
-
|
46
|
+
|
37
47
|
Call this in the same folder as your presentation to serve your files on port 9292. You can optionally pass in an alternate location for the presentation.rb file.
|
38
48
|
|
39
49
|
slidehero serve ../other/folder/presentation.rb
|
40
|
-
|
50
|
+
|
41
51
|
### Compilation
|
42
52
|
|
43
53
|
slidehero compile
|
44
|
-
|
54
|
+
|
45
55
|
Use this if you just want a folder with the markup files. A new `presentation` folder is created.
|
46
56
|
|
47
57
|
### DSL
|
@@ -49,7 +59,7 @@ Use this if you just want a folder with the markup files. A new `presentation` f
|
|
49
59
|
The DSL for SlideHero was created to add expressibility to creating slides.
|
50
60
|
|
51
61
|
**presentation**
|
52
|
-
|
62
|
+
|
53
63
|
```ruby
|
54
64
|
presentation "My Presentation" do
|
55
65
|
end
|
@@ -66,7 +76,7 @@ presentation "My Presentation" do
|
|
66
76
|
end
|
67
77
|
end
|
68
78
|
```
|
69
|
-
|
79
|
+
|
70
80
|
`#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.
|
71
81
|
|
72
82
|
```ruby
|
@@ -104,11 +114,11 @@ end
|
|
104
114
|
```ruby
|
105
115
|
presentation "My Presentation" do
|
106
116
|
defaults headline_size: :medium, transition: :fade
|
107
|
-
|
117
|
+
|
108
118
|
slide "A slide" do
|
109
119
|
#…
|
110
120
|
end
|
111
|
-
|
121
|
+
|
112
122
|
slide "Some slides override", headline_size: :large do
|
113
123
|
#…#…
|
114
124
|
end
|
@@ -130,7 +140,7 @@ Valid theme options are: default, sky, beige, simple, serif, night, moon, solari
|
|
130
140
|
**plugins**
|
131
141
|
|
132
142
|
You can activate revealjs plugins by passing a symbol array to the
|
133
|
-
`set_plugins` method.
|
143
|
+
`set_plugins` method.
|
134
144
|
|
135
145
|
``` ruby
|
136
146
|
presentation "My Presentation" do
|
@@ -141,7 +151,7 @@ end
|
|
141
151
|
Currently supported plugins are `:class_list`, `:markdown`, `:highlight`, `:zoom`,
|
142
152
|
`:notes`, `:remote`, and `:leap`.
|
143
153
|
|
144
|
-
`:class_list`, `:
|
154
|
+
`:class_list`, `:highlight`, and `:notes` are used if `set_plugins` is
|
145
155
|
not called.
|
146
156
|
|
147
157
|
See Reveal.js [documentation](https://github.com/hakimel/reveal.js/#dependencies) for more info on these plugins.
|
@@ -171,7 +181,7 @@ presentation "My Presentation" do
|
|
171
181
|
end
|
172
182
|
end
|
173
183
|
```
|
174
|
-
|
184
|
+
|
175
185
|
`#grouped_slides` lets you nest slides. In reveal, this translates into vertical slides.
|
176
186
|
|
177
187
|
**lists**
|
@@ -187,7 +197,7 @@ presentation "My Presentation" do
|
|
187
197
|
slide "Slide 2" do
|
188
198
|
list(:ordered) do
|
189
199
|
point "I should go first"
|
190
|
-
point "I'm
|
200
|
+
point "I'm OK going second"
|
191
201
|
list do
|
192
202
|
point "I'm in a nested list"
|
193
203
|
end
|
@@ -196,7 +206,7 @@ presentation "My Presentation" do
|
|
196
206
|
end
|
197
207
|
```
|
198
208
|
|
199
|
-
`#list` must be nested in a slide. It takes an optional argument of :ordered to
|
209
|
+
`#list` must be nested in a slide. It takes an optional argument of :ordered to
|
200
210
|
create an ordered list. List items are added by the `#point` method.
|
201
211
|
|
202
212
|
**code**
|
@@ -210,9 +220,9 @@ presentation "My Presentation" do
|
|
210
220
|
end
|
211
221
|
end
|
212
222
|
```
|
213
|
-
|
214
|
-
`#code` must be nested in a slide. It loads any code file in the same directory as the file.
|
215
|
-
The language passed as an argument will be embedded in the markup.
|
223
|
+
|
224
|
+
`#code` must be nested in a slide. It loads any code file in the same directory as the file.
|
225
|
+
The language passed as an argument will be embedded in the markup.
|
216
226
|
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.
|
217
227
|
All supported languages can be found on the [Highlight.js Page](http://softwaremaniacs.org/media/soft/highlight/test.html)
|
218
228
|
|
@@ -236,9 +246,21 @@ presentation "My Presentation" do
|
|
236
246
|
image "chunky_bacon.png"
|
237
247
|
end
|
238
248
|
end
|
239
|
-
```
|
240
|
-
`#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'
|
241
|
-
In this example, it will load an image named 'chunky_bacon.png in the images folder.
|
249
|
+
```
|
250
|
+
`#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' sub-folder
|
251
|
+
In this example, it will load an image named 'chunky_bacon.png' in the images folder.
|
252
|
+
|
253
|
+
**remote_image**
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
presentation "My Presentation" do
|
257
|
+
slide "A slide" do
|
258
|
+
remote_image "http://example.com/chunky_bacon.png", as: "bacon"
|
259
|
+
end
|
260
|
+
end
|
261
|
+
```
|
262
|
+
|
263
|
+
`#remote_image` takes the same arguments as `#image` with the addition of the `as:` parameter. The file is downloaded and stored in the presentation's `images` folder and is named after the `as` value. Leave the `as` option off if you want to use the name in the url.
|
242
264
|
|
243
265
|
**media**
|
244
266
|
|
@@ -251,7 +273,7 @@ In this example, it will load an image named 'chunky_bacon.png in the images fol
|
|
251
273
|
media "audio.mp3", type: audio
|
252
274
|
end
|
253
275
|
end
|
254
|
-
|
276
|
+
|
255
277
|
`#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.
|
256
278
|
|
257
279
|
#### Animation
|
@@ -260,7 +282,7 @@ Animation for points are supported.
|
|
260
282
|
|
261
283
|
```ruby
|
262
284
|
#…
|
263
|
-
slide do
|
285
|
+
slide do
|
264
286
|
point "My point", animation: "grow"
|
265
287
|
list do
|
266
288
|
point "My", animation: "step"
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "open-uri"
|
2
|
+
module SlideHero
|
3
|
+
class RemoteImage
|
4
|
+
attr_reader :location, :alt_text, :width, :height, :image_class, :as, :destination
|
5
|
+
def initialize(location, alt_text="", image_class:Image, width:nil, height:nil, destination: 'images', as:nil)
|
6
|
+
@location = location
|
7
|
+
@alt_text = alt_text
|
8
|
+
@width = width
|
9
|
+
@height = height
|
10
|
+
@image_class = image_class
|
11
|
+
@destination = destination
|
12
|
+
@as = as
|
13
|
+
end
|
14
|
+
|
15
|
+
def compile
|
16
|
+
fetch_remote_file unless file_cached?
|
17
|
+
image_class.new(filename, alt_text, width: width, height:height).compile
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def file_cached?
|
23
|
+
File.exist?("#{destination}/#{filename}")
|
24
|
+
end
|
25
|
+
|
26
|
+
def fetch_remote_file
|
27
|
+
open(location) do |f|
|
28
|
+
File.open("#{destination}/#{filename}","wb") do |file|
|
29
|
+
file.puts f.read
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def filename
|
35
|
+
local_filename || remote_filename
|
36
|
+
end
|
37
|
+
|
38
|
+
def local_filename
|
39
|
+
return nil unless as
|
40
|
+
file_extention = URI.parse(location).path.split('.').last
|
41
|
+
"#{as}.#{file_extention}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def remote_filename
|
45
|
+
URI.parse(location).path.split('/').last
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/slide_hero/slide.rb
CHANGED
@@ -40,13 +40,17 @@ module SlideHero
|
|
40
40
|
points << Image.new(*args, **kwargs).compile
|
41
41
|
end
|
42
42
|
|
43
|
+
def remote_image(*args, **kwargs)
|
44
|
+
points << RemoteImage.new(*args, **kwargs).compile
|
45
|
+
end
|
46
|
+
|
43
47
|
def media(*args, **kwargs)
|
44
48
|
points << Media.new(*args, **kwargs).compile
|
45
49
|
end
|
46
50
|
|
47
51
|
private
|
48
52
|
def size_to_markup
|
49
|
-
{
|
53
|
+
{
|
50
54
|
large: :h1,
|
51
55
|
medium: :h2,
|
52
56
|
small: :h3
|
data/lib/slide_hero/version.rb
CHANGED
data/lib/slide_hero.rb
CHANGED
@@ -9,6 +9,7 @@ require_relative "slide_hero/code"
|
|
9
9
|
require_relative "slide_hero/presentation"
|
10
10
|
require_relative "slide_hero/note"
|
11
11
|
require_relative "slide_hero/image"
|
12
|
+
require_relative "slide_hero/remote_image"
|
12
13
|
require_relative "slide_hero/media"
|
13
14
|
require_relative "slide_hero/dsl"
|
14
15
|
|
@@ -19,8 +20,8 @@ module SlideHero
|
|
19
20
|
|
20
21
|
def self.template_path
|
21
22
|
gem = Gem.loaded_specs['slide_hero']
|
22
|
-
if gem
|
23
|
-
gem.full_gem_path
|
23
|
+
if gem
|
24
|
+
gem.full_gem_path
|
24
25
|
else
|
25
26
|
'.'
|
26
27
|
end
|
data/slide_hero.gemspec
CHANGED
Binary file
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
require 'webmock/minitest'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module SlideHero
|
6
|
+
describe Image do
|
7
|
+
|
8
|
+
describe "using the `as` parameter" do
|
9
|
+
after do
|
10
|
+
image = File.join(Dir.pwd,"test","tmp","images", "le_troll.png")
|
11
|
+
File.delete(image)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "downloads remote file, and serves it locally" do
|
15
|
+
stub_request(:get, "http://example.com/troll.png").
|
16
|
+
to_return(body: File.open(File.join(Dir.pwd,"test","fixtures","images", "image.png")))
|
17
|
+
|
18
|
+
destination_folder = File.join(Dir.pwd,"test","tmp","images")
|
19
|
+
image = RemoteImage.new("http://example.com/troll.png", "Troll", width: 280, height: 326, as: "le_troll", destination: destination_folder)
|
20
|
+
image.compile.must_equal %{<img width="280" height="326" src="images/le_troll.png" alt="Troll">}
|
21
|
+
assert_requested :get, "http://example.com/troll.png"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "does not make web request if image is in destination folder" do
|
25
|
+
destination_folder = File.join(Dir.pwd,"test","tmp","images")
|
26
|
+
FileUtils.touch("#{destination_folder}/le_troll.png")
|
27
|
+
|
28
|
+
stub_request(:get, "http://example.com/troll.png")
|
29
|
+
|
30
|
+
image = RemoteImage.new("http://example.com/troll.png", "Troll", width: 280, height: 326, as: "le_troll", destination: destination_folder)
|
31
|
+
image.compile.must_equal %{<img width="280" height="326" src="images/le_troll.png" alt="Troll">}
|
32
|
+
assert_not_requested :get, "http://example.com/troll.png"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
describe "not providing filename" do
|
38
|
+
after do
|
39
|
+
image = File.join(Dir.pwd,"test","tmp","images", "troll.png")
|
40
|
+
File.delete(image)
|
41
|
+
end
|
42
|
+
it "uses filename from url if not provided" do
|
43
|
+
stub_request(:get, "http://example.com/troll.png").
|
44
|
+
to_return(body: File.open(File.join(Dir.pwd,"test","fixtures","images", "image.png")))
|
45
|
+
|
46
|
+
destination_folder = File.join(Dir.pwd,"test","tmp","images")
|
47
|
+
image = RemoteImage.new("http://example.com/troll.png", "Troll", width: 280, height: 326, destination: destination_folder)
|
48
|
+
image.compile.must_equal %{<img width="280" height="326" src="images/troll.png" alt="Troll">}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'minitest_helper'
|
2
|
+
require 'webmock/minitest'
|
2
3
|
|
3
4
|
module SlideHero
|
4
5
|
describe Slide do
|
@@ -185,6 +186,26 @@ end
|
|
185
186
|
end
|
186
187
|
end
|
187
188
|
|
189
|
+
describe "#remote_image" do
|
190
|
+
after do
|
191
|
+
image = File.join(Dir.pwd,"test","tmp","images", "le_troll.png")
|
192
|
+
File.delete(image)
|
193
|
+
end
|
194
|
+
|
195
|
+
it "returns a formatted Image from a remote source" do
|
196
|
+
stub_request(:get, "http://example.com/troll.png").
|
197
|
+
to_return(body: File.open(File.join(Dir.pwd,"test","fixtures","images", "image.png")))
|
198
|
+
|
199
|
+
destination_folder = File.join(Dir.pwd,"test","tmp","images")
|
200
|
+
|
201
|
+
slide = Slide.new "Image" do
|
202
|
+
remote_image("http://example.com/troll.png", "Troll", width: 280, height: 326, as: "le_troll", destination: destination_folder)
|
203
|
+
end
|
204
|
+
|
205
|
+
slide.compile.must_include %{<img width="280" height="326" src="images/le_troll.png" alt="Troll">}
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
188
209
|
describe "#media" do
|
189
210
|
it "returns a formatted media element" do
|
190
211
|
slide = Slide.new "Video" do
|
data/test/slide_hero_spec.rb
CHANGED
@@ -9,6 +9,7 @@ require_relative 'slide_hero/presentation_spec'
|
|
9
9
|
require_relative 'slide_hero/dsl_spec'
|
10
10
|
require_relative 'slide_hero/note_spec'
|
11
11
|
require_relative 'slide_hero/image_spec'
|
12
|
+
require_relative 'slide_hero/remote_image_spec'
|
12
13
|
require_relative 'slide_hero/media_spec'
|
13
14
|
require_relative 'slide_hero/plugins_spec'
|
14
15
|
|
metadata
CHANGED
@@ -1,127 +1,141 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slide_hero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Nunez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tilt
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: thor
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0.18'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.18'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rack
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.5'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '10.1'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '10.1'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: minitest
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '5.2'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '5.2'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: guard
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '2.4'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '2.4'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: guard-minitest
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '2.2'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - ~>
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '2.2'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.20'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.20'
|
125
139
|
description: Used for creating slide decks backed by reveal.js
|
126
140
|
email:
|
127
141
|
- steven.nunez@gmail.com
|
@@ -130,10 +144,11 @@ executables:
|
|
130
144
|
extensions: []
|
131
145
|
extra_rdoc_files: []
|
132
146
|
files:
|
133
|
-
- .gitignore
|
134
|
-
- .ruby-gemset
|
135
|
-
- .ruby-version
|
136
|
-
- .
|
147
|
+
- ".gitignore"
|
148
|
+
- ".ruby-gemset"
|
149
|
+
- ".ruby-version"
|
150
|
+
- ".tags"
|
151
|
+
- ".travis.yml"
|
137
152
|
- Gemfile
|
138
153
|
- Guardfile
|
139
154
|
- LICENSE.txt
|
@@ -153,6 +168,7 @@ files:
|
|
153
168
|
- lib/slide_hero/plugins.rb
|
154
169
|
- lib/slide_hero/point.rb
|
155
170
|
- lib/slide_hero/presentation.rb
|
171
|
+
- lib/slide_hero/remote_image.rb
|
156
172
|
- lib/slide_hero/slide.rb
|
157
173
|
- lib/slide_hero/version.rb
|
158
174
|
- lib/slide_hero/views/_footer.html.erb
|
@@ -167,6 +183,7 @@ files:
|
|
167
183
|
- slide_hero.gemspec
|
168
184
|
- templates/new_presentation.tt
|
169
185
|
- test/fixtures/code/testclass.rb
|
186
|
+
- test/fixtures/images/image.png
|
170
187
|
- test/minitest_helper.rb
|
171
188
|
- test/slide_hero/code_spec.rb
|
172
189
|
- test/slide_hero/dsl_spec.rb
|
@@ -179,6 +196,7 @@ files:
|
|
179
196
|
- test/slide_hero/plugins_spec.rb
|
180
197
|
- test/slide_hero/point_spec.rb
|
181
198
|
- test/slide_hero/presentation_spec.rb
|
199
|
+
- test/slide_hero/remote_image_spec.rb
|
182
200
|
- test/slide_hero/slide_spec.rb
|
183
201
|
- test/slide_hero_spec.rb
|
184
202
|
- vendor/reveal.js/.gitignore
|
@@ -272,22 +290,23 @@ require_paths:
|
|
272
290
|
- lib
|
273
291
|
required_ruby_version: !ruby/object:Gem::Requirement
|
274
292
|
requirements:
|
275
|
-
- -
|
293
|
+
- - ">="
|
276
294
|
- !ruby/object:Gem::Version
|
277
295
|
version: '0'
|
278
296
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
279
297
|
requirements:
|
280
|
-
- -
|
298
|
+
- - ">="
|
281
299
|
- !ruby/object:Gem::Version
|
282
300
|
version: '0'
|
283
301
|
requirements: []
|
284
302
|
rubyforge_project:
|
285
|
-
rubygems_version: 2.
|
303
|
+
rubygems_version: 2.4.5
|
286
304
|
signing_key:
|
287
305
|
specification_version: 4
|
288
306
|
summary: Used for creating slide decks backed by reveal.js
|
289
307
|
test_files:
|
290
308
|
- test/fixtures/code/testclass.rb
|
309
|
+
- test/fixtures/images/image.png
|
291
310
|
- test/minitest_helper.rb
|
292
311
|
- test/slide_hero/code_spec.rb
|
293
312
|
- test/slide_hero/dsl_spec.rb
|
@@ -300,5 +319,6 @@ test_files:
|
|
300
319
|
- test/slide_hero/plugins_spec.rb
|
301
320
|
- test/slide_hero/point_spec.rb
|
302
321
|
- test/slide_hero/presentation_spec.rb
|
322
|
+
- test/slide_hero/remote_image_spec.rb
|
303
323
|
- test/slide_hero/slide_spec.rb
|
304
324
|
- test/slide_hero_spec.rb
|