reveal-ck 0.1.6 → 0.1.7

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.
Files changed (83) hide show
  1. checksums.yaml +8 -8
  2. data/bin/reveal-ck +18 -12
  3. data/lib/reveal-ck.rb +3 -10
  4. data/lib/reveal-ck/builders.rb +4 -0
  5. data/lib/reveal-ck/builders/build_task.rb +21 -0
  6. data/lib/reveal-ck/builders/builder.rb +27 -0
  7. data/lib/reveal-ck/builders/index_html.rb +85 -0
  8. data/lib/reveal-ck/builders/packaged_slides.rb +84 -0
  9. data/lib/reveal-ck/changers.rb +3 -0
  10. data/lib/reveal-ck/changers/slicer.rb +25 -0
  11. data/lib/reveal-ck/changers/splicer.rb +37 -0
  12. data/lib/reveal-ck/changers/string_replacer.rb +18 -0
  13. data/lib/reveal-ck/config.rb +51 -23
  14. data/lib/reveal-ck/presentation.rb +24 -15
  15. data/lib/reveal-ck/presentation_dsl.rb +20 -12
  16. data/lib/reveal-ck/slide.rb +3 -3
  17. data/lib/reveal-ck/templates.rb +3 -0
  18. data/lib/reveal-ck/templates/finder.rb +35 -0
  19. data/lib/reveal-ck/templates/processor.rb +32 -0
  20. data/lib/reveal-ck/templates/render_scope.rb +14 -0
  21. data/lib/reveal-ck/version.rb +1 -1
  22. data/rakelib/examples.rake +7 -0
  23. data/spec/data/{slicer → changers/slicer}/after_remove +0 -0
  24. data/spec/data/{slicer → changers/slicer}/before_remove +0 -0
  25. data/spec/data/{splicer → changers/splicer}/abcd +0 -0
  26. data/spec/data/{splicer → changers/splicer}/after_insert +0 -0
  27. data/spec/data/{splicer → changers/splicer}/before_insert +0 -0
  28. data/spec/data/{string_replacer → changers/string_replacer}/after_replace +0 -0
  29. data/spec/data/{string_replacer → changers/string_replacer}/before_replace +0 -0
  30. data/spec/data/config/full_config.toml +7 -0
  31. data/spec/data/config/partial_config.toml +1 -0
  32. data/spec/data/presentation/slides.haml +2 -0
  33. data/spec/data/presentation/slides.rb +5 -0
  34. data/spec/data/{dsl/slides.rb → presentation_dsl/dsl.rb} +4 -0
  35. data/spec/data/templates/finder/code/function.rb +3 -0
  36. data/spec/data/{template_finder/automated/automated.slim → templates/finder/quotes/create} +0 -0
  37. data/spec/data/{template_finder/automated/common.haml → templates/finder/templates/template_one.slim} +0 -0
  38. data/spec/data/{template_finder/custom/common.haml → templates/finder/templates/template_two.slim} +0 -0
  39. data/spec/data/{template_finder/custom/custom.slim → templates/finder/templates/text.slim} +0 -0
  40. data/spec/data/{haml → templates/processor}/basic.haml +0 -0
  41. data/spec/data/{slim → templates/processor}/basic.slim +0 -0
  42. data/spec/data/templates/render_scope/quote +2 -0
  43. data/spec/examples/programmatic_slides_spec.rb +12 -0
  44. data/spec/examples/slide_output_spec.rb +12 -0
  45. data/spec/lib/reveal-ck/builders/builder_spec.rb +39 -0
  46. data/spec/lib/reveal-ck/builders/packaged_slides_spec.rb +39 -0
  47. data/spec/lib/reveal-ck/changers/slicer_spec.rb +46 -0
  48. data/spec/lib/reveal-ck/changers/splicer_spec.rb +45 -0
  49. data/spec/lib/reveal-ck/changers/string_replacer_spec.rb +35 -0
  50. data/spec/lib/reveal-ck/config_spec.rb +68 -20
  51. data/spec/lib/reveal-ck/presentation_dsl_spec.rb +21 -11
  52. data/spec/lib/reveal-ck/presentation_spec.rb +40 -38
  53. data/spec/lib/reveal-ck/slide_spec.rb +3 -3
  54. data/spec/lib/reveal-ck/templates/finder_spec.rb +88 -0
  55. data/spec/lib/reveal-ck/templates/processor_spec.rb +31 -0
  56. data/spec/lib/reveal-ck/templates/render_scope_spec.rb +24 -0
  57. data/templates/{title.slim → intro.slim} +0 -0
  58. metadata +77 -71
  59. data/lib/reveal-ck/build_task.rb +0 -19
  60. data/lib/reveal-ck/builder.rb +0 -25
  61. data/lib/reveal-ck/file_slicer.rb +0 -23
  62. data/lib/reveal-ck/file_splicer.rb +0 -36
  63. data/lib/reveal-ck/file_string_replacer.rb +0 -16
  64. data/lib/reveal-ck/presentation_builder.rb +0 -94
  65. data/lib/reveal-ck/slide_builder.rb +0 -81
  66. data/lib/reveal-ck/slides_html_builder.rb +0 -39
  67. data/lib/reveal-ck/template_finder.rb +0 -33
  68. data/lib/reveal-ck/template_processor.rb +0 -28
  69. data/spec/data/config/config.toml +0 -6
  70. data/spec/data/html/converted_basic_haml.html +0 -10
  71. data/spec/data/html/converted_basic_slim.html +0 -10
  72. data/spec/data/html/reveal-js-index.html +0 -375
  73. data/spec/data/slides_html_builder/slides.haml +0 -3
  74. data/spec/data/slides_html_builder/slides.rb +0 -14
  75. data/spec/data/slides_html_builder/slides.slim +0 -2
  76. data/spec/lib/reveal-ck/builder_spec.rb +0 -37
  77. data/spec/lib/reveal-ck/file_slicer_spec.rb +0 -44
  78. data/spec/lib/reveal-ck/file_splicer_spec.rb +0 -43
  79. data/spec/lib/reveal-ck/file_string_replacer_spec.rb +0 -34
  80. data/spec/lib/reveal-ck/presentation_builder_spec.rb +0 -37
  81. data/spec/lib/reveal-ck/slides_html_builder_spec.rb +0 -102
  82. data/spec/lib/reveal-ck/template_finder_spec.rb +0 -87
  83. data/spec/lib/reveal-ck/template_processor_spec.rb +0 -29
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+ require 'fileutils'
3
+ require 'tmpdir'
4
+
5
+ module RevealCK
6
+ module Changers
7
+ describe Splicer do
8
+
9
+ describe '.insert!' do
10
+
11
+ let :before_insert do
12
+ spec_data 'changers', 'splicer', 'before_insert'
13
+ end
14
+
15
+ let :abcd do
16
+ spec_data 'changers', 'splicer', 'abcd'
17
+ end
18
+
19
+ let :after_insert do
20
+ spec_data 'changers', 'splicer', 'after_insert'
21
+ end
22
+
23
+ it 'inserts one file into another' do
24
+ Dir.mktmpdir do |tmp_dir|
25
+ FileUtils.cp before_insert, tmp_dir
26
+ test_file = File.join tmp_dir, 'before_insert'
27
+ Splicer.insert! abcd, into: test_file, after: '3'
28
+ test_file_contents = File.open(test_file).read
29
+ after_insert_contents = File.open(after_insert).read
30
+ test_file_contents.should == after_insert_contents
31
+ end
32
+ end
33
+ end
34
+
35
+ describe '#insert' do
36
+ it 'inserts lines after a match' do
37
+ original = ['0', '1', '2', '3']
38
+ splicer = Splicer.new original
39
+ result = splicer.insert ['a', 'b', 'c'], after: '2'
40
+ result.should == ['0', '1', '2', 'a', 'b', 'c', '3']
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+ require 'fileutils'
3
+ require 'tmpdir'
4
+
5
+ module RevealCK
6
+ module Changers
7
+ describe StringReplacer do
8
+
9
+ describe '.replace!' do
10
+
11
+ let :before_replace do
12
+ spec_data 'changers', 'string_replacer', 'before_replace'
13
+ end
14
+
15
+ let :after_replace do
16
+ spec_data 'changers', 'string_replacer', 'after_replace'
17
+ end
18
+
19
+ it 'replaces content within a file' do
20
+ Dir.mktmpdir do |tmp_dir|
21
+ FileUtils.cp before_replace, tmp_dir
22
+ test_file = File.join tmp_dir, 'before_replace'
23
+ StringReplacer.replace!(test_file,
24
+ old: ' hideaway at sea',
25
+ new: 'hh coconuts!')
26
+ test_file_contents = File.open(test_file).read
27
+ after_replace_contents = File.open(after_replace).read
28
+ test_file_contents.should == after_replace_contents
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,50 +1,98 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  module RevealCK
4
+
4
5
  describe Config do
5
6
 
6
- context 'when no config is supplied' do
7
+ class Example
8
+ include Config
9
+ end
10
+
11
+ context 'when included in a class' do
12
+
13
+ it 'supplies an #theme, and #theme=' do
14
+ example = Example.new
15
+ example.theme = 'night'
16
+ expect(example.theme).to eq 'night'
17
+ end
18
+
19
+ it 'supplies a default theme' do
20
+ example = Example.new
21
+ expect(example.theme).to eq 'default'
22
+ end
23
+
24
+ it 'supplies an #author, and #author=' do
25
+ example = Example.new
26
+ example.author = 'Jed Northridge'
27
+ expect(example.author).to eq 'Jed Northridge'
28
+ end
7
29
 
8
- let :config do
9
- Config.new
30
+ it 'supplies a default author' do
31
+ example = Example.new
32
+ expect(example.author).to eq ''
10
33
  end
11
34
 
12
- it '#title defaults to "Slides"' do
13
- config.title.should == "Slides"
35
+ it 'supplies an #title, and #title=' do
36
+ example = Example.new
37
+ example.title = 'My Presentation'
38
+ expect(example.title).to eq 'My Presentation'
14
39
  end
15
40
 
16
- it '#author defaults to "Hakim El Hattab"' do
17
- config.author.should == "Hakim El Hattab"
41
+ it 'supplies a default title' do
42
+ example = Example.new
43
+ expect(example.title).to eq 'Slides'
18
44
  end
19
45
 
20
- it '#theme defaults to "default"' do
21
- config.theme.should == "default"
46
+ it 'supplies an #transition, and #transition=' do
47
+ example = Example.new
48
+ example.transition = 'page'
49
+ expect(example.transition).to eq 'page'
50
+ end
51
+
52
+ it 'supplies a default transition' do
53
+ example = Example.new
54
+ expect(example.transition).to eq 'default'
22
55
  end
23
56
 
24
57
  end
25
58
 
26
- context 'when a config is supplied' do
59
+ describe '#merge_config' do
27
60
 
28
- let :config_file do
29
- File.join 'spec', 'data', 'config', 'config.toml'
61
+ let :full_config_file do
62
+ spec_data 'config', 'full_config.toml'
30
63
  end
31
64
 
32
- let :config do
33
- Config.new config_file: config_file
65
+ let :partial_config_file do
66
+ spec_data 'config', 'partial_config.toml'
34
67
  end
35
68
 
36
- it '#title comes from the config file' do
37
- expect(config.title).to eq "The Never Sea Slides"
69
+ it 'writes unset config options stored in a file' do
70
+ example = Example.new
71
+ example.merge_config file: full_config_file
72
+ expect(example.title).to eq 'The Never Sea Slides'
73
+ expect(example.author).to eq 'Captain Hook'
74
+ expect(example.theme).to eq 'night'
75
+ expect(example.transition).to eq 'page'
38
76
  end
39
77
 
40
- it '#author comes from the config file' do
41
- expect(config.author).to eq "Captain Hook"
78
+ it 'can grab just a single option' do
79
+ example = Example.new
80
+ example.merge_config file: partial_config_file
81
+ expect(example.title).to eq 'The Never Sea Slides'
42
82
  end
43
83
 
44
- it '#theme comes from the config file' do
45
- config.theme.should == "night"
84
+ it 'will not overwrite already set config options' do
85
+ example = Example.new
86
+ example.author = 'Jed Northridge'
87
+ example.transition = 'fade'
88
+ example.merge_config file: full_config_file
89
+ expect(example.author).to eq 'Jed Northridge'
90
+ expect(example.transition).to eq 'fade'
91
+ expect(example.title).to eq 'The Never Sea Slides'
92
+ expect(example.theme).to eq 'night'
46
93
  end
47
94
 
48
95
  end
96
+
49
97
  end
50
98
  end
@@ -4,37 +4,47 @@ module RevealCK
4
4
  describe PresentationDSL do
5
5
 
6
6
  let :dsl_file do
7
- File.join 'spec', 'data', 'dsl', 'slides.rb'
7
+ spec_data 'presentation_dsl', 'dsl.rb'
8
8
  end
9
9
 
10
10
  let :presentation do
11
11
  PresentationDSL.load dsl_file
12
12
  end
13
13
 
14
- describe '#load' do
14
+ describe '.load' do
15
15
  it 'can build a RevealCK::Presentation from a file' do
16
16
  result = PresentationDSL.load dsl_file
17
17
  expect(result).to be_a Presentation
18
18
  end
19
19
  end
20
20
 
21
- describe '.author' do
22
- it 'defines the author in the Presentation' do
21
+ describe 'A Presentation loaded from a dsl' do
22
+
23
+ let :html do
24
+ presentation.html
25
+ end
26
+
27
+ it 'retains the author in the dsl file' do
23
28
  expect(presentation.author).to eq 'Presentation Author'
24
29
  end
25
- end
26
30
 
27
- describe '.theme' do
28
- it 'defines the theme in the Presentation' do
31
+ it 'retains the theme in the dsl file' do
29
32
  expect(presentation.theme).to eq 'night'
30
33
  end
31
- end
32
34
 
33
- describe '.title' do
34
- it 'defines the title in the Presentation' do
35
+ it 'retains the title in the dsl file' do
35
36
  expect(presentation.title).to eq 'Presentation Title'
36
37
  end
37
- end
38
38
 
39
+ it 'retains the transition in the dsl file' do
40
+ expect(presentation.transition).to eq 'page'
41
+ end
42
+
43
+ it 'retains the slides defined in the dsl file' do
44
+ expect(html).to include 'Hello World'
45
+ expect(html).to include 'Thanks!'
46
+ expect(html).to include 'module RevealCK'
47
+ end
48
+ end
39
49
  end
40
50
  end
@@ -3,58 +3,60 @@ require 'spec_helper'
3
3
  module RevealCK
4
4
  describe Presentation do
5
5
 
6
- describe '#add_slide' do
7
-
8
- it 'maintains a list of slides' do
9
- presentation = Presentation.new
10
- presentation.add_slide double('slide', html: "first")
11
- presentation.add_slide double('slide', html: "second")
12
- end
13
-
6
+ let :presentation do
7
+ presentation = Presentation.new
8
+ presentation.add double('content', html: 'first')
9
+ presentation.add double('content', html: 'second')
10
+ presentation
14
11
  end
15
12
 
16
- describe '#content' do
17
-
18
- let :presentation do
19
- presentation = Presentation.new
20
- presentation.add_slide double('slide', html: "first")
21
- presentation.add_slide double('slide', html: "second")
22
- presentation
23
- end
13
+ let :html do
14
+ presentation.html
15
+ end
24
16
 
25
- let :content do
26
- presentation.content.strip
17
+ describe '#add' do
18
+ it 'adds to a growing list of html' do
19
+ expect(html).to include 'first'
20
+ expect(html).to include 'second'
21
+ expect(html.strip).to start_with 'first'
22
+ expect(html.strip).to end_with 'second'
27
23
  end
24
+ end
28
25
 
29
- it 'returns the content from each slide' do
30
- expect(content).to start_with 'first'
31
- expect(content).to end_with 'second'
26
+ describe '#html' do
27
+ it 'returns the html, in order, added so far' do
28
+ expect(html).to start_with 'first'
29
+ expect(html).to end_with 'second'
32
30
  end
33
-
34
31
  end
35
32
 
36
- describe '#theme' do
37
- it 'can be set and read' do
38
- presentation = Presentation.new
39
- presentation.theme = 'night'
40
- expect(presentation.theme).to eq 'night'
41
- end
33
+ let :slides_haml do
34
+ spec_data 'presentation', 'slides.haml'
35
+ end
42
36
 
43
- it 'has a default value of "default"' do
44
- expect(Presentation.new.theme).to eq 'default'
37
+ describe '.from_template' do
38
+ it 'loads presentation html from a template' do
39
+ presentation = Presentation.from_template slides_haml
40
+ html = presentation.html
41
+ expect(html).to start_with '<section>'
42
+ expect(html).to include 'slides.haml'
43
+ expect(html).to include '</section>'
45
44
  end
46
45
  end
47
46
 
48
- it 'responds to #title= and #title' do
49
- presentation = Presentation.new
50
- presentation.title = 'My Favorite Slides'
51
- expect(presentation.title).to eq 'My Favorite Slides'
47
+ let :slides_rb do
48
+ spec_data 'presentation', 'slides.rb'
52
49
  end
53
50
 
54
- it 'responds to #author= and #author' do
55
- presentation = Presentation.new
56
- presentation.author = 'Hakim El Hattab'
57
- expect(presentation.author).to eq 'Hakim El Hattab'
51
+ describe '.from_dsl' do
52
+ it 'loads presentation html and metadata from a dsl' do
53
+ presentation = Presentation.from_dsl slides_rb
54
+ html = presentation.html
55
+ expect(html).to start_with '<section>'
56
+ expect(html).to include 'slides.rb'
57
+ expect(html).to include '</section>'
58
+ expect(presentation.theme).to eq 'night'
59
+ end
58
60
  end
59
61
 
60
62
  end
@@ -3,8 +3,8 @@ require 'spec_helper'
3
3
  module RevealCK
4
4
  describe Slide do
5
5
 
6
- let :title_slide do
7
- Slide.new template: 'title',
6
+ let :intro_slide do
7
+ Slide.new template: 'intro',
8
8
  title: 'Reveal.js',
9
9
  subtitle: 'HTML Presentations Made Easy',
10
10
  author: 'Hakim El Hattab',
@@ -14,7 +14,7 @@ module RevealCK
14
14
 
15
15
  describe '#html' do
16
16
  it 'produces html output' do
17
- output = title_slide.html
17
+ output = intro_slide.html
18
18
  expect(output).to include 'Reveal.js'
19
19
  end
20
20
  end
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+ require 'tmpdir'
3
+ require 'fileutils'
4
+
5
+ module RevealCK
6
+ module Templates
7
+ describe Finder do
8
+
9
+ let :reveal_ck_dir do
10
+ Dir.pwd
11
+ end
12
+
13
+ describe '#paths' do
14
+
15
+ it 'defaults to Dir.pwd/templates and reveal-ck/templates' do
16
+ Dir.mktmpdir do |dir|
17
+ Dir.chdir(dir) do
18
+ finder = Finder.new
19
+ expect(finder.paths).to include File.join(Dir.pwd, 'templates')
20
+ expect(finder.paths)
21
+ .to(include File.join(reveal_ck_dir, 'templates'))
22
+ expect(finder.paths.size).to eq 2
23
+ end
24
+ end
25
+ end
26
+
27
+ it 'can be assigned via initializer' do
28
+ Dir.mktmpdir do |dir|
29
+ paths = [ dir, File.join(dir, 'templates') ]
30
+ finder = Finder.new paths: paths
31
+ expect(finder.paths).to include dir
32
+ expect(finder.paths).to include File.join(dir, 'templates')
33
+ expect(finder.paths.size).to eq 2
34
+ end
35
+ end
36
+
37
+ end
38
+
39
+ describe '#find' do
40
+
41
+ let :project_templates do
42
+ spec_data 'templates', 'finder', 'templates'
43
+ end
44
+
45
+ let :reveal_ck_templates_dir do
46
+ File.join reveal_ck_dir, 'templates'
47
+ end
48
+
49
+ let :finder do
50
+ paths = [project_templates, reveal_ck_templates_dir]
51
+ Finder.new paths: paths
52
+ end
53
+
54
+ it 'searches project templates/ and reveal-ck/templates' do
55
+ result = finder.find 'template_one'
56
+ template_one = File.join('templates', 'template_one.slim')
57
+ expect(result).to include template_one
58
+
59
+ result = finder.find 'intro'
60
+ intro_slim = File.join('reveal-ck', 'templates', 'intro.slim')
61
+ expect(result).to include intro_slim
62
+ end
63
+
64
+ it 'searches in order and returns the first match' do
65
+ result = finder.find 'text'
66
+ expect(result).to include File.join('templates', 'text.slim')
67
+
68
+ result = finder.find 'quote'
69
+ expect(result).to include reveal_ck_templates_dir
70
+ end
71
+
72
+ it 'searches for files based on the beginnings of names' do
73
+ result = finder.find 'tex'
74
+ expect(result).to include File.join('templates', 'text.slim')
75
+ end
76
+
77
+ it 'only finds regular files' do
78
+ result = finder.find 'code'
79
+ expect(result).to include reveal_ck_templates_dir
80
+ end
81
+
82
+ it 'raises if it cannot find what you asked for' do
83
+ expect { finder.find 'unknown' }.to raise_error
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end