presentation 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 762c3d623ecdde5570b5d23ced5e3096cbc8b953
4
+ data.tar.gz: 8d0847e8488003c4009e28ebd744edd479e29430
5
+ SHA512:
6
+ metadata.gz: f8727d45307f035cfe8a68e34d7556aa85f35851542df189a682968e39f9a7fc0ce8ebc87bf61c00d3978dcf2db60fe0bc6d3c00d6cc6c6da3d87814738a7b64
7
+ data.tar.gz: 796f3fb55b7f7d9edb83777c4b2722fca892fa6a11ab391cccb60945700caf131622406227c839addd8adecdd82a84c742083c80b9df6f81574891d329d0029a
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p247
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in presentation.gemspec
4
+ gemspec
5
+
6
+ gem 'pry'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Andrew Havens
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # Presentation
2
+
3
+ Presentation is a Ruby library for creating fullscreen presentations.
4
+
5
+ ## Installation
6
+
7
+ $ gem install presentation
8
+
9
+ ## Usage
10
+
11
+ $ presentation new my-ruby-talk
12
+ $ cd my-ruby-talk
13
+ $ presentation start
14
+
15
+ ## Contributing
16
+
17
+ Pull requests are welcome! Feel free to submit an an issue if you have any suggestions for improvement.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/presentation ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/presentation/cli'
3
+ Presentation::CLI.start
@@ -0,0 +1,22 @@
1
+ # use `presentation start` in this directory to view this presentation
2
+
3
+ slide {
4
+ title 'Ruby Programming'
5
+ subtitle 'A simple introduction'
6
+ }
7
+
8
+ slide {
9
+ title 'What is Ruby?'
10
+ b 'a programming language'
11
+ b 'lots of interpreters'
12
+ b 'lots of fun!'
13
+ }
14
+
15
+ slide {
16
+ title 'What does Ruby look like?'
17
+ ruby_code "Use up/down arrow keys to scroll\n\n" + File.read(__FILE__)
18
+ }
19
+
20
+ slide {
21
+ title 'The end!'
22
+ }
@@ -0,0 +1,20 @@
1
+ # TODO: This doesn't actually work yet, but
2
+ # something like this might be nice to have
3
+
4
+ class IntroSlide
5
+
6
+ style :title do
7
+ font_family 'Georgia'
8
+ font_size 50
9
+ text_align :center
10
+ top '30%'
11
+ end
12
+
13
+ style :subtitle do
14
+ font_family 'Helvetica'
15
+ font_size 30
16
+ text_align :center
17
+ bottom '30%'
18
+ end
19
+
20
+ end
data/examples/theme.rb ADDED
@@ -0,0 +1,25 @@
1
+ # TODO: This doesn't actually work yet, but
2
+ # something like this might be nice to have
3
+
4
+ slide {
5
+ padding 50
6
+ }
7
+
8
+ title {
9
+ font_family 'Georgia'
10
+ font_size 50
11
+ text_align :center
12
+ top '30%'
13
+ }
14
+
15
+ subtitle {
16
+ font_family 'Helvetica'
17
+ font_size 30
18
+ text_align :center
19
+ bottom '30%'
20
+ }
21
+
22
+ list_item {
23
+ font_family 'Helvetica'
24
+ font_size 20
25
+ }
@@ -0,0 +1,28 @@
1
+ require 'pry'
2
+ require 'gosu'
3
+
4
+ require_relative 'presentation/slide_deck'
5
+ require_relative 'presentation/window'
6
+
7
+ class Presentation
8
+
9
+ def slide_deck
10
+ @slide_deck ||= SlideDeck.new
11
+ end
12
+
13
+ def load_slides_from_file(filename)
14
+ slide_deck.load_slides_from_file(filename)
15
+ end
16
+
17
+ # TODO: Implement something like this
18
+ # def load_theme(filename)
19
+ # source = File.read(filename)
20
+ # @theme = Theme.new.parse(source, filename, 0)
21
+ # end
22
+
23
+ def start
24
+ @window = Window.new(slide_deck)
25
+ @window.show
26
+ end
27
+
28
+ end
@@ -0,0 +1,27 @@
1
+ require 'thor'
2
+ require_relative '../presentation'
3
+
4
+ class Presentation
5
+
6
+ class CLI < Thor
7
+ include Thor::Actions
8
+
9
+ desc "new NAME", "Generate a new presentation"
10
+ def new(name)
11
+ create_file "#{name}/presentation.rb" do
12
+ File.read File.expand_path("../../../examples/presentation.rb", __FILE__)
13
+ end
14
+ end
15
+
16
+ desc "start [presentation.rb]", "Start a full screen presentation"
17
+ # method_option %w(theme -t) => 'theme.rb'
18
+ def start(name = nil)
19
+ name ||= 'presentation.rb'
20
+ p = Presentation.new
21
+ p.load_slides_from_file File.expand_path(name)
22
+ # TODO: p.load_theme File.expand_path(options[:theme])
23
+ p.start
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,76 @@
1
+ require_relative 'slide'
2
+
3
+ class Presentation
4
+ class SlidesDSL
5
+
6
+ attr_reader :slides
7
+
8
+ def slides
9
+ @slides ||= []
10
+ end
11
+
12
+ def slide(type = nil, &block)
13
+ if type and type.is_a? Class
14
+ s = type.new
15
+ s.instance_eval(&block)
16
+ slides << s
17
+ else
18
+ s = SlideDSL.new
19
+ s.instance_eval(&block)
20
+ slides << s.slide
21
+ end
22
+ # FIXME: why doesnt this work?
23
+ # s = Slide.new
24
+ # s.instance_eval &block
25
+ # slides << s
26
+ end
27
+
28
+ end
29
+
30
+ class SlideDSL
31
+ def slide
32
+ @slide ||= Slide.new
33
+ end
34
+
35
+ def method_missing(method, *args, &block)
36
+ if method =~ /(.*)_code$/
37
+ code($1, *args, &block)
38
+ else
39
+ slide.send("#{method}=", *args, &block)
40
+ end
41
+ end
42
+
43
+ def code(language, text)
44
+ # TODO: find/create some sort of Gosu compatible syntax highlighter
45
+ slide.code = text
46
+ end
47
+
48
+ def bullet(bullet)
49
+ slide.list ||= []
50
+ slide.list << bullet
51
+ end
52
+ alias_method :b, :bullet
53
+ end
54
+
55
+ # TODO: Implement something like this maybe?
56
+ # class Theme < SomeStylesheetLibrary
57
+ # allow_styles_for :slide do
58
+ # type :container
59
+ # include Padding
60
+ # include Background
61
+ # end
62
+
63
+ # allow_styles_for :title, :subtitle do
64
+ # type :text
65
+ # include Positioning
66
+ # include Text
67
+ # end
68
+
69
+ # allow_styles_for :bullet do
70
+ # type :text
71
+ # include Positioning
72
+ # include Text
73
+ # end
74
+ # end
75
+
76
+ end
@@ -0,0 +1,79 @@
1
+ class Presentation
2
+ class Slide
3
+
4
+ # TODO: create different/customizable slide layouts
5
+
6
+ attr_accessor :title, :subtitle, :code, :list, :code_offset_top
7
+
8
+ def code_offset_top
9
+ @code_offset_top ||= 0
10
+ end
11
+
12
+ def slide_padding
13
+ (@window.width / 100) * 5
14
+ end
15
+
16
+ def create_text(text, font_family: 'Arial', font_size: 80, line_spacing: 10, max_width: nil, align: :center)
17
+ max_width ||= @window.width - slide_padding
18
+ Gosu::Image.from_text(@window, text, font_family, font_size, line_spacing, max_width, align)
19
+ end
20
+
21
+ def title_text
22
+ @title_text ||= create_text @title, font_size: 80, align: :center
23
+ end
24
+
25
+ def subtitle_text
26
+ @subtitle_text ||= create_text @subtitle, font_size: 50, align: :center
27
+ end
28
+
29
+ def code_text
30
+ @code_text ||= create_text @code, font_family: 'Courier', font_size: 50, align: :left
31
+ end
32
+
33
+ def list_as_string
34
+ return '' unless @list
35
+ @list.map do |line|
36
+ line = '• ' + line
37
+ end.join("\n")
38
+ end
39
+
40
+ def list_text
41
+ @list_text ||= create_text list_as_string, font_size: 50, align: :left
42
+ end
43
+
44
+ def scroll_up
45
+ @code_offset_top ||= 0
46
+ @code_offset_top -= 5
47
+ end
48
+
49
+ def scroll_down
50
+ @code_offset_top ||= 0
51
+ @code_offset_top += 5
52
+ end
53
+
54
+ def draw(window)
55
+ @window = window
56
+ if code or list
57
+ draw_normal_screen
58
+ else
59
+ draw_title_screen
60
+ end
61
+ end
62
+
63
+ def draw_title_screen
64
+ left = slide_padding
65
+ top = (@window.height / 100) * 30
66
+ title_text.draw(left, top, 0, 1, 1, 0xffffffff)
67
+ subtitle_text.draw(left, top + title_text.height, 0, 1, 1, 0xffffffff)
68
+ end
69
+
70
+ def draw_normal_screen
71
+ left = slide_padding
72
+ top = (@window.height / 100) * 5
73
+ title_text.draw(left, top, 0, 1, 1, 0xffffffff)
74
+ code_text.draw(left, top + title_text.height + code_offset_top, 0, 1, 1, 0xffffffff)
75
+ list_text.draw(left, top + title_text.height, 0, 1, 1, 0xffffffff)
76
+ end
77
+
78
+ end
79
+ end
@@ -0,0 +1,31 @@
1
+ require_relative 'dsl'
2
+
3
+ class Presentation
4
+ class SlideDeck
5
+
6
+ def initialize
7
+ @current_slide = 0
8
+ @slides = []
9
+ end
10
+
11
+ def current_slide
12
+ @slides[@current_slide]
13
+ end
14
+
15
+ def previous_slide
16
+ @current_slide -=1 unless @current_slide == 0
17
+ end
18
+
19
+ def next_slide
20
+ @current_slide += 1 unless @current_slide == @slides.count - 1
21
+ end
22
+
23
+ def load_slides_from_file(filename)
24
+ source = File.read(filename)
25
+ dsl = SlidesDSL.new
26
+ dsl.instance_eval(source, filename, 0)
27
+ @slides = dsl.slides
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ class Presentation
2
+ class Window < Gosu::Window
3
+
4
+ def initialize(slide_deck)
5
+ @slide_deck = slide_deck
6
+ super(1200, 600, true) # TODO: set to fullscreen when Gosu fixes issue #157
7
+ end
8
+
9
+ def button_down(button)
10
+ case button
11
+ when Gosu::KbEscape then close
12
+ when Gosu::KbRight, Gosu::KbSpace, Gosu::KbReturn
13
+ @slide_deck.next_slide
14
+ when Gosu::KbLeft
15
+ @slide_deck.previous_slide
16
+ end
17
+ end
18
+
19
+ def update
20
+ @slide_deck.current_slide.scroll_up if button_down? Gosu::KbUp
21
+ @slide_deck.current_slide.scroll_down if button_down? Gosu::KbDown
22
+ end
23
+
24
+ def draw
25
+ @slide_deck.current_slide.draw(self)
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ # encoding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "presentation"
5
+ spec.version = "0.0.1"
6
+ spec.authors = ["Andrew Havens"]
7
+ spec.email = ["email@andrewhavens.com"]
8
+ spec.description = %q{Create fullscreen presentations using Ruby.}
9
+ spec.summary = %q{Create fullscreen presentations using Ruby.}
10
+ spec.homepage = "https://github.com/andrewhavens/presentation"
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files`.split($/)
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_dependency "thor"
19
+ spec.add_dependency "gosu"
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: presentation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Havens
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: gosu
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Create fullscreen presentations using Ruby.
70
+ email:
71
+ - email@andrewhavens.com
72
+ executables:
73
+ - presentation
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - .ruby-version
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/presentation
84
+ - examples/presentation.rb
85
+ - examples/slides/intro_slide.rb
86
+ - examples/theme.rb
87
+ - lib/presentation.rb
88
+ - lib/presentation/cli.rb
89
+ - lib/presentation/dsl.rb
90
+ - lib/presentation/slide.rb
91
+ - lib/presentation/slide_deck.rb
92
+ - lib/presentation/window.rb
93
+ - presentation.gemspec
94
+ homepage: https://github.com/andrewhavens/presentation
95
+ licenses:
96
+ - MIT
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.0.2
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Create fullscreen presentations using Ruby.
118
+ test_files: []